fluo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] keith-turner closed pull request #1040: Replace anonymous types with lambda
Date Mon, 09 Jul 2018 13:17:02 GMT
keith-turner closed pull request #1040: Replace anonymous types with lambda
URL: https://github.com/apache/fluo/pull/1040
 
 
   

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/modules/api/src/main/java/org/apache/fluo/api/observer/ObserverProvider.java
b/modules/api/src/main/java/org/apache/fluo/api/observer/ObserverProvider.java
index 95438d6d..5da18622 100644
--- a/modules/api/src/main/java/org/apache/fluo/api/observer/ObserverProvider.java
+++ b/modules/api/src/main/java/org/apache/fluo/api/observer/ObserverProvider.java
@@ -137,12 +137,8 @@
    * @param colRegistry register all observed columns with this consumer
    */
   default void provideColumns(BiConsumer<Column, NotificationType> colRegistry, Context
ctx) {
-    Registry or = new Registry() {
-      @Override
-      public IdentityOption forColumn(Column observedColumn, NotificationType ntfyType) {
-        return new ColumnProviderRegistry(observedColumn, ntfyType, colRegistry);
-      }
-    };
+    Registry or = (observedColumn, ntfyType) -> new ColumnProviderRegistry(observedColumn,
ntfyType,
+        colRegistry);
 
     provide(or, ctx);
   }
diff --git a/modules/cluster/pom.xml b/modules/cluster/pom.xml
index 68f2a1d8..4fe810e8 100644
--- a/modules/cluster/pom.xml
+++ b/modules/cluster/pom.xml
@@ -50,11 +50,6 @@
       <artifactId>guice</artifactId>
       <version>4.0</version>
     </dependency>
-    <dependency>
-      <groupId>javax.inject</groupId>
-      <artifactId>javax.inject</artifactId>
-      <version>1</version>
-    </dependency>
     <dependency>
       <groupId>org.apache.accumulo</groupId>
       <artifactId>accumulo-core</artifactId>
diff --git a/modules/cluster/src/main/java/org/apache/fluo/cluster/runner/AppRunner.java b/modules/cluster/src/main/java/org/apache/fluo/cluster/runner/AppRunner.java
index 355e16ba..8621a907 100644
--- a/modules/cluster/src/main/java/org/apache/fluo/cluster/runner/AppRunner.java
+++ b/modules/cluster/src/main/java/org/apache/fluo/cluster/runner/AppRunner.java
@@ -157,13 +157,7 @@ public void waitUntilFinished(FluoConfiguration config) {
     @Override
     protected void configure() {
       requestStaticInjection(clazz);
-      bind(FluoConfiguration.class).toProvider(new Provider<FluoConfiguration>() {
-        @Override
-        public FluoConfiguration get() {
-          // TODO Auto-generated method stub
-          return fluoConfig;
-        }
-      });
+      bind(FluoConfiguration.class).toProvider((Provider<FluoConfiguration>) () ->
fluoConfig);
     }
   }
 
diff --git a/modules/core/src/main/java/org/apache/fluo/core/async/CommitManager.java b/modules/core/src/main/java/org/apache/fluo/core/async/CommitManager.java
index 1b589cf8..ece178cc 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/async/CommitManager.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/async/CommitManager.java
@@ -44,13 +44,9 @@ public CommitManager(final Environment env) {
     memoryLimit = new Limit(FluoConfigurationImpl.getTxCommitMemory(env.getConfiguration()));
     commitingTransactions = new AtomicInteger(0);
 
-    env.getSharedResources().getMetricRegistry()
-        .register(env.getMetricNames().getCommitsProcessing(), new Gauge<Integer>()
{
-          @Override
-          public Integer getValue() {
-            return commitingTransactions.get();
-          }
-        });
+    env.getSharedResources().getMetricRegistry().register(
+        env.getMetricNames().getCommitsProcessing(),
+        (Gauge<Integer>) () -> commitingTransactions.get());
   }
 
 
diff --git a/modules/core/src/main/java/org/apache/fluo/core/impl/SharedBatchWriter.java b/modules/core/src/main/java/org/apache/fluo/core/impl/SharedBatchWriter.java
index d87e9a71..012f2d3c 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/SharedBatchWriter.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/SharedBatchWriter.java
@@ -141,12 +141,9 @@ private void processBatches(ArrayList<MutationBatch> batches)
     this.bw = bw;
     this.mutQueue = new ArrayBlockingQueue<>(100000);
     Thread thread = new FluoThreadFactory("sharedBW").newThread(new FlushTask());
-    thread.setUncaughtExceptionHandler(new UncaughtExceptionHandler() {
-      @Override
-      public void uncaughtException(Thread t, Throwable e) {
-        System.err.println("Uncaught exception in shared batch writer");
-        e.printStackTrace();
-      }
+    thread.setUncaughtExceptionHandler((t, e) -> {
+      System.err.println("Uncaught exception in shared batch writer");
+      e.printStackTrace();
     });
     thread.setDaemon(true);
     thread.start();
diff --git a/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorCache.java b/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorCache.java
index 28313299..17105a92 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorCache.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/TransactorCache.java
@@ -77,12 +77,9 @@ private void logTimedoutTransactor(Long transactorId, long lockTs, Long
startTim
   public void addTimedoutTransactor(final Long transactorId, final long lockTs,
       final Long startTime) {
     try {
-      AtomicLong cachedLockTs = timeoutCache.get(transactorId, new Callable<AtomicLong>()
{
-        @Override
-        public AtomicLong call() throws Exception {
-          logTimedoutTransactor(transactorId, lockTs, startTime);
-          return new AtomicLong(lockTs);
-        }
+      AtomicLong cachedLockTs = timeoutCache.get(transactorId, () -> {
+        logTimedoutTransactor(transactorId, lockTs, startTime);
+        return new AtomicLong(lockTs);
       });
 
       long currVal = cachedLockTs.get();
diff --git a/modules/core/src/main/java/org/apache/fluo/core/impl/VisibilityCache.java b/modules/core/src/main/java/org/apache/fluo/core/impl/VisibilityCache.java
index 439b9a80..8cbcde34 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/VisibilityCache.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/VisibilityCache.java
@@ -66,12 +66,7 @@ public ColumnVisibility getCV(final Bytes colvis) {
     }
 
     try {
-      return visCache.get(colvis, new Callable<ColumnVisibility>() {
-        @Override
-        public ColumnVisibility call() throws Exception {
-          return new ColumnVisibility(ByteUtil.toText(colvis));
-        }
-      });
+      return visCache.get(colvis, () -> new ColumnVisibility(ByteUtil.toText(colvis)));
     } catch (ExecutionException e) {
       throw new RuntimeException(e);
     }
diff --git a/modules/core/src/main/java/org/apache/fluo/core/impl/scanner/ScannerBuilderImpl.java
b/modules/core/src/main/java/org/apache/fluo/core/impl/scanner/ScannerBuilderImpl.java
index 21db046c..b6f4c6f5 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/impl/scanner/ScannerBuilderImpl.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/impl/scanner/ScannerBuilderImpl.java
@@ -79,12 +79,9 @@ public CellScanner build() {
 
   @Override
   public RowScannerBuilder byRow() {
-    return new RowScannerBuilder() {
-      @Override
-      public RowScanner build() {
-        SnapshotScanner snapScanner = tx.newSnapshotScanner(span, columns);
-        return new RowScannerImpl(snapScanner, columns);
-      }
+    return () -> {
+      SnapshotScanner snapScanner = tx.newSnapshotScanner(span, columns);
+      return new RowScannerImpl(snapScanner, columns);
     };
   }
 }
diff --git a/modules/core/src/main/java/org/apache/fluo/core/log/TracingScannerBuilder.java
b/modules/core/src/main/java/org/apache/fluo/core/log/TracingScannerBuilder.java
index 39647112..e0a9d8ae 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/log/TracingScannerBuilder.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/log/TracingScannerBuilder.java
@@ -87,16 +87,13 @@ public CellScanner build() {
   @Override
   public RowScannerBuilder byRow() {
     String scanId = Integer.toHexString(Math.abs(Objects.hash(span, columns, txid)));
-    return new RowScannerBuilder() {
-      @Override
-      public RowScanner build() {
-        log.trace("txid: {} scanId: {} scanner().over({}).fetch({}).byRow().build()", txid,
scanId,
-            Hex.encNonAscii(span), Hex.encNonAscii(columns));
-        if (TracingCellScanner.log.isTraceEnabled()) {
-          return new TracingRowScanner(wrappedBuilder.byRow().build(), txid, scanId);
-        } else {
-          return wrappedBuilder.byRow().build();
-        }
+    return () -> {
+      log.trace("txid: {} scanId: {} scanner().over({}).fetch({}).byRow().build()", txid,
scanId,
+          Hex.encNonAscii(span), Hex.encNonAscii(columns));
+      if (TracingCellScanner.log.isTraceEnabled()) {
+        return new TracingRowScanner(wrappedBuilder.byRow().build(), txid, scanId);
+      } else {
+        return wrappedBuilder.byRow().build();
       }
     };
   }
diff --git a/modules/core/src/main/java/org/apache/fluo/core/metrics/ReporterUtil.java b/modules/core/src/main/java/org/apache/fluo/core/metrics/ReporterUtil.java
index f40e122b..7b940aef 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/metrics/ReporterUtil.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/metrics/ReporterUtil.java
@@ -74,16 +74,12 @@ public String getDomain() {
 
     log.info("Started {} metrics reporters", allReporters.size());
 
-    return new AutoCloseable() {
-
-      @Override
-      public void close() {
-        for (AutoCloseable closeable : allReporters) {
-          try {
-            closeable.close();
-          } catch (Exception e) {
-            e.printStackTrace();
-          }
+    return () -> {
+      for (AutoCloseable closeable : allReporters) {
+        try {
+          closeable.close();
+        } catch (Exception e) {
+          e.printStackTrace();
         }
       }
     };
diff --git a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
index 0c35240f..7bb6b105 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/oracle/OracleServer.java
@@ -299,15 +299,7 @@ private InetSocketAddress startServer() throws TTransportException {
     serverArgs.outputProtocolFactory(new TCompactProtocol.Factory());
     server = new THsHaServer(serverArgs);
 
-    Runnable st = new Runnable() {
-
-      @Override
-      public void run() {
-        server.serve();
-      }
-    };
-
-    serverThread = new Thread(st);
+    serverThread = new Thread(server::serve);
     serverThread.setDaemon(true);
     serverThread.start();
 
diff --git a/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java b/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
index 1aa2d944..ffaad60f 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/util/CuratorUtil.java
@@ -193,13 +193,10 @@ public static NodeCache startAppIdWatcher(Environment env) {
       final String uuid = new String(uuidBytes, StandardCharsets.UTF_8);
 
       final NodeCache nodeCache = new NodeCache(curator, ZookeeperPath.CONFIG_FLUO_APPLICATION_ID);
-      nodeCache.getListenable().addListener(new NodeCacheListener() {
-        @Override
-        public void nodeChanged() throws Exception {
-          ChildData node = nodeCache.getCurrentData();
-          if (node == null || !uuid.equals(new String(node.getData(), StandardCharsets.UTF_8)))
{
-            Halt.halt("Fluo Application UUID has changed or disappeared");
-          }
+      nodeCache.getListenable().addListener(() -> {
+        ChildData node = nodeCache.getCurrentData();
+        if (node == null || !uuid.equals(new String(node.getData(), StandardCharsets.UTF_8)))
{
+          Halt.halt("Fluo Application UUID has changed or disappeared");
         }
       });
       nodeCache.start();
diff --git a/modules/core/src/main/java/org/apache/fluo/core/util/Halt.java b/modules/core/src/main/java/org/apache/fluo/core/util/Halt.java
index 9b41b4aa..477328e5 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/util/Halt.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/util/Halt.java
@@ -27,33 +27,20 @@
   private Halt() {}
 
   public static void halt(final String msg) {
-    halt(0, new Runnable() {
-      @Override
-      public void run() {
-        log.error(fatal, msg);
-      }
-    });
+    halt(0, () -> log.error(fatal, msg));
   }
 
   public static void halt(final String msg, int status) {
-    halt(status, new Runnable() {
-      @Override
-      public void run() {
-        log.error(fatal, msg);
-      }
-    });
+    halt(status, () -> log.error(fatal, msg));
   }
 
   public static void halt(final int status, Runnable runnable) {
     try {
       // give ourselves a little time to try and do something
-      Thread thread = new Thread() {
-        @Override
-        public void run() {
-          UtilWaitThread.sleep(100);
-          Runtime.getRuntime().halt(status);
-        }
-      };
+      Thread thread = new Thread(() -> {
+        UtilWaitThread.sleep(100);
+        Runtime.getRuntime().halt(status);
+      });
       thread.setDaemon(true);
       thread.start();
 
diff --git a/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationProcessor.java
b/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationProcessor.java
index 5dca6875..16b6d21c 100644
--- a/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationProcessor.java
+++ b/modules/core/src/main/java/org/apache/fluo/core/worker/NotificationProcessor.java
@@ -56,13 +56,8 @@ public NotificationProcessor(Environment env) {
     this.executor = FluoExecutors.newFixedThreadPool(numThreads, queue, "ntfyProc");
     this.tracker = new NotificationTracker();
     this.observers = env.getConfiguredObservers().getObservers(env);
-    env.getSharedResources().getMetricRegistry()
-        .register(env.getMetricNames().getNotificationQueued(), new Gauge<Integer>()
{
-          @Override
-          public Integer getValue() {
-            return queue.size();
-          }
-        });
+    env.getSharedResources().getMetricRegistry().register(
+        env.getMetricNames().getNotificationQueued(), (Gauge<Integer>) () -> queue.size());
   }
 
   // little utility class that tracks all notifications in queue
diff --git a/modules/integration/src/test/java/org/apache/fluo/integration/impl/ParallelScannerIT.java
b/modules/integration/src/test/java/org/apache/fluo/integration/impl/ParallelScannerIT.java
index ae0ebd17..f314e8a7 100644
--- a/modules/integration/src/test/java/org/apache/fluo/integration/impl/ParallelScannerIT.java
+++ b/modules/integration/src/test/java/org/apache/fluo/integration/impl/ParallelScannerIT.java
@@ -102,15 +102,12 @@ public void testConcurrentParallelScan() throws Exception {
 
     // create a thread that will unlock column while transaction tx3 is executing
 
-    Runnable finishCommitTask = new Runnable() {
-      @Override
-      public void run() {
-        try {
-          Thread.sleep(500);
-          tx2.finishCommit(cd2, commitTs);
-        } catch (Exception e) {
-          e.printStackTrace();
-        }
+    Runnable finishCommitTask = () -> {
+      try {
+        Thread.sleep(500);
+        tx2.finishCommit(cd2, commitTs);
+      } catch (Exception e) {
+        e.printStackTrace();
       }
     };
 


 

----------------------------------------------------------------
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

Mime
View raw message