You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@accumulo.apache.org by GitBox <gi...@apache.org> on 2018/04/20 13:41:36 UTC
[GitHub] mikewalch closed pull request #435: Replace anonymous types with
lambdas
mikewalch closed pull request #435: Replace anonymous types with lambdas
URL: https://github.com/apache/accumulo/pull/435
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/SyncingTabletLocator.java b/core/src/main/java/org/apache/accumulo/core/client/impl/SyncingTabletLocator.java
index b098bb566e..24e088a4a6 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/SyncingTabletLocator.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/SyncingTabletLocator.java
@@ -53,12 +53,7 @@ public SyncingTabletLocator(Callable<TabletLocator> getLocatorFunction) {
}
public SyncingTabletLocator(final ClientContext context, final Table.ID tableId) {
- this(new Callable<TabletLocator>() {
- @Override
- public TabletLocator call() throws Exception {
- return TabletLocator.getLocator(context, tableId);
- }
- });
+ this(() -> TabletLocator.getLocator(context, tableId));
}
private TabletLocator syncLocator() {
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
index 8dd736b84d..7e232afd95 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletLocatorImpl.java
@@ -208,13 +208,8 @@ public TabletLocatorImpl(Table.ID tableId, TabletLocator parent, TabletLocationO
}
if (notInCache.size() > 0) {
- Collections.sort(notInCache, new Comparator<Mutation>() {
- @Override
- public int compare(Mutation o1, Mutation o2) {
- return WritableComparator.compareBytes(o1.getRow(), 0, o1.getRow().length, o2.getRow(), 0,
- o2.getRow().length);
- }
- });
+ Collections.sort(notInCache, (o1, o2) -> WritableComparator.compareBytes(o1.getRow(), 0, o1.getRow().length, o2.getRow(), 0,
+ o2.getRow().length));
wLock.lock();
try {
diff --git a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
index 07f4aeb6e3..868d70425d 100644
--- a/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
+++ b/core/src/main/java/org/apache/accumulo/core/client/impl/TabletServerBatchWriter.java
@@ -252,12 +252,7 @@ public synchronized void addMutation(Table.ID table, Mutation m)
checkForFailures();
- waitRTE(new WaitCondition() {
- @Override
- public boolean shouldWait() {
- return (totalMemUsed > maxMem || flushing) && !somethingFailed;
- }
- });
+ waitRTE(() -> (totalMemUsed > maxMem || flushing) && !somethingFailed);
// do checks again since things could have changed while waiting and not holding lock
if (closed)
@@ -316,12 +311,7 @@ public synchronized void flush() throws MutationsRejectedException {
if (flushing) {
// some other thread is currently flushing, so wait
- waitRTE(new WaitCondition() {
- @Override
- public boolean shouldWait() {
- return flushing && !somethingFailed;
- }
- });
+ waitRTE(() -> flushing && !somethingFailed);
checkForFailures();
@@ -333,12 +323,7 @@ public boolean shouldWait() {
startProcessing();
checkForFailures();
- waitRTE(new WaitCondition() {
- @Override
- public boolean shouldWait() {
- return totalMemUsed > 0 && !somethingFailed;
- }
- });
+ waitRTE(() -> totalMemUsed > 0 && !somethingFailed);
flushing = false;
this.notifyAll();
@@ -361,12 +346,7 @@ public synchronized void close() throws MutationsRejectedException {
startProcessing();
- waitRTE(new WaitCondition() {
- @Override
- public boolean shouldWait() {
- return totalMemUsed > 0 && !somethingFailed;
- }
- });
+ waitRTE(() -> totalMemUsed > 0 && !somethingFailed);
logStats();
diff --git a/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java b/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java
index 2151ccb5cd..ff11bc5abb 100644
--- a/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java
+++ b/core/src/main/java/org/apache/accumulo/core/file/rfile/MultiLevelIndex.java
@@ -607,12 +607,7 @@ public void close(DataOutput out) throws IOException {
}
private Node lookup(Key key) throws IOException {
- int pos = Collections.binarySearch(indexBlock.getKeyIndex(), key, new Comparator<Key>() {
- @Override
- public int compare(Key o1, Key o2) {
- return o1.compareTo(o2);
- }
- });
+ int pos = Collections.binarySearch(indexBlock.getKeyIndex(), key, Comparator.naturalOrder());
if (pos < 0)
pos = (pos * -1) - 1;
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java b/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
index be686e11b9..fad9cc1746 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/Combiner.java
@@ -22,7 +22,6 @@
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -190,16 +189,13 @@ public void next() throws IOException {
private void sawDelete() {
if (isMajorCompaction && !reduceOnFullCompactionOnly) {
try {
- loggedMsgCache.get(this.getClass().getName(), new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- sawDeleteLog.error("Combiner of type {} saw a delete during a"
- + " partial compaction. This could cause undesired results. See"
- + " ACCUMULO-2232. Will not log subsequent occurences for at least" + " 1 hour.",
- Combiner.this.getClass().getSimpleName());
- // the value is not used and does not matter
- return Boolean.TRUE;
- }
+ loggedMsgCache.get(this.getClass().getName(), () -> {
+ sawDeleteLog.error("Combiner of type {} saw a delete during a"
+ + " partial compaction. This could cause undesired results. See"
+ + " ACCUMULO-2232. Will not log subsequent occurences for at least" + " 1 hour.",
+ Combiner.this.getClass().getSimpleName());
+ // the value is not used and does not matter
+ return Boolean.TRUE;
});
} catch (ExecutionException e) {
throw new RuntimeException(e);
diff --git a/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java b/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
index 95a1dfff7c..9191486adf 100644
--- a/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
+++ b/core/src/main/java/org/apache/accumulo/core/iterators/user/TransformingIterator.java
@@ -109,12 +109,7 @@
private LRUMap parsedVisibilitiesCache = null;
private long maxBufferSize;
- private static Comparator<Pair<Key,Value>> keyComparator = new Comparator<Pair<Key,Value>>() {
- @Override
- public int compare(Pair<Key,Value> o1, Pair<Key,Value> o2) {
- return o1.getFirst().compareTo(o2.getFirst());
- }
- };
+ private static Comparator<Pair<Key,Value>> keyComparator = Comparator.comparing(Pair::getFirst);
public TransformingIterator() {}
diff --git a/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java b/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
index bd3b8dc416..f968b21732 100644
--- a/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/file/rfile/RFileTest.java
@@ -2186,12 +2186,7 @@ public void testSampleLG() throws IOException {
allSampleData.addAll(sampleDataLG1);
allSampleData.addAll(sampleDataLG2);
- Collections.sort(allSampleData, new Comparator<Entry<Key,Value>>() {
- @Override
- public int compare(Entry<Key,Value> o1, Entry<Key,Value> o2) {
- return o1.getKey().compareTo(o2.getKey());
- }
- });
+ Collections.sort(allSampleData, Comparator.comparing(Entry::getKey));
checkSample(sample, allSampleData, newColFamByteSequence("dataA", "metaA"), true);
checkSample(sample, allSampleData, EMPTY_COL_FAMS, false);
diff --git a/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java b/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
index 348993ee29..496f8036b8 100644
--- a/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
+++ b/core/src/test/java/org/apache/accumulo/core/file/rfile/bcfile/CompressionTest.java
@@ -128,14 +128,9 @@ public void testManyStartNotNull() throws IOException, InterruptedException, Exe
ArrayList<Future<Boolean>> results = new ArrayList<>();
for (int i = 0; i < 30; i++) {
- results.add(service.submit(new Callable<Boolean>() {
-
- @Override
- public Boolean call() throws Exception {
- Assert.assertNotNull(al + " should not be null", al.getCodec());
- return true;
- }
-
+ results.add(service.submit(() -> {
+ Assert.assertNotNull(al + " should not be null", al.getCodec());
+ return true;
}));
}
@@ -173,14 +168,9 @@ public void testManyDontStartUntilThread()
for (int i = 0; i < 30; i++) {
- results.add(service.submit(new Callable<Boolean>() {
-
- @Override
- public Boolean call() throws Exception {
- Assert.assertNotNull(al + " should have a non-null codec", al.getCodec());
- return true;
- }
-
+ results.add(service.submit(() -> {
+ Assert.assertNotNull(al + " should have a non-null codec", al.getCodec());
+ return true;
}));
}
@@ -218,18 +208,14 @@ public void testThereCanBeOnlyOne() throws IOException, InterruptedException, Ex
final HashSet<Integer> testSet = new HashSet<>();
for (int i = 0; i < 40; i++) {
- list.add(new Callable<Boolean>() {
-
- @Override
- public Boolean call() throws Exception {
- CompressionCodec codec = al.getCodec();
- Assert.assertNotNull(al + " resulted in a non-null codec", codec);
- // add the identity hashcode to the set.
- synchronized (testSet) {
- testSet.add(System.identityHashCode(codec));
- }
- return true;
+ list.add(() -> {
+ CompressionCodec codec = al.getCodec();
+ Assert.assertNotNull(al + " resulted in a non-null codec", codec);
+ // add the identity hashcode to the set.
+ synchronized (testSet) {
+ testSet.add(System.identityHashCode(codec));
}
+ return true;
});
}
diff --git a/fate/src/test/java/org/apache/accumulo/fate/zookeeper/TransactionWatcherTest.java b/fate/src/test/java/org/apache/accumulo/fate/zookeeper/TransactionWatcherTest.java
index 6779f6cd45..e3f197022c 100644
--- a/fate/src/test/java/org/apache/accumulo/fate/zookeeper/TransactionWatcherTest.java
+++ b/fate/src/test/java/org/apache/accumulo/fate/zookeeper/TransactionWatcherTest.java
@@ -20,7 +20,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import java.util.concurrent.Callable;
import org.junit.Assert;
import org.junit.Test;
@@ -100,12 +99,9 @@ public void testTransactionWatcher() throws Exception {
}
txw.isActive(txid);
Assert.assertFalse(txw.isActive(txid));
- txw.run(txType, txid, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- Assert.assertTrue(txw.isActive(txid));
- return null;
- }
+ txw.run(txType, txid, () -> {
+ Assert.assertTrue(txw.isActive(txid));
+ return null;
});
Assert.assertFalse(txw.isActive(txid));
Assert.assertFalse(sa.transactionComplete(txType, txid));
@@ -115,12 +111,9 @@ public Object call() throws Exception {
sa.cleanup(txType, txid);
Assert.assertTrue(sa.transactionComplete(txType, txid));
try {
- txw.run(txType, txid, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- Assert.fail("Should not be able to start a new work on a discontinued transaction");
- return null;
- }
+ txw.run(txType, txid, () -> {
+ Assert.fail("Should not be able to start a new work on a discontinued transaction");
+ return null;
});
Assert.fail("work against stopped transaction should fail");
} catch (Exception ex) {
@@ -128,26 +121,20 @@ public Object call() throws Exception {
}
final long txid2 = 9;
sa.start(txType, txid2);
- txw.run(txType, txid2, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- Assert.assertTrue(txw.isActive(txid2));
- sa.stop(txType, txid2);
- try {
- txw.run(txType, txid2, new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- Assert.fail("Should not be able to start a new work on a discontinued transaction");
- return null;
- }
- });
- Assert.fail("work against a stopped transaction should fail");
- } catch (Exception ex) {
- // expected
- }
- Assert.assertTrue(txw.isActive(txid2));
- return null;
+ txw.run(txType, txid2, () -> {
+ Assert.assertTrue(txw.isActive(txid2));
+ sa.stop(txType, txid2);
+ try {
+ txw.run(txType, txid2, () -> {
+ Assert.fail("Should not be able to start a new work on a discontinued transaction");
+ return null;
+ });
+ Assert.fail("work against a stopped transaction should fail");
+ } catch (Exception ex) {
+ // expected
}
+ Assert.assertTrue(txw.isActive(txid2));
+ return null;
});
}
diff --git a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
index f78eeec1e5..f294b65d47 100644
--- a/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
+++ b/minicluster/src/main/java/org/apache/accumulo/minicluster/impl/MiniAccumuloClusterImpl.java
@@ -22,7 +22,6 @@
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
-import java.io.FileFilter;
import java.io.FileWriter;
import java.io.IOException;
import java.io.InputStream;
@@ -46,7 +45,6 @@
import java.util.Map.Entry;
import java.util.Properties;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -213,13 +211,7 @@ private boolean containsSiteFile(File f) {
if (!f.isDirectory()) {
return false;
} else {
- File[] files = f.listFiles(new FileFilter() {
-
- @Override
- public boolean accept(File pathname) {
- return pathname.getName().endsWith("site.xml");
- }
- });
+ File[] files = f.listFiles(pathname -> pathname.getName().endsWith("site.xml"));
return files != null && files.length > 0;
}
}
@@ -815,12 +807,9 @@ protected ExecutorService getShutdownExecutor() {
int stopProcessWithTimeout(final Process proc, long timeout, TimeUnit unit)
throws InterruptedException, ExecutionException, TimeoutException {
- FutureTask<Integer> future = new FutureTask<>(new Callable<Integer>() {
- @Override
- public Integer call() throws InterruptedException {
- proc.destroy();
- return proc.waitFor();
- }
+ FutureTask<Integer> future = new FutureTask<>(() -> {
+ proc.destroy();
+ return proc.waitFor();
});
executor.execute(future);
diff --git a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
index e3adec6d9f..98e3dc0615 100644
--- a/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
+++ b/server/base/src/main/java/org/apache/accumulo/server/client/ClientServiceHandler.java
@@ -26,7 +26,6 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeSet;
-import java.util.concurrent.Callable;
import org.apache.accumulo.core.Constants;
import org.apache.accumulo.core.client.AccumuloException;
@@ -345,15 +344,12 @@ public void revokeNamespacePermission(TInfo tinfo, TCredentials credentials, Str
bulkImportStatus.updateBulkImportStatus(files, BulkImportState.INITIAL);
log.debug("Got request to bulk import files to table({}): {}", tableId, files);
return transactionWatcher.run(Constants.BULK_ARBITRATOR_TYPE, tid,
- new Callable<List<String>>() {
- @Override
- public List<String> call() throws Exception {
- bulkImportStatus.updateBulkImportStatus(files, BulkImportState.PROCESSING);
- try {
- return BulkImporter.bulkLoad(context, tid, tableId, files, errorDir, setTime);
- } finally {
- bulkImportStatus.removeBulkImportStatus(files);
- }
+ () -> {
+ bulkImportStatus.updateBulkImportStatus(files, BulkImportState.PROCESSING);
+ try {
+ return BulkImporter.bulkLoad(context, tid, tableId, files, errorDir, setTime);
+ } finally {
+ bulkImportStatus.removeBulkImportStatus(files);
}
});
} catch (AccumuloSecurityException e) {
diff --git a/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java b/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java
index eb79ce8813..f356a9b2e5 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/AccumuloServerContextTest.java
@@ -21,8 +21,6 @@
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.security.PrivilegedExceptionAction;
-import java.util.Iterator;
-import java.util.Map.Entry;
import org.apache.accumulo.core.client.ClientConfiguration;
import org.apache.accumulo.core.client.ClientConfiguration.ClientProperty;
@@ -40,7 +38,6 @@
import org.apache.hadoop.fs.CommonConfigurationKeys;
import org.apache.hadoop.security.UserGroupInformation;
import org.easymock.EasyMock;
-import org.easymock.IAnswer;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -102,21 +99,13 @@ public Void run() throws Exception {
// AccumuloConfiguration)
// Presently, we only need get(Property) and iterator().
EasyMock.expect(siteConfig.get(EasyMock.anyObject(Property.class)))
- .andAnswer(new IAnswer<String>() {
- @Override
- public String answer() {
- Object[] args = EasyMock.getCurrentArguments();
- return conf.get((Property) args[0]);
- }
+ .andAnswer(() -> {
+ Object[] args = EasyMock.getCurrentArguments();
+ return conf.get((Property) args[0]);
}).anyTimes();
EasyMock.expect(siteConfig.iterator())
- .andAnswer(new IAnswer<Iterator<Entry<String,String>>>() {
- @Override
- public Iterator<Entry<String,String>> answer() {
- return conf.iterator();
- }
- }).anyTimes();
+ .andAnswer(() -> conf.iterator()).anyTimes();
EasyMock.replay(factory, context, siteConfig);
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/AdminTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/AdminTest.java
index ab60b6705c..b533a79ab8 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/AdminTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/AdminTest.java
@@ -26,7 +26,6 @@
import org.apache.accumulo.fate.zookeeper.ZooCache;
import org.apache.accumulo.fate.zookeeper.ZooCache.ZcStat;
import org.easymock.EasyMock;
-import org.easymock.IAnswer;
import org.junit.Test;
public class AdminTest {
@@ -57,15 +56,10 @@ public void testQualifySessionId() {
String serverPath = root + "/" + server;
EasyMock.expect(zc.getChildren(serverPath)).andReturn(Collections.singletonList("child"));
EasyMock.expect(zc.get(EasyMock.eq(serverPath + "/child"), EasyMock.anyObject(ZcStat.class)))
- .andAnswer(new IAnswer<byte[]>() {
-
- @Override
- public byte[] answer() throws Throwable {
- ZcStat stat = (ZcStat) EasyMock.getCurrentArguments()[1];
- stat.setEphemeralOwner(session);
- return new byte[0];
- }
-
+ .andAnswer(() -> {
+ ZcStat stat = (ZcStat) EasyMock.getCurrentArguments()[1];
+ stat.setEphemeralOwner(session);
+ return new byte[0];
});
EasyMock.replay(zc);
diff --git a/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java b/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java
index 4c5d99e233..7deea7e288 100644
--- a/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java
+++ b/server/base/src/test/java/org/apache/accumulo/server/util/ReplicationTableUtilTest.java
@@ -55,7 +55,6 @@
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.easymock.EasyMock;
-import org.easymock.IAnswer;
import org.junit.Assert;
import org.junit.Test;
@@ -68,12 +67,9 @@ public void properPathInRow() throws Exception {
final List<Mutation> mutations = new ArrayList<>();
// Mock a Writer to just add the mutation to a list
- EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
- @Override
- public Object answer() {
- mutations.add(((Mutation) EasyMock.getCurrentArguments()[0]));
- return null;
- }
+ EasyMock.expectLastCall().andAnswer(() -> {
+ mutations.add(((Mutation) EasyMock.getCurrentArguments()[0]));
+ return null;
});
EasyMock.replay(writer);
diff --git a/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java b/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java
index eb2d6b94d0..6716a078c3 100644
--- a/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java
+++ b/server/gc/src/test/java/org/apache/accumulo/gc/SimpleGarbageCollectorTest.java
@@ -30,9 +30,7 @@
import java.io.FileNotFoundException;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
import org.apache.accumulo.core.client.Instance;
import org.apache.accumulo.core.client.impl.Credentials;
@@ -47,7 +45,6 @@
import org.apache.accumulo.server.security.SystemCredentials;
import org.apache.hadoop.fs.Path;
import org.easymock.EasyMock;
-import org.easymock.IAnswer;
import org.junit.Before;
import org.junit.Test;
@@ -77,28 +74,17 @@ public void setUp() {
// Just make the SiteConfiguration delegate to our AccumuloConfiguration
// Presently, we only need get(Property) and iterator().
EasyMock.expect(siteConfig.get(EasyMock.anyObject(Property.class)))
- .andAnswer(new IAnswer<String>() {
- @Override
- public String answer() {
- Object[] args = EasyMock.getCurrentArguments();
- return systemConfig.get((Property) args[0]);
- }
+ .andAnswer(() -> {
+ Object[] args = EasyMock.getCurrentArguments();
+ return systemConfig.get((Property) args[0]);
}).anyTimes();
EasyMock.expect(siteConfig.getBoolean(EasyMock.anyObject(Property.class)))
- .andAnswer(new IAnswer<Boolean>() {
- @Override
- public Boolean answer() {
- Object[] args = EasyMock.getCurrentArguments();
- return systemConfig.getBoolean((Property) args[0]);
- }
+ .andAnswer(() -> {
+ Object[] args = EasyMock.getCurrentArguments();
+ return systemConfig.getBoolean((Property) args[0]);
}).anyTimes();
- EasyMock.expect(siteConfig.iterator()).andAnswer(new IAnswer<Iterator<Entry<String,String>>>() {
- @Override
- public Iterator<Entry<String,String>> answer() {
- return systemConfig.iterator();
- }
- }).anyTimes();
+ EasyMock.expect(siteConfig.iterator()).andAnswer(() -> systemConfig.iterator()).anyTimes();
replay(instance, factory, siteConfig);
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
index 325211b79f..04c7ccc5c4 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/BulkImport.java
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -200,62 +199,59 @@ private String prepareBulkImport(Master master, final VolumeManager fs, String d
for (FileStatus file : mapFiles) {
final FileStatus fileStatus = file;
- results.add(workers.submit(new Callable<Exception>() {
- @Override
- public Exception call() throws Exception {
- try {
- String sa[] = fileStatus.getPath().getName().split("\\.");
- String extension = "";
- if (sa.length > 1) {
- extension = sa[sa.length - 1];
-
- if (!FileOperations.getValidExtensions().contains(extension)) {
- log.warn("{} does not have a valid extension, ignoring", fileStatus.getPath());
- return null;
- }
- } else {
- // assume it is a map file
- extension = Constants.MAPFILE_EXTENSION;
+ results.add(workers.submit(() -> {
+ try {
+ String sa[] = fileStatus.getPath().getName().split("\\.");
+ String extension = "";
+ if (sa.length > 1) {
+ extension = sa[sa.length - 1];
+
+ if (!FileOperations.getValidExtensions().contains(extension)) {
+ log.warn("{} does not have a valid extension, ignoring", fileStatus.getPath());
+ return null;
}
+ } else {
+ // assume it is a map file
+ extension = Constants.MAPFILE_EXTENSION;
+ }
- if (extension.equals(Constants.MAPFILE_EXTENSION)) {
- if (!fileStatus.isDirectory()) {
- log.warn("{} is not a map file, ignoring", fileStatus.getPath());
- return null;
- }
+ if (extension.equals(Constants.MAPFILE_EXTENSION)) {
+ if (!fileStatus.isDirectory()) {
+ log.warn("{} is not a map file, ignoring", fileStatus.getPath());
+ return null;
+ }
- if (fileStatus.getPath().getName().equals("_logs")) {
- log.info("{} is probably a log directory from a map/reduce task, skipping",
- fileStatus.getPath());
- return null;
- }
- try {
- FileStatus dataStatus = fs
- .getFileStatus(new Path(fileStatus.getPath(), MapFile.DATA_FILE_NAME));
- if (dataStatus.isDirectory()) {
- log.warn("{} is not a map file, ignoring", fileStatus.getPath());
- return null;
- }
- } catch (FileNotFoundException fnfe) {
+ if (fileStatus.getPath().getName().equals("_logs")) {
+ log.info("{} is probably a log directory from a map/reduce task, skipping",
+ fileStatus.getPath());
+ return null;
+ }
+ try {
+ FileStatus dataStatus = fs
+ .getFileStatus(new Path(fileStatus.getPath(), MapFile.DATA_FILE_NAME));
+ if (dataStatus.isDirectory()) {
log.warn("{} is not a map file, ignoring", fileStatus.getPath());
return null;
}
+ } catch (FileNotFoundException fnfe) {
+ log.warn("{} is not a map file, ignoring", fileStatus.getPath());
+ return null;
}
+ }
- String newName = "I" + namer.getNextName() + "." + extension;
- Path newPath = new Path(bulkDir, newName);
- try {
- fs.rename(fileStatus.getPath(), newPath);
- log.debug("Moved {} to {}", fileStatus.getPath(), newPath);
- } catch (IOException E1) {
- log.error("Could not move: {} {}", fileStatus.getPath().toString(), E1.getMessage());
- }
-
- } catch (Exception ex) {
- return ex;
+ String newName = "I" + namer.getNextName() + "." + extension;
+ Path newPath = new Path(bulkDir, newName);
+ try {
+ fs.rename(fileStatus.getPath(), newPath);
+ log.debug("Moved {} to {}", fileStatus.getPath(), newPath);
+ } catch (IOException E1) {
+ log.error("Could not move: {} {}", fileStatus.getPath().toString(), E1.getMessage());
}
- return null;
+
+ } catch (Exception ex) {
+ return ex;
}
+ return null;
}));
}
workers.shutdown();
diff --git a/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java b/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java
index 225bed8d01..7bed4bfe29 100644
--- a/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java
+++ b/server/master/src/main/java/org/apache/accumulo/master/tableOps/LoadFiles.java
@@ -28,7 +28,6 @@
import java.util.List;
import java.util.Random;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Future;
import java.util.concurrent.ThreadPoolExecutor;
@@ -157,39 +156,33 @@ private static synchronized ExecutorService getThreadPool(Master master) {
}
if (servers.length > 0) {
for (final String file : filesToLoad) {
- results.add(executor.submit(new Callable<List<String>>() {
- @Override
- public List<String> call() {
- List<String> failures = new ArrayList<>();
- ClientService.Client client = null;
- HostAndPort server = null;
- try {
- // get a connection to a random tablet server, do not prefer cached connections
- // because
- // this is running on the master and there are lots of connections to tablet servers
- // serving the metadata tablets
- long timeInMillis = master.getConfiguration()
- .getTimeInMillis(Property.MASTER_BULK_TIMEOUT);
- // Pair<String,Client> pair = ServerClient.getConnection(master, false,
- // timeInMillis);
- server = servers[random.nextInt(servers.length)].getLocation();
- client = ThriftUtil.getTServerClient(server, master, timeInMillis);
- List<String> attempt = Collections.singletonList(file);
- log.debug("Asking " + server + " to bulk import " + file);
- List<String> fail = client.bulkImportFiles(Tracer.traceInfo(), master.rpcCreds(),
- tid, tableId.canonicalID(), attempt, errorDir, setTime);
- if (fail.isEmpty()) {
- loaded.add(file);
- } else {
- failures.addAll(fail);
- }
- } catch (Exception ex) {
- log.error("rpc failed server:" + server + ", tid:" + tid + " " + ex);
- } finally {
- ThriftUtil.returnClient(client);
+ results.add(executor.submit(() -> {
+ List<String> failures = new ArrayList<>();
+ ClientService.Client client = null;
+ HostAndPort server = null;
+ try {
+ // get a connection to a random tablet server, do not prefer cached connections
+ // because this is running on the master and there are lots of connections to tablet
+ // servers serving the metadata tablets
+ long timeInMillis = master.getConfiguration()
+ .getTimeInMillis(Property.MASTER_BULK_TIMEOUT);
+ server = servers[random.nextInt(servers.length)].getLocation();
+ client = ThriftUtil.getTServerClient(server, master, timeInMillis);
+ List<String> attempt1 = Collections.singletonList(file);
+ log.debug("Asking " + server + " to bulk import " + file);
+ List<String> fail = client.bulkImportFiles(Tracer.traceInfo(), master.rpcCreds(),
+ tid, tableId.canonicalID(), attempt1, errorDir, setTime);
+ if (fail.isEmpty()) {
+ loaded.add(file);
+ } else {
+ failures.addAll(fail);
}
- return failures;
+ } catch (Exception ex) {
+ log.error("rpc failed server:" + server + ", tid:" + tid + " " + ex);
+ } finally {
+ ThriftUtil.returnClient(client);
}
+ return failures;
}));
}
}
diff --git a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
index 2451d88c2f..69377ad0e7 100644
--- a/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
+++ b/server/tracer/src/main/java/org/apache/accumulo/tracer/TraceDump.java
@@ -22,7 +22,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.Date;
import java.util.List;
import java.util.Map.Entry;
@@ -75,12 +74,7 @@ public static void main(String[] args) throws Exception {
public static List<RemoteSpan> sortByStart(Collection<RemoteSpan> spans) {
List<RemoteSpan> spanList = new ArrayList<>(spans);
- Collections.sort(spanList, new Comparator<RemoteSpan>() {
- @Override
- public int compare(RemoteSpan o1, RemoteSpan o2) {
- return (int) (o1.start - o2.start);
- }
- });
+ Collections.sort(spanList, (o1, o2) -> (int) (o1.start - o2.start));
return spanList;
}
diff --git a/server/tracer/src/test/java/org/apache/accumulo/tracer/TracerTest.java b/server/tracer/src/test/java/org/apache/accumulo/tracer/TracerTest.java
index 6b31299ad0..65531e9aaf 100644
--- a/server/tracer/src/test/java/org/apache/accumulo/tracer/TracerTest.java
+++ b/server/tracer/src/test/java/org/apache/accumulo/tracer/TracerTest.java
@@ -201,11 +201,8 @@ public void run() {
@Before
public void setup() {
- callable = new Callable<Object>() {
- @Override
- public Object call() throws IOException {
- throw new IOException();
- }
+ callable = () -> {
+ throw new IOException();
};
}
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/ConditionalMutationSet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/ConditionalMutationSet.java
index 95d68c94f1..19d19e302d 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/ConditionalMutationSet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/ConditionalMutationSet.java
@@ -19,7 +19,6 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -83,13 +82,8 @@ static void deferDuplicatesRows(Map<KeyExtent,List<ServerConditionalMutation>> u
static void sortConditionalMutations(Map<KeyExtent,List<ServerConditionalMutation>> updates) {
for (Entry<KeyExtent,List<ServerConditionalMutation>> entry : updates.entrySet()) {
- Collections.sort(entry.getValue(), new Comparator<ServerConditionalMutation>() {
- @Override
- public int compare(ServerConditionalMutation o1, ServerConditionalMutation o2) {
- return WritableComparator.compareBytes(o1.getRow(), 0, o1.getRow().length, o2.getRow(), 0,
- o2.getRow().length);
- }
- });
+ Collections.sort(entry.getValue(), (o1, o2) -> WritableComparator.compareBytes(o1.getRow(), 0, o1.getRow().length, o2.getRow(), 0,
+ o2.getRow().length));
}
}
}
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
index 2dc559ef4e..51e25263a9 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/TabletServer.java
@@ -31,7 +31,6 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -3346,12 +3345,7 @@ public void recover(VolumeManager fs, KeyExtent extent, TableConfiguration tconf
throws IOException {
List<Path> recoveryLogs = new ArrayList<>();
List<LogEntry> sorted = new ArrayList<>(logEntries);
- Collections.sort(sorted, new Comparator<LogEntry>() {
- @Override
- public int compare(LogEntry e1, LogEntry e2) {
- return (int) (e1.timestamp - e2.timestamp);
- }
- });
+ Collections.sort(sorted, (e1, e2) -> (int) (e1.timestamp - e2.timestamp));
for (LogEntry entry : sorted) {
Path recovery = null;
Path finished = RecoveryPath.getRecoveryPath(fs,
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/compaction/DefaultCompactionStrategy.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/compaction/DefaultCompactionStrategy.java
index 85dcb39840..52b0bef744 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/compaction/DefaultCompactionStrategy.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/compaction/DefaultCompactionStrategy.java
@@ -17,7 +17,6 @@
package org.apache.accumulo.tserver.compaction;
import java.util.ArrayList;
-import java.util.Comparator;
import java.util.List;
import java.util.Map.Entry;
import java.util.TreeMap;
@@ -69,17 +68,14 @@ public CompactionFile(FileRef file, long size) {
if (request.getFiles().size() <= 1)
return null;
- TreeSet<CompactionFile> candidateFiles = new TreeSet<>(new Comparator<CompactionFile>() {
- @Override
- public int compare(CompactionFile o1, CompactionFile o2) {
- if (o1 == o2)
- return 0;
- if (o1.size < o2.size)
- return -1;
- if (o1.size > o2.size)
- return 1;
- return o1.file.compareTo(o2.file);
- }
+ TreeSet<CompactionFile> candidateFiles = new TreeSet<>((o1, o2) -> {
+ if (o1 == o2)
+ return 0;
+ if (o1.size < o2.size)
+ return -1;
+ if (o1.size > o2.size)
+ return 1;
+ return o1.file.compareTo(o2.file);
});
double ratio = Double.parseDouble(request.getTableConfig(Property.TABLE_MAJC_RATIO.getKey()));
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java
index d180dc22eb..57f25430bd 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/log/LogSorter.java
@@ -185,12 +185,7 @@ private void writeBuffer(String destPath, List<Pair<LogFileKey,LogFileValue>> bu
try (MapFile.Writer output = new MapFile.Writer(ns.getConf(), ns.makeQualified(path),
MapFile.Writer.keyClass(LogFileKey.class),
MapFile.Writer.valueClass(LogFileValue.class))) {
- Collections.sort(buffer, new Comparator<Pair<LogFileKey,LogFileValue>>() {
- @Override
- public int compare(Pair<LogFileKey,LogFileValue> o1, Pair<LogFileKey,LogFileValue> o2) {
- return o1.getFirst().compareTo(o2.getFirst());
- }
- });
+ Collections.sort(buffer, Comparator.comparing(Pair::getFirst));
for (Pair<LogFileKey,LogFileValue> entry : buffer) {
output.append(entry.getFirst(), entry.getSecond());
}
diff --git a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
index 44c0f72e22..9c337dd64b 100644
--- a/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
+++ b/server/tserver/src/main/java/org/apache/accumulo/tserver/tablet/Tablet.java
@@ -27,7 +27,6 @@
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
-import java.util.Comparator;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.HashSet;
@@ -39,7 +38,6 @@
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;
-import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.TimeUnit;
@@ -2057,15 +2055,12 @@ protected AccumuloConfiguration createTableConfiguration(TableConfiguration base
}
PriorityQueue<Pair<FileRef,Long>> fileHeap = new PriorityQueue<>(filesToCompact.size(),
- new Comparator<Pair<FileRef,Long>>() {
- @Override
- public int compare(Pair<FileRef,Long> o1, Pair<FileRef,Long> o2) {
- if (o1.getSecond() == o2.getSecond())
- return o1.getFirst().compareTo(o2.getFirst());
- if (o1.getSecond() < o2.getSecond())
- return -1;
- return 1;
- }
+ (o1, o2) -> {
+ if (o1.getSecond() == o2.getSecond())
+ return o1.getFirst().compareTo(o2.getFirst());
+ if (o1.getSecond() < o2.getSecond())
+ return -1;
+ return 1;
});
for (Iterator<Entry<FileRef,DataFileValue>> iterator = filesToCompact.entrySet()
@@ -2426,12 +2421,7 @@ public void importMapFiles(long tid, Map<FileRef,MapFileInfo> fileMap, boolean s
this.notifyAll();
try {
- bulkImported.get(tid, new Callable<List<FileRef>>() {
- @Override
- public List<FileRef> call() throws Exception {
- return new ArrayList<>();
- }
- }).addAll(fileMap.keySet());
+ bulkImported.get(tid, ArrayList::new).addAll(fileMap.keySet());
} catch (Exception ex) {
log.info(ex.toString(), ex);
}
diff --git a/shell/src/main/java/org/apache/accumulo/shell/commands/ActiveCompactionIterator.java b/shell/src/main/java/org/apache/accumulo/shell/commands/ActiveCompactionIterator.java
index 6655e579d3..1728712c56 100644
--- a/shell/src/main/java/org/apache/accumulo/shell/commands/ActiveCompactionIterator.java
+++ b/shell/src/main/java/org/apache/accumulo/shell/commands/ActiveCompactionIterator.java
@@ -18,7 +18,6 @@
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Comparator;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -64,12 +63,7 @@ private void readNext() {
acl = new ArrayList<>(acl);
- Collections.sort(acl, new Comparator<ActiveCompaction>() {
- @Override
- public int compare(ActiveCompaction o1, ActiveCompaction o2) {
- return (int) (o2.getAge() - o1.getAge());
- }
- });
+ Collections.sort(acl, (o1, o2) -> (int) (o2.getAge() - o1.getAge()));
for (ActiveCompaction ac : acl) {
String output = ac.getOutputFile();
diff --git a/test/src/main/java/org/apache/accumulo/test/BalanceWithOfflineTableIT.java b/test/src/main/java/org/apache/accumulo/test/BalanceWithOfflineTableIT.java
index 5b7ba2983b..b4147df514 100644
--- a/test/src/main/java/org/apache/accumulo/test/BalanceWithOfflineTableIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/BalanceWithOfflineTableIT.java
@@ -18,7 +18,6 @@
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
@@ -75,12 +74,9 @@ public void test() throws Exception {
log.info("Waiting for balance");
SimpleThreadPool pool = new SimpleThreadPool(1, "waitForBalance");
- Future<Boolean> wait = pool.submit(new Callable<Boolean>() {
- @Override
- public Boolean call() throws Exception {
- c.instanceOperations().waitForBalance();
- return true;
- }
+ Future<Boolean> wait = pool.submit(() -> {
+ c.instanceOperations().waitForBalance();
+ return true;
});
wait.get(20, TimeUnit.SECONDS);
log.info("Balance succeeded with an offline table");
diff --git a/test/src/main/java/org/apache/accumulo/test/BulkImportMonitoringIT.java b/test/src/main/java/org/apache/accumulo/test/BulkImportMonitoringIT.java
index 15732f5d6f..f77b0ca477 100644
--- a/test/src/main/java/org/apache/accumulo/test/BulkImportMonitoringIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/BulkImportMonitoringIT.java
@@ -23,7 +23,6 @@
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -90,25 +89,22 @@ public void test() throws Exception {
List<Future<Pair<String,String>>> futures = new ArrayList<>();
for (int i = 0; i < 10; i++) {
final int which = i;
- futures.add(es.submit(new Callable<Pair<String,String>>() {
- @Override
- public Pair<String,String> call() throws Exception {
- Path bulkFailures = new Path(base, "failures" + which);
- Path files = new Path(base, "files" + which);
- fs.mkdirs(bulkFailures);
- fs.mkdirs(files);
- for (int i = 0; i < 10; i++) {
- FileSKVWriter writer = FileOperations.getInstance().newWriterBuilder()
- .forFile(files.toString() + "/bulk_" + i + "." + RFile.EXTENSION, fs, fs.getConf())
- .withTableConfiguration(DefaultConfiguration.getInstance()).build();
- writer.startDefaultLocalityGroup();
- for (int j = 0x100; j < 0xfff; j += 3) {
- writer.append(new Key(Integer.toHexString(j)), new Value(new byte[0]));
- }
- writer.close();
+ futures.add(es.submit(() -> {
+ Path bulkFailures = new Path(base, "failures" + which);
+ Path files = new Path(base, "files" + which);
+ fs.mkdirs(bulkFailures);
+ fs.mkdirs(files);
+ for (int i1 = 0; i1 < 10; i1++) {
+ FileSKVWriter writer = FileOperations.getInstance().newWriterBuilder()
+ .forFile(files.toString() + "/bulk_" + i1 + "." + RFile.EXTENSION, fs, fs.getConf())
+ .withTableConfiguration(DefaultConfiguration.getInstance()).build();
+ writer.startDefaultLocalityGroup();
+ for (int j = 0x100; j < 0xfff; j += 3) {
+ writer.append(new Key(Integer.toHexString(j)), new Value(new byte[0]));
}
- return new Pair<>(files.toString(), bulkFailures.toString());
+ writer.close();
}
+ return new Pair<>(files.toString(), bulkFailures.toString());
}));
}
List<Pair<String,String>> dirs = new ArrayList<>();
@@ -121,12 +117,9 @@ public void test() throws Exception {
for (Pair<String,String> entry : dirs) {
final String dir = entry.getFirst();
final String err = entry.getSecond();
- errs.add(es.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- c.tableOperations().importDirectory(tableName, dir, err, false);
- return null;
- }
+ errs.add(es.submit(() -> {
+ c.tableOperations().importDirectory(tableName, dir, err, false);
+ return null;
}));
}
es.shutdown();
diff --git a/test/src/main/java/org/apache/accumulo/test/GetFileInfoBulkIT.java b/test/src/main/java/org/apache/accumulo/test/GetFileInfoBulkIT.java
index 159fac6931..d6cf212b59 100644
--- a/test/src/main/java/org/apache/accumulo/test/GetFileInfoBulkIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/GetFileInfoBulkIT.java
@@ -26,7 +26,6 @@
import java.util.Map;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -115,25 +114,22 @@ public void test() throws Exception {
List<Future<Pair<String,String>>> futures = new ArrayList<>();
for (int i = 0; i < 10; i++) {
final int which = i;
- futures.add(es.submit(new Callable<Pair<String,String>>() {
- @Override
- public Pair<String,String> call() throws Exception {
- Path bulkFailures = new Path(base, "failures" + which);
- Path files = new Path(base, "files" + which);
- fs.mkdirs(bulkFailures);
- fs.mkdirs(files);
- for (int i = 0; i < 100; i++) {
- FileSKVWriter writer = FileOperations.getInstance().newWriterBuilder()
- .forFile(files.toString() + "/bulk_" + i + "." + RFile.EXTENSION, fs, fs.getConf())
- .withTableConfiguration(DefaultConfiguration.getInstance()).build();
- writer.startDefaultLocalityGroup();
- for (int j = 0x100; j < 0xfff; j += 3) {
- writer.append(new Key(Integer.toHexString(j)), new Value(new byte[0]));
- }
- writer.close();
+ futures.add(es.submit(() -> {
+ Path bulkFailures = new Path(base, "failures" + which);
+ Path files = new Path(base, "files" + which);
+ fs.mkdirs(bulkFailures);
+ fs.mkdirs(files);
+ for (int i1 = 0; i1 < 100; i1++) {
+ FileSKVWriter writer = FileOperations.getInstance().newWriterBuilder()
+ .forFile(files.toString() + "/bulk_" + i1 + "." + RFile.EXTENSION, fs, fs.getConf())
+ .withTableConfiguration(DefaultConfiguration.getInstance()).build();
+ writer.startDefaultLocalityGroup();
+ for (int j = 0x100; j < 0xfff; j += 3) {
+ writer.append(new Key(Integer.toHexString(j)), new Value(new byte[0]));
}
- return new Pair<>(files.toString(), bulkFailures.toString());
+ writer.close();
}
+ return new Pair<>(files.toString(), bulkFailures.toString());
}));
}
List<Pair<String,String>> dirs = new ArrayList<>();
@@ -147,12 +143,9 @@ public void test() throws Exception {
for (Pair<String,String> entry : dirs) {
final String dir = entry.getFirst();
final String err = entry.getSecond();
- errs.add(es.submit(new Callable<Object>() {
- @Override
- public Object call() throws Exception {
- c.tableOperations().importDirectory(tableName, dir, err, false);
- return null;
- }
+ errs.add(es.submit(() -> {
+ c.tableOperations().importDirectory(tableName, dir, err, false);
+ return null;
}));
}
for (Future<Object> err : errs) {
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java b/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java
index 20ef885cea..f19e77767d 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/NativeMapIT.java
@@ -492,12 +492,7 @@ public void test11() {
for (int i = 0; i < 2; i++) {
// sort data
- Collections.sort(testData, new Comparator<Pair<Key,Value>>() {
- @Override
- public int compare(Pair<Key,Value> o1, Pair<Key,Value> o2) {
- return o1.getFirst().compareTo(o2.getFirst());
- }
- });
+ Collections.sort(testData, Comparator.comparing(Pair::getFirst));
// verify
Iterator<Entry<Key,Value>> iter1 = nm.iterator();
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 bc81e3765f..6130bc5b06 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
@@ -39,7 +39,6 @@
import java.util.Map.Entry;
import java.util.Set;
import java.util.TreeMap;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -253,66 +252,60 @@ public void multiTableTest() throws Exception {
final ClusterControl control = cluster.getClusterControl();
final String prefix = getClass().getSimpleName() + "_" + testName.getMethodName();
ExecutorService svc = Executors.newFixedThreadPool(2);
- Future<Integer> p1 = svc.submit(new Callable<Integer>() {
- @Override
- public Integer call() {
- try {
- // Invocation is different for SASL. We're only logged in via this processes memory (not
- // via some credentials cache on disk)
- // Need to pass along the keytab because of that.
- if (saslEnabled()) {
- String principal = getAdminPrincipal();
- AuthenticationToken token = getAdminToken();
- assertTrue("Expected KerberosToken, but was " + token.getClass(),
- token instanceof KerberosToken);
- KerberosToken kt = (KerberosToken) token;
- assertNotNull("Expected keytab in token", kt.getKeytab());
- return control.exec(TestMultiTableIngest.class,
- args("--count", Integer.toString(ROWS), "-i", instance, "-z", keepers,
- "--tablePrefix", prefix, "--keytab", kt.getKeytab().getAbsolutePath(), "-u",
- principal));
- }
-
+ Future<Integer> p1 = svc.submit(() -> {
+ try {
+ // Invocation is different for SASL. We're only logged in via this processes memory (not
+ // via some credentials cache on disk)
+ // Need to pass along the keytab because of that.
+ if (saslEnabled()) {
+ String principal = getAdminPrincipal();
+ AuthenticationToken token = getAdminToken();
+ assertTrue("Expected KerberosToken, but was " + token.getClass(),
+ token instanceof KerberosToken);
+ KerberosToken kt = (KerberosToken) token;
+ assertNotNull("Expected keytab in token", kt.getKeytab());
return control.exec(TestMultiTableIngest.class,
- args("--count", Integer.toString(ROWS), "-u", getAdminPrincipal(), "-i", instance,
- "-z", keepers, "-p",
- new String(((PasswordToken) getAdminToken()).getPassword(), UTF_8),
- "--tablePrefix", prefix));
- } catch (IOException e) {
- log.error("Error running MultiTableIngest", e);
- return -1;
+ args("--count", Integer.toString(ROWS), "-i", instance, "-z", keepers,
+ "--tablePrefix", prefix, "--keytab", kt.getKeytab().getAbsolutePath(), "-u",
+ principal));
}
+
+ return control.exec(TestMultiTableIngest.class,
+ args("--count", Integer.toString(ROWS), "-u", getAdminPrincipal(), "-i", instance,
+ "-z", keepers, "-p",
+ new String(((PasswordToken) getAdminToken()).getPassword(), UTF_8),
+ "--tablePrefix", prefix));
+ } catch (IOException e) {
+ log.error("Error running MultiTableIngest", e);
+ return -1;
}
});
- Future<Integer> p2 = svc.submit(new Callable<Integer>() {
- @Override
- public Integer call() {
- try {
- // Invocation is different for SASL. We're only logged in via this processes memory (not
- // via some credentials cache on disk)
- // Need to pass along the keytab because of that.
- if (saslEnabled()) {
- String principal = getAdminPrincipal();
- AuthenticationToken token = getAdminToken();
- assertTrue("Expected KerberosToken, but was " + token.getClass(),
- token instanceof KerberosToken);
- KerberosToken kt = (KerberosToken) token;
- assertNotNull("Expected keytab in token", kt.getKeytab());
- return control.exec(TestMultiTableIngest.class,
- args("--count", Integer.toString(ROWS), "--readonly", "-i", instance, "-z", keepers,
- "--tablePrefix", prefix, "--keytab", kt.getKeytab().getAbsolutePath(), "-u",
- principal));
- }
-
+ Future<Integer> p2 = svc.submit(() -> {
+ try {
+ // Invocation is different for SASL. We're only logged in via this processes memory (not
+ // via some credentials cache on disk)
+ // Need to pass along the keytab because of that.
+ if (saslEnabled()) {
+ String principal = getAdminPrincipal();
+ AuthenticationToken token = getAdminToken();
+ assertTrue("Expected KerberosToken, but was " + token.getClass(),
+ token instanceof KerberosToken);
+ KerberosToken kt = (KerberosToken) token;
+ assertNotNull("Expected keytab in token", kt.getKeytab());
return control.exec(TestMultiTableIngest.class,
- args("--count", Integer.toString(ROWS), "--readonly", "-u", getAdminPrincipal(), "-i",
- instance, "-z", keepers, "-p",
- new String(((PasswordToken) getAdminToken()).getPassword(), UTF_8),
- "--tablePrefix", prefix));
- } catch (IOException e) {
- log.error("Error running MultiTableIngest", e);
- return -1;
+ args("--count", Integer.toString(ROWS), "--readonly", "-i", instance, "-z", keepers,
+ "--tablePrefix", prefix, "--keytab", kt.getKeytab().getAbsolutePath(), "-u",
+ principal));
}
+
+ return control.exec(TestMultiTableIngest.class,
+ args("--count", Integer.toString(ROWS), "--readonly", "-u", getAdminPrincipal(), "-i",
+ instance, "-z", keepers, "-p",
+ new String(((PasswordToken) getAdminToken()).getPassword(), UTF_8),
+ "--tablePrefix", prefix));
+ } catch (IOException e) {
+ log.error("Error running MultiTableIngest", e);
+ return -1;
}
});
svc.shutdown();
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/RestartIT.java b/test/src/main/java/org/apache/accumulo/test/functional/RestartIT.java
index d048610f2b..a6ead9b739 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/RestartIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/RestartIT.java
@@ -22,7 +22,6 @@
import java.io.IOException;
import java.util.Map.Entry;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -129,15 +128,12 @@ public void restartMaster() throws Exception {
}
OPTS.setConnectionInfo(getConnectionInfo());
- Future<Integer> ret = svc.submit(new Callable<Integer>() {
- @Override
- public Integer call() {
- try {
- return control.exec(TestIngest.class, args);
- } catch (IOException e) {
- log.error("Error running TestIngest", e);
- return -1;
- }
+ Future<Integer> ret = svc.submit(() -> {
+ try {
+ return control.exec(TestIngest.class, args);
+ } catch (IOException e) {
+ log.error("Error running TestIngest", e);
+ return -1;
}
});
@@ -224,15 +220,12 @@ public void restartMasterSplit() throws Exception {
OPTS.setConnectionInfo(getConnectionInfo());
VOPTS.setConnectionInfo(getConnectionInfo());
- Future<Integer> ret = svc.submit(new Callable<Integer>() {
- @Override
- public Integer call() {
- try {
- return control.exec(TestIngest.class, args);
- } catch (Exception e) {
- log.error("Error running TestIngest", e);
- return -1;
- }
+ Future<Integer> ret = svc.submit(() -> {
+ try {
+ return control.exec(TestIngest.class, args);
+ } catch (Exception e) {
+ log.error("Error running TestIngest", e);
+ return -1;
}
});
diff --git a/test/src/main/java/org/apache/accumulo/test/functional/RestartStressIT.java b/test/src/main/java/org/apache/accumulo/test/functional/RestartStressIT.java
index 3ab9dfcee0..e36f5e2969 100644
--- a/test/src/main/java/org/apache/accumulo/test/functional/RestartStressIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/functional/RestartStressIT.java
@@ -21,7 +21,6 @@
import static org.junit.Assert.assertEquals;
import java.util.Map;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -120,15 +119,12 @@ public void test() throws Exception {
throw new RuntimeException("Unrecognized token");
}
- Future<Integer> retCode = svc.submit(new Callable<Integer>() {
- @Override
- public Integer call() {
- try {
- return control.exec(TestIngest.class, args);
- } catch (Exception e) {
- log.error("Error running TestIngest", e);
- return -1;
- }
+ Future<Integer> retCode = svc.submit(() -> {
+ try {
+ return control.exec(TestIngest.class, args);
+ } catch (Exception e) {
+ log.error("Error running TestIngest", e);
+ return -1;
}
});
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 a9b9e826d7..9fa939783c 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
@@ -25,7 +25,6 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -114,15 +113,13 @@ public void run() throws Exception {
final List<Future<Boolean>> callables = new ArrayList<>();
final CountDownLatch latch = new CountDownLatch(10);
for (int i = 0; i < 10; i++) {
- Future<Boolean> callable = service.submit(new Callable<Boolean>() {
- public Boolean call() {
- latch.countDown();
- while (slow.hasNext()) {
-
- slow.next();
- }
- return slow.hasNext();
+ Future<Boolean> callable = service.submit(() -> {
+ latch.countDown();
+ while (slow.hasNext()) {
+
+ slow.next();
}
+ return slow.hasNext();
});
callables.add(callable);
}
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 feb8b36569..d187ee76e2 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
@@ -22,7 +22,6 @@
import java.util.Collections;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.Map.Entry;
import java.util.Set;
@@ -54,7 +53,6 @@
import org.apache.accumulo.test.functional.ConfigurableMacBase;
import org.apache.hadoop.io.Text;
import org.easymock.EasyMock;
-import org.easymock.IAnswer;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
@@ -102,28 +100,17 @@ public void setupEasyMockStuff() {
// Just make the SiteConfiguration delegate to our AccumuloConfiguration
// Presently, we only need get(Property) and iterator().
EasyMock.expect(siteConfig.get(EasyMock.anyObject(Property.class)))
- .andAnswer(new IAnswer<String>() {
- @Override
- public String answer() {
- Object[] args = EasyMock.getCurrentArguments();
- return systemConf.get((Property) args[0]);
- }
+ .andAnswer(() -> {
+ Object[] args = EasyMock.getCurrentArguments();
+ return systemConf.get((Property) args[0]);
}).anyTimes();
EasyMock.expect(siteConfig.getBoolean(EasyMock.anyObject(Property.class)))
- .andAnswer(new IAnswer<Boolean>() {
- @Override
- public Boolean answer() {
- Object[] args = EasyMock.getCurrentArguments();
- return systemConf.getBoolean((Property) args[0]);
- }
+ .andAnswer(() -> {
+ Object[] args = EasyMock.getCurrentArguments();
+ return systemConf.getBoolean((Property) args[0]);
}).anyTimes();
- EasyMock.expect(siteConfig.iterator()).andAnswer(new IAnswer<Iterator<Entry<String,String>>>() {
- @Override
- public Iterator<Entry<String,String>> answer() {
- return systemConf.iterator();
- }
- }).anyTimes();
+ EasyMock.expect(siteConfig.iterator()).andAnswer(() -> systemConf.iterator()).anyTimes();
replay(mockInst, factory, siteConfig);
refs = new WrappedCloseWriteAheadLogReferences(new AccumuloServerContext(mockInst, factory));
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 7f5fabb9de..83555ca7ea 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
@@ -24,7 +24,6 @@
import static org.junit.Assert.fail;
import java.io.File;
-import java.io.FileFilter;
import java.io.IOException;
import org.apache.accumulo.core.client.BatchWriter;
@@ -184,12 +183,7 @@ private void handleWriteTests(boolean content) throws Exception {
MRTester.main(new String[] {content ? TEST_TABLE : EMPTY_TABLE, f.getAbsolutePath()});
assertTrue(f.exists());
- File[] files = f.listFiles(new FileFilter() {
- @Override
- public boolean accept(File file) {
- return file.getName().startsWith("part-m-");
- }
- });
+ File[] files = f.listFiles(file -> file.getName().startsWith("part-m-"));
assertNotNull(files);
if (content) {
assertEquals(1, files.length);
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 879ddf45fc..5e0d999bad 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
@@ -21,7 +21,6 @@
import static org.junit.Assert.assertTrue;
import java.io.File;
-import java.io.FileFilter;
import java.io.IOException;
import org.apache.accumulo.core.client.BatchWriter;
@@ -197,12 +196,7 @@ private void handleWriteTests(boolean content) throws Exception {
MRTester.main(new String[] {content ? TEST_TABLE : EMPTY_TABLE, f.getAbsolutePath()});
assertTrue(f.exists());
- File[] files = f.listFiles(new FileFilter() {
- @Override
- public boolean accept(File file) {
- return file.getName().startsWith("part-m-");
- }
- });
+ File[] files = f.listFiles(file -> file.getName().startsWith("part-m-"));
assertNotNull(files);
if (content) {
assertEquals(1, files.length);
diff --git a/test/src/main/java/org/apache/accumulo/test/master/SuspendedTabletsIT.java b/test/src/main/java/org/apache/accumulo/test/master/SuspendedTabletsIT.java
index 1a21233181..2e12e81b81 100644
--- a/test/src/main/java/org/apache/accumulo/test/master/SuspendedTabletsIT.java
+++ b/test/src/main/java/org/apache/accumulo/test/master/SuspendedTabletsIT.java
@@ -31,7 +31,6 @@
import java.util.Set;
import java.util.SortedSet;
import java.util.TreeSet;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.FutureTask;
@@ -295,13 +294,10 @@ public static TabletLocations retrieve(final ClientContext ctx, final String tab
while (true) {
try {
- FutureTask<TabletLocations> tlsFuture = new FutureTask<>(new Callable<TabletLocations>() {
- @Override
- public TabletLocations call() throws Exception {
- TabletLocations answer = new TabletLocations();
- answer.scan(ctx, tableName);
- return answer;
- }
+ FutureTask<TabletLocations> tlsFuture = new FutureTask<>(() -> {
+ TabletLocations answer = new TabletLocations();
+ answer.scan(ctx, tableName);
+ return answer;
});
THREAD_POOL.submit(tlsFuture);
return tlsFuture.get(5, SECONDS);
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 51275c3420..2057d39015 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
@@ -23,7 +23,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -265,17 +264,12 @@ public void dataWasReplicatedToThePeer() throws Exception {
ProtobufUtil.toString(Status.parseFrom(kv.getValue().get())));
}
- Future<Boolean> future = executor.submit(new Callable<Boolean>() {
-
- @Override
- public Boolean call() throws Exception {
- long then = System.currentTimeMillis();
- connMaster.replicationOperations().drain(masterTable, filesNeedingReplication);
- long now = System.currentTimeMillis();
- log.info("Drain completed in " + (now - then) + "ms");
- return true;
- }
-
+ Future<Boolean> future = executor.submit(() -> {
+ long then = System.currentTimeMillis();
+ connMaster.replicationOperations().drain(masterTable, filesNeedingReplication);
+ long now = System.currentTimeMillis();
+ log.info("Drain completed in " + (now - then) + "ms");
+ return true;
});
try {
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 9c0cb46422..f389fd9270 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
@@ -23,7 +23,6 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
-import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
@@ -266,15 +265,10 @@ public void dataWasReplicatedToThePeer() throws Exception {
ProtobufUtil.toString(Status.parseFrom(kv.getValue().get())));
}
- Future<Boolean> future = executor.submit(new Callable<Boolean>() {
-
- @Override
- public Boolean call() throws Exception {
- connMaster.replicationOperations().drain(masterTable, filesNeedingReplication);
- log.info("Drain completed");
- return true;
- }
-
+ Future<Boolean> future = executor.submit(() -> {
+ connMaster.replicationOperations().drain(masterTable, filesNeedingReplication);
+ log.info("Drain completed");
+ return true;
});
long timeoutSeconds = timeoutFactor * 30;
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
With regards,
Apache Git Services