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/06/27 21:11:28 UTC

[incubator-heron] branch huijunw/togglepolicy updated: update condition check in toggle policy

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

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


The following commit(s) were added to refs/heads/huijunw/togglepolicy by this push:
     new ffc2ec8  update condition check in toggle policy
ffc2ec8 is described below

commit ffc2ec827b87ac55dca2cc134faa0d9e5d494f7f
Author: Huijun Wu <hu...@twitter.com>
AuthorDate: Wed Jun 27 14:11:03 2018 -0700

    update condition check in toggle policy
---
 .../heron/healthmgr/policy/ToggleablePolicy.java   | 26 +++++++++++-----------
 1 file changed, 13 insertions(+), 13 deletions(-)

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 1971179..9addb20 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
@@ -78,20 +78,20 @@ public class ToggleablePolicy extends HealthPolicyImpl {
         : physicalPlanProvider.get().getTopology().getTopologyConfig().getKvsList()) {
       LOG.fine("kv " + kv.getKey() + ":" + kv.getValue());
       if (kv.getKey().equals(policyIdRuntime)) {
-        PolicyMode val = PolicyMode.valueOf(kv.getValue());
-        if (PolicyMode.deactivated.equals(val)
-            && policyMode.equals(PolicyMode.activated)) {
-          policyMode = PolicyMode.deactivated;
-          LOG.info("policy " + policyId + " status changed to " + policyMode);
-        } else if (PolicyMode.activated.equals(val)
-            && policyMode.equals(PolicyMode.deactivated)) {
-          policyMode = PolicyMode.activated;
-          LOG.info("policy " + policyId + " status changed to " + policyMode);
-        } else {
-          LOG.info("policy " + policyId
-              + " status does not change " + policyMode + "; input " + val);
+        try {
+          PolicyMode val = PolicyMode.valueOf(kv.getValue());
+          if (!policyMode.equals(val)) {
+            policyMode = val;
+            LOG.info("policy " + policyId + " status changed to " + policyMode);
+          } else {
+            LOG.info("policy " + policyId + " status does not change " + policyMode
+                + "; unknown input " + val);
+          }
+          break;
+        } catch (IllegalArgumentException e) {
+          LOG.warning("policy " + policyId + " status does not change " + policyMode
+              + "; unknown input " + kv.getValue());
         }
-        break;
       }
     }