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/02/26 15:27:14 UTC
[accumulo] branch master updated: More try-with-resources
BatchWriter updates (#989)
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 64a33c8 More try-with-resources BatchWriter updates (#989)
64a33c8 is described below
commit 64a33c8a41ebf9c4cb8dea42a50b3cf01567db02
Author: Mike Walch <mw...@apache.org>
AuthorDate: Tue Feb 26 10:26:03 2019 -0500
More try-with-resources BatchWriter updates (#989)
---
.../accumulo/test/functional/BloomFilterIT.java | 11 ++-
.../accumulo/test/functional/CloneTestIT.java | 3 +-
.../test/functional/KerberosRenewalIT.java | 11 ++-
.../accumulo/test/functional/LargeRowIT.java | 27 +++-----
.../test/functional/ManyWriteAheadLogsIT.java | 6 +-
.../test/functional/MasterAssignmentIT.java | 11 ++-
.../apache/accumulo/test/functional/MergeIT.java | 39 ++++++-----
.../accumulo/test/functional/PermissionsIT.java | 39 +++++------
.../accumulo/test/functional/ReadWriteIT.java | 14 ++--
.../apache/accumulo/test/functional/ScanIdIT.java | 7 +-
.../accumulo/test/functional/ScanIteratorIT.java | 36 ++++------
.../accumulo/test/functional/ScanRangeIT.java | 25 +++----
.../test/functional/ScanSessionTimeOutIT.java | 17 ++---
.../accumulo/test/functional/ScannerContextIT.java | 49 +++++++-------
.../apache/accumulo/test/functional/ScannerIT.java | 15 ++--
.../test/functional/ServerSideErrorIT.java | 14 ++--
.../test/functional/SessionBlockVerifyIT.java | 17 ++---
.../test/functional/SessionDurabilityIT.java | 12 ++--
.../test/functional/SparseColumnFamilyIT.java | 30 ++++----
.../apache/accumulo/test/functional/SummaryIT.java | 14 ++--
.../apache/accumulo/test/functional/TabletIT.java | 18 +++--
.../functional/TabletStateChangeIteratorIT.java | 12 ++--
.../apache/accumulo/test/functional/TimeoutIT.java | 18 +++--
.../accumulo/test/functional/TooManyDeletesIT.java | 7 +-
.../accumulo/test/functional/VisibilityIT.java | 79 ++++++++++------------
.../accumulo/test/functional/WALSunnyDayIT.java | 32 ++++-----
.../test/functional/ZookeeperRestartIT.java | 10 +--
27 files changed, 253 insertions(+), 320 deletions(-)
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 e329fa4..3ede1ba 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
@@ -28,7 +28,6 @@ import java.util.Random;
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.Scanner;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.conf.Property;
@@ -95,11 +94,11 @@ public class BloomFilterIT extends AccumuloClusterHarness {
log.info("Writing complete");
// test inserting an empty key
- BatchWriter bw = c.createBatchWriter(tables[3], new BatchWriterConfig());
- Mutation m = new Mutation(new Text(""));
- m.put(new Text(""), new Text(""), new Value("foo1".getBytes()));
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(tables[3])) {
+ Mutation m = new Mutation(new Text(""));
+ m.put(new Text(""), new Text(""), new Value("foo1".getBytes()));
+ bw.addMutation(m);
+ }
c.tableOperations().flush(tables[3], null, null, true);
for (String table : Arrays.asList(tables[0], tables[1], tables[2])) {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java b/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
index 9133380..7b8fbbe 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/CloneTestIT.java
@@ -35,7 +35,6 @@ import java.util.TreeSet;
import org.apache.accumulo.cluster.AccumuloCluster;
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.client.admin.DiskUsage;
@@ -270,7 +269,7 @@ public class CloneTestIT extends AccumuloClusterHarness {
client.tableOperations().addSplits(tables[0], splits);
- try (BatchWriter bw = client.createBatchWriter(tables[0], new BatchWriterConfig())) {
+ try (BatchWriter bw = client.createBatchWriter(tables[0])) {
bw.addMutations(mutations);
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java b/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
index 17ffde1..8307720 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/KerberosRenewalIT.java
@@ -26,7 +26,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;
@@ -184,11 +183,11 @@ public class KerberosRenewalIT extends AccumuloITBase {
AccumuloSecurityException, AccumuloException, TableExistsException {
final String table = testName.getMethodName() + "_table";
client.tableOperations().create(table);
- BatchWriter bw = client.createBatchWriter(table, new BatchWriterConfig());
- Mutation m = new Mutation("a");
- m.put("b", "c", "d");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ Mutation m = new Mutation("a");
+ m.put("b", "c", "d");
+ bw.addMutation(m);
+ }
client.tableOperations().compact(table, new CompactionConfig().setFlush(true).setWait(true));
try (Scanner s = client.createScanner(table, Authorizations.EMPTY)) {
Entry<Key,Value> entry = Iterables.getOnlyElement(s);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/LargeRowIT.java b/test/src/main/java/org/apache/accumulo/test/functional/LargeRowIT.java
index f28a22b..43e532e 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/LargeRowIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/LargeRowIT.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.Scanner;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
@@ -156,25 +155,21 @@ public class LargeRowIT extends AccumuloClusterHarness {
@SuppressFBWarnings(value = "PREDICTABLE_RANDOM",
justification = "predictable random is okay for testing")
private void basicTest(AccumuloClient c, String table, int expectedSplits) throws Exception {
- BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig());
+ try (BatchWriter bw = c.createBatchWriter(table)) {
- Random r = new Random();
- byte rowData[] = new byte[ROW_SIZE];
-
- r.setSeed(SEED);
+ Random r = new Random();
+ byte rowData[] = new byte[ROW_SIZE];
+ r.setSeed(SEED);
- for (int i = 0; i < NUM_ROWS; i++) {
-
- r.nextBytes(rowData);
- TestIngest.toPrintableChars(rowData);
-
- Mutation mut = new Mutation(new Text(rowData));
- mut.put(new Text(""), new Text(""), new Value(Integer.toString(i).getBytes(UTF_8)));
- bw.addMutation(mut);
+ for (int i = 0; i < NUM_ROWS; i++) {
+ r.nextBytes(rowData);
+ TestIngest.toPrintableChars(rowData);
+ Mutation mut = new Mutation(new Text(rowData));
+ mut.put(new Text(""), new Text(""), new Value(Integer.toString(i).getBytes(UTF_8)));
+ bw.addMutation(mut);
+ }
}
- bw.close();
-
FunctionalTestUtils.checkSplits(c, table, expectedSplits, expectedSplits);
verify(c, table);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ManyWriteAheadLogsIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ManyWriteAheadLogsIT.java
index d88b99b..e9c8fb6 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ManyWriteAheadLogsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ManyWriteAheadLogsIT.java
@@ -31,7 +31,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.conf.Property;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.harness.AccumuloClusterHarness;
@@ -108,9 +107,8 @@ public class ManyWriteAheadLogsIT extends AccumuloClusterHarness {
// WALs. If nothing is done about all of these closed WALs, then it could cause a large burden
// at recovery time.
- try (BatchWriter manyWALsWriter = c.createBatchWriter(manyWALsTable, new BatchWriterConfig());
- BatchWriter rollWALsWriter = c.createBatchWriter(rollWALsTable,
- new BatchWriterConfig())) {
+ try (BatchWriter manyWALsWriter = c.createBatchWriter(manyWALsTable);
+ BatchWriter rollWALsWriter = c.createBatchWriter(rollWALsTable)) {
byte[] val = new byte[768];
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MasterAssignmentIT.java b/test/src/main/java/org/apache/accumulo/test/functional/MasterAssignmentIT.java
index eb82d5e..6a5d830 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/MasterAssignmentIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/MasterAssignmentIT.java
@@ -22,7 +22,6 @@ import static org.junit.Assert.assertNull;
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.ClientContext;
import org.apache.accumulo.core.data.Mutation;
import org.apache.accumulo.core.data.Range;
@@ -57,11 +56,11 @@ public class MasterAssignmentIT extends AccumuloClusterHarness {
assertNull(newTablet.future);
// put something in it
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m = new Mutation("a");
- m.put("b", "c", "d");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ Mutation m = new Mutation("a");
+ m.put("b", "c", "d");
+ bw.addMutation(m);
+ }
// give it a last location
c.tableOperations().flush(tableName, null, null, true);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java b/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
index fdd7244..4178f65 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/MergeIT.java
@@ -60,13 +60,13 @@ public class MergeIT extends AccumuloClusterHarness {
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
c.tableOperations().addSplits(tableName, splits("a b c d e f g h i j k".split(" ")));
- BatchWriter bw = c.createBatchWriter(tableName, null);
- for (String row : "a b c d e f g h i j k".split(" ")) {
- Mutation m = new Mutation(row);
- m.put("cf", "cq", "value");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (String row : "a b c d e f g h i j k".split(" ")) {
+ Mutation m = new Mutation(row);
+ m.put("cf", "cq", "value");
+ bw.addMutation(m);
+ }
}
- bw.close();
c.tableOperations().flush(tableName, null, null, true);
c.tableOperations().merge(tableName, new Text("c1"), new Text("f1"));
assertEquals(8, c.tableOperations().listSplits(tableName).size());
@@ -80,13 +80,13 @@ public class MergeIT extends AccumuloClusterHarness {
c.tableOperations().create(tableName);
c.tableOperations().addSplits(tableName,
splits("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(" ")));
- BatchWriter bw = c.createBatchWriter(tableName, null);
- for (String row : "c e f y".split(" ")) {
- Mutation m = new Mutation(row);
- m.put("cf", "cq", "mersydotesanddozeydotesanlittolamsiedives");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (String row : "c e f y".split(" ")) {
+ Mutation m = new Mutation(row);
+ m.put("cf", "cq", "mersydotesanddozeydotesanlittolamsiedives");
+ bw.addMutation(m);
+ }
}
- bw.close();
c.tableOperations().flush(tableName, null, null, true);
Merge merge = new Merge();
merge.mergomatic(c, tableName, null, null, 100, false);
@@ -172,17 +172,16 @@ public class MergeIT extends AccumuloClusterHarness {
}
client.tableOperations().addSplits(table, splitSet);
- BatchWriter bw = client.createBatchWriter(table, null);
HashSet<String> expected = new HashSet<>();
- for (String row : inserts) {
- Mutation m = new Mutation(row);
- m.put("cf", "cq", row);
- bw.addMutation(m);
- expected.add(row);
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ for (String row : inserts) {
+ Mutation m = new Mutation(row);
+ m.put("cf", "cq", row);
+ bw.addMutation(m);
+ expected.add(row);
+ }
}
- bw.close();
-
client.tableOperations().merge(table, start == null ? null : new Text(start),
end == null ? null : new Text(end));
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java b/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
index 76db2fd..2447525 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/PermissionsIT.java
@@ -35,7 +35,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.MutationsRejectedException;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.client.TableNotFoundException;
@@ -605,16 +604,16 @@ public class PermissionsIT extends AccumuloClusterHarness {
}
private void createTestTable(AccumuloClient c, String testUser, String tableName)
- throws Exception, MutationsRejectedException {
+ throws Exception {
if (!c.tableOperations().exists(tableName)) {
// create the test table
c.tableOperations().create(tableName);
// put in some initial data
- BatchWriter writer = c.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m = new Mutation(new Text("row"));
- m.put(new Text("cf"), new Text("cq"), new Value("val".getBytes()));
- writer.addMutation(m);
- writer.close();
+ try (BatchWriter writer = c.createBatchWriter(tableName)) {
+ Mutation m = new Mutation(new Text("row"));
+ m.put(new Text("cf"), new Text("cq"), new Value("val".getBytes()));
+ writer.addMutation(m);
+ }
// verify proper permissions for creator and test user
verifyHasOnlyTheseTablePermissions(c, c.whoami(), tableName, TablePermission.values());
@@ -647,12 +646,10 @@ public class PermissionsIT extends AccumuloClusterHarness {
break;
case WRITE:
try {
- writer = test_user_client.createBatchWriter(tableName, new BatchWriterConfig());
- m = new Mutation(new Text("row"));
- m.put(new Text("a"), new Text("b"), new Value("c".getBytes()));
- writer.addMutation(m);
- try {
- writer.close();
+ try (BatchWriter bw = test_user_client.createBatchWriter(tableName)) {
+ m = new Mutation(new Text("row"));
+ m.put(new Text("a"), new Text("b"), new Value("c".getBytes()));
+ bw.addMutation(m);
} catch (MutationsRejectedException e1) {
if (e1.getSecurityErrorCodes().size() > 0)
throw new AccumuloSecurityException(test_user_client.whoami(),
@@ -713,10 +710,8 @@ public class PermissionsIT extends AccumuloClusterHarness {
}
private void testGrantedTablePermission(AccumuloClient test_user_client, TablePermission perm,
- String tableName) throws AccumuloException, AccumuloSecurityException, TableNotFoundException,
- MutationsRejectedException {
- BatchWriter writer;
- Mutation m;
+ String tableName)
+ throws AccumuloException, AccumuloSecurityException, TableNotFoundException {
log.debug("Confirming that the presence of the {} permission properly permits the user", perm);
// test permission after granting it
@@ -729,11 +724,11 @@ public class PermissionsIT extends AccumuloClusterHarness {
}
break;
case WRITE:
- writer = test_user_client.createBatchWriter(tableName, new BatchWriterConfig());
- m = new Mutation(new Text("row"));
- m.put(new Text("a"), new Text("b"), new Value("c".getBytes()));
- writer.addMutation(m);
- writer.close();
+ try (BatchWriter bw = test_user_client.createBatchWriter(tableName)) {
+ Mutation m = new Mutation(new Text("row"));
+ m.put(new Text("a"), new Text("b"), new Value("c".getBytes()));
+ bw.addMutation(m);
+ }
break;
case BULK_IMPORT:
// test for bulk import permission would go here
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
index 5a9ceda..f6e5754 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ReadWriteIT.java
@@ -59,13 +59,9 @@ import org.apache.accumulo.core.cli.BatchWriterOpts;
import org.apache.accumulo.core.cli.ScannerOpts;
import org.apache.accumulo.core.client.Accumulo;
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.BatchScanner;
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.client.admin.NewTableConfiguration;
import org.apache.accumulo.core.client.admin.TableOperations;
import org.apache.accumulo.core.client.security.tokens.AuthenticationToken;
@@ -387,9 +383,9 @@ public class ReadWriteIT extends AccumuloClusterHarness {
accumuloClient.tableOperations().setProperty(tableName, "table.groups.enabled", "g1");
ingest(accumuloClient, getClientInfo(), 2000, 1, 50, 0, tableName);
accumuloClient.tableOperations().compact(tableName, null, null, true, true);
- BatchWriter bw = accumuloClient.createBatchWriter(tableName, new BatchWriterConfig());
- bw.addMutation(m("zzzzzzzzzzz", "colf2", "cq", "value"));
- bw.close();
+ try (BatchWriter bw = accumuloClient.createBatchWriter(tableName)) {
+ bw.addMutation(m("zzzzzzzzzzz", "colf2", "cq", "value"));
+ }
long now = System.currentTimeMillis();
try (Scanner scanner = accumuloClient.createScanner(tableName, Authorizations.EMPTY)) {
scanner.fetchColumnFamily(new Text("colf"));
@@ -402,7 +398,6 @@ public class ReadWriteIT extends AccumuloClusterHarness {
scanner.fetchColumnFamily(new Text("colf2"));
Iterators.size(scanner.iterator());
}
- bw.close();
long diff2 = System.currentTimeMillis() - now;
assertTrue(diff2 < diff);
}
@@ -442,8 +437,7 @@ public class ReadWriteIT extends AccumuloClusterHarness {
}
private void verifyLocalityGroupsInRFile(final AccumuloClient accumuloClient,
- final String tableName)
- throws Exception, AccumuloException, AccumuloSecurityException, TableNotFoundException {
+ final String tableName) throws Exception {
ingest(accumuloClient, getClientInfo(), 2000, 1, 50, 0, tableName);
verify(accumuloClient, getClientInfo(), 2000, 1, 50, 0, tableName);
accumuloClient.tableOperations().flush(tableName, null, null, true);
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanIdIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanIdIT.java
index a62fa59..4219cd4 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanIdIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScanIdIT.java
@@ -44,7 +44,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;
@@ -362,9 +361,7 @@ public class ScanIdIT extends AccumuloClusterHarness {
*/
private void generateSampleData(AccumuloClient accumuloClient, final String tablename) {
- try {
-
- BatchWriter bw = accumuloClient.createBatchWriter(tablename, new BatchWriterConfig());
+ try (BatchWriter bw = accumuloClient.createBatchWriter(tablename)) {
ColumnVisibility vis = new ColumnVisibility("public");
@@ -383,8 +380,6 @@ public class ScanIdIT extends AccumuloClusterHarness {
bw.addMutation(m);
}
-
- bw.close();
} catch (TableNotFoundException | MutationsRejectedException ex) {
throw new IllegalStateException("Initialization failed. Could not create test data", ex);
}
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 cbc4a73..5847378 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
@@ -29,7 +29,6 @@ import org.apache.accumulo.cluster.ClusterUser;
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.MutationsRejectedException;
import org.apache.accumulo.core.client.Scanner;
@@ -110,20 +109,17 @@ public class ScanIteratorIT extends AccumuloClusterHarness {
String tableName = getUniqueNames(1)[0];
try (AccumuloClient c = createAccumuloClient()) {
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
-
- for (int i = 0; i < 1000; i++) {
- Mutation m = new Mutation(new Text(String.format("%06d", i)));
- m.put(new Text("cf1"), new Text("cq1"),
- new Value(Integer.toString(1000 - i).getBytes(UTF_8)));
- m.put(new Text("cf1"), new Text("cq2"),
- new Value(Integer.toString(i - 1000).getBytes(UTF_8)));
-
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < 1000; i++) {
+ Mutation m = new Mutation(new Text(String.format("%06d", i)));
+ m.put(new Text("cf1"), new Text("cq1"),
+ new Value(Integer.toString(1000 - i).getBytes(UTF_8)));
+ m.put(new Text("cf1"), new Text("cq2"),
+ new Value(Integer.toString(i - 1000).getBytes(UTF_8)));
+ bw.addMutation(m);
+ }
}
- bw.close();
-
try (Scanner scanner = c.createScanner(tableName, new Authorizations());
BatchScanner bscanner = c.createBatchScanner(tableName, new Authorizations(), 3)) {
@@ -243,13 +239,11 @@ public class ScanIteratorIT extends AccumuloClusterHarness {
private void writeTestMutation(AccumuloClient userC)
throws TableNotFoundException, MutationsRejectedException {
- BatchWriter batchWriter = userC.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m = new Mutation("1");
- m.put(new Text("2"), new Text("3"), new Value("".getBytes()));
- batchWriter.addMutation(m);
- batchWriter.flush();
- batchWriter.close();
-
+ try (BatchWriter batchWriter = userC.createBatchWriter(tableName)) {
+ Mutation m = new Mutation("1");
+ m.put(new Text("2"), new Text("3"), new Value("".getBytes()));
+ batchWriter.addMutation(m);
+ batchWriter.flush();
+ }
}
-
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeIT.java
index 79c6a08..3a55342 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScanRangeIT.java
@@ -23,7 +23,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.data.Key;
import org.apache.accumulo.core.data.Mutation;
@@ -227,23 +226,19 @@ public class ScanRangeIT extends AccumuloClusterHarness {
private void insertData(AccumuloClient c, String table) throws Exception {
- BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig());
-
- for (int i = 0; i < ROW_LIMIT; i++) {
- Mutation m = new Mutation(createRow(i));
-
- for (int j = 0; j < CF_LIMIT; j++) {
- for (int k = 0; k < CQ_LIMIT; k++) {
- for (int t = 0; t < TS_LIMIT; t++) {
- m.put(createCF(j), createCQ(k), t,
- new Value(String.format("%06d_%03d_%03d_%03d", i, j, k, t).getBytes(UTF_8)));
+ try (BatchWriter bw = c.createBatchWriter(table)) {
+ for (int i = 0; i < ROW_LIMIT; i++) {
+ Mutation m = new Mutation(createRow(i));
+ for (int j = 0; j < CF_LIMIT; j++) {
+ for (int k = 0; k < CQ_LIMIT; k++) {
+ for (int t = 0; t < TS_LIMIT; t++) {
+ m.put(createCF(j), createCQ(k), t,
+ new Value(String.format("%06d_%03d_%03d_%03d", i, j, k, t).getBytes(UTF_8)));
+ }
}
}
+ bw.addMutation(m);
}
-
- bw.addMutation(m);
}
-
- bw.close();
}
}
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java
index 2c48388..f355743 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScanSessionTimeOutIT.java
@@ -26,7 +26,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.admin.InstanceOperations;
import org.apache.accumulo.core.conf.ConfigurationTypeHelper;
@@ -99,18 +98,16 @@ public class ScanSessionTimeOutIT extends AccumuloClusterHarness {
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < 100000; i++) {
+ Mutation m = new Mutation(new Text(String.format("%08d", i)));
+ for (int j = 0; j < 3; j++)
+ m.put(new Text("cf1"), new Text("cq" + j), new Value((i + "_" + j).getBytes(UTF_8)));
- for (int i = 0; i < 100000; i++) {
- Mutation m = new Mutation(new Text(String.format("%08d", i)));
- for (int j = 0; j < 3; j++)
- m.put(new Text("cf1"), new Text("cq" + j), new Value((i + "_" + j).getBytes(UTF_8)));
-
- bw.addMutation(m);
+ bw.addMutation(m);
+ }
}
- bw.close();
-
try (Scanner scanner = c.createScanner(tableName, new Authorizations())) {
scanner.setBatchSize(1000);
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 658f571..47d6eb9 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
@@ -29,7 +29,6 @@ import java.util.Map.Entry;
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;
@@ -93,13 +92,13 @@ public class ScannerContextIT extends AccumuloClusterHarness {
// Insert rows with the word "Test" in the value.
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- for (int i = 0; i < ITERATIONS; i++) {
- Mutation m = new Mutation("row" + i);
- m.put("cf", "col1", "Test");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < ITERATIONS; i++) {
+ Mutation m = new Mutation("row" + i);
+ m.put("cf", "col1", "Test");
+ bw.addMutation(m);
+ }
}
- bw.close();
// Ensure that we can get the data back
scanCheck(c, tableName, null, null, "Test");
batchCheck(c, tableName, null, null, "Test");
@@ -150,13 +149,13 @@ public class ScannerContextIT extends AccumuloClusterHarness {
c.tableOperations().create(tableName);
// Set the FOO context on the table
c.tableOperations().setProperty(tableName, Property.TABLE_CLASSPATH.getKey(), tableContext);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- for (int i = 0; i < ITERATIONS; i++) {
- Mutation m = new Mutation("row" + i);
- m.put("cf", "col1", "Test");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < ITERATIONS; i++) {
+ Mutation m = new Mutation("row" + i);
+ m.put("cf", "col1", "Test");
+ bw.addMutation(m);
+ }
}
- bw.close();
scanCheck(c, tableName, null, null, "Test");
batchCheck(c, tableName, null, null, "Test");
// This iterator is in the test iterators jar file
@@ -198,13 +197,13 @@ public class ScannerContextIT extends AccumuloClusterHarness {
// Insert rows with the word "Test" in the value.
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- for (int i = 0; i < ITERATIONS; i++) {
- Mutation m = new Mutation("row" + i);
- m.put("cf", "col1", "Test");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < ITERATIONS; i++) {
+ Mutation m = new Mutation("row" + i);
+ m.put("cf", "col1", "Test");
+ bw.addMutation(m);
+ }
}
- bw.close();
try (Scanner one = c.createScanner(tableName, Authorizations.EMPTY);
Scanner two = c.createScanner(tableName, Authorizations.EMPTY)) {
@@ -244,13 +243,13 @@ public class ScannerContextIT extends AccumuloClusterHarness {
// Insert rows with the word "Test" in the value.
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- for (int i = 0; i < ITERATIONS; i++) {
- Mutation m = new Mutation("row" + i);
- m.put("cf", "col1", "Test");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < ITERATIONS; i++) {
+ Mutation m = new Mutation("row" + i);
+ m.put("cf", "col1", "Test");
+ bw.addMutation(m);
+ }
}
- bw.close();
try (Scanner one = c.createScanner(tableName, Authorizations.EMPTY)) {
IteratorSetting cfg = new IteratorSetting(21, "reverse",
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ScannerIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ScannerIT.java
index c681354..7ed16a0 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ScannerIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ScannerIT.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.IteratorSetting;
import org.apache.accumulo.core.client.Scanner;
import org.apache.accumulo.core.data.Key;
@@ -51,16 +50,14 @@ public class ScannerIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(table);
- BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig());
-
- Mutation m = new Mutation("a");
- for (int i = 0; i < 10; i++) {
- m.put(Integer.toString(i), "", "");
+ try (BatchWriter bw = c.createBatchWriter(table)) {
+ Mutation m = new Mutation("a");
+ for (int i = 0; i < 10; i++) {
+ m.put(Integer.toString(i), "", "");
+ }
+ bw.addMutation(m);
}
- bw.addMutation(m);
- bw.close();
-
IteratorSetting cfg;
Stopwatch sw;
Iterator<Entry<Key,Value>> iterator;
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
index 968fa30..6e9f35f 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ServerSideErrorIT.java
@@ -25,7 +25,6 @@ import java.util.concurrent.TimeUnit;
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.client.admin.TableOperations;
@@ -55,14 +54,11 @@ public class ServerSideErrorIT extends AccumuloClusterHarness {
Combiner.setColumns(is, Collections.singletonList(new IteratorSetting.Column("acf")));
c.tableOperations().attachIterator(tableName, is);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
-
- Mutation m = new Mutation(new Text("r1"));
- m.put(new Text("acf"), new Text("foo"), new Value(new byte[] {'1'}));
-
- bw.addMutation(m);
-
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ Mutation m = new Mutation(new Text("r1"));
+ m.put(new Text("acf"), new Text("foo"), new Value(new byte[] {'1'}));
+ bw.addMutation(m);
+ }
boolean caught = false;
// try to scan table
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SessionBlockVerifyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SessionBlockVerifyIT.java
index 300b794..73a48cb 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SessionBlockVerifyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SessionBlockVerifyIT.java
@@ -32,7 +32,6 @@ import java.util.concurrent.Future;
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.ActiveScan;
@@ -86,18 +85,16 @@ public class SessionBlockVerifyIT extends ScanSessionTimeOutIT {
String tableName = getUniqueNames(1)[0];
c.tableOperations().create(tableName);
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ for (int i = 0; i < 1000; i++) {
+ Mutation m = new Mutation(new Text(String.format("%08d", i)));
+ for (int j = 0; j < 3; j++)
+ m.put(new Text("cf1"), new Text("cq" + j), new Value((i + "_" + j).getBytes(UTF_8)));
- for (int i = 0; i < 1000; i++) {
- Mutation m = new Mutation(new Text(String.format("%08d", i)));
- for (int j = 0; j < 3; j++)
- m.put(new Text("cf1"), new Text("cq" + j), new Value((i + "_" + j).getBytes(UTF_8)));
-
- bw.addMutation(m);
+ bw.addMutation(m);
+ }
}
- bw.close();
-
try (Scanner scanner = c.createScanner(tableName, new Authorizations())) {
scanner.setReadaheadThreshold(20000);
scanner.setRange(new Range(String.format("%08d", 0), String.format("%08d", 1000)));
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
index 7141b14..7f3b78b 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SessionDurabilityIT.java
@@ -90,13 +90,13 @@ public class SessionDurabilityIT extends ConfigurableMacBase {
private void writeSome(AccumuloClient c, String tableName, int n, BatchWriterConfig cfg)
throws Exception {
- BatchWriter bw = c.createBatchWriter(tableName, cfg);
- for (int i = 0; i < n; i++) {
- Mutation m = new Mutation(i + "");
- m.put("", "", "");
- bw.addMutation(m);
+ try (BatchWriter bw = c.createBatchWriter(tableName, cfg)) {
+ for (int i = 0; i < n; i++) {
+ Mutation m = new Mutation(i + "");
+ m.put("", "", "");
+ bw.addMutation(m);
+ }
}
- bw.close();
}
@Test(timeout = 3 * 60 * 1000)
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/SparseColumnFamilyIT.java b/test/src/main/java/org/apache/accumulo/test/functional/SparseColumnFamilyIT.java
index 6d11f11..3390052 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/SparseColumnFamilyIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/SparseColumnFamilyIT.java
@@ -21,7 +21,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.data.Key;
import org.apache.accumulo.core.data.Mutation;
@@ -48,25 +47,24 @@ public class SparseColumnFamilyIT extends AccumuloClusterHarness {
try (AccumuloClient c = createAccumuloClient()) {
c.tableOperations().create(scftt);
- BatchWriter bw = c.createBatchWriter(scftt, new BatchWriterConfig());
+ try (BatchWriter bw = c.createBatchWriter(scftt)) {
- // create file in the tablet that has mostly column family 0, with a few entries for column
- // family 1
+ // create file in the tablet that has mostly column family 0, with a few entries for column
+ // family 1
+ bw.addMutation(nm(0, 1, 0));
+ for (int i = 1; i < 99999; i++) {
+ bw.addMutation(nm(i * 2, 0, i));
+ }
+ bw.addMutation(nm(99999 * 2, 1, 99999));
+ bw.flush();
- bw.addMutation(nm(0, 1, 0));
- for (int i = 1; i < 99999; i++) {
- bw.addMutation(nm(i * 2, 0, i));
- }
- bw.addMutation(nm(99999 * 2, 1, 99999));
- bw.flush();
+ c.tableOperations().flush(scftt, null, null, true);
- c.tableOperations().flush(scftt, null, null, true);
-
- // create a file that has column family 1 and 0 interleaved
- for (int i = 0; i < 100000; i++) {
- bw.addMutation(nm(i * 2 + 1, i % 2 == 0 ? 0 : 1, i));
+ // create a file that has column family 1 and 0 interleaved
+ for (int i = 0; i < 100000; i++) {
+ bw.addMutation(nm(i * 2 + 1, i % 2 == 0 ? 0 : 1, i));
+ }
}
- bw.close();
c.tableOperations().flush(scftt, null, null, true);
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 e927fab..198a8f6 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
@@ -486,7 +486,7 @@ public class SummaryIT extends AccumuloClusterHarness {
ntc.enableSummarization(sc1);
c.tableOperations().create(table, ntc);
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
write(bw, "bar1", "f1", "q1", "v1");
write(bw, "bar2", "f1", "q1", "v2");
write(bw, "foo1", "f1", "q1", "v3");
@@ -515,7 +515,7 @@ public class SummaryIT extends AccumuloClusterHarness {
assertEquals(2, counts.size());
}
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
write(bw, "foo2", "f1", "q1", "v4");
write(bw, "foo3", "f1", "q1", "v5");
write(bw, "foo4", "f1", "q1", "v6");
@@ -558,7 +558,7 @@ public class SummaryIT extends AccumuloClusterHarness {
// add a single split so that summary stats merge is forced
c.tableOperations().addSplits(table, new TreeSet<>(Collections.singleton(new Text("g"))));
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
write(bw, "bar1", "f1", "q1", "v1");
write(bw, "bar2", "f1", "q1", "v2");
write(bw, "foo1", "f1", "q1", "v3");
@@ -582,7 +582,7 @@ public class SummaryIT extends AccumuloClusterHarness {
ntc.enableSummarization(sc1);
c.tableOperations().create(table, ntc);
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
write(bw, "bar1", "f1", "q1", "v1");
write(bw, "bar2", "f1", "q1", "v2");
write(bw, "foo1", "f1", "q1", "v3");
@@ -658,7 +658,7 @@ public class SummaryIT extends AccumuloClusterHarness {
ntc.enableSummarization(sc1);
c.tableOperations().create(table, ntc);
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
write(bw, "a_large", "f1", "q1", "v1");
write(bw, "v_small", "f1", "q1", "v2");
}
@@ -739,7 +739,7 @@ public class SummaryIT extends AccumuloClusterHarness {
c.tableOperations().create(table, ntc);
Map<Key,Value> expected = new HashMap<>();
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
write(bw, expected, "order:001", "chocolate", "dark", 3L, "99kg");
write(bw, expected, "order:001", "chocolate", "light", 4L, "94kg");
write(bw, expected, "order:001", "coffee", "dark", 5L, "33kg");
@@ -861,7 +861,7 @@ public class SummaryIT extends AccumuloClusterHarness {
for (int t = 0; t < 20; t++) {
// this loop should cause a varying number of files and compactions
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
for (int i = 0; i < 10000; i++) {
String row = String.format("%06d", rand.nextInt(1_000_000));
String fam = String.format("%03d", rand.nextInt(100));
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TabletIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TabletIT.java
index bc72450..84e6712 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TabletIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TabletIT.java
@@ -25,7 +25,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.conf.Property;
import org.apache.accumulo.core.data.Key;
@@ -80,16 +79,15 @@ public class TabletIT extends AccumuloClusterHarness {
accumuloClient.tableOperations().setProperty(tableName,
Property.TABLE_SPLIT_THRESHOLD.getKey(), "200");
accumuloClient.tableOperations().addSplits(tableName, keys);
- BatchWriter b = accumuloClient.createBatchWriter(tableName, new BatchWriterConfig());
-
- // populate
- for (int i = 0; i < N; i++) {
- Mutation m = new Mutation(new Text(String.format("%05d", i)));
- m.put(new Text("col" + Integer.toString((i % 3) + 1)), new Text("qual"),
- new Value("junk".getBytes(UTF_8)));
- b.addMutation(m);
+ try (BatchWriter b = accumuloClient.createBatchWriter(tableName)) {
+ // populate
+ for (int i = 0; i < N; i++) {
+ Mutation m = new Mutation(new Text(String.format("%05d", i)));
+ m.put(new Text("col" + Integer.toString((i % 3) + 1)), new Text("qual"),
+ new Value("junk".getBytes(UTF_8)));
+ b.addMutation(m);
+ }
}
- b.close();
}
try (Scanner scanner = accumuloClient.createScanner(tableName, Authorizations.EMPTY)) {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
index 8784d17..8180bb7 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TabletStateChangeIteratorIT.java
@@ -147,9 +147,9 @@ public class TabletStateChangeIteratorIT extends AccumuloClusterHarness {
Mutation m = new Mutation(new KeyExtent(tableIdToModify, null, null).getMetadataEntry());
m.put(MetadataSchema.TabletsSection.CurrentLocationColumnFamily.NAME, new Text("1234567"),
new Value("fake:9005".getBytes(UTF_8)));
- BatchWriter bw = client.createBatchWriter(table, null);
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ bw.addMutation(m);
+ }
}
private void reassignLocation(AccumuloClient client, String table, String tableNameToModify)
@@ -165,9 +165,9 @@ public class TabletStateChangeIteratorIT extends AccumuloClusterHarness {
entry.getKey().getTimestamp());
m.put(entry.getKey().getColumnFamily(), new Text("1234567"),
entry.getKey().getTimestamp() + 1, new Value("fake:9005".getBytes(UTF_8)));
- BatchWriter bw = client.createBatchWriter(table, null);
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(table)) {
+ bw.addMutation(m);
+ }
}
}
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 57aba52..41d3463 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
@@ -81,16 +81,14 @@ public class TimeoutIT extends AccumuloClusterHarness {
public void testBatchScannerTimeout(AccumuloClient client, String tableName) throws Exception {
client.tableOperations().create(tableName);
- BatchWriter bw = client.createBatchWriter(tableName, new BatchWriterConfig());
-
- Mutation m = new Mutation("r1");
- m.put("cf1", "cq1", "v1");
- m.put("cf1", "cq2", "v2");
- m.put("cf1", "cq3", "v3");
- m.put("cf1", "cq4", "v4");
-
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
+ Mutation m = new Mutation("r1");
+ m.put("cf1", "cq1", "v1");
+ m.put("cf1", "cq2", "v2");
+ m.put("cf1", "cq3", "v3");
+ m.put("cf1", "cq4", "v4");
+ bw.addMutation(m);
+ }
try (BatchScanner bs = client.createBatchScanner(tableName, Authorizations.EMPTY, 2)) {
bs.setRanges(Collections.singletonList(new Range()));
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/TooManyDeletesIT.java b/test/src/main/java/org/apache/accumulo/test/functional/TooManyDeletesIT.java
index b14e4c5..50949bb 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/TooManyDeletesIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/TooManyDeletesIT.java
@@ -24,7 +24,6 @@ import java.util.List;
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.summary.SummarizerConfiguration;
import org.apache.accumulo.core.client.summary.Summary;
@@ -59,7 +58,7 @@ public class TooManyDeletesIT extends AccumuloClusterHarness {
c.tableOperations().create(table, ntc);
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
for (int i = 0; i < 1000; i++) {
Mutation m = new Mutation("row" + i);
m.put("f", "q", "v" + i);
@@ -76,7 +75,7 @@ public class TooManyDeletesIT extends AccumuloClusterHarness {
assertEquals(1000L, (long) summary.getStatistics().get(DeletesSummarizer.TOTAL_STAT));
assertEquals(0L, (long) summary.getStatistics().get(DeletesSummarizer.DELETES_STAT));
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
for (int i = 0; i < 100; i++) {
Mutation m = new Mutation("row" + i);
m.putDelete("f", "q");
@@ -92,7 +91,7 @@ public class TooManyDeletesIT extends AccumuloClusterHarness {
assertEquals(1100L, (long) summary.getStatistics().get(DeletesSummarizer.TOTAL_STAT));
assertEquals(100L, (long) summary.getStatistics().get(DeletesSummarizer.DELETES_STAT));
- try (BatchWriter bw = c.createBatchWriter(table, new BatchWriterConfig())) {
+ try (BatchWriter bw = c.createBatchWriter(table)) {
for (int i = 100; i < 300; i++) {
Mutation m = new Mutation("row" + i);
m.putDelete("f", "q");
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/VisibilityIT.java b/test/src/main/java/org/apache/accumulo/test/functional/VisibilityIT.java
index ecdb7de..0a9445d 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/VisibilityIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/VisibilityIT.java
@@ -33,7 +33,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.Scanner;
import org.apache.accumulo.core.conf.Property;
import org.apache.accumulo.core.data.Key;
@@ -118,43 +117,39 @@ public class VisibilityIT extends AccumuloClusterHarness {
private void insertData(AccumuloClient c, String tableName) throws Exception {
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m1 = new Mutation(new Text("row1"));
-
- mput(m1, "cf1", "cq1", "", "v1");
- mput(m1, "cf1", "cq1", "A", "v2");
- mput(m1, "cf1", "cq1", "B", "v3");
- mput(m1, "cf1", "cq1", "A&B", "v4");
- mput(m1, "cf1", "cq1", "A&(L|M)", "v5");
- mput(m1, "cf1", "cq1", "B&(L|M)", "v6");
- mput(m1, "cf1", "cq1", "A&B&(L|M)", "v7");
- mput(m1, "cf1", "cq1", "A&B&(L)", "v8");
- mput(m1, "cf1", "cq1", "A&FOO", "v9");
- mput(m1, "cf1", "cq1", "A&FOO&(L|M)", "v10");
- mput(m1, "cf1", "cq1", "FOO", "v11");
- mput(m1, "cf1", "cq1", "(A|B)&FOO&(L|M)", "v12");
- mput(m1, "cf1", "cq1", "A&B&(L|M|FOO)", "v13");
-
- bw.addMutation(m1);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ Mutation m1 = new Mutation(new Text("row1"));
+ mput(m1, "cf1", "cq1", "", "v1");
+ mput(m1, "cf1", "cq1", "A", "v2");
+ mput(m1, "cf1", "cq1", "B", "v3");
+ mput(m1, "cf1", "cq1", "A&B", "v4");
+ mput(m1, "cf1", "cq1", "A&(L|M)", "v5");
+ mput(m1, "cf1", "cq1", "B&(L|M)", "v6");
+ mput(m1, "cf1", "cq1", "A&B&(L|M)", "v7");
+ mput(m1, "cf1", "cq1", "A&B&(L)", "v8");
+ mput(m1, "cf1", "cq1", "A&FOO", "v9");
+ mput(m1, "cf1", "cq1", "A&FOO&(L|M)", "v10");
+ mput(m1, "cf1", "cq1", "FOO", "v11");
+ mput(m1, "cf1", "cq1", "(A|B)&FOO&(L|M)", "v12");
+ mput(m1, "cf1", "cq1", "A&B&(L|M|FOO)", "v13");
+ bw.addMutation(m1);
+ }
}
private void deleteData(AccumuloClient c, String tableName) throws Exception {
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m1 = new Mutation(new Text("row1"));
-
- mputDelete(m1, "cf1", "cq1", "");
- mputDelete(m1, "cf1", "cq1", "A");
- mputDelete(m1, "cf1", "cq1", "A&B");
- mputDelete(m1, "cf1", "cq1", "B&(L|M)");
- mputDelete(m1, "cf1", "cq1", "A&B&(L)");
- mputDelete(m1, "cf1", "cq1", "A&FOO&(L|M)");
- mputDelete(m1, "cf1", "cq1", "(A|B)&FOO&(L|M)");
- mputDelete(m1, "cf1", "cq1", "FOO&A"); // should not delete anything
-
- bw.addMutation(m1);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ Mutation m1 = new Mutation(new Text("row1"));
+ mputDelete(m1, "cf1", "cq1", "");
+ mputDelete(m1, "cf1", "cq1", "A");
+ mputDelete(m1, "cf1", "cq1", "A&B");
+ mputDelete(m1, "cf1", "cq1", "B&(L|M)");
+ mputDelete(m1, "cf1", "cq1", "A&B&(L)");
+ mputDelete(m1, "cf1", "cq1", "A&FOO&(L|M)");
+ mputDelete(m1, "cf1", "cq1", "(A|B)&FOO&(L|M)");
+ mputDelete(m1, "cf1", "cq1", "FOO&A"); // should not delete anything
+ bw.addMutation(m1);
+ }
Map<Set<String>,Set<String>> expected = new HashMap<>();
@@ -173,15 +168,13 @@ public class VisibilityIT extends AccumuloClusterHarness {
}
private void insertDefaultData(AccumuloClient c, String tableName) throws Exception {
- BatchWriter bw = c.createBatchWriter(tableName, new BatchWriterConfig());
- Mutation m1 = new Mutation(new Text("row1"));
-
- mput(m1, "cf1", "cq1", "BASE", "v1");
- mput(m1, "cf1", "cq2", "DEFLABEL", "v2");
- mput(m1, "cf1", "cq3", "", "v3");
-
- bw.addMutation(m1);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter(tableName)) {
+ Mutation m1 = new Mutation(new Text("row1"));
+ mput(m1, "cf1", "cq1", "BASE", "v1");
+ mput(m1, "cf1", "cq2", "DEFLABEL", "v2");
+ mput(m1, "cf1", "cq3", "", "v3");
+ bw.addMutation(m1);
+ }
}
private static void uniqueCombos(List<Set<String>> all, Set<String> prefix, Set<String> suffix) {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/WALSunnyDayIT.java b/test/src/main/java/org/apache/accumulo/test/functional/WALSunnyDayIT.java
index c03bf17..7a56323 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/WALSunnyDayIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/WALSunnyDayIT.java
@@ -170,25 +170,25 @@ public class WALSunnyDayIT extends ConfigurableMacBase {
private void writeSomeData(AccumuloClient client, String tableName, int row, int col)
throws Exception {
Random rand = new SecureRandom();
- BatchWriter bw = client.createBatchWriter(tableName, null);
- byte[] rowData = new byte[10];
- byte[] cq = new byte[10];
- byte[] value = new byte[10];
+ try (BatchWriter bw = client.createBatchWriter(tableName)) {
+ byte[] rowData = new byte[10];
+ byte[] cq = new byte[10];
+ byte[] value = new byte[10];
- for (int r = 0; r < row; r++) {
- rand.nextBytes(rowData);
- Mutation m = new Mutation(rowData);
- for (int c = 0; c < col; c++) {
- rand.nextBytes(cq);
- rand.nextBytes(value);
- m.put(CF, new Text(cq), new Value(value));
- }
- bw.addMutation(m);
- if (r % 100 == 0) {
- bw.flush();
+ for (int r = 0; r < row; r++) {
+ rand.nextBytes(rowData);
+ Mutation m = new Mutation(rowData);
+ for (int c = 0; c < col; c++) {
+ rand.nextBytes(cq);
+ rand.nextBytes(value);
+ m.put(CF, new Text(cq), new Value(value));
+ }
+ bw.addMutation(m);
+ if (r % 100 == 0) {
+ bw.flush();
+ }
}
}
- bw.close();
}
private Map<KeyExtent,List<String>> getRecoveryMarkers(AccumuloClient c) throws Exception {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/ZookeeperRestartIT.java b/test/src/main/java/org/apache/accumulo/test/functional/ZookeeperRestartIT.java
index 2e0cabf..41d4189 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/ZookeeperRestartIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/ZookeeperRestartIT.java
@@ -61,11 +61,11 @@ public class ZookeeperRestartIT extends ConfigurableMacBase {
public void test() throws Exception {
try (AccumuloClient c = createClient()) {
c.tableOperations().create("test_ingest");
- BatchWriter bw = c.createBatchWriter("test_ingest", null);
- Mutation m = new Mutation("row");
- m.put("cf", "cq", "value");
- bw.addMutation(m);
- bw.close();
+ try (BatchWriter bw = c.createBatchWriter("test_ingest")) {
+ Mutation m = new Mutation("row");
+ m.put("cf", "cq", "value");
+ bw.addMutation(m);
+ }
// kill zookeeper
for (ProcessReference proc : cluster.getProcesses().get(ServerType.ZOOKEEPER))