helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jiajunw...@apache.org
Subject [helix] branch customizeView updated: add listener and config for customized view aggregation (#815)
Date Thu, 27 Feb 2020 00:34:36 GMT
This is an automated email from the ASF dual-hosted git repository.

jiajunwang pushed a commit to branch customizeView
in repository https://gitbox.apache.org/repos/asf/helix.git


The following commit(s) were added to refs/heads/customizeView by this push:
     new 87aec1a  add listener and config for customized view aggregation (#815)
87aec1a is described below

commit 87aec1a1871a742236ab5eff1136ffbb7e7d2f61
Author: zhangmeng916 <56051770+zhangmeng916@users.noreply.github.com>
AuthorDate: Wed Feb 26 16:34:27 2020 -0800

    add listener and config for customized view aggregation (#815)
    
    Add listeners for customized state and customized state aggregation config in Helix managers
---
 .../main/java/org/apache/helix/HelixConstants.java |  2 +
 .../main/java/org/apache/helix/HelixManager.java   | 22 ++++++++++-
 .../main/java/org/apache/helix/PropertyType.java   |  2 +-
 ...mizedStateAggregationConfigChangeListener.java} | 40 +++++++++-----------
 .../listeners/CustomizedStateChangeListener.java}  | 43 ++++++++++------------
 .../helix/controller/stages/AttributeName.java     |  1 +
 .../apache/helix/manager/zk/ZKHelixManager.java    | 19 ++++++++++
 .../controller/stages/DummyClusterManager.java     | 16 ++++++++
 .../manager/TestParticipantManager.java            |  2 +-
 .../java/org/apache/helix/mock/MockManager.java    | 15 ++++++++
 .../helix/participant/MockZKHelixManager.java      | 16 ++++++++
 11 files changed, 129 insertions(+), 49 deletions(-)

diff --git a/helix-core/src/main/java/org/apache/helix/HelixConstants.java b/helix-core/src/main/java/org/apache/helix/HelixConstants.java
index b0783bf..27f82c6 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixConstants.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixConstants.java
@@ -30,9 +30,11 @@ public interface HelixConstants {
     CONFIG (PropertyType.CONFIGS),
     INSTANCE_CONFIG (PropertyType.CONFIGS),
     RESOURCE_CONFIG (PropertyType.CONFIGS),
+    CUSTOMIZED_STATE_AGGREGATION_CONFIG (PropertyType.CONFIGS),
     CLUSTER_CONFIG (PropertyType.CONFIGS),
     LIVE_INSTANCE (PropertyType.LIVEINSTANCES),
     CURRENT_STATE (PropertyType.CURRENTSTATES),
+    CUSTOMIZED_STATE (PropertyType.CUSTOMIZEDSTATES),
     MESSAGE (PropertyType.MESSAGES),
     EXTERNAL_VIEW (PropertyType.EXTERNALVIEW),
     CUSTOMIZED_VIEW (PropertyType.CUSTOMIZEDVIEW),
diff --git a/helix-core/src/main/java/org/apache/helix/HelixManager.java b/helix-core/src/main/java/org/apache/helix/HelixManager.java
index 5675f9b..886c885 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixManager.java
@@ -26,6 +26,8 @@ import org.apache.helix.api.listeners.ClusterConfigChangeListener;
 import org.apache.helix.api.listeners.ConfigChangeListener;
 import org.apache.helix.api.listeners.ControllerChangeListener;
 import org.apache.helix.api.listeners.CurrentStateChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateAggregationConfigChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateChangeListener;
 import org.apache.helix.api.listeners.ExternalViewChangeListener;
 import org.apache.helix.api.listeners.CustomizedViewChangeListener;
 import org.apache.helix.api.listeners.IdealStateChangeListener;
@@ -39,6 +41,7 @@ import org.apache.helix.controller.pipeline.Pipeline;
 import org.apache.helix.healthcheck.ParticipantHealthReportCollector;
 import org.apache.helix.manager.zk.ZKHelixManager;
 import org.apache.helix.model.ClusterConfig;
+import org.apache.helix.model.CustomizedStateAggregationConfig;
 import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
 import org.apache.helix.participant.HelixStateMachineEngine;
 import org.apache.helix.participant.StateMachineEngine;
@@ -156,6 +159,15 @@ public interface HelixManager {
   void addResourceConfigChangeListener(ResourceConfigChangeListener listener) throws Exception;
 
   /**
+   * @see CustomizedStateAggregationConfigChangeListener#onCustomizedStateAggregationConfigChange(CustomizedStateAggregationConfig,
+   *      NotificationContext)
+   * @param listener
+   */
+
+  void addCustomizedStateAggregationConfigChangeListener(
+      CustomizedStateAggregationConfigChangeListener listener) throws Exception;
+
+  /**
    * @see ClusterConfigChangeListener#onClusterConfigChange(ClusterConfig, NotificationContext)
    * @param listener
    */
@@ -213,6 +225,14 @@ public interface HelixManager {
       String sessionId) throws Exception;
 
   /**
+   * @see CustomizedStateChangeListener#onCustomizedStateChange(String, List, NotificationContext)
+   * @param listener
+   * @param instanceName
+   */
+  void addCustomizedStateChangeListener(CustomizedStateChangeListener listener, String instanceName,
+      String stateName) throws Exception;
+
+  /**
    * @see ExternalViewChangeListener#onExternalViewChange(List, NotificationContext)
    * @param listener
    */
@@ -423,4 +443,4 @@ public interface HelixManager {
    * @return ParticipantHealthReportCollector
    */
   ParticipantHealthReportCollector getHealthReportCollector();
-}
+}
\ No newline at end of file
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyType.java b/helix-core/src/main/java/org/apache/helix/PropertyType.java
index 363db21..03a6ce8 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyType.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyType.java
@@ -216,4 +216,4 @@ public enum PropertyType {
   public boolean isCached() {
     return isCached;
   }
-}
+}
\ No newline at end of file
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
b/helix-core/src/main/java/org/apache/helix/api/listeners/CustomizedStateAggregationConfigChangeListener.java
similarity index 53%
copy from helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
copy to helix-core/src/main/java/org/apache/helix/api/listeners/CustomizedStateAggregationConfigChangeListener.java
index a2b63f8..2617ef3 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
+++ b/helix-core/src/main/java/org/apache/helix/api/listeners/CustomizedStateAggregationConfigChangeListener.java
@@ -1,4 +1,4 @@
-package org.apache.helix.controller.stages;
+package org.apache.helix.api.listeners;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -9,7 +9,7 @@ package org.apache.helix.controller.stages;
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -19,24 +19,18 @@ package org.apache.helix.controller.stages;
  * under the License.
  */
 
-public enum AttributeName {
-  RESOURCES,
-  RESOURCES_TO_REBALANCE,
-  BEST_POSSIBLE_STATE,
-  CURRENT_STATE,
-  INTERMEDIATE_STATE,
-  MESSAGES_ALL,
-  MESSAGES_SELECTED,
-  MESSAGES_THROTTLE,
-  LOCAL_STATE,
-  EVENT_CREATE_TIME,
-  helixmanager,
-  clusterStatusMonitor,
-  changeContext,
-  instanceName,
-  eventData,
-  AsyncFIFOWorkerPool,
-  PipelineType,
-  LastRebalanceFinishTimeStamp,
-  ControllerDataProvider
-}
+import org.apache.helix.NotificationContext;
+import org.apache.helix.model.CustomizedStateAggregationConfig;
+
+/**
+ * Interface to implement to listen for changes to customized state aggregation configurations.
+ */
+public interface CustomizedStateAggregationConfigChangeListener {
+  /**
+   * Invoked when customized state aggregation config changes
+   * @param customizedStateAggregationConfig
+   * @param context
+   */
+  void onCustomizedStateAggregationConfigChange(CustomizedStateAggregationConfig customizedStateAggregationConfig,
+      NotificationContext context);
+}
\ No newline at end of file
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
b/helix-core/src/main/java/org/apache/helix/api/listeners/CustomizedStateChangeListener.java
similarity index 51%
copy from helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
copy to helix-core/src/main/java/org/apache/helix/api/listeners/CustomizedStateChangeListener.java
index a2b63f8..0753f67 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
+++ b/helix-core/src/main/java/org/apache/helix/api/listeners/CustomizedStateChangeListener.java
@@ -1,4 +1,4 @@
-package org.apache.helix.controller.stages;
+package org.apache.helix.api.listeners;
 
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
@@ -9,7 +9,7 @@ package org.apache.helix.controller.stages;
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
  *
- *   http://www.apache.org/licenses/LICENSE-2.0
+ *     http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
@@ -19,24 +19,21 @@ package org.apache.helix.controller.stages;
  * under the License.
  */
 
-public enum AttributeName {
-  RESOURCES,
-  RESOURCES_TO_REBALANCE,
-  BEST_POSSIBLE_STATE,
-  CURRENT_STATE,
-  INTERMEDIATE_STATE,
-  MESSAGES_ALL,
-  MESSAGES_SELECTED,
-  MESSAGES_THROTTLE,
-  LOCAL_STATE,
-  EVENT_CREATE_TIME,
-  helixmanager,
-  clusterStatusMonitor,
-  changeContext,
-  instanceName,
-  eventData,
-  AsyncFIFOWorkerPool,
-  PipelineType,
-  LastRebalanceFinishTimeStamp,
-  ControllerDataProvider
-}
+import java.util.List;
+import org.apache.helix.NotificationContext;
+import org.apache.helix.model.CustomizedState;
+
+/**
+ * Interface to implement to respond to changes in the current state
+ */
+public interface CustomizedStateChangeListener {
+
+  /**
+   * Invoked when customized state changes
+   * @param instanceName name of the instance whose state changed
+   * @param customizedStatesInfo a list of the customized states
+   * @param changeContext the change event and state
+   */
+  void onCustomizedStateChange(String instanceName, List<CustomizedState> customizedStatesInfo,
+      NotificationContext changeContext);
+}
\ No newline at end of file
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
b/helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
index a2b63f8..40aeb23 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/AttributeName.java
@@ -24,6 +24,7 @@ public enum AttributeName {
   RESOURCES_TO_REBALANCE,
   BEST_POSSIBLE_STATE,
   CURRENT_STATE,
+  CUSTOMIZED_STATE,
   INTERMEDIATE_STATE,
   MESSAGES_ALL,
   MESSAGES_SELECTED,
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
index e2cb0f4..77fcd84 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZKHelixManager.java
@@ -56,6 +56,8 @@ import org.apache.helix.api.listeners.ConfigChangeListener;
 import org.apache.helix.api.listeners.ControllerChangeListener;
 import org.apache.helix.api.listeners.CurrentStateChangeListener;
 import org.apache.helix.api.listeners.CustomizedViewChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateAggregationConfigChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateChangeListener;
 import org.apache.helix.api.listeners.ExternalViewChangeListener;
 import org.apache.helix.api.listeners.IdealStateChangeListener;
 import org.apache.helix.api.listeners.InstanceConfigChangeListener;
@@ -470,6 +472,15 @@ public class ZKHelixManager implements HelixManager, IZkStateListener
{
   }
 
   @Override
+  public void addCustomizedStateAggregationConfigChangeListener(
+      CustomizedStateAggregationConfigChangeListener listener) throws Exception {
+    addListener(listener, new Builder(_clusterName).customizedStateAggregationConfig(),
+        ChangeType.CUSTOMIZED_STATE_AGGREGATION_CONFIG, new EventType[] {
+            EventType.NodeDataChanged
+        });
+  }
+
+  @Override
   public void addClusterfigChangeListener(ClusterConfigChangeListener listener) throws Exception{
     addListener(listener, new Builder(_clusterName).clusterConfig(), ChangeType.CLUSTER_CONFIG,
         new EventType[] { EventType.NodeDataChanged
@@ -559,6 +570,14 @@ public class ZKHelixManager implements HelixManager, IZkStateListener
{
   }
 
   @Override
+  public void addCustomizedStateChangeListener(CustomizedStateChangeListener listener,
+      String instanceName, String customizedStateName) throws Exception {
+    addListener(listener, new Builder(_clusterName).customizedStates(instanceName, customizedStateName),
+        ChangeType.CUSTOMIZED_STATE, new EventType[] { EventType.NodeChildrenChanged
+        });
+  }
+
+  @Override
   public void addExternalViewChangeListener(ExternalViewChangeListener listener) throws Exception
{
     addListener(listener, new Builder(_clusterName).externalViews(), ChangeType.EXTERNAL_VIEW,
         new EventType[] { EventType.NodeChildrenChanged });
diff --git a/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
b/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
index a62b73a..1134e64 100644
--- a/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
+++ b/helix-core/src/test/java/org/apache/helix/controller/stages/DummyClusterManager.java
@@ -37,6 +37,8 @@ import org.apache.helix.api.listeners.ClusterConfigChangeListener;
 import org.apache.helix.api.listeners.ConfigChangeListener;
 import org.apache.helix.api.listeners.ControllerChangeListener;
 import org.apache.helix.api.listeners.CurrentStateChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateAggregationConfigChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateChangeListener;
 import org.apache.helix.api.listeners.ExternalViewChangeListener;
 import org.apache.helix.api.listeners.CustomizedViewChangeListener;
 import org.apache.helix.api.listeners.IdealStateChangeListener;
@@ -132,6 +134,13 @@ public class DummyClusterManager implements HelixManager {
   }
 
   @Override
+  public void addCustomizedStateChangeListener(CustomizedStateChangeListener listener,
+      String instanceName, String sessionId) throws Exception {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
   public void addExternalViewChangeListener(ExternalViewChangeListener listener) throws Exception
{
     // TODO Auto-generated method stub
 
@@ -293,6 +302,13 @@ public class DummyClusterManager implements HelixManager {
   }
 
   @Override
+  public void addCustomizedStateAggregationConfigChangeListener(CustomizedStateAggregationConfigChangeListener
listener)
+      throws Exception {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
   public void addClusterfigChangeListener(ClusterConfigChangeListener listener)
       throws Exception {
     // TODO Auto-generated method stub
diff --git a/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
b/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
index 684e339..054ec75 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/manager/TestParticipantManager.java
@@ -151,7 +151,7 @@ public class TestParticipantManager extends ZkTestBase {
     // check HelixCallback Monitor
     Set<ObjectInstance> objs =
         _server.queryMBeans(buildCallbackMonitorObjectName(type, clusterName, instanceName),
null);
-    Assert.assertEquals(objs.size(), 14);
+    Assert.assertEquals(objs.size(), 16);
 
     // check HelixZkClient Monitors
     objs =
diff --git a/helix-core/src/test/java/org/apache/helix/mock/MockManager.java b/helix-core/src/test/java/org/apache/helix/mock/MockManager.java
index 540971c..5d7e275 100644
--- a/helix-core/src/test/java/org/apache/helix/mock/MockManager.java
+++ b/helix-core/src/test/java/org/apache/helix/mock/MockManager.java
@@ -40,6 +40,8 @@ import org.apache.helix.api.listeners.ConfigChangeListener;
 import org.apache.helix.api.listeners.ControllerChangeListener;
 import org.apache.helix.api.listeners.CurrentStateChangeListener;
 import org.apache.helix.api.listeners.CustomizedViewChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateAggregationConfigChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateChangeListener;
 import org.apache.helix.api.listeners.ExternalViewChangeListener;
 import org.apache.helix.api.listeners.IdealStateChangeListener;
 import org.apache.helix.api.listeners.InstanceConfigChangeListener;
@@ -136,6 +138,13 @@ public class MockManager implements HelixManager {
   }
 
   @Override
+  public void addCustomizedStateChangeListener(CustomizedStateChangeListener listener,
+      String instanceName, String sessionId) {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
   public void addExternalViewChangeListener(ExternalViewChangeListener listener) {
     // TODO Auto-generated method stub
 
@@ -164,6 +173,12 @@ public class MockManager implements HelixManager {
   }
 
   @Override
+  public void addCustomizedStateAggregationConfigChangeListener(CustomizedStateAggregationConfigChangeListener
listener)
+      throws Exception {
+
+  }
+
+  @Override
   public void addClusterfigChangeListener(ClusterConfigChangeListener listener)
       throws Exception {
 
diff --git a/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
b/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
index e0e7d9c..496e10f 100644
--- a/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
+++ b/helix-core/src/test/java/org/apache/helix/participant/MockZKHelixManager.java
@@ -39,6 +39,8 @@ import org.apache.helix.api.listeners.ConfigChangeListener;
 import org.apache.helix.api.listeners.ControllerChangeListener;
 import org.apache.helix.api.listeners.CurrentStateChangeListener;
 import org.apache.helix.api.listeners.CustomizedViewChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateAggregationConfigChangeListener;
+import org.apache.helix.api.listeners.CustomizedStateChangeListener;
 import org.apache.helix.api.listeners.ExternalViewChangeListener;
 import org.apache.helix.api.listeners.IdealStateChangeListener;
 import org.apache.helix.api.listeners.InstanceConfigChangeListener;
@@ -124,6 +126,13 @@ public class MockZKHelixManager implements HelixManager {
   }
 
   @Override
+  public void addCustomizedStateAggregationConfigChangeListener(CustomizedStateAggregationConfigChangeListener
listener)
+      throws Exception {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
   public void addClusterfigChangeListener(ClusterConfigChangeListener listener)
       throws Exception {
     // TODO Auto-generated method stub
@@ -161,6 +170,13 @@ public class MockZKHelixManager implements HelixManager {
   }
 
   @Override
+  public void addCustomizedStateChangeListener(CustomizedStateChangeListener listener,
+      String instanceName, String sessionId) throws Exception {
+    // TODO Auto-generated method stub
+
+  }
+
+  @Override
   public void addExternalViewChangeListener(ExternalViewChangeListener listener) throws Exception
{
     // TODO Auto-generated method stub
 


Mime
View raw message