You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@helix.apache.org by GitBox <gi...@apache.org> on 2021/05/11 18:52:19 UTC

[GitHub] [helix] zhangmeng916 opened a new pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

zhangmeng916 opened a new pull request #1732:
URL: https://github.com/apache/helix/pull/1732


   …etrics to dynamic metrics
   
   ### Issues
   
   - [X] My PR addresses the following Helix issues and references them in the PR description:
   Fixed #1683 
   ### Description
   
   - [X] Here are some details about my PR, including screenshots of any UI changes:
   
   These PR continues to change some legacy metrics that use static metric to the standard ones that use dynamic metric. The changed monitor includes workflow monitor and perinstanceresource monitor. There are also some corresponding changes made in the test and caller functions.
   
   ### Tests
   
   - The following is the result of the "mvn test" command on the appropriate module:
   Helix-core:
   [INFO] Tests run: 1268, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 5,062.131 s - in TestSuite
   [INFO]
   [INFO] Results:
   [INFO]
   [INFO] Tests run: 1268, Failures: 0, Errors: 0, Skipped: 0
   [INFO]
   [INFO]
   [INFO] --- jacoco-maven-plugin:0.8.6:report (generate-code-coverage-report) @ helix-core ---
   [INFO] Loading execution data file /home/mnzhang/helix/helix-core/target/jacoco.exec
   [INFO] Analyzed bundle 'Apache Helix :: Core' with 894 classes
   [INFO] ------------------------------------------------------------------------
   [INFO] BUILD SUCCESS
   [INFO] ------------------------------------------------------------------------
   [INFO] Total time:  01:24 h
   [INFO] Finished at: 2021-05-11T11:27:32-07:00
   
   ### Changes that Break Backward Compatibility (Optional)
   
   - My PR contains changes that break backward compatibility or previous assumptions for certain methods or API. They include:
   
   (Consider including all behavior changes for public methods or API. Also include these changes in merge description so that other developers are aware of these changes. This allows them to make relevant code changes in feature branches accounting for the new method/API behavior.)
   
   ### Documentation (Optional)
   
   - In case of new functionality, my PR adds documentation in the following wiki page:
   
   (Link the GitHub wiki you added)
   
   ### Commits
   
   - My commits all reference appropriate Apache Helix GitHub issues in their subject lines. In addition, my commits follow the guidelines from "[How to write a good git commit message](http://chris.beams.io/posts/git-commit/)":
     1. Subject is separated from body by a blank line
     1. Subject is limited to 50 characters (not including Jira issue reference)
     1. Subject does not end with a period
     1. Subject uses the imperative mood ("add", not "adding")
     1. Body wraps at 72 characters
     1. Body explains "what" and "why", not "how"
   
   ### Code Quality
   
   - My diff has been formatted using helix-style.xml 
   (helix-style-intellij.xml if IntelliJ IDE is used)
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r630585446



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -898,26 +896,19 @@ private void unregisterPerInstanceResources(
       throws MalformedObjectNameException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor.BeanName beanName : beanNames) {
-        unregister(getObjectName(
-            getPerInstanceResourceBeanName(beanName.instanceName(), beanName.resourceName())));
+        _perInstanceResourceMonitorMap.get(beanName).unregister();

Review comment:
       Better to check null to avoid NPE.

##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -710,8 +709,8 @@ private String preProcessWorkflow(String workflowType) {
       if (!_perTypeWorkflowMonitorMap.containsKey(workflowType)) {
         WorkflowMonitor monitor = new WorkflowMonitor(_clusterName, workflowType);
         try {
-          registerWorkflow(monitor);
-        } catch (MalformedObjectNameException e) {
+          monitor.register();
+        } catch (Exception e) {

Review comment:
       Should only throw JMException? And the same question to the other catches.

##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/PerInstanceResourceMonitor.java
##########
@@ -113,6 +118,10 @@ public String getResourceName() {
     return _resourceName;
   }
 
+  public String getBeanName() {

Review comment:
       Is this method used anywhere? And the return string seems not to be a valid MBean name, which should look like, "%s,%s=%s,%s=%s"

##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/WorkflowMonitor.java
##########
@@ -142,12 +113,72 @@ public void resetGauges() {
    */
   public void updateWorkflowGauges(TaskState current) {
     if (current == null || current.equals(TaskState.NOT_STARTED)) {
-      _queuedWorkflowGauge++;
+      incrementSimpleDynamicMetric(_queuedWorkflowGauge, 1);
     } else if (current.equals(TaskState.IN_PROGRESS)) {
-      _runningWorkflowGauge++;
+      incrementSimpleDynamicMetric(_runningWorkflowGauge, 1);
     } else if (current.equals(TaskState.FAILED)) {
-      _failedWorkflowGauge++;
+      incrementSimpleDynamicMetric(_failedWorkflowGauge, 1);
     }
-    _existingWorkflowGauge++;
+    incrementSimpleDynamicMetric(_existingWorkflowGauge);
+  }
+
+  // All the get functions are for testing purpose only.
+  public long getSuccessfulWorkflowCount() {
+    return _successfulWorkflowCount.getValue();
+  }
+
+  public long getFailedWorkflowCount() {
+    return _failedWorkflowCount.getValue();
+  }
+
+  public long getFailedWorkflowGauge() {
+    return _failedWorkflowGauge.getValue();
+  }
+
+  public long getExistingWorkflowGauge() {
+    return _existingWorkflowGauge.getValue();
+  }
+
+  public long getQueuedWorkflowGauge() {
+    return _queuedWorkflowGauge.getValue();
+  }
+
+  public long getRunningWorkflowGauge() {
+    return _runningWorkflowGauge.getValue();
+  }
+
+  @Override
+  public DynamicMBeanProvider register() throws JMException {
+    List<DynamicMetric<?, ?>> attributeList = new ArrayList<>();
+    attributeList.add(_successfulWorkflowCount);
+    attributeList.add(_failedWorkflowCount);
+    attributeList.add(_failedWorkflowGauge);
+    attributeList.add(_existingWorkflowGauge);
+    attributeList.add(_queuedWorkflowGauge);
+    attributeList.add(_runningWorkflowGauge);
+    attributeList.add(_totalWorkflowLatencyCount);
+    attributeList.add(_maximumWorkflowLatencyGauge);
+    attributeList.add(_lastResetTime);
+    String workflowBeanName = getWorkflowBeanName(_workflowType);
+    doRegister(attributeList, MBEAN_DESCRIPTION, getObjectName(workflowBeanName));
+    return this;
+  }
+
+  private ObjectName getObjectName(String name) throws MalformedObjectNameException {
+    return new ObjectName(String.format("%s:%s", MonitorDomainNames.ClusterStatus.name(), name));
+  }
+
+  /**
+   * Build workflow per type bean name
+   * "cluster={clusterName},workflowType={workflowType},
+   * @param workflowType The workflow type
+   * @return per workflow type bean name
+   */
+  private String getWorkflowBeanName(String workflowType) {
+    return String.format("%s, %s=%s", clusterBeanName(), WORKFLOW_TYPE_DN_KEY, workflowType);
+  }
+
+  private String clusterBeanName() {
+    return String.format("%s=%s", CLUSTER_DN_KEY, _clusterName);
   }

Review comment:
       I think these nested String.format calls are too verbose. If they are not shared, can we just make it one single method?

##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/PerInstanceResourceMonitor.java
##########
@@ -131,13 +140,41 @@ public synchronized void update(Map<Partition, String> stateMap, Set<String> tag
     int cnt = 0;
     for (String state : stateMap.values()) {
       // Skip DROPPED and initial state (e.g. OFFLINE)
-      if (state.equalsIgnoreCase(HelixDefinedState.DROPPED.name())
-          || state.equalsIgnoreCase(stateModelDef.getInitialState())) {
+      if (state.equalsIgnoreCase(HelixDefinedState.DROPPED.name()) || state
+          .equalsIgnoreCase(stateModelDef.getInitialState())) {
         continue;
       }
       cnt++;
     }
-    _partitions = cnt;
+    _partitions.updateValue(Long.valueOf(cnt));
+  }
+
+  @Override
+  public DynamicMBeanProvider register() throws JMException {
+    List<DynamicMetric<?, ?>> attributeList = new ArrayList<>();
+    attributeList.add(_partitions);
+    String beanName = getPerInstanceResourceBeanName(_participantName, _resourceName);
+    doRegister(attributeList, MBEAN_DESCRIPTION, getObjectName(beanName));
+    return this;
+  }
+
+  /**

Review comment:
       These are just for generating the Object name, since BeanName won't be used in the ClusterStatusMonitor anymore, can we just make it private and change the logic to return a complete ObjectName?

##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/WorkflowMonitor.java
##########
@@ -142,12 +113,72 @@ public void resetGauges() {
    */
   public void updateWorkflowGauges(TaskState current) {
     if (current == null || current.equals(TaskState.NOT_STARTED)) {
-      _queuedWorkflowGauge++;
+      incrementSimpleDynamicMetric(_queuedWorkflowGauge, 1);

Review comment:
       Not for this PR, but this method seems to be a better fit in the SimpleDynamicMetric class




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r630697993



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -874,13 +873,12 @@ private void unregisterAllEventMonitors() {
   }
 
   private void registerPerInstanceResources(Collection<PerInstanceResourceMonitor> monitors)
-      throws MalformedObjectNameException {
+      throws JMException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor monitor : monitors) {
         String instanceName = monitor.getInstanceName();
         String resourceName = monitor.getResourceName();
-        String beanName = getPerInstanceResourceBeanName(instanceName, resourceName);
-        register(monitor, getObjectName(beanName));

Review comment:
       I see. So this register is only registering cluster status monitor, which we haven't changed it yet. And inside cluster status monitor, other monitors got registered individually with different methods. Once we start to change cluster status monitor, we may need to handle its register from its calling class.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r631283876



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -898,26 +896,19 @@ private void unregisterPerInstanceResources(
       throws MalformedObjectNameException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor.BeanName beanName : beanNames) {
-        unregister(getObjectName(
-            getPerInstanceResourceBeanName(beanName.instanceName(), beanName.resourceName())));
+        _perInstanceResourceMonitorMap.get(beanName).unregister();

Review comment:
       _perInstanceResourceMonitorMap.get(beanName) could be null?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r630600737



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -898,26 +896,19 @@ private void unregisterPerInstanceResources(
       throws MalformedObjectNameException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor.BeanName beanName : beanNames) {
-        unregister(getObjectName(
-            getPerInstanceResourceBeanName(beanName.instanceName(), beanName.resourceName())));
+        _perInstanceResourceMonitorMap.get(beanName).unregister();

Review comment:
       Unregister already has a null check like this. Should be enough, right?
   public static void unregister(ObjectName objectName) {
       if (objectName != null && _beanServer.isRegistered(objectName)) {
         try {
   ..................
          




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 merged pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
zhangmeng916 merged pull request #1732:
URL: https://github.com/apache/helix/pull/1732


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r630681417



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -874,13 +873,12 @@ private void unregisterAllEventMonitors() {
   }
 
   private void registerPerInstanceResources(Collection<PerInstanceResourceMonitor> monitors)
-      throws MalformedObjectNameException {
+      throws JMException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor monitor : monitors) {
         String instanceName = monitor.getInstanceName();
         String resourceName = monitor.getResourceName();
-        String beanName = getPerInstanceResourceBeanName(instanceName, resourceName);
-        register(monitor, getObjectName(beanName));

Review comment:
       Yeah, as long as we changed the register of workflow monitor and perinstanceresource monitor to use the dynamic register, we shouldn't be concerned about other places in this monitor. Later we may still need to change them though if we would like to change corresponding monitors.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on pull request #1732:
URL: https://github.com/apache/helix/pull/1732#issuecomment-841435057


   This PR is ready to merge. Approve by @junkaixue and @jiajunwang 
   Final commit message:
   Change Workflow monitor and PerInstanceResource monitor from static metric to dynamic metric.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r631465432



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/PerInstanceResourceMonitor.java
##########
@@ -131,13 +140,41 @@ public synchronized void update(Map<Partition, String> stateMap, Set<String> tag
     int cnt = 0;
     for (String state : stateMap.values()) {
       // Skip DROPPED and initial state (e.g. OFFLINE)
-      if (state.equalsIgnoreCase(HelixDefinedState.DROPPED.name())
-          || state.equalsIgnoreCase(stateModelDef.getInitialState())) {
+      if (state.equalsIgnoreCase(HelixDefinedState.DROPPED.name()) || state
+          .equalsIgnoreCase(stateModelDef.getInitialState())) {
         continue;
       }
       cnt++;
     }
-    _partitions = cnt;
+    _partitions.updateValue(Long.valueOf(cnt));
+  }
+
+  @Override
+  public DynamicMBeanProvider register() throws JMException {
+    List<DynamicMetric<?, ?>> attributeList = new ArrayList<>();
+    attributeList.add(_partitions);
+    String beanName = getPerInstanceResourceBeanName(_participantName, _resourceName);
+    doRegister(attributeList, MBEAN_DESCRIPTION, getObjectName(beanName));
+    return this;
+  }
+
+  /**

Review comment:
       I don't think this comment has been addressed.
   Originally, the PerInstanceResourceMonitor does not know cluster info. The BeanName object only contains the instance and resource info. So the registration is done in the ClusterStatusMonitor.
   In this new version, since we encapsulate the register method inside PerInstanceResourceMonitor (since now it is a DynamicMBeanProvider). Based on this, I think there are 2 options,
   
   1. Remove BeanName class and always let the PerInstanceResourceMonitor initialized with the fully generated ObjectName (which includes the cluster name). For the existing BeanName usages in the ClusterStatusMonitor, we can change to use the ObjectName. The downside of this option is the PerInstanceResourceMonitor needs to understand MonitorDomainNames.ClusterStatus to generate full ObjectName.
   2. Since every PerInstanceResourceMonitor is generated in the ClusterStatusMonitor, we add a private method in the ClusterStatusMonitor to generate full ObjectName of the PerInstanceResourceMonitor when constructing it. And PerInstanceResourceMonitor does not need to know about the domain names etc. For example, we are now doing this design for InstanceMonitor. In this case, BeanName can also be removed since it is duplicated with the ObjectName parameter.
   
   Please consider picking up either one of these 2 designs. The current implementation is a mix-up and the MBean name generating logic has duplicated code. It might introduce bugs if we change in one side (BeanName), but forget to change the other side (getObjectName).




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] dasahcc commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
dasahcc commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r630569489



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/WorkflowMonitor.java
##########
@@ -112,27 +81,28 @@ public void updateWorkflowCounters(TaskState to) {
 
   public void updateWorkflowCounters(TaskState to, long latency) {
     if (to.equals(TaskState.FAILED)) {
-      _failedWorkflowCount++;
+      incrementSimpleDynamicMetric(_failedWorkflowCount, 1);
     } else if (to.equals(TaskState.COMPLETED)) {
-      _successfulWorkflowCount++;
+      incrementSimpleDynamicMetric(_successfulWorkflowCount, 1);
 
       // Only record latency larger than 0 and succeeded workflows
-      _maximumWorkflowLatencyGauge = Math.max(_maximumWorkflowLatencyGauge, latency);
-      _totalWorkflowLatencyCount += latency > 0 ? latency : 0;
+      _maximumWorkflowLatencyGauge
+          .updateValue(Math.max(_maximumWorkflowLatencyGauge.getValue(), latency));

Review comment:
       NIT: we can use the same function of incrementSimpleDynamicMetric




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
rabashizade commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r630686434



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -874,13 +873,12 @@ private void unregisterAllEventMonitors() {
   }
 
   private void registerPerInstanceResources(Collection<PerInstanceResourceMonitor> monitors)
-      throws MalformedObjectNameException {
+      throws JMException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor monitor : monitors) {
         String instanceName = monitor.getInstanceName();
         String resourceName = monitor.getResourceName();
-        String beanName = getPerInstanceResourceBeanName(instanceName, resourceName);
-        register(monitor, getObjectName(beanName));

Review comment:
       I see, thanks for clarification, but what about in other classes? My main concern is its usage in `public void active()` method, which in turn is used in `private void enableClusterStatusMonitor(boolean enable)` method in `GenericHelixController`. Although since the tests are passing it should be fine, but I was just curious.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
rabashizade commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r630654853



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -874,13 +873,12 @@ private void unregisterAllEventMonitors() {
   }
 
   private void registerPerInstanceResources(Collection<PerInstanceResourceMonitor> monitors)
-      throws MalformedObjectNameException {
+      throws JMException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor monitor : monitors) {
         String instanceName = monitor.getInstanceName();
         String resourceName = monitor.getResourceName();
-        String beanName = getPerInstanceResourceBeanName(instanceName, resourceName);
-        register(monitor, getObjectName(beanName));

Review comment:
       Is it okay that this method (`private void register(Object bean, ObjectName name)`) is still used in other places in the code?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] rabashizade commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
rabashizade commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r630699081



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -874,13 +873,12 @@ private void unregisterAllEventMonitors() {
   }
 
   private void registerPerInstanceResources(Collection<PerInstanceResourceMonitor> monitors)
-      throws MalformedObjectNameException {
+      throws JMException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor monitor : monitors) {
         String instanceName = monitor.getInstanceName();
         String resourceName = monitor.getResourceName();
-        String beanName = getPerInstanceResourceBeanName(instanceName, resourceName);
-        register(monitor, getObjectName(beanName));

Review comment:
       Got it, thanks.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] zhangmeng916 commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
zhangmeng916 commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r632728233



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/PerInstanceResourceMonitor.java
##########
@@ -131,13 +140,41 @@ public synchronized void update(Map<Partition, String> stateMap, Set<String> tag
     int cnt = 0;
     for (String state : stateMap.values()) {
       // Skip DROPPED and initial state (e.g. OFFLINE)
-      if (state.equalsIgnoreCase(HelixDefinedState.DROPPED.name())
-          || state.equalsIgnoreCase(stateModelDef.getInitialState())) {
+      if (state.equalsIgnoreCase(HelixDefinedState.DROPPED.name()) || state
+          .equalsIgnoreCase(stateModelDef.getInitialState())) {
         continue;
       }
       cnt++;
     }
-    _partitions = cnt;
+    _partitions.updateValue(Long.valueOf(cnt));
+  }
+
+  @Override
+  public DynamicMBeanProvider register() throws JMException {
+    List<DynamicMetric<?, ?>> attributeList = new ArrayList<>();
+    attributeList.add(_partitions);
+    String beanName = getPerInstanceResourceBeanName(_participantName, _resourceName);
+    doRegister(attributeList, MBEAN_DESCRIPTION, getObjectName(beanName));
+    return this;
+  }
+
+  /**

Review comment:
       Discussed offline. We will have everything inside BeanName structure, and deprecate other related get bean name functions to concentrate all logic.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org


[GitHub] [helix] jiajunwang commented on a change in pull request #1732: Change Workflow monitor and PerInstanceResource monitor from static m…

Posted by GitBox <gi...@apache.org>.
jiajunwang commented on a change in pull request #1732:
URL: https://github.com/apache/helix/pull/1732#discussion_r631283876



##########
File path: helix-core/src/main/java/org/apache/helix/monitoring/mbeans/ClusterStatusMonitor.java
##########
@@ -898,26 +896,19 @@ private void unregisterPerInstanceResources(
       throws MalformedObjectNameException {
     synchronized (_perInstanceResourceMonitorMap) {
       for (PerInstanceResourceMonitor.BeanName beanName : beanNames) {
-        unregister(getObjectName(
-            getPerInstanceResourceBeanName(beanName.instanceName(), beanName.resourceName())));
+        _perInstanceResourceMonitorMap.get(beanName).unregister();

Review comment:
       _perInstanceResourceMonitorMap.get(beanName) could be null. And you are about to not use the unregister(objectName) method that has protection, right?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@helix.apache.org
For additional commands, e-mail: reviews-help@helix.apache.org