You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@asterixdb.apache.org by mh...@apache.org on 2019/02/21 16:47:20 UTC

[asterixdb] branch master updated: [NO ISSUE][OTH] Replace Inner Class By Lambda

This is an automated email from the ASF dual-hosted git repository.

mhubail pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/asterixdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 23003c1  [NO ISSUE][OTH] Replace Inner Class By Lambda
23003c1 is described below

commit 23003c1e4c932b9e1d4a6efcacd5c8dc0a1493d9
Author: Murtadha Hubail <mh...@apache.org>
AuthorDate: Thu Feb 21 13:39:41 2019 +0300

    [NO ISSUE][OTH] Replace Inner Class By Lambda
    
    - user model changes: no
    - storage format changes: no
    - interface changes: no
    
    Details:
    - Replace anonymous inner class by lambda in
      ApplicationMessageWork.
    
    Change-Id: Ia50f5d51401671c1c10453b20ed84d21c49cfe3a
    Reviewed-on: https://asterix-gerrit.ics.uci.edu/3224
    Sonar-Qube: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Integration-Tests: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Tested-by: Jenkins <je...@fulliautomatix.ics.uci.edu>
    Reviewed-by: Till Westmann <ti...@apache.org>
---
 .../control/cc/work/ApplicationMessageWork.java    | 29 ++++++++++++----------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/ApplicationMessageWork.java b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/ApplicationMessageWork.java
index f2aa1f4..771832e 100644
--- a/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/ApplicationMessageWork.java
+++ b/hyracks-fullstack/hyracks/hyracks-control/hyracks-control-cc/src/main/java/org/apache/hyracks/control/cc/work/ApplicationMessageWork.java
@@ -18,12 +18,13 @@
  */
 package org.apache.hyracks.control.cc.work;
 
+import java.util.concurrent.ExecutorService;
+
 import org.apache.hyracks.api.application.ICCServiceContext;
 import org.apache.hyracks.api.deployment.DeploymentId;
 import org.apache.hyracks.api.messages.IMessage;
 import org.apache.hyracks.control.cc.ClusterControllerService;
 import org.apache.hyracks.control.common.deployment.DeploymentUtils;
-import org.apache.logging.log4j.Level;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 
@@ -48,19 +49,10 @@ public class ApplicationMessageWork extends AbstractHeartbeatWork {
         final ICCServiceContext ctx = ccs.getContext();
         try {
             final IMessage data = (IMessage) DeploymentUtils.deserialize(message, deploymentId, ctx);
-            ccs.getExecutor().execute(new Runnable() {
-                @Override
-                public void run() {
-                    try {
-                        ctx.getMessageBroker().receivedMessage(data, nodeId);
-                    } catch (Exception e) {
-                        throw new RuntimeException(e);
-                    }
-                }
-            });
+            notifyMessageBroker(ctx, data, nodeId);
         } catch (Exception e) {
-            LOGGER.log(Level.WARN, "Error in stats reporting", e);
-            throw new RuntimeException(e);
+            LOGGER.error("unexpected error", e);
+            throw new IllegalStateException(e);
         }
     }
 
@@ -68,4 +60,15 @@ public class ApplicationMessageWork extends AbstractHeartbeatWork {
     public String toString() {
         return getName() + ": nodeID: " + nodeId;
     }
+
+    private static void notifyMessageBroker(ICCServiceContext ctx, IMessage msg, String nodeId) {
+        final ExecutorService executor = ctx.getControllerService().getExecutor();
+        executor.execute(() -> {
+            try {
+                ctx.getMessageBroker().receivedMessage(msg, nodeId);
+            } catch (Exception e) {
+                throw new IllegalStateException(e);
+            }
+        });
+    }
 }