You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@accumulo.apache.org by mw...@apache.org on 2019/03/06 21:31:48 UTC
[accumulo] branch master updated: Integration test cleanup (#1015)
This is an automated email from the ASF dual-hosted git repository.
mwalch pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/accumulo.git
The following commit(s) were added to refs/heads/master by this push:
new 93fb801 Integration test cleanup (#1015)
93fb801 is described below
commit 93fb8012db6f9f4abb7826cc1467a4cd68f7bdc4
Author: Mike Walch <mw...@apache.org>
AuthorDate: Wed Mar 6 16:31:43 2019 -0500
Integration test cleanup (#1015)
* Use try with resources
* Simplify batch writer creation
* Put duplicate code in shared methods
---
.../apache/accumulo/test/MetaGetsReadersIT.java | 16 +--
.../org/apache/accumulo/test/MetaRecoveryIT.java | 15 ++-
.../test/MissingWalHeaderCompletesRecoveryIT.java | 13 ++-
.../org/apache/accumulo/test/NamespacesIT.java | 43 ++++-----
.../org/apache/accumulo/test/OrIteratorIT.java | 37 +++----
.../test/RecoveryCompactionsAreFlushesIT.java | 22 ++---
.../accumulo/test/RewriteTabletDirectoriesIT.java | 43 ++++-----
.../java/org/apache/accumulo/test/SampleIT.java | 12 +--
.../apache/accumulo/test/ScanFlushWithTimeIT.java | 12 +--
.../apache/accumulo/test/SplitCancelsMajCIT.java | 3 +-
.../org/apache/accumulo/test/SplitRecoveryIT.java | 81 ++++++++--------
.../apache/accumulo/test/TableOperationsIT.java | 31 +++---
.../accumulo/test/TabletServerHdfsRestartIT.java | 12 +--
.../org/apache/accumulo/test/TotalQueuedIT.java | 42 ++++----
.../test/TracerRecoversAfterOfflineTableIT.java | 10 +-
.../accumulo/test/UserCompactionStrategyIT.java | 23 ++---
.../accumulo/test/VerifySerialRecoveryIT.java | 12 +--
.../org/apache/accumulo/test/VolumeChooserIT.java | 13 ++-
.../java/org/apache/accumulo/test/VolumeIT.java | 46 ++++-----
.../org/apache/accumulo/test/YieldScannersIT.java | 2 +-
.../accumulo/test/functional/BatchScanSplitIT.java | 3 +-
.../accumulo/test/functional/BloomFilterIT.java | 2 +-
.../accumulo/test/functional/ConcurrencyIT.java | 3 +-
.../accumulo/test/functional/ConstraintIT.java | 15 ++-
.../accumulo/test/functional/CreateAndUseIT.java | 3 +-
.../test/functional/DeleteEverythingIT.java | 3 +-
.../accumulo/test/functional/KerberosIT.java | 2 +-
.../accumulo/test/functional/LogicalTimeIT.java | 3 +-
.../accumulo/test/functional/MetadataIT.java | 6 +-
.../accumulo/test/functional/RowDeleteIT.java | 3 +-
.../accumulo/test/functional/ScanIteratorIT.java | 4 +-
.../accumulo/test/functional/ScannerContextIT.java | 2 +-
.../apache/accumulo/test/functional/SummaryIT.java | 3 +-
.../apache/accumulo/test/functional/TimeoutIT.java | 3 +-
.../CloseWriteAheadLogReferencesIT.java | 39 ++++----
.../test/mapred/AccumuloFileOutputFormatIT.java | 25 +++--
.../test/mapred/AccumuloInputFormatIT.java | 25 +++--
.../mapred/AccumuloMultiTableInputFormatIT.java | 24 ++---
.../test/mapred/AccumuloOutputFormatIT.java | 12 +--
.../test/mapred/AccumuloRowInputFormatIT.java | 9 +-
.../apache/accumulo/test/mapred/TokenFileIT.java | 13 ++-
.../test/mapreduce/AccumuloFileOutputFormatIT.java | 25 +++--
.../test/mapreduce/AccumuloInputFormatIT.java | 53 +++-------
.../test/mapreduce/AccumuloOutputFormatIT.java | 22 +++--
.../apache/accumulo/test/master/MergeStateIT.java | 7 +-
.../test/replication/CyclicReplicationIT.java | 11 +--
...GarbageCollectorCommunicatesWithTServersIT.java | 43 ++++-----
.../test/replication/KerberosReplicationIT.java | 20 ++--
.../replication/MultiInstanceReplicationIT.java | 107 ++++++++++-----------
.../accumulo/test/replication/ReplicationIT.java | 94 +++++++++---------
.../UnorderedWorkAssignerReplicationIT.java | 107 ++++++++++-----------
.../UnusedWalDoesntCloseReplicationStatusIT.java | 35 ++++---
52 files changed, 555 insertions(+), 659 deletions(-)
diff --git a/test/src/main/java/org/apache/accumulo/test/MetaGetsReadersIT.java b/test/src/main/java/org/apache/accumulo/test/MetaGetsReadersIT.java
index 130daab..6caa3f1 100644
--- a/test/src/main/java/org/apache/accumulo/test/MetaGetsReadersIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/MetaGetsReadersIT.java
@@ -84,15 +84,15 @@ public class MetaGetsReadersIT extends ConfigurableMacBase {
try (AccumuloClient c = Accumulo.newClient().from(getClientProperties()).build()) {
c.tableOperations().create(tableName);
Random random = new SecureRandom();
- BatchWriter bw = c.createBatchWriter(tableName, null);
- for (int i = 0; i < 50000; i++) {
- byte[] row = new byte[100];
- random.nextBytes(row);
- Mutation m = new Mutation(row);
- m.put("", "", "");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < 50000; i++) {
+ byte[] row = new byte[100];
+ random.nextBytes(row);
+ Mutation m = new Mutation(row);
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
}
- bw.close();
c.tableOperations().flush(tableName, null, null, true);
final AtomicBoolean stop = new AtomicBoolean(false);
Thread t1 = slowScan(c, tableName, stop);
diff --git a/test/src/main/java/org/apache/accumulo/test/MetaRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/MetaRecoveryIT.java
index 9e93d0a..8c8273f 100644
--- a/test/src/main/java/org/apache/accumulo/test/MetaRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/MetaRecoveryIT.java
@@ -31,7 +31,6 @@ import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.metadata.MetadataTable;
import org.apache.accumulo.core.metadata.RootTable;
-import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.minicluster.ServerType;
import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
import org.apache.accumulo.test.functional.ConfigurableMacBase;
@@ -62,13 +61,13 @@ public class MetaRecoveryIT extends ConfigurableMacBase {
for (String table : tables) {
log.info("Creating table {}", i);
c.tableOperations().create(table);
- BatchWriter bw = c.createBatchWriter(table, null);
- for (int j = 0; j < 1000; j++) {
- Mutation m = new Mutation("" + j);
- m.put("cf", "cq", "value");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(table)) {
+ for (int j = 0; j < 1000; j++) {
+ Mutation m = new Mutation("" + j);
+ m.put("cf", "cq", "value");
+ bw.addMutation(m);
+ }
}
- bw.close();
log.info("Data written to table {}", i);
i++;
}
@@ -86,7 +85,7 @@ public class MetaRecoveryIT extends ConfigurableMacBase {
getCluster().start();
log.info("Verifying");
for (String table : tables) {
- try (BatchScanner scanner = c.createBatchScanner(table, Authorizations.EMPTY, 5)) {
+ try (BatchScanner scanner = c.createBatchScanner(table)) {
scanner.setRanges(Collections.singletonList(new Range()));
assertEquals(1000, Iterators.size(scanner.iterator()));
}
diff --git a/test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java
index b6e9e6d..054ded0 100644
--- a/test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/MissingWalHeaderCompletesRecoveryIT.java
@@ -27,7 +27,6 @@ import java.util.UUID;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Mutation;
@@ -149,9 +148,9 @@ public class MissingWalHeaderCompletesRecoveryIT extends ConfigurableMacBase {
Mutation m = new Mutation(row);
m.put(logEntry.getColumnFamily(), logEntry.getColumnQualifier(), logEntry.getValue());
- BatchWriter bw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(MetadataTable.NAME)) {
+ bw.addMutation(m);
+ }
log.info("Bringing {} online", tableName);
client.tableOperations().online(tableName, true);
@@ -209,9 +208,9 @@ public class MissingWalHeaderCompletesRecoveryIT extends ConfigurableMacBase {
Mutation m = new Mutation(row);
m.put(logEntry.getColumnFamily(), logEntry.getColumnQualifier(), logEntry.getValue());
- BatchWriter bw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(MetadataTable.NAME)) {
+ bw.addMutation(m);
+ }
log.info("Bringing {} online", tableName);
client.tableOperations().online(tableName, true);
diff --git a/test/src/main/java/org/apache/accumulo/test/NamespacesIT.java b/test/src/main/java/org/apache/accumulo/test/NamespacesIT.java
index 96390b9..5119c97 100644
--- a/test/src/main/java/org/apache/accumulo/test/NamespacesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/NamespacesIT.java
@@ -42,7 +42,6 @@ import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.NamespaceExistsException;
@@ -319,17 +318,17 @@ public class NamespacesIT extends AccumuloClusterHarness {
c.tableOperations().create(t1);
String iterName = namespace + "_iter";
- BatchWriter bw = c.createBatchWriter(t1, new BatchWriterConfig());
- Mutation m = new Mutation("r");
- m.put("a", "b", new Value("abcde".getBytes()));
- bw.addMutation(m);
- bw.flush();
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(t1)) {
+ Mutation m = new Mutation("r");
+ m.put("a", "b", new Value("abcde".getBytes()));
+ bw.addMutation(m);
+ bw.flush();
+ }
IteratorSetting setting = new IteratorSetting(250, iterName, SimpleFilter.class.getName());
// verify can see inserted entry
- try (Scanner s = c.createScanner(t1, Authorizations.EMPTY)) {
+ try (Scanner s = c.createScanner(t1)) {
assertTrue(s.iterator().hasNext());
assertFalse(c.namespaceOperations().listIterators(namespace).containsKey(iterName));
assertFalse(c.tableOperations().listIterators(t1).containsKey(iterName));
@@ -541,7 +540,7 @@ public class NamespacesIT extends AccumuloClusterHarness {
passed = false;
for (int i = 0; i < 5; i++) {
- BatchWriter bw = c.createBatchWriter(t1, new BatchWriterConfig());
+ BatchWriter bw = c.createBatchWriter(t1);
bw.addMutations(Arrays.asList(m1, m2, m3));
try {
bw.close();
@@ -574,7 +573,7 @@ public class NamespacesIT extends AccumuloClusterHarness {
passed = false;
for (int i = 0; i < 5; i++) {
- BatchWriter bw = c.createBatchWriter(t1, new BatchWriterConfig());
+ BatchWriter bw = c.createBatchWriter(t1);
try {
bw.addMutations(Arrays.asList(m1, m2, m3));
bw.close();
@@ -715,11 +714,11 @@ public class NamespacesIT extends AccumuloClusterHarness {
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.DROP_TABLE);
c.tableOperations().create(t3);
- BatchWriter bw = c.createBatchWriter(t3, null);
- Mutation m = new Mutation("row");
- m.put("cf", "cq", "value");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(t3)) {
+ Mutation m = new Mutation("row");
+ m.put("cf", "cq", "value");
+ bw.addMutation(m);
+ }
loginAs(user1);
Iterator<Entry<Key,Value>> i = user1Con.createScanner(t3, new Authorizations()).iterator();
@@ -732,9 +731,9 @@ public class NamespacesIT extends AccumuloClusterHarness {
}
loginAs(user1);
- m = new Mutation(u1);
+ Mutation m = new Mutation(u1);
m.put("cf", "cq", "turtles");
- bw = user1Con.createBatchWriter(t3, null);
+ BatchWriter bw = user1Con.createBatchWriter(t3);
try {
bw.addMutation(m);
bw.close();
@@ -761,11 +760,11 @@ public class NamespacesIT extends AccumuloClusterHarness {
c.securityOperations().grantNamespacePermission(u1, n1, NamespacePermission.WRITE);
loginAs(user1);
- m = new Mutation(u1);
- m.put("cf", "cq", "turtles");
- bw = user1Con.createBatchWriter(t3, null);
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw2 = user1Con.createBatchWriter(t3)) {
+ m = new Mutation(u1);
+ m.put("cf", "cq", "turtles");
+ bw2.addMutation(m);
+ }
loginAs(root);
c.securityOperations().revokeNamespacePermission(u1, n1, NamespacePermission.WRITE);
diff --git a/test/src/main/java/org/apache/accumulo/test/OrIteratorIT.java b/test/src/main/java/org/apache/accumulo/test/OrIteratorIT.java
index 4298bd3..1354cc5 100644
--- a/test/src/main/java/org/apache/accumulo/test/OrIteratorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/OrIteratorIT.java
@@ -34,7 +34,6 @@ import java.util.TreeSet;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchScanner;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.conf.Property;
@@ -44,9 +43,9 @@ import org.apache.accumulo.core.data.PartialKey;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
import org.apache.accumulo.core.iterators.OrIterator;
-import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.harness.AccumuloClusterHarness;
import org.apache.hadoop.io.Text;
+import org.junit.Assert;
import org.junit.Test;
public class OrIteratorIT extends AccumuloClusterHarness {
@@ -63,7 +62,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
final String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
- try (BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig())) {
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
Mutation m = new Mutation("row1");
m.put("bob", "2", EMPTY);
m.put("frank", "3", EMPTY);
@@ -84,7 +83,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
expectedData.put("frank", "3");
expectedData.put("mort", "6");
- try (BatchScanner bs = client.createBatchScanner(tableName, Authorizations.EMPTY, 1)) {
+ try (BatchScanner bs = client.createBatchScanner(tableName)) {
Set<Range> ranges = new HashSet<>(Arrays.asList(Range.exact("row1"), Range.exact("row2")));
bs.setRanges(ranges);
bs.addScanIterator(is);
@@ -105,7 +104,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
final String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
- try (BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig())) {
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
Mutation m = new Mutation("row1");
m.put("bob", "2", EMPTY);
m.put("frank", "3", EMPTY);
@@ -137,7 +136,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
expectedData.put("mort", "6");
expectedData.put("nick", "3");
- try (BatchScanner bs = client.createBatchScanner(tableName, Authorizations.EMPTY, 1)) {
+ try (BatchScanner bs = client.createBatchScanner(tableName)) {
bs.setRanges(Collections.singleton(new Range()));
bs.addScanIterator(is);
for (Entry<Key,Value> entry : bs) {
@@ -158,7 +157,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
client.tableOperations().create(tableName);
client.tableOperations().setProperty(tableName, Property.TABLE_SCAN_MAXMEM.getKey(), "1");
- try (BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig())) {
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
Mutation m = new Mutation("row1");
m.put("bob", "02", EMPTY);
m.put("carl", "07", EMPTY);
@@ -184,7 +183,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
expectedData.put("nick", "12");
expectedData.put("richard", "18");
- try (BatchScanner bs = client.createBatchScanner(tableName, Authorizations.EMPTY, 1)) {
+ try (BatchScanner bs = client.createBatchScanner(tableName)) {
bs.setRanges(Collections.singleton(new Range()));
bs.addScanIterator(is);
for (Entry<Key,Value> entry : bs) {
@@ -205,7 +204,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
final String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
- try (BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig())) {
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
Mutation m = new Mutation("row1");
m.put("bob", "02", EMPTY);
m.put("carl", "07", EMPTY);
@@ -223,19 +222,11 @@ public class OrIteratorIT extends AccumuloClusterHarness {
IteratorSetting is = new IteratorSetting(50, OrIterator.class);
is.addOption(OrIterator.COLUMNS_KEY, "theresa,sally");
- Map<String,String> expectedData = Collections.emptyMap();
- try (BatchScanner bs = client.createBatchScanner(tableName, Authorizations.EMPTY, 1)) {
+ try (BatchScanner bs = client.createBatchScanner(tableName)) {
bs.setRanges(Collections.singleton(new Range()));
bs.addScanIterator(is);
- for (Entry<Key,Value> entry : bs) {
- String term = entry.getKey().getColumnFamily().toString();
- String expectedDocId = expectedData.remove(term);
- assertNotNull("Found unexpected term: " + term + " or the docId was unexpectedly null",
- expectedDocId);
- assertEquals(expectedDocId, entry.getKey().getColumnQualifier().toString());
- }
- assertTrue("Expected no leftover entries but saw " + expectedData, expectedData.isEmpty());
+ assertFalse("Found matches when none expected", bs.iterator().hasNext());
}
}
}
@@ -246,7 +237,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
final String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
- try (BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig())) {
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
Mutation m = new Mutation("row1");
m.put("bob", "02", EMPTY);
m.put("carl", "07", EMPTY);
@@ -280,7 +271,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
client.tableOperations().addSplits(tableName,
new TreeSet<>(Arrays.asList(new Text("row2"), new Text("row3"))));
- try (BatchScanner bs = client.createBatchScanner(tableName, Authorizations.EMPTY, 1)) {
+ try (BatchScanner bs = client.createBatchScanner(tableName)) {
bs.setRanges(Collections.singleton(new Range()));
bs.addScanIterator(is);
for (Entry<Key,Value> entry : bs) {
@@ -301,7 +292,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
final String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
- try (BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig())) {
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
Mutation m = new Mutation("row1");
m.put("bob", "2", EMPTY);
m.put("frank", "3", EMPTY);
@@ -312,7 +303,7 @@ public class OrIteratorIT extends AccumuloClusterHarness {
IteratorSetting is = new IteratorSetting(50, OrIterator.class);
is.addOption(OrIterator.COLUMNS_KEY, "bob,steve");
- try (Scanner s = client.createScanner(tableName, Authorizations.EMPTY)) {
+ try (Scanner s = client.createScanner(tableName)) {
s.addScanIterator(is);
Iterator<Entry<Key,Value>> iter = s.iterator();
assertTrue(iter.hasNext());
diff --git a/test/src/main/java/org/apache/accumulo/test/RecoveryCompactionsAreFlushesIT.java b/test/src/main/java/org/apache/accumulo/test/RecoveryCompactionsAreFlushesIT.java
index cb87447..4a82b33 100644
--- a/test/src/main/java/org/apache/accumulo/test/RecoveryCompactionsAreFlushesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/RecoveryCompactionsAreFlushesIT.java
@@ -23,7 +23,6 @@ import java.util.Map.Entry;
import org.apache.accumulo.cluster.ClusterControl;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
@@ -66,26 +65,23 @@ public class RecoveryCompactionsAreFlushesIT extends AccumuloClusterHarness {
c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "100");
c.tableOperations().setProperty(tableName, Property.TABLE_FILE_MAX.getKey(), "3");
// create 3 flush files
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m = new Mutation("a");
- m.put("b", "c", new Value("v".getBytes()));
- for (int i = 0; i < 3; i++) {
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ Mutation m = new Mutation("a");
+ m.put("b", "c", new Value("v".getBytes()));
+ for (int i = 0; i < 3; i++) {
+ bw.addMutation(m);
+ bw.flush();
+ c.tableOperations().flush(tableName, null, null, true);
+ }
+ // create an unsaved mutation
bw.addMutation(m);
- bw.flush();
- c.tableOperations().flush(tableName, null, null, true);
}
- // create an unsaved mutation
- bw.addMutation(m);
- bw.close();
ClusterControl control = cluster.getClusterControl();
-
// kill the tablet servers
control.stopAllServers(ServerType.TABLET_SERVER);
-
// recover
control.startAllServers(ServerType.TABLET_SERVER);
-
// ensure the table is readable
Iterators.size(c.createScanner(tableName, Authorizations.EMPTY).iterator());
diff --git a/test/src/main/java/org/apache/accumulo/test/RewriteTabletDirectoriesIT.java b/test/src/main/java/org/apache/accumulo/test/RewriteTabletDirectoriesIT.java
index 0d6d8ba..c4ab993 100644
--- a/test/src/main/java/org/apache/accumulo/test/RewriteTabletDirectoriesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/RewriteTabletDirectoriesIT.java
@@ -88,40 +88,39 @@ public class RewriteTabletDirectoriesIT extends ConfigurableMacBase {
c.tableOperations().create(tableName);
// Write some data to a table and add some splits
- BatchWriter bw = c.createBatchWriter(tableName, null);
final SortedSet<Text> splits = new TreeSet<>();
- for (String split : "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",")) {
- splits.add(new Text(split));
- Mutation m = new Mutation(new Text(split));
- m.put(new byte[] {}, new byte[] {}, new byte[] {});
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (String split : "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z".split(",")) {
+ splits.add(new Text(split));
+ Mutation m = new Mutation(new Text(split));
+ m.put(new byte[] {}, new byte[] {}, new byte[] {});
+ bw.addMutation(m);
+ }
}
- bw.close();
c.tableOperations().addSplits(tableName, splits);
- try (BatchScanner scanner = c.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY,
- 1)) {
+ try (BatchScanner scanner = c.createBatchScanner(MetadataTable.NAME)) {
DIRECTORY_COLUMN.fetch(scanner);
TableId tableId = TableId.of(c.tableOperations().tableIdMap().get(tableName));
assertNotNull("TableID for " + tableName + " was null", tableId);
scanner.setRanges(Collections.singletonList(TabletsSection.getRange(tableId)));
// verify the directory entries are all on v1, make a few entries relative
- bw = c.createBatchWriter(MetadataTable.NAME, null);
int count = 0;
- for (Entry<Key,Value> entry : scanner) {
- assertTrue("Expected " + entry.getValue() + " to contain " + v1,
- entry.getValue().toString().contains(v1.toString()));
- count++;
- if (count % 2 == 0) {
- String[] parts = entry.getValue().toString().split("/");
- Key key = entry.getKey();
- Mutation m = new Mutation(key.getRow());
- m.put(key.getColumnFamily(), key.getColumnQualifier(),
- new Value((Path.SEPARATOR + parts[parts.length - 1]).getBytes()));
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(MetadataTable.NAME)) {
+ for (Entry<Key,Value> entry : scanner) {
+ assertTrue("Expected " + entry.getValue() + " to contain " + v1,
+ entry.getValue().toString().contains(v1.toString()));
+ count++;
+ if (count % 2 == 0) {
+ String[] parts = entry.getValue().toString().split("/");
+ Key key = entry.getKey();
+ Mutation m = new Mutation(key.getRow());
+ m.put(key.getColumnFamily(), key.getColumnQualifier(),
+ new Value((Path.SEPARATOR + parts[parts.length - 1]).getBytes()));
+ bw.addMutation(m);
+ }
}
}
- bw.close();
assertEquals(splits.size() + 1, count);
// This should fail: only one volume
diff --git a/test/src/main/java/org/apache/accumulo/test/SampleIT.java b/test/src/main/java/org/apache/accumulo/test/SampleIT.java
index 28c4cde..eb5fbdc 100644
--- a/test/src/main/java/org/apache/accumulo/test/SampleIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/SampleIT.java
@@ -146,7 +146,7 @@ public class SampleIT extends AccumuloClusterHarness {
isoScanner.setSamplerConfiguration(SC1);
isoScanner.setBatchSize(10);
- BatchScanner bScanner = client.createBatchScanner(tableName, Authorizations.EMPTY, 2);
+ BatchScanner bScanner = client.createBatchScanner(tableName);
bScanner.setSamplerConfiguration(SC1);
bScanner.setRanges(Arrays.asList(new Range()));
@@ -426,13 +426,11 @@ public class SampleIT extends AccumuloClusterHarness {
writeData(bw, SC1, expected);
}
- Scanner scanner = client.createScanner(tableName, Authorizations.EMPTY);
- Scanner isoScanner = new IsolatedScanner(
- client.createScanner(tableName, Authorizations.EMPTY));
+ Scanner scanner = client.createScanner(tableName);
+ Scanner isoScanner = new IsolatedScanner(client.createScanner(tableName));
isoScanner.setBatchSize(10);
- Scanner csiScanner = new ClientSideIteratorScanner(
- client.createScanner(tableName, Authorizations.EMPTY));
- BatchScanner bScanner = client.createBatchScanner(tableName, Authorizations.EMPTY, 2);
+ Scanner csiScanner = new ClientSideIteratorScanner(client.createScanner(tableName));
+ BatchScanner bScanner = client.createBatchScanner(tableName);
bScanner.setRanges(Arrays.asList(new Range()));
// ensure sample not present exception occurs when sampling is not configured
diff --git a/test/src/main/java/org/apache/accumulo/test/ScanFlushWithTimeIT.java b/test/src/main/java/org/apache/accumulo/test/ScanFlushWithTimeIT.java
index c31246e..c925f31 100644
--- a/test/src/main/java/org/apache/accumulo/test/ScanFlushWithTimeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/ScanFlushWithTimeIT.java
@@ -62,13 +62,13 @@ public class ScanFlushWithTimeIT extends AccumuloClusterHarness {
log.info("waiting for zookeeper propagation");
UtilWaitThread.sleep(5 * 1000);
log.info("Adding a few entries");
- BatchWriter bw = c.createBatchWriter(tableName, null);
- for (int i = 0; i < 10; i++) {
- Mutation m = new Mutation("" + i);
- m.put("", "", "");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < 10; i++) {
+ Mutation m = new Mutation("" + i);
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
}
- bw.close();
log.info("Fetching some entries: should timeout and return something");
log.info("Scanner");
diff --git a/test/src/main/java/org/apache/accumulo/test/SplitCancelsMajCIT.java b/test/src/main/java/org/apache/accumulo/test/SplitCancelsMajCIT.java
index d9bac52..2645022 100644
--- a/test/src/main/java/org/apache/accumulo/test/SplitCancelsMajCIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/SplitCancelsMajCIT.java
@@ -27,7 +27,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Value;
@@ -66,7 +65,7 @@ public class SplitCancelsMajCIT extends SharedMiniClusterBase {
IteratorSetting it = new IteratorSetting(100, SlowIterator.class);
SlowIterator.setSleepTime(it, 500);
c.tableOperations().attachIterator(tableName, it, EnumSet.of(IteratorScope.majc));
- try (BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
for (int i = 0; i < 100; i++) {
Mutation m = new Mutation("" + i);
m.put("", "", new Value());
diff --git a/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
index 07d9558..a2ca838 100644
--- a/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/SplitRecoveryIT.java
@@ -24,7 +24,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.data.Key;
@@ -52,9 +51,9 @@ public class SplitRecoveryIT extends AccumuloClusterHarness {
return result;
}
- boolean isOffline(String tablename, AccumuloClient accumuloClient) throws TableNotFoundException {
- String tableId = accumuloClient.tableOperations().tableIdMap().get(tablename);
- try (Scanner scanner = accumuloClient.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+ boolean isOffline(String tablename, AccumuloClient client) throws TableNotFoundException {
+ String tableId = client.tableOperations().tableIdMap().get(tablename);
+ try (Scanner scanner = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
scanner.setRange(new Range(new Text(tableId + ";"), new Text(tableId + "<")));
scanner.fetchColumnFamily(TabletsSection.CurrentLocationColumnFamily.NAME);
return Iterators.size(scanner.iterator()) == 0;
@@ -71,24 +70,24 @@ public class SplitRecoveryIT extends AccumuloClusterHarness {
String tableName = getUniqueNames(1)[0];
- try (AccumuloClient accumuloClient = createAccumuloClient()) {
+ try (AccumuloClient client = createAccumuloClient()) {
for (int tn = 0; tn < 2; tn++) {
// create a table and put some data in it
- accumuloClient.tableOperations().create(tableName);
- BatchWriter bw = accumuloClient.createBatchWriter(tableName, new BatchWriterConfig());
- bw.addMutation(m("a"));
- bw.addMutation(m("b"));
- bw.addMutation(m("c"));
- bw.close();
+ client.tableOperations().create(tableName);
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
+ bw.addMutation(m("a"));
+ bw.addMutation(m("b"));
+ bw.addMutation(m("c"));
+ }
// take the table offline
- accumuloClient.tableOperations().offline(tableName);
- while (!isOffline(tableName, accumuloClient))
+ client.tableOperations().offline(tableName);
+ while (!isOffline(tableName, client))
sleepUninterruptibly(200, TimeUnit.MILLISECONDS);
// poke a partial split into the metadata table
- accumuloClient.securityOperations().grantTablePermission(getAdminPrincipal(),
- MetadataTable.NAME, TablePermission.WRITE);
- TableId tableId = TableId.of(accumuloClient.tableOperations().tableIdMap().get(tableName));
+ client.securityOperations().grantTablePermission(getAdminPrincipal(), MetadataTable.NAME,
+ TablePermission.WRITE);
+ TableId tableId = TableId.of(client.tableOperations().tableIdMap().get(tableName));
KeyExtent extent = new KeyExtent(tableId, null, new Text("b"));
Mutation m = extent.getPrevRowUpdateMutation();
@@ -97,38 +96,36 @@ public class SplitRecoveryIT extends AccumuloClusterHarness {
new Value(Double.toString(0.5).getBytes()));
TabletsSection.TabletColumnFamily.OLD_PREV_ROW_COLUMN.put(m,
KeyExtent.encodePrevEndRow(null));
- bw = accumuloClient.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- bw.addMutation(m);
-
- if (tn == 1) {
-
- bw.flush();
-
- try (Scanner scanner = accumuloClient.createScanner(MetadataTable.NAME,
- Authorizations.EMPTY)) {
- scanner.setRange(extent.toMetadataRange());
- scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
-
- KeyExtent extent2 = new KeyExtent(tableId, new Text("b"), null);
- m = extent2.getPrevRowUpdateMutation();
- TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m, new Value("/t2".getBytes()));
- TabletsSection.ServerColumnFamily.TIME_COLUMN.put(m, new Value("M0".getBytes()));
-
- for (Entry<Key,Value> entry : scanner) {
- m.put(DataFileColumnFamily.NAME, entry.getKey().getColumnQualifier(),
- entry.getValue());
+ try (BatchWriter bw = client.createBatchWriter(MetadataTable.NAME)) {
+ bw.addMutation(m);
+
+ if (tn == 1) {
+ bw.flush();
+
+ try (Scanner scanner = client.createScanner(MetadataTable.NAME)) {
+ scanner.setRange(extent.toMetadataRange());
+ scanner.fetchColumnFamily(DataFileColumnFamily.NAME);
+
+ KeyExtent extent2 = new KeyExtent(tableId, new Text("b"), null);
+ m = extent2.getPrevRowUpdateMutation();
+ TabletsSection.ServerColumnFamily.DIRECTORY_COLUMN.put(m,
+ new Value("/t2".getBytes()));
+ TabletsSection.ServerColumnFamily.TIME_COLUMN.put(m, new Value("M0".getBytes()));
+
+ for (Entry<Key,Value> entry : scanner) {
+ m.put(DataFileColumnFamily.NAME, entry.getKey().getColumnQualifier(),
+ entry.getValue());
+ }
+ bw.addMutation(m);
}
-
- bw.addMutation(m);
}
}
- bw.close();
// bring the table online
- accumuloClient.tableOperations().online(tableName);
+ client.tableOperations().online(tableName);
// verify the tablets went online
- try (Scanner scanner = accumuloClient.createScanner(tableName, Authorizations.EMPTY)) {
+ try (Scanner scanner = client.createScanner(tableName)) {
int i = 0;
String[] expected = {"a", "b", "c"};
for (Entry<Key,Value> entry : scanner) {
@@ -137,7 +134,7 @@ public class SplitRecoveryIT extends AccumuloClusterHarness {
}
assertEquals(3, i);
- accumuloClient.tableOperations().delete(tableName);
+ client.tableOperations().delete(tableName);
}
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java b/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java
index a2312eb..eaf021b 100644
--- a/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/TableOperationsIT.java
@@ -41,7 +41,6 @@ import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableExistsException;
@@ -130,12 +129,12 @@ public class TableOperationsIT extends AccumuloClusterHarness {
assertEquals(tableName, diskUsages.get(0).getTables().first());
// add some data
- BatchWriter bw = accumuloClient.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m = new Mutation("a");
- m.put("b", "c", new Value("abcde".getBytes()));
- bw.addMutation(m);
- bw.flush();
- bw.close();
+ try (BatchWriter bw = accumuloClient.createBatchWriter(tableName)) {
+ Mutation m = new Mutation("a");
+ m.put("b", "c", new Value("abcde".getBytes()));
+ bw.addMutation(m);
+ bw.flush();
+ }
accumuloClient.tableOperations().compact(tableName, new Text("A"), new Text("z"), true, true);
@@ -199,20 +198,18 @@ public class TableOperationsIT extends AccumuloClusterHarness {
tops.create(originalTable);
tops.addSplits(originalTable, splits);
- BatchWriter bw = accumuloClient.createBatchWriter(originalTable, new BatchWriterConfig());
- for (Text row : splits) {
- Mutation m = new Mutation(row);
- for (int i = 0; i < 10; i++) {
- for (int j = 0; j < 10; j++) {
- m.put(Integer.toString(i), Integer.toString(j), Integer.toString(i + j));
+ try (BatchWriter bw = accumuloClient.createBatchWriter(originalTable)) {
+ for (Text row : splits) {
+ Mutation m = new Mutation(row);
+ for (int i = 0; i < 10; i++) {
+ for (int j = 0; j < 10; j++) {
+ m.put(Integer.toString(i), Integer.toString(j), Integer.toString(i + j));
+ }
}
+ bw.addMutation(m);
}
-
- bw.addMutation(m);
}
- bw.close();
-
String clonedTable = names[1];
tops.clone(originalTable, clonedTable, true, null, null);
diff --git a/test/src/main/java/org/apache/accumulo/test/TabletServerHdfsRestartIT.java b/test/src/main/java/org/apache/accumulo/test/TabletServerHdfsRestartIT.java
index 6e7b599..cb0b799 100644
--- a/test/src/main/java/org/apache/accumulo/test/TabletServerHdfsRestartIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/TabletServerHdfsRestartIT.java
@@ -52,13 +52,13 @@ public class TabletServerHdfsRestartIT extends ConfigurableMacBase {
}
final String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
- BatchWriter bw = client.createBatchWriter(tableName, null);
- for (int i = 0; i < N; i++) {
- Mutation m = new Mutation("" + i);
- m.put("", "", "");
- bw.addMutation(m);
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
+ for (int i = 0; i < N; i++) {
+ Mutation m = new Mutation("" + i);
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
}
- bw.close();
client.tableOperations().flush(tableName, null, null, true);
// Kill dfs
diff --git a/test/src/main/java/org/apache/accumulo/test/TotalQueuedIT.java b/test/src/main/java/org/apache/accumulo/test/TotalQueuedIT.java
index 8df9dcd..6681559 100644
--- a/test/src/main/java/org/apache/accumulo/test/TotalQueuedIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/TotalQueuedIT.java
@@ -50,9 +50,9 @@ public class TotalQueuedIT extends ConfigurableMacBase {
cfg.useMiniDFS();
}
- int SMALL_QUEUE_SIZE = 100000;
- int LARGE_QUEUE_SIZE = SMALL_QUEUE_SIZE * 10;
- static final long N = 1000000;
+ private int SMALL_QUEUE_SIZE = 100000;
+ private int LARGE_QUEUE_SIZE = SMALL_QUEUE_SIZE * 10;
+ private static final long N = 1000000;
@Test(timeout = 4 * 60 * 1000)
public void test() throws Exception {
@@ -72,17 +72,17 @@ public class TotalQueuedIT extends ConfigurableMacBase {
cfg.setMaxLatency(1, TimeUnit.SECONDS);
cfg.setMaxMemory(1024 * 1024);
long realSyncs = getSyncs(c);
- BatchWriter bw = c.createBatchWriter(tableName, cfg);
long now = System.currentTimeMillis();
long bytesSent = 0;
- for (int i = 0; i < N; i++) {
- random.nextBytes(row);
- Mutation m = new Mutation(row);
- m.put("", "", "");
- bw.addMutation(m);
- bytesSent += m.estimatedMemoryUsed();
+ try (BatchWriter bw = c.createBatchWriter(tableName, cfg)) {
+ for (int i = 0; i < N; i++) {
+ random.nextBytes(row);
+ Mutation m = new Mutation(row);
+ m.put("", "", "");
+ bw.addMutation(m);
+ bytesSent += m.estimatedMemoryUsed();
+ }
}
- bw.close();
long diff = System.currentTimeMillis() - now;
double secs = diff / 1000.;
double syncs = bytesSent / SMALL_QUEUE_SIZE;
@@ -99,17 +99,17 @@ public class TotalQueuedIT extends ConfigurableMacBase {
"" + LARGE_QUEUE_SIZE);
c.tableOperations().flush(tableName, null, null, true);
sleepUninterruptibly(1, TimeUnit.SECONDS);
- bw = c.createBatchWriter(tableName, cfg);
- now = System.currentTimeMillis();
- bytesSent = 0;
- for (int i = 0; i < N; i++) {
- random.nextBytes(row);
- Mutation m = new Mutation(row);
- m.put("", "", "");
- bw.addMutation(m);
- bytesSent += m.estimatedMemoryUsed();
+ try (BatchWriter bw = c.createBatchWriter(tableName, cfg)) {
+ now = System.currentTimeMillis();
+ bytesSent = 0;
+ for (int i = 0; i < N; i++) {
+ random.nextBytes(row);
+ Mutation m = new Mutation(row);
+ m.put("", "", "");
+ bw.addMutation(m);
+ bytesSent += m.estimatedMemoryUsed();
+ }
}
- bw.close();
diff = System.currentTimeMillis() - now;
secs = diff / 1000.;
syncs = bytesSent / LARGE_QUEUE_SIZE;
diff --git a/test/src/main/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java b/test/src/main/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
index 1e593e9..0d52a4b 100644
--- a/test/src/main/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/TracerRecoversAfterOfflineTableIT.java
@@ -78,11 +78,11 @@ public class TracerRecoversAfterOfflineTableIT extends ConfigurableMacBase {
long rootTraceId;
try (TraceScope root = Trace.startSpan("traceTest", Sampler.ALWAYS)) {
rootTraceId = root.getSpan().getTraceId();
- BatchWriter bw = client.createBatchWriter(tableName, null);
- Mutation m = new Mutation("m");
- m.put("a", "b", "c");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
+ Mutation m = new Mutation("m");
+ m.put("a", "b", "c");
+ bw.addMutation(m);
+ }
}
log.info("Bringing trace table back online");
diff --git a/test/src/main/java/org/apache/accumulo/test/UserCompactionStrategyIT.java b/test/src/main/java/org/apache/accumulo/test/UserCompactionStrategyIT.java
index 79ee9d4..6bbf1bb 100644
--- a/test/src/main/java/org/apache/accumulo/test/UserCompactionStrategyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/UserCompactionStrategyIT.java
@@ -36,7 +36,6 @@ import java.util.TreeSet;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
@@ -320,13 +319,11 @@ public class UserCompactionStrategyIT extends AccumuloClusterHarness {
byte[] data1 = new byte[size];
rand.nextBytes(data1);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
-
- Mutation m1 = new Mutation("r" + rand.nextInt(909090));
- m1.put("data", "bl0b", new Value(data1));
-
- bw.addMutation(m1);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ Mutation m1 = new Mutation("r" + rand.nextInt(909090));
+ m1.put("data", "bl0b", new Value(data1));
+ bw.addMutation(m1);
+ }
c.tableOperations().flush(tableName, null, null, true);
}
@@ -340,11 +337,11 @@ public class UserCompactionStrategyIT extends AccumuloClusterHarness {
}
private void writeFlush(AccumuloClient client, String tablename, String row) throws Exception {
- BatchWriter bw = client.createBatchWriter(tablename, new BatchWriterConfig());
- Mutation m = new Mutation(row);
- m.put("", "", "");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(tablename)) {
+ Mutation m = new Mutation(row);
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
client.tableOperations().flush(tablename, null, null, true);
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/VerifySerialRecoveryIT.java b/test/src/main/java/org/apache/accumulo/test/VerifySerialRecoveryIT.java
index 0eaaf4a..7155dce 100644
--- a/test/src/main/java/org/apache/accumulo/test/VerifySerialRecoveryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/VerifySerialRecoveryIT.java
@@ -83,13 +83,13 @@ public class VerifySerialRecoveryIT extends ConfigurableMacBase {
}
c.tableOperations().addSplits(tableName, splits);
// load data to give the recovery something to do
- BatchWriter bw = c.createBatchWriter(tableName, null);
- for (int i = 0; i < 50000; i++) {
- Mutation m = new Mutation(randomHex(8));
- m.put("", "", "");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < 50000; i++) {
+ Mutation m = new Mutation(randomHex(8));
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
}
- bw.close();
// kill the tserver
for (ProcessReference ref : getCluster().getProcesses().get(ServerType.TABLET_SERVER))
getCluster().killProcess(ServerType.TABLET_SERVER, ref);
diff --git a/test/src/main/java/org/apache/accumulo/test/VolumeChooserIT.java b/test/src/main/java/org/apache/accumulo/test/VolumeChooserIT.java
index bf77105..94335b7 100644
--- a/test/src/main/java/org/apache/accumulo/test/VolumeChooserIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/VolumeChooserIT.java
@@ -33,7 +33,6 @@ import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.conf.Property;
@@ -163,13 +162,13 @@ public class VolumeChooserIT extends ConfigurableMacBase {
public static void writeDataToTable(AccumuloClient accumuloClient, String tableName,
String[] rows) throws Exception {
// Write some data to the table
- BatchWriter bw = accumuloClient.createBatchWriter(tableName, new BatchWriterConfig());
- for (String s : rows) {
- Mutation m = new Mutation(new Text(s));
- m.put(EMPTY, EMPTY, EMPTY_VALUE);
- bw.addMutation(m);
+ try (BatchWriter bw = accumuloClient.createBatchWriter(tableName)) {
+ for (String s : rows) {
+ Mutation m = new Mutation(new Text(s));
+ m.put(EMPTY, EMPTY, EMPTY_VALUE);
+ bw.addMutation(m);
+ }
}
- bw.close();
}
public static void verifyVolumes(AccumuloClient accumuloClient, Range tableRange, String vol)
diff --git a/test/src/main/java/org/apache/accumulo/test/VolumeIT.java b/test/src/main/java/org/apache/accumulo/test/VolumeIT.java
index 1749c10..a46b83f 100644
--- a/test/src/main/java/org/apache/accumulo/test/VolumeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/VolumeIT.java
@@ -39,7 +39,6 @@ import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableExistsException;
import org.apache.accumulo.core.client.TableNotFoundException;
@@ -204,7 +203,7 @@ public class VolumeIT extends ConfigurableMacBase {
client.tableOperations().addSplits(tableName, partitions);
- BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig());
+ BatchWriter bw = client.createBatchWriter(tableName);
// create two files in each tablet
for (String s : VolumeChooserIT.alpha_rows) {
@@ -238,24 +237,22 @@ public class VolumeIT extends ConfigurableMacBase {
metaScanner.fetchColumnFamily(MetadataSchema.TabletsSection.DataFileColumnFamily.NAME);
metaScanner.setRange(new KeyExtent(tableId, null, null).toMetadataRange());
- BatchWriter mbw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
-
- for (Entry<Key,Value> entry : metaScanner) {
- String cq = entry.getKey().getColumnQualifier().toString();
- if (cq.startsWith(v1.toString())) {
- Path path = new Path(cq);
- String relPath = "/" + path.getParent().getName() + "/" + path.getName();
- Mutation fileMut = new Mutation(entry.getKey().getRow());
- fileMut.putDelete(entry.getKey().getColumnFamily(),
- entry.getKey().getColumnQualifier());
- fileMut.put(entry.getKey().getColumnFamily().toString(), relPath,
- entry.getValue().toString());
- mbw.addMutation(fileMut);
+ try (BatchWriter mbw = client.createBatchWriter(MetadataTable.NAME)) {
+ for (Entry<Key,Value> entry : metaScanner) {
+ String cq = entry.getKey().getColumnQualifier().toString();
+ if (cq.startsWith(v1.toString())) {
+ Path path = new Path(cq);
+ String relPath = "/" + path.getParent().getName() + "/" + path.getName();
+ Mutation fileMut = new Mutation(entry.getKey().getRow());
+ fileMut.putDelete(entry.getKey().getColumnFamily(),
+ entry.getKey().getColumnQualifier());
+ fileMut.put(entry.getKey().getColumnFamily().toString(), relPath,
+ entry.getValue().toString());
+ mbw.addMutation(fileMut);
+ }
}
}
- mbw.close();
-
client.tableOperations().online(tableName, true);
verifyData(expected, client.createScanner(tableName, Authorizations.EMPTY));
@@ -360,15 +357,14 @@ public class VolumeIT extends ConfigurableMacBase {
client.tableOperations().create(tableName);
client.tableOperations().addSplits(tableName, splits);
- BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- String row = String.format("%06d", i * 100 + 3);
- Mutation m = new Mutation(row);
- m.put("cf1", "cq1", "1");
- bw.addMutation(m);
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
+ for (int i = 0; i < 100; i++) {
+ String row = String.format("%06d", i * 100 + 3);
+ Mutation m = new Mutation(row);
+ m.put("cf1", "cq1", "1");
+ bw.addMutation(m);
+ }
}
-
- bw.close();
}
private void verifyVolumesUsed(AccumuloClient client, String tableName, boolean shouldExist,
diff --git a/test/src/main/java/org/apache/accumulo/test/YieldScannersIT.java b/test/src/main/java/org/apache/accumulo/test/YieldScannersIT.java
index 473a285..c987b7c 100644
--- a/test/src/main/java/org/apache/accumulo/test/YieldScannersIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/YieldScannersIT.java
@@ -131,7 +131,7 @@ public class YieldScannersIT extends AccumuloClusterHarness {
log.info("Creating batch scanner");
// make a scanner for a table with 10 keys
- try (BatchScanner scanner = client.createBatchScanner(tableName, Authorizations.EMPTY, 1)) {
+ try (BatchScanner scanner = client.createBatchScanner(tableName)) {
final IteratorSetting cfg = new IteratorSetting(100, YieldingIterator.class);
scanner.addScanIterator(cfg);
scanner.setRanges(Collections.singleton(new Range()));
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java
index 37b7530..b7952a1 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BatchScanSplitIT.java
@@ -35,7 +35,6 @@ import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.harness.AccumuloClusterHarness;
import org.apache.accumulo.miniclusterImpl.MiniAccumuloConfigImpl;
import org.apache.hadoop.conf.Configuration;
@@ -101,7 +100,7 @@ public class BatchScanSplitIT extends AccumuloClusterHarness {
HashMap<Text,Value> found = new HashMap<>();
for (int i = 0; i < 20; i++) {
- try (BatchScanner bs = c.createBatchScanner(tableName, Authorizations.EMPTY, 4)) {
+ try (BatchScanner bs = c.createBatchScanner(tableName)) {
found.clear();
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/BloomFilterIT.java b/test/src/main/java/org/apache/accumulo/test/functional/BloomFilterIT.java
index 3ede1ba..0605e59 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/BloomFilterIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/BloomFilterIT.java
@@ -213,7 +213,7 @@ public class BloomFilterIT extends AccumuloClusterHarness {
ranges.add(range);
}
- try (BatchScanner bs = c.createBatchScanner(table, Authorizations.EMPTY, 1)) {
+ try (BatchScanner bs = c.createBatchScanner(table)) {
bs.setRanges(ranges);
long t1 = System.currentTimeMillis();
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java
index 50613a9..43e2639 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ConcurrencyIT.java
@@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
@@ -108,7 +107,7 @@ public class ConcurrencyIT extends AccumuloClusterHarness {
EnumSet.of(IteratorScope.minc, IteratorScope.majc));
c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "1.0");
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ BatchWriter bw = c.createBatchWriter(tableName);
for (int i = 0; i < 50; i++) {
Mutation m = new Mutation(new Text(String.format("%06d", i)));
m.put(new Text("cf1"), new Text("cq1"), new Value("foo".getBytes(UTF_8)));
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ConstraintIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ConstraintIT.java
index f622ed4..c308cef 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ConstraintIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ConstraintIT.java
@@ -28,7 +28,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.conf.Property;
@@ -90,7 +89,7 @@ public class ConstraintIT extends AccumuloClusterHarness {
}
private void test1(AccumuloClient client, String tableName) throws Exception {
- BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig());
+ BatchWriter bw = client.createBatchWriter(tableName);
Mutation mut1 = new Mutation(new Text("r1"));
mut1.put(new Text("cf1"), new Text("cq1"), new Value("123".getBytes(UTF_8)));
@@ -100,7 +99,7 @@ public class ConstraintIT extends AccumuloClusterHarness {
// should not throw any exceptions
bw.close();
- bw = client.createBatchWriter(tableName, new BatchWriterConfig());
+ bw = client.createBatchWriter(tableName);
// create a mutation with a non numeric value
Mutation mut2 = new Mutation(new Text("r1"));
@@ -164,7 +163,7 @@ public class ConstraintIT extends AccumuloClusterHarness {
sleepUninterruptibly(1, TimeUnit.SECONDS);
// now should be able to add a non numeric value
- bw = client.createBatchWriter(tableName, new BatchWriterConfig());
+ bw = client.createBatchWriter(tableName);
bw.addMutation(mut2);
bw.close();
@@ -191,7 +190,7 @@ public class ConstraintIT extends AccumuloClusterHarness {
sleepUninterruptibly(1, TimeUnit.SECONDS);
// add a mutation
- bw = client.createBatchWriter(tableName, new BatchWriterConfig());
+ bw = client.createBatchWriter(tableName);
Mutation mut3 = new Mutation(new Text("r1"));
mut3.put(new Text("cf1"), new Text("cq1"), new Value("foo".getBytes(UTF_8)));
@@ -234,7 +233,7 @@ public class ConstraintIT extends AccumuloClusterHarness {
sleepUninterruptibly(1, TimeUnit.SECONDS);
// try the mutation again
- bw = client.createBatchWriter(tableName, new BatchWriterConfig());
+ bw = client.createBatchWriter(tableName);
bw.addMutation(mut3);
bw.close();
@@ -269,7 +268,7 @@ public class ConstraintIT extends AccumuloClusterHarness {
// should go through
int numericErrors = 2;
- BatchWriter bw = client.createBatchWriter(table, new BatchWriterConfig());
+ BatchWriter bw = client.createBatchWriter(table);
bw.addMutation(newMut("r1", "cf1", "cq1", "123"));
bw.addMutation(newMut("r1", "cf1", "cq2", "I'm a bad value"));
if (doFlush) {
@@ -283,7 +282,7 @@ public class ConstraintIT extends AccumuloClusterHarness {
} catch (MutationsRejectedException ex) {
// ignored
}
- bw = client.createBatchWriter(table, new BatchWriterConfig());
+ bw = client.createBatchWriter(table);
numericErrors = 1;
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CreateAndUseIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
index e640f04..3d189a4 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CreateAndUseIT.java
@@ -124,11 +124,10 @@ public class CreateAndUseIT extends AccumuloClusterHarness {
String table3 = getUniqueNames(1)[0];
client.tableOperations().create(table3);
client.tableOperations().addSplits(table3, splits);
- try (BatchScanner bs = client.createBatchScanner(table3, Authorizations.EMPTY, 3)) {
+ try (BatchScanner bs = client.createBatchScanner(table3)) {
bs.setRanges(ranges);
Iterator<Entry<Key,Value>> iter = bs.iterator();
int count = Iterators.size(iter);
-
assertEquals("Did not expect to find any entries", 0, count);
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java b/test/src/main/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java
index 92e96d6..6679e8c 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/DeleteEverythingIT.java
@@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.conf.ConfigurationTypeHelper;
import org.apache.accumulo.core.conf.Property;
@@ -85,7 +84,7 @@ public class DeleteEverythingIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ BatchWriter bw = c.createBatchWriter(tableName);
Mutation m = new Mutation(new Text("foo"));
m.put(new Text("bar"), new Text("1910"), new Value("5".getBytes(UTF_8)));
bw.addMutation(m);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
index 9315a17..baf5ec8 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosIT.java
@@ -427,7 +427,7 @@ public class KerberosIT extends AccumuloITBase {
int recordsSeen = userWithoutPrivs.doAs((PrivilegedExceptionAction<Integer>) () -> {
AccumuloClient client = mac.createAccumuloClient(rootUser.getPrincipal(), delegationToken);
- try (BatchScanner bs = client.createBatchScanner(tableName, Authorizations.EMPTY, 2)) {
+ try (BatchScanner bs = client.createBatchScanner(tableName)) {
bs.setRanges(Collections.singleton(new Range()));
return Iterables.size(bs);
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeIT.java b/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeIT.java
index 01e8c43..11ca793 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/LogicalTimeIT.java
@@ -20,7 +20,6 @@ import java.util.TreeSet;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.admin.NewTableConfiguration;
import org.apache.accumulo.core.client.admin.TimeType;
@@ -100,7 +99,7 @@ public class LogicalTimeIT extends AccumuloClusterHarness {
}
client.tableOperations().addSplits(table, splitSet);
- BatchWriter bw = client.createBatchWriter(table, new BatchWriterConfig());
+ BatchWriter bw = client.createBatchWriter(table);
for (String row : inserts) {
Mutation m = new Mutation(row);
m.put("cf", "cq", "v");
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MetadataIT.java b/test/src/main/java/org/apache/accumulo/test/functional/MetadataIT.java
index 7f367bf..1070d17 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/MetadataIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/MetadataIT.java
@@ -129,8 +129,7 @@ public class MetadataIT extends AccumuloClusterHarness {
// batch scan regular metadata table
int count = 0;
- try (BatchScanner s = c.createBatchScanner(MetadataTable.NAME, Authorizations.EMPTY, 1)) {
-
+ try (BatchScanner s = c.createBatchScanner(MetadataTable.NAME)) {
s.setRanges(Collections.singleton(new Range()));
for (Entry<Key,Value> e : s) {
if (e != null)
@@ -141,7 +140,7 @@ public class MetadataIT extends AccumuloClusterHarness {
assertTrue(count > 0);
// batch scan root metadata table
- try (BatchScanner s = c.createBatchScanner(RootTable.NAME, Authorizations.EMPTY, 1)) {
+ try (BatchScanner s = c.createBatchScanner(RootTable.NAME)) {
s.setRanges(Collections.singleton(new Range()));
count = 0;
for (Entry<Key,Value> e : s) {
@@ -152,5 +151,4 @@ public class MetadataIT extends AccumuloClusterHarness {
}
}
}
-
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteIT.java b/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteIT.java
index 496ef15..bf5c65f 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/RowDeleteIT.java
@@ -28,7 +28,6 @@ import java.util.Set;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.conf.Property;
@@ -69,7 +68,7 @@ public class RowDeleteIT extends AccumuloClusterHarness {
c.tableOperations().attachIterator(tableName, setting, EnumSet.of(IteratorScope.majc));
c.tableOperations().setProperty(tableName, Property.TABLE_MAJC_RATIO.getKey(), "100");
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ BatchWriter bw = c.createBatchWriter(tableName);
bw.addMutation(nm("r1", "foo", "cf1", "v1"));
bw.addMutation(nm("r1", "bar", "cf1", "v2"));
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorIT.java
index 5847378..8b11373 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScanIteratorIT.java
@@ -120,8 +120,8 @@ public class ScanIteratorIT extends AccumuloClusterHarness {
}
}
- try (Scanner scanner = c.createScanner(tableName, new Authorizations());
- BatchScanner bscanner = c.createBatchScanner(tableName, new Authorizations(), 3)) {
+ try (Scanner scanner = c.createScanner(tableName);
+ BatchScanner bscanner = c.createBatchScanner(tableName)) {
setupIter(scanner);
verify(scanner, 1, 999);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
index 47d6eb9..5fad3a1 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScannerContextIT.java
@@ -300,7 +300,7 @@ public class ScannerContextIT extends AccumuloClusterHarness {
private void batchCheck(AccumuloClient c, String tableName, IteratorSetting cfg, String context,
String expected) throws Exception {
- try (BatchScanner bs = c.createBatchScanner(tableName, Authorizations.EMPTY, 1)) {
+ try (BatchScanner bs = c.createBatchScanner(tableName)) {
bs.setRanges(Collections.singleton(new Range()));
if (context != null) {
bs.setClassLoaderContext(context);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SummaryIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SummaryIT.java
index 198a8f6..bd3e8bb 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SummaryIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SummaryIT.java
@@ -55,7 +55,6 @@ import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.Scanner;
@@ -245,7 +244,7 @@ public class SummaryIT extends AccumuloClusterHarness {
private BatchWriter writeData(final String table, AccumuloClient c)
throws TableNotFoundException, MutationsRejectedException {
- BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig());
+ BatchWriter bw = c.createBatchWriter(table);
for (int i = 0; i < 100_000; i++) {
Mutation m = new Mutation(String.format("r%09x", i));
m.put("f1", "q1", "" + i);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT.java
index 41d3463..0667213 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TimeoutIT.java
@@ -34,7 +34,6 @@ import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Range;
import org.apache.accumulo.core.data.Value;
-import org.apache.accumulo.core.security.Authorizations;
import org.apache.accumulo.harness.AccumuloClusterHarness;
import org.junit.Test;
@@ -90,7 +89,7 @@ public class TimeoutIT extends AccumuloClusterHarness {
bw.addMutation(m);
}
- try (BatchScanner bs = client.createBatchScanner(tableName, Authorizations.EMPTY, 2)) {
+ try (BatchScanner bs = client.createBatchScanner(tableName)) {
bs.setRanges(Collections.singletonList(new Range()));
// should not timeout
diff --git a/test/src/main/java/org/apache/accumulo/test/gc/replication/CloseWriteAheadLogReferencesIT.java b/test/src/main/java/org/apache/accumulo/test/gc/replication/CloseWriteAheadLogReferencesIT.java
index af1ef19..d4518e5 100644
--- a/test/src/main/java/org/apache/accumulo/test/gc/replication/CloseWriteAheadLogReferencesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/gc/replication/CloseWriteAheadLogReferencesIT.java
@@ -32,7 +32,6 @@ import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.conf.AccumuloConfiguration;
import org.apache.accumulo.core.conf.ConfigurationCopy;
@@ -131,13 +130,13 @@ public class CloseWriteAheadLogReferencesIT extends ConfigurableMacBase {
@Test
public void unclosedWalsLeaveStatusOpen() throws Exception {
Set<String> wals = Collections.emptySet();
- BatchWriter bw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- Mutation m = new Mutation(
- ReplicationSection.getRowPrefix() + "file:/accumulo/wal/tserver+port/12345");
- m.put(ReplicationSection.COLF, new Text("1"),
- StatusUtil.fileCreatedValue(System.currentTimeMillis()));
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(MetadataTable.NAME)) {
+ Mutation m = new Mutation(
+ ReplicationSection.getRowPrefix() + "file:/accumulo/wal/tserver+port/12345");
+ m.put(ReplicationSection.COLF, new Text("1"),
+ StatusUtil.fileCreatedValue(System.currentTimeMillis()));
+ bw.addMutation(m);
+ }
refs.updateReplicationEntries(client, wals);
@@ -153,16 +152,16 @@ public class CloseWriteAheadLogReferencesIT extends ConfigurableMacBase {
public void closedWalsUpdateStatus() throws Exception {
String file = "file:/accumulo/wal/tserver+port/12345";
Set<String> wals = Collections.singleton(file);
- BatchWriter bw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file);
- m.put(ReplicationSection.COLF, new Text("1"),
- StatusUtil.fileCreatedValue(System.currentTimeMillis()));
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(MetadataTable.NAME)) {
+ Mutation m = new Mutation(ReplicationSection.getRowPrefix() + file);
+ m.put(ReplicationSection.COLF, new Text("1"),
+ StatusUtil.fileCreatedValue(System.currentTimeMillis()));
+ bw.addMutation(m);
+ }
refs.updateReplicationEntries(client, wals);
- try (Scanner s = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
+ try (Scanner s = client.createScanner(MetadataTable.NAME)) {
s.fetchColumnFamily(ReplicationSection.COLF);
Entry<Key,Value> entry = Iterables.getOnlyElement(s);
Status status = Status.parseFrom(entry.getValue().get());
@@ -174,11 +173,11 @@ public class CloseWriteAheadLogReferencesIT extends ConfigurableMacBase {
public void partiallyReplicatedReferencedWalsAreNotClosed() throws Exception {
String file = "file:/accumulo/wal/tserver+port/12345";
Set<String> wals = Collections.singleton(file);
- BatchWriter bw = ReplicationTable.getBatchWriter(client);
- Mutation m = new Mutation(file);
- StatusSection.add(m, TableId.of("1"), ProtobufUtil.toValue(StatusUtil.ingestedUntil(1000)));
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = ReplicationTable.getBatchWriter(client)) {
+ Mutation m = new Mutation(file);
+ StatusSection.add(m, TableId.of("1"), ProtobufUtil.toValue(StatusUtil.ingestedUntil(1000)));
+ bw.addMutation(m);
+ }
refs.updateReplicationEntries(client, wals);
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloFileOutputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloFileOutputFormatIT.java
index 7a3d285..9a77c9a 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloFileOutputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloFileOutputFormatIT.java
@@ -26,7 +26,6 @@ import java.io.File;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.sample.RowSampler;
import org.apache.accumulo.core.client.sample.SamplerConfiguration;
import org.apache.accumulo.core.clientImpl.ClientInfo;
@@ -91,11 +90,11 @@ public class AccumuloFileOutputFormatIT extends AccumuloClusterHarness {
public void testRealWrite() throws Exception {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(TEST_TABLE);
- BatchWriter bw = c.createBatchWriter(TEST_TABLE, new BatchWriterConfig());
- Mutation m = new Mutation("Key");
- m.put("", "", "");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(TEST_TABLE)) {
+ Mutation m = new Mutation("Key");
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
handleWriteTests(true);
}
}
@@ -213,13 +212,13 @@ public class AccumuloFileOutputFormatIT extends AccumuloClusterHarness {
public void writeBadVisibility() throws Exception {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(BAD_TABLE);
- BatchWriter bw = c.createBatchWriter(BAD_TABLE, new BatchWriterConfig());
- Mutation m = new Mutation("r1");
- m.put("cf1", "cq1", "A&B");
- m.put("cf1", "cq1", "A&B");
- m.put("cf1", "cq2", "A&");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(BAD_TABLE)) {
+ Mutation m = new Mutation("r1");
+ m.put("cf1", "cq1", "A&B");
+ m.put("cf1", "cq1", "A&B");
+ m.put("cf1", "cq2", "A&");
+ bw.addMutation(m);
+ }
File f = folder.newFile(testName.getMethodName());
if (f.delete()) {
log.debug("Deleted {}", f);
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloInputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloInputFormatIT.java
index 80bd4f1..5a4644e 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloInputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloInputFormatIT.java
@@ -25,7 +25,6 @@ import java.util.Collections;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.admin.NewTableConfiguration;
import org.apache.accumulo.core.client.sample.RowSampler;
import org.apache.accumulo.core.client.sample.SamplerConfiguration;
@@ -160,13 +159,13 @@ public class AccumuloInputFormatIT extends AccumuloClusterHarness {
String table = getUniqueNames(1)[0];
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(table);
- BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(table)) {
+ for (int i = 0; i < 100; i++) {
+ Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
+ m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
+ bw.addMutation(m);
+ }
}
- bw.close();
e1 = null;
e2 = null;
@@ -187,13 +186,13 @@ public class AccumuloInputFormatIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(TEST_TABLE_3,
new NewTableConfiguration().enableSampling(SAMPLER_CONFIG));
- BatchWriter bw = c.createBatchWriter(TEST_TABLE_3, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(TEST_TABLE_3)) {
+ for (int i = 0; i < 100; i++) {
+ Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
+ m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
+ bw.addMutation(m);
+ }
}
- bw.close();
MRTester.main(TEST_TABLE_3, "False", "True");
assertEquals(38, e1Count);
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloMultiTableInputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloMultiTableInputFormatIT.java
index 47b4823..a60fa4b 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloMultiTableInputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloMultiTableInputFormatIT.java
@@ -25,7 +25,6 @@ import java.util.Map;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.clientImpl.ClientInfo;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
@@ -148,18 +147,19 @@ public class AccumuloMultiTableInputFormatIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(table1);
c.tableOperations().create(table2);
- BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig());
- BatchWriter bw2 = c.createBatchWriter(table2, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation t1m = new Mutation(new Text(String.format("%s_%09x", table1, i + 1)));
- t1m.put(new Text(), new Text(), new Value(String.format("%s_%09x", table1, i).getBytes()));
- bw.addMutation(t1m);
- Mutation t2m = new Mutation(new Text(String.format("%s_%09x", table2, i + 1)));
- t2m.put(new Text(), new Text(), new Value(String.format("%s_%09x", table2, i).getBytes()));
- bw2.addMutation(t2m);
+ try (BatchWriter bw = c.createBatchWriter(table1);
+ BatchWriter bw2 = c.createBatchWriter(table2)) {
+ for (int i = 0; i < 100; i++) {
+ Mutation t1m = new Mutation(new Text(String.format("%s_%09x", table1, i + 1)));
+ t1m.put(new Text(), new Text(),
+ new Value(String.format("%s_%09x", table1, i).getBytes()));
+ bw.addMutation(t1m);
+ Mutation t2m = new Mutation(new Text(String.format("%s_%09x", table2, i + 1)));
+ t2m.put(new Text(), new Text(),
+ new Value(String.format("%s_%09x", table2, i).getBytes()));
+ bw2.addMutation(t2m);
+ }
}
- bw.close();
- bw2.close();
MRTester.main(new String[] {table1, table2});
assertNull(e1);
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
index 4f46083..cb05b0b 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloOutputFormatIT.java
@@ -223,13 +223,13 @@ public class AccumuloOutputFormatIT extends ConfigurableMacBase {
String table2 = instanceName + "_t2";
c.tableOperations().create(table1);
c.tableOperations().create(table2);
- BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(table1)) {
+ for (int i = 0; i < 100; i++) {
+ Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
+ m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
+ bw.addMutation(m);
+ }
}
- bw.close();
MRTester.main(new String[] {"root", ROOT_PASSWORD, table1, table2, instanceName,
getCluster().getZooKeepers()});
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloRowInputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloRowInputFormatIT.java
index ae2b318..087257c 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloRowInputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/AccumuloRowInputFormatIT.java
@@ -28,7 +28,6 @@ import java.util.Map.Entry;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.clientImpl.ClientInfo;
import org.apache.accumulo.core.data.Key;
@@ -193,16 +192,10 @@ public class AccumuloRowInputFormatIT extends AccumuloClusterHarness {
try (AccumuloClient client = createAccumuloClient()) {
String tableName = getUniqueNames(1)[0];
client.tableOperations().create(tableName);
- BatchWriter writer = null;
- try {
- writer = client.createBatchWriter(tableName, new BatchWriterConfig());
+ try (BatchWriter writer = client.createBatchWriter(tableName)) {
insertList(writer, row1);
insertList(writer, row2);
insertList(writer, row3);
- } finally {
- if (writer != null) {
- writer.close();
- }
}
MRTester.main(new String[] {tableName});
assertNull(e1);
diff --git a/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java b/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
index 7a010d4..e15f287 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapred/TokenFileIT.java
@@ -29,7 +29,6 @@ import java.util.Map.Entry;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.clientImpl.ClientInfo;
import org.apache.accumulo.core.clientImpl.Credentials;
@@ -160,13 +159,13 @@ public class TokenFileIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(table1);
c.tableOperations().create(table2);
- BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(table1)) {
+ for (int i = 0; i < 100; i++) {
+ Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
+ m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
+ bw.addMutation(m);
+ }
}
- bw.close();
File tf = folder.newFile("root_test.pw");
try (PrintStream out = new PrintStream(tf)) {
diff --git a/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloFileOutputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloFileOutputFormatIT.java
index 8c9ca57..a1220db 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloFileOutputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloFileOutputFormatIT.java
@@ -25,7 +25,6 @@ import java.io.File;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.sample.RowSampler;
import org.apache.accumulo.core.client.sample.SamplerConfiguration;
import org.apache.accumulo.core.clientImpl.ClientInfo;
@@ -88,18 +87,18 @@ public class AccumuloFileOutputFormatIT extends AccumuloClusterHarness {
c.tableOperations().create(EMPTY_TABLE);
c.tableOperations().create(TEST_TABLE);
c.tableOperations().create(BAD_TABLE);
- BatchWriter bw = c.createBatchWriter(TEST_TABLE, new BatchWriterConfig());
- Mutation m = new Mutation("Key");
- m.put("", "", "");
- bw.addMutation(m);
- bw.close();
- bw = c.createBatchWriter(BAD_TABLE, new BatchWriterConfig());
- m = new Mutation("r1");
- m.put("cf1", "cq1", "A&B");
- m.put("cf1", "cq1", "A&B");
- m.put("cf1", "cq2", "A&");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(TEST_TABLE)) {
+ Mutation m = new Mutation("Key");
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
+ try (BatchWriter bw = c.createBatchWriter(BAD_TABLE)) {
+ Mutation m = new Mutation("r1");
+ m.put("cf1", "cq1", "A&B");
+ m.put("cf1", "cq1", "A&B");
+ m.put("cf1", "cq2", "A&");
+ bw.addMutation(m);
+ }
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloInputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloInputFormatIT.java
index da003a8..4ee4e31 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloInputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloInputFormatIT.java
@@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.client.admin.NewTableConfiguration;
import org.apache.accumulo.core.client.sample.RowSampler;
@@ -205,16 +204,14 @@ public class AccumuloInputFormatIT extends AccumuloClusterHarness {
private void insertData(AccumuloClient client, String tableName, long ts)
throws AccumuloException, TableNotFoundException {
- BatchWriter bw = client.createBatchWriter(tableName, null);
-
- for (int i = 0; i < 10000; i++) {
- String row = String.format("%09d", i);
-
- Mutation m = new Mutation(new Text(row));
- m.put(new Text("cf1"), new Text("cq1"), ts, new Value(("" + i).getBytes()));
- bw.addMutation(m);
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
+ for (int i = 0; i < 10000; i++) {
+ String row = String.format("%09d", i);
+ Mutation m = new Mutation(new Text(row));
+ m.put(new Text("cf1"), new Text("cq1"), ts, new Value(("" + i).getBytes()));
+ bw.addMutation(m);
+ }
}
- bw.close();
}
// track errors in the map reduce job; jobs insert a dummy error for the map and cleanup tasks (to
@@ -326,14 +323,7 @@ public class AccumuloInputFormatIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(TEST_TABLE_1);
- BatchWriter bw = c.createBatchWriter(TEST_TABLE_1, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
- }
- bw.close();
-
+ AccumuloOutputFormatIT.insertData(c, TEST_TABLE_1);
assertEquals(0, MRTester.main(new String[] {TEST_TABLE_1,
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.class.getName()}));
assertEquals(1, assertionErrors.get(TEST_TABLE_1 + "_map").size());
@@ -351,14 +341,7 @@ public class AccumuloInputFormatIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(TEST_TABLE_3,
new NewTableConfiguration().enableSampling(SAMPLER_CONFIG));
- BatchWriter bw = c.createBatchWriter(TEST_TABLE_3, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
- }
- bw.close();
-
+ AccumuloOutputFormatIT.insertData(c, TEST_TABLE_3);
assertEquals(0,
MRTester.main(new String[] {TEST_TABLE_3,
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.class.getName(),
@@ -390,14 +373,7 @@ public class AccumuloInputFormatIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(TEST_TABLE_2);
- BatchWriter bw = c.createBatchWriter(TEST_TABLE_2, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
- }
- bw.close();
-
+ AccumuloOutputFormatIT.insertData(c, TEST_TABLE_2);
assertEquals(0,
MRTester.main(new String[] {TEST_TABLE_2,
org.apache.accumulo.core.client.mapreduce.AccumuloInputFormat.class.getName(), "True",
@@ -461,14 +437,7 @@ public class AccumuloInputFormatIT extends AccumuloClusterHarness {
String table = getUniqueNames(1)[0];
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(table);
- BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
- }
- bw.close();
-
+ AccumuloOutputFormatIT.insertData(c, table);
assertEquals(0,
MRTester.main(new String[] {table, EmptySplitsAccumuloInputFormat.class.getName()}));
assertEquals(1, assertionErrors.get(table + "_map").size());
diff --git a/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java b/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java
index 821f925..020a00f 100644
--- a/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/mapreduce/AccumuloOutputFormatIT.java
@@ -26,10 +26,13 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.Map.Entry;
+import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
import org.apache.accumulo.core.client.BatchWriterConfig;
+import org.apache.accumulo.core.client.MutationsRejectedException;
import org.apache.accumulo.core.client.Scanner;
+import org.apache.accumulo.core.client.TableNotFoundException;
import org.apache.accumulo.core.clientImpl.ClientInfo;
import org.apache.accumulo.core.data.Key;
import org.apache.accumulo.core.data.Mutation;
@@ -135,6 +138,17 @@ public class AccumuloOutputFormatIT extends AccumuloClusterHarness {
}
}
+ public static void insertData(AccumuloClient client, String table) throws TableNotFoundException,
+ MutationsRejectedException {
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ for (int i = 0; i < 100; i++) {
+ Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
+ m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
+ bw.addMutation(m);
+ }
+ }
+ }
+
@Test
public void testMR() throws Exception {
String[] tableNames = getUniqueNames(2);
@@ -143,13 +157,7 @@ public class AccumuloOutputFormatIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(table1);
c.tableOperations().create(table2);
- BatchWriter bw = c.createBatchWriter(table1, new BatchWriterConfig());
- for (int i = 0; i < 100; i++) {
- Mutation m = new Mutation(new Text(String.format("%09x", i + 1)));
- m.put(new Text(), new Text(), new Value(String.format("%09x", i).getBytes()));
- bw.addMutation(m);
- }
- bw.close();
+ insertData(c, table1);
MRTester.main(new String[] {table1, table2});
assertNull(e1);
diff --git a/test/src/main/java/org/apache/accumulo/test/master/MergeStateIT.java b/test/src/main/java/org/apache/accumulo/test/master/MergeStateIT.java
index 89b407d..756b281 100644
--- a/test/src/main/java/org/apache/accumulo/test/master/MergeStateIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/master/MergeStateIT.java
@@ -99,9 +99,9 @@ public class MergeStateIT extends ConfigurableMacBase {
private static void update(AccumuloClient c, Mutation m)
throws TableNotFoundException, MutationsRejectedException {
- BatchWriter bw = c.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(MetadataTable.NAME)) {
+ bw.addMutation(m);
+ }
}
@Test
@@ -202,7 +202,6 @@ public class MergeStateIT extends ConfigurableMacBase {
// now we can split
stats = scan(state, metaDataStateStore);
assertEquals(MergeState.MERGING, stats.nextMergeState(accumuloClient, state));
-
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
index 6404455..6fe92df 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/CyclicReplicationIT.java
@@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.admin.NewTableConfiguration;
@@ -298,11 +297,11 @@ public class CyclicReplicationIT {
clientMaster2.tableOperations().attachIterator(master2Table, summingCombiner);
// Write a single entry
- BatchWriter bw = clientMaster1.createBatchWriter(master1Table, new BatchWriterConfig());
- Mutation m = new Mutation("row");
- m.put("count", "", "1");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = clientMaster1.createBatchWriter(master1Table)) {
+ Mutation m = new Mutation("row");
+ m.put("count", "", "1");
+ bw.addMutation(m);
+ }
Set<String> files = clientMaster1.replicationOperations().referencedFiles(master1Table);
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/GarbageCollectorCommunicatesWithTServersIT.java b/test/src/main/java/org/apache/accumulo/test/replication/GarbageCollectorCommunicatesWithTServersIT.java
index 71a629c..8c7f0d8 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/GarbageCollectorCommunicatesWithTServersIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/GarbageCollectorCommunicatesWithTServersIT.java
@@ -190,7 +190,7 @@ public class GarbageCollectorCommunicatesWithTServersIT extends ConfigurableMacB
log.info("Writing a few mutations to the table");
- BatchWriter bw = client.createBatchWriter(table, null);
+ BatchWriter bw = client.createBatchWriter(table);
byte[] empty = new byte[0];
for (int i = 0; i < 5; i++) {
@@ -282,18 +282,16 @@ public class GarbageCollectorCommunicatesWithTServersIT extends ConfigurableMacB
log.info("Writing a few mutations to the table");
- BatchWriter bw = client.createBatchWriter(table, null);
-
byte[] empty = new byte[0];
- for (int i = 0; i < 5; i++) {
- Mutation m = new Mutation(Integer.toString(i));
- m.put(empty, empty, empty);
- bw.addMutation(m);
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ for (int i = 0; i < 5; i++) {
+ Mutation m = new Mutation(Integer.toString(i));
+ m.put(empty, empty, empty);
+ bw.addMutation(m);
+ }
+ log.info("Flushing mutations to the server");
}
- log.info("Flushing mutations to the server");
- bw.close();
-
log.info("Checking that metadata only has one WAL recorded for this table");
Set<String> wals = getWalsForTable(table);
@@ -363,22 +361,21 @@ public class GarbageCollectorCommunicatesWithTServersIT extends ConfigurableMacB
*/
client.tableOperations().create(otherTable);
- bw = client.createBatchWriter(otherTable, null);
- // 500k
- byte[] bigValue = new byte[1024 * 500];
- Arrays.fill(bigValue, (byte) 1);
- // 500k * 50
- for (int i = 0; i < 50; i++) {
- Mutation m = new Mutation(Integer.toString(i));
- m.put(empty, empty, bigValue);
- bw.addMutation(m);
- if (i % 10 == 0) {
- bw.flush();
+ try (BatchWriter bw = client.createBatchWriter(otherTable)) {
+ // 500k
+ byte[] bigValue = new byte[1024 * 500];
+ Arrays.fill(bigValue, (byte) 1);
+ // 500k * 50
+ for (int i = 0; i < 50; i++) {
+ Mutation m = new Mutation(Integer.toString(i));
+ m.put(empty, empty, bigValue);
+ bw.addMutation(m);
+ if (i % 10 == 0) {
+ bw.flush();
+ }
}
}
- bw.close();
-
client.tableOperations().flush(otherTable, null, null, true);
// Get the tservers which the master deems as active
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/KerberosReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/KerberosReplicationIT.java
index cd6ed1e..b17a597 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/KerberosReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/KerberosReplicationIT.java
@@ -27,7 +27,6 @@ import java.util.Set;
import org.apache.accumulo.cluster.ClusterUser;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.security.tokens.KerberosToken;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.clientImpl.ClientInfo;
@@ -213,20 +212,19 @@ public class KerberosReplicationIT extends AccumuloITBase {
Property.TABLE_REPLICATION_TARGET.getKey() + PEER_NAME, peerTableId1);
// Write some data to table1
- BatchWriter bw = primaryclient.createBatchWriter(primaryTable1, new BatchWriterConfig());
long masterTable1Records = 0L;
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(primaryTable1 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
- masterTable1Records++;
+ try (BatchWriter bw = primaryclient.createBatchWriter(primaryTable1)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(primaryTable1 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ masterTable1Records++;
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to primary cluster");
Set<String> filesFor1 = primaryclient.replicationOperations()
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/MultiInstanceReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/MultiInstanceReplicationIT.java
index 8550875..0c00b2c 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/MultiInstanceReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/MultiInstanceReplicationIT.java
@@ -38,7 +38,6 @@ import java.util.concurrent.TimeoutException;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.ClientProperty;
@@ -221,18 +220,17 @@ public class MultiInstanceReplicationIT extends ConfigurableMacBase {
Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId);
// Write some data to table1
- BatchWriter bw = clientMaster.createBatchWriter(masterTable, new BatchWriterConfig());
- for (int rows = 0; rows < 5000; rows++) {
- Mutation m = new Mutation(Integer.toString(rows));
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable)) {
+ for (int rows = 0; rows < 5000; rows++) {
+ Mutation m = new Mutation(Integer.toString(rows));
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to master cluster");
final Set<String> filesNeedingReplication = clientMaster.replicationOperations()
@@ -410,35 +408,33 @@ public class MultiInstanceReplicationIT extends ConfigurableMacBase {
Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId2);
// Write some data to table1
- BatchWriter bw = clientMaster.createBatchWriter(masterTable1, new BatchWriterConfig());
long masterTable1Records = 0L;
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(masterTable1 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
- masterTable1Records++;
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable1)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(masterTable1 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ masterTable1Records++;
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
// Write some data to table2
- bw = clientMaster.createBatchWriter(masterTable2, new BatchWriterConfig());
long masterTable2Records = 0L;
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(masterTable2 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
- masterTable2Records++;
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable2)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(masterTable2 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ masterTable2Records++;
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to master cluster");
Set<String> filesFor1 = clientMaster.replicationOperations().referencedFiles(masterTable1),
@@ -558,18 +554,17 @@ public class MultiInstanceReplicationIT extends ConfigurableMacBase {
Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId);
// Write some data to table1
- BatchWriter bw = clientMaster.createBatchWriter(masterTable, new BatchWriterConfig());
- for (int rows = 0; rows < 5000; rows++) {
- Mutation m = new Mutation(Integer.toString(rows));
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable)) {
+ for (int rows = 0; rows < 5000; rows++) {
+ Mutation m = new Mutation(Integer.toString(rows));
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to master cluster");
Set<String> files = clientMaster.replicationOperations().referencedFiles(masterTable);
@@ -694,31 +689,29 @@ public class MultiInstanceReplicationIT extends ConfigurableMacBase {
Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId2);
// Write some data to table1
- BatchWriter bw = clientMaster.createBatchWriter(masterTable1, new BatchWriterConfig());
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(masterTable1 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable1)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(masterTable1 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
// Write some data to table2
- bw = clientMaster.createBatchWriter(masterTable2, new BatchWriterConfig());
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(masterTable2 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable2)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(masterTable2 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to master cluster");
for (ProcessReference proc : cluster.getProcesses().get(ServerType.TABLET_SERVER)) {
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
index 9aebdae..696651a 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/ReplicationIT.java
@@ -46,7 +46,6 @@ import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.AccumuloException;
import org.apache.accumulo.core.client.AccumuloSecurityException;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.IteratorSetting;
import org.apache.accumulo.core.client.IteratorSetting.Column;
import org.apache.accumulo.core.client.Scanner;
@@ -301,15 +300,14 @@ public class ReplicationIT extends ConfigurableMacBase {
// If we have more than one tserver, this is subject to a race condition.
client.tableOperations().setProperty(table, Property.TABLE_REPLICATION.getKey(), "true");
- BatchWriter bw = client.createBatchWriter(table, new BatchWriterConfig());
- for (int i = 0; i < 10; i++) {
- Mutation m = new Mutation(Integer.toString(i));
- m.put(new byte[0], new byte[0], new byte[0]);
- bw.addMutation(m);
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ for (int i = 0; i < 10; i++) {
+ Mutation m = new Mutation(Integer.toString(i));
+ m.put(new byte[0], new byte[0], new byte[0]);
+ bw.addMutation(m);
+ }
}
- bw.close();
-
// After writing data, we'll get a replication table online
while (!ReplicationTable.isOnline(client)) {
sleepUninterruptibly(MILLIS_BETWEEN_REPLICATION_TABLE_ONLINE_CHECKS, TimeUnit.MILLISECONDS);
@@ -528,16 +526,16 @@ public class ReplicationIT extends ConfigurableMacBase {
private void writeSomeData(AccumuloClient client, String table, int rows, int cols)
throws Exception {
- BatchWriter bw = client.createBatchWriter(table, new BatchWriterConfig());
- for (int row = 0; row < rows; row++) {
- Mutation m = new Mutation(Integer.toString(row));
- for (int col = 0; col < cols; col++) {
- String value = Integer.toString(col);
- m.put(value, "", value);
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ for (int row = 0; row < rows; row++) {
+ Mutation m = new Mutation(Integer.toString(row));
+ for (int col = 0; col < cols; col++) {
+ String value = Integer.toString(col);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
}
@Test
@@ -668,12 +666,12 @@ public class ReplicationIT extends ConfigurableMacBase {
Status stat1 = StatusUtil.fileCreated(100);
Status stat2 = StatusUtil.fileClosed();
- BatchWriter bw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- Mutation m = new Mutation(
- ReplicationSection.getRowPrefix() + "file:/accumulo/wals/tserver+port/uuid");
- m.put(ReplicationSection.COLF, new Text("1"), ProtobufUtil.toValue(stat1));
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(MetadataTable.NAME)) {
+ Mutation m = new Mutation(
+ ReplicationSection.getRowPrefix() + "file:/accumulo/wals/tserver+port/uuid");
+ m.put(ReplicationSection.COLF, new Text("1"), ProtobufUtil.toValue(stat1));
+ bw.addMutation(m);
+ }
Status actual;
try (Scanner s = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
@@ -682,12 +680,12 @@ public class ReplicationIT extends ConfigurableMacBase {
actual = Status.parseFrom(Iterables.getOnlyElement(s).getValue().get());
assertEquals(stat1, actual);
- bw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- m = new Mutation(
- ReplicationSection.getRowPrefix() + "file:/accumulo/wals/tserver+port/uuid");
- m.put(ReplicationSection.COLF, new Text("1"), ProtobufUtil.toValue(stat2));
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(MetadataTable.NAME)) {
+ Mutation m = new Mutation(
+ ReplicationSection.getRowPrefix() + "file:/accumulo/wals/tserver+port/uuid");
+ m.put(ReplicationSection.COLF, new Text("1"), ProtobufUtil.toValue(stat2));
+ bw.addMutation(m);
+ }
}
try (Scanner s = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
@@ -765,18 +763,18 @@ public class ReplicationIT extends ConfigurableMacBase {
ReplicaSystemFactory.getPeerConfigurationValue(MockReplicaSystem.class, "50000"));
// Write a mutation to make a log file
- BatchWriter bw = client.createBatchWriter(table, new BatchWriterConfig());
- Mutation m = new Mutation("one");
- m.put("", "", "");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ Mutation m = new Mutation("one");
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
// Write another to make sure the logger rolls itself?
- bw = client.createBatchWriter(table, new BatchWriterConfig());
- m = new Mutation("three");
- m.put("", "", "");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ Mutation m = new Mutation("three");
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
try (Scanner s = client.createScanner(MetadataTable.NAME, Authorizations.EMPTY)) {
s.fetchColumnFamily(TabletsSection.LogColumnFamily.NAME);
@@ -789,16 +787,16 @@ public class ReplicationIT extends ConfigurableMacBase {
log.warn("Found wals {}", wals);
- bw = client.createBatchWriter(table, new BatchWriterConfig());
- m = new Mutation("three");
- byte[] bytes = new byte[1024 * 1024];
- m.put("1".getBytes(), new byte[0], bytes);
- m.put("2".getBytes(), new byte[0], bytes);
- m.put("3".getBytes(), new byte[0], bytes);
- m.put("4".getBytes(), new byte[0], bytes);
- m.put("5".getBytes(), new byte[0], bytes);
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ Mutation m = new Mutation("three");
+ byte[] bytes = new byte[1024 * 1024];
+ m.put("1".getBytes(), new byte[0], bytes);
+ m.put("2".getBytes(), new byte[0], bytes);
+ m.put("3".getBytes(), new byte[0], bytes);
+ m.put("4".getBytes(), new byte[0], bytes);
+ m.put("5".getBytes(), new byte[0], bytes);
+ bw.addMutation(m);
+ }
client.tableOperations().flush(table, null, null, true);
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java b/test/src/main/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
index 25bd866..408ed6f 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/UnorderedWorkAssignerReplicationIT.java
@@ -38,7 +38,6 @@ import java.util.concurrent.TimeoutException;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.security.tokens.PasswordToken;
import org.apache.accumulo.core.conf.ClientProperty;
@@ -229,18 +228,17 @@ public class UnorderedWorkAssignerReplicationIT extends ConfigurableMacBase {
sleepUninterruptibly(3, TimeUnit.SECONDS);
// Write some data to table1
- BatchWriter bw = clientMaster.createBatchWriter(masterTable, new BatchWriterConfig());
- for (int rows = 0; rows < 5000; rows++) {
- Mutation m = new Mutation(Integer.toString(rows));
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable)) {
+ for (int rows = 0; rows < 5000; rows++) {
+ Mutation m = new Mutation(Integer.toString(rows));
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to master cluster");
final Set<String> filesNeedingReplication = clientMaster.replicationOperations()
@@ -410,35 +408,33 @@ public class UnorderedWorkAssignerReplicationIT extends ConfigurableMacBase {
sleepUninterruptibly(3, TimeUnit.SECONDS);
// Write some data to table1
- BatchWriter bw = clientMaster.createBatchWriter(masterTable1, new BatchWriterConfig());
long masterTable1Records = 0L;
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(masterTable1 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
- masterTable1Records++;
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable1)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(masterTable1 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ masterTable1Records++;
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
// Write some data to table2
- bw = clientMaster.createBatchWriter(masterTable2, new BatchWriterConfig());
long masterTable2Records = 0L;
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(masterTable2 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
- masterTable2Records++;
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable2)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(masterTable2 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ masterTable2Records++;
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to master cluster");
Set<String> filesFor1 = clientMaster.replicationOperations().referencedFiles(masterTable1),
@@ -569,18 +565,17 @@ public class UnorderedWorkAssignerReplicationIT extends ConfigurableMacBase {
Property.TABLE_REPLICATION_TARGET.getKey() + peerClusterName, peerTableId);
// Write some data to table1
- BatchWriter bw = clientMaster.createBatchWriter(masterTable, new BatchWriterConfig());
- for (int rows = 0; rows < 5000; rows++) {
- Mutation m = new Mutation(Integer.toString(rows));
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable)) {
+ for (int rows = 0; rows < 5000; rows++) {
+ Mutation m = new Mutation(Integer.toString(rows));
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to master cluster");
Set<String> files = clientMaster.replicationOperations().referencedFiles(masterTable);
@@ -704,31 +699,29 @@ public class UnorderedWorkAssignerReplicationIT extends ConfigurableMacBase {
sleepUninterruptibly(3, TimeUnit.SECONDS);
// Write some data to table1
- BatchWriter bw = clientMaster.createBatchWriter(masterTable1, new BatchWriterConfig());
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(masterTable1 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable1)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(masterTable1 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
// Write some data to table2
- bw = clientMaster.createBatchWriter(masterTable2, new BatchWriterConfig());
- for (int rows = 0; rows < 2500; rows++) {
- Mutation m = new Mutation(masterTable2 + rows);
- for (int cols = 0; cols < 100; cols++) {
- String value = Integer.toString(cols);
- m.put(value, "", value);
+ try (BatchWriter bw = clientMaster.createBatchWriter(masterTable2)) {
+ for (int rows = 0; rows < 2500; rows++) {
+ Mutation m = new Mutation(masterTable2 + rows);
+ for (int cols = 0; cols < 100; cols++) {
+ String value = Integer.toString(cols);
+ m.put(value, "", value);
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
}
- bw.close();
-
log.info("Wrote all data to master cluster");
while (!ReplicationTable.isOnline(clientMaster)) {
diff --git a/test/src/main/java/org/apache/accumulo/test/replication/UnusedWalDoesntCloseReplicationStatusIT.java b/test/src/main/java/org/apache/accumulo/test/replication/UnusedWalDoesntCloseReplicationStatusIT.java
index 2564e90..4a46d2f 100644
--- a/test/src/main/java/org/apache/accumulo/test/replication/UnusedWalDoesntCloseReplicationStatusIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/replication/UnusedWalDoesntCloseReplicationStatusIT.java
@@ -32,7 +32,6 @@ import java.util.UUID;
import org.apache.accumulo.core.client.Accumulo;
import org.apache.accumulo.core.client.AccumuloClient;
import org.apache.accumulo.core.client.BatchWriter;
-import org.apache.accumulo.core.client.BatchWriterConfig;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
@@ -151,11 +150,11 @@ public class UnusedWalDoesntCloseReplicationStatusIT extends ConfigurableMacBase
dos.close();
- BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m = new Mutation("m");
- m.put("m", "m", "M");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
+ Mutation m = new Mutation("m");
+ m.put("m", "m", "M");
+ bw.addMutation(m);
+ }
log.info("State of metadata table after inserting a record");
@@ -181,18 +180,18 @@ public class UnusedWalDoesntCloseReplicationStatusIT extends ConfigurableMacBase
// Add our fake WAL to the log column for this table
String walUri = tserverWal.toURI().toString();
KeyExtent extent = new KeyExtent(tableId, null, null);
- bw = client.createBatchWriter(MetadataTable.NAME, new BatchWriterConfig());
- m = new Mutation(extent.getMetadataEntry());
- m.put(MetadataSchema.TabletsSection.LogColumnFamily.NAME,
- new Text("localhost:12345/" + walUri), new Value((walUri + "|1").getBytes(UTF_8)));
- bw.addMutation(m);
-
- // Add a replication entry for our fake WAL
- m = new Mutation(MetadataSchema.ReplicationSection.getRowPrefix() + new Path(walUri));
- m.put(MetadataSchema.ReplicationSection.COLF, new Text(tableId.canonical()),
- new Value(StatusUtil.fileCreated(System.currentTimeMillis()).toByteArray()));
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(MetadataTable.NAME)) {
+ Mutation m = new Mutation(extent.getMetadataEntry());
+ m.put(MetadataSchema.TabletsSection.LogColumnFamily.NAME,
+ new Text("localhost:12345/" + walUri), new Value((walUri + "|1").getBytes(UTF_8)));
+ bw.addMutation(m);
+
+ // Add a replication entry for our fake WAL
+ m = new Mutation(MetadataSchema.ReplicationSection.getRowPrefix() + new Path(walUri));
+ m.put(MetadataSchema.ReplicationSection.COLF, new Text(tableId.canonical()),
+ new Value(StatusUtil.fileCreated(System.currentTimeMillis()).toByteArray()));
+ bw.addMutation(m);
+ }
log.info("State of metadata after injecting WAL manually");
}