You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@heron.apache.org by hu...@apache.org on 2018/07/20 13:36:27 UTC

[incubator-heron] branch master updated: Upgrade to the latest Dhalion (#2968)

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

huijun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-heron.git


The following commit(s) were added to refs/heads/master by this push:
     new 3ea9082  Upgrade to the latest Dhalion (#2968)
3ea9082 is described below

commit 3ea9082bc7028ffeb92ae4260e2f422f0c920726
Author: Ashvin <as...@users.noreply.github.com>
AuthorDate: Fri Jul 20 06:36:24 2018 -0700

    Upgrade to the latest Dhalion (#2968)
    
    * Upgrade to the latest Dhalion
    
    Fixes #2927
    
    * Remove unused import to fix checkstyle error
---
 WORKSPACE                                                        | 2 +-
 .../heron/healthmgr/policy/DynamicResourceAllocationPolicy.java  | 9 +++++----
 .../java/org/apache/heron/healthmgr/policy/ToggleablePolicy.java | 7 ++++---
 .../heron/healthmgr/resolvers/RestartContainerResolver.java      | 9 +++------
 4 files changed, 13 insertions(+), 14 deletions(-)

diff --git a/WORKSPACE b/WORKSPACE
index 0f4d932..bb622b9 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -460,7 +460,7 @@ maven_jar(
 
 maven_jar(
   name = "com_microsoft_dhalion",
-  artifact = "com.microsoft.dhalion:dhalion:0.2.1",
+  artifact = "com.microsoft.dhalion:dhalion:0.2.3",
 )
 
 maven_jar(
diff --git a/heron/healthmgr/src/java/org/apache/heron/healthmgr/policy/DynamicResourceAllocationPolicy.java b/heron/healthmgr/src/java/org/apache/heron/healthmgr/policy/DynamicResourceAllocationPolicy.java
index 45293f0..f0f1092 100644
--- a/heron/healthmgr/src/java/org/apache/heron/healthmgr/policy/DynamicResourceAllocationPolicy.java
+++ b/heron/healthmgr/src/java/org/apache/heron/healthmgr/policy/DynamicResourceAllocationPolicy.java
@@ -21,11 +21,12 @@ package org.apache.heron.healthmgr.policy;
 
 import java.time.Duration;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.logging.Logger;
 
 import javax.inject.Inject;
 
-import com.microsoft.dhalion.api.IResolver;
+import com.microsoft.dhalion.core.Action;
 import com.microsoft.dhalion.core.Diagnosis;
 import com.microsoft.dhalion.core.DiagnosisTable;
 import com.microsoft.dhalion.events.EventHandler;
@@ -92,7 +93,7 @@ public class DynamicResourceAllocationPolicy extends HealthPolicyImpl
   }
 
   @Override
-  public IResolver selectResolver(Collection<Diagnosis> diagnosis) {
+  public Collection<Action> executeResolvers(Collection<Diagnosis> diagnosis) {
     DiagnosisTable diagnosisTable = DiagnosisTable.of(diagnosis);
 
     if (diagnosisTable.type(DIAGNOSIS_DATA_SKEW.text()).size() > 0) {
@@ -100,10 +101,10 @@ public class DynamicResourceAllocationPolicy extends HealthPolicyImpl
     } else if (diagnosisTable.type(DIAGNOSIS_SLOW_INSTANCE.text()).size() > 0) {
       LOG.warning("Slow Instance diagnoses. This diagnosis does not have any resolver.");
     } else if (diagnosisTable.type(DIAGNOSIS_UNDER_PROVISIONING.text()).size() > 0) {
-      return scaleUpResolver;
+      return scaleUpResolver.resolve(diagnosis);
     }
 
-    return null;
+    return Collections.EMPTY_LIST;
   }
 
   @Override
diff --git a/heron/healthmgr/src/java/org/apache/heron/healthmgr/policy/ToggleablePolicy.java b/heron/healthmgr/src/java/org/apache/heron/healthmgr/policy/ToggleablePolicy.java
index a55764e..e88ab5a 100644
--- a/heron/healthmgr/src/java/org/apache/heron/healthmgr/policy/ToggleablePolicy.java
+++ b/heron/healthmgr/src/java/org/apache/heron/healthmgr/policy/ToggleablePolicy.java
@@ -21,6 +21,7 @@ package org.apache.heron.healthmgr.policy;
 
 import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.logging.Logger;
 
 import javax.inject.Inject;
@@ -97,7 +98,7 @@ public class ToggleablePolicy extends HealthPolicyImpl {
     if (policyMode.equals(PolicyMode.activated)) {
       return super.executeSensors();
     } else {
-      return new ArrayList<Measurement>();
+      return Collections.EMPTY_LIST;
     }
   }
 
@@ -106,7 +107,7 @@ public class ToggleablePolicy extends HealthPolicyImpl {
     if (policyMode.equals(PolicyMode.activated)) {
       return super.executeDetectors(measurements);
     } else {
-      return new ArrayList<Symptom>();
+      return Collections.EMPTY_LIST;
     }
   }
 
@@ -115,7 +116,7 @@ public class ToggleablePolicy extends HealthPolicyImpl {
     if (policyMode.equals(PolicyMode.activated)) {
       return super.executeDiagnosers(symptoms);
     } else {
-      return new ArrayList<Diagnosis>();
+      return Collections.EMPTY_LIST;
     }
   }
 
diff --git a/heron/healthmgr/src/java/org/apache/heron/healthmgr/resolvers/RestartContainerResolver.java b/heron/healthmgr/src/java/org/apache/heron/healthmgr/resolvers/RestartContainerResolver.java
index 44b91aa..85a624c 100644
--- a/heron/healthmgr/src/java/org/apache/heron/healthmgr/resolvers/RestartContainerResolver.java
+++ b/heron/healthmgr/src/java/org/apache/heron/healthmgr/resolvers/RestartContainerResolver.java
@@ -20,10 +20,9 @@
 package org.apache.heron.healthmgr.resolvers;
 
 import java.time.Instant;
-import java.util.ArrayList;
 import java.util.Collection;
+import java.util.Collections;
 import java.util.HashSet;
-import java.util.List;
 import java.util.logging.Logger;
 
 import javax.inject.Inject;
@@ -74,7 +73,6 @@ public class RestartContainerResolver implements IResolver {
   public Collection<Action> resolve(Collection<Diagnosis> diagnosis) {
     publishingMetrics.executeResolver(RESTART_CONTAINER_RESOLVER);
 
-    List<Action> actions = new ArrayList<>();
 
     // find all back pressure measurements reported in this execution cycle
     Instant current = context.checkpoint();
@@ -85,7 +83,7 @@ public class RestartContainerResolver implements IResolver {
 
     if (bpSymptoms.size() == 0) {
       LOG.fine("No back-pressure measurements found, ending as there's nothing to fix");
-      return actions;
+      return Collections.EMPTY_LIST;
     }
 
     Collection<String> allBpInstances = new HashSet<>();
@@ -116,7 +114,6 @@ public class RestartContainerResolver implements IResolver {
     LOG.info("Broadcasting container restart event");
     ContainerRestart action = new ContainerRestart(current, stmgrIds);
     eventManager.onEvent(action);
-    actions.add(action);
-    return actions;
+    return Collections.singletonList(action);
   }
 }