[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 <jenkins@fulliautomatix.ics.uci.edu>
Integration-Tests: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Tested-by: Jenkins <jenkins@fulliautomatix.ics.uci.edu>
Reviewed-by: Till Westmann <tillw@apache.org>
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 @@
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 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);
+ }
+ });
+ }
}