helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From l...@apache.org
Subject [23/38] helix git commit: Rename ParticipantMonitor class
Date Wed, 08 Feb 2017 17:59:58 GMT
Rename ParticipantMonitor class


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/6a375071
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/6a375071
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/6a375071

Branch: refs/heads/helix-0.6.x
Commit: 6a3750715a140e4da406a8707c1e41a1bb4b7427
Parents: 7245d19
Author: Boyan Li <boli@linkedin.com>
Authored: Wed Sep 14 10:48:23 2016 -0700
Committer: Lei Xia <lxia@linkedin.com>
Committed: Wed Feb 8 09:52:30 2017 -0800

----------------------------------------------------------------------
 .../messaging/handling/HelixTaskExecutor.java   |   8 +-
 .../helix/monitoring/ParticipantMonitor.java    | 111 -------------------
 .../monitoring/ParticipantStatusMonitor.java    | 111 +++++++++++++++++++
 .../monitoring/TestParticipantMonitor.java      |   4 +-
 4 files changed, 117 insertions(+), 117 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/6a375071/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
index 7a1210f..188992b 100644
--- a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
+++ b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixTaskExecutor.java
@@ -57,7 +57,7 @@ import org.apache.helix.model.Message;
 import org.apache.helix.model.Message.MessageState;
 import org.apache.helix.model.Message.MessageType;
 import org.apache.helix.model.builder.HelixConfigScopeBuilder;
-import org.apache.helix.monitoring.ParticipantMonitor;
+import org.apache.helix.monitoring.ParticipantStatusMonitor;
 import org.apache.helix.monitoring.mbeans.MessageQueueMonitor;
 import org.apache.helix.participant.HelixStateMachineEngine;
 import org.apache.helix.participant.statemachine.StateModel;
@@ -105,7 +105,7 @@ public class HelixTaskExecutor implements MessageListener, TaskExecutor
{
   protected final Map<String, MessageTaskInfo> _taskMap;
   private final Object _lock;
   private final StatusUpdateUtil _statusUpdateUtil;
-  private final ParticipantMonitor _monitor;
+  private final ParticipantStatusMonitor _monitor;
   public static final String MAX_THREADS = "maxThreads";
 
   private MessageQueueMonitor _messageQueueMonitor;
@@ -137,7 +137,7 @@ public class HelixTaskExecutor implements MessageListener, TaskExecutor
{
 
     _lock = new Object();
     _statusUpdateUtil = new StatusUpdateUtil();
-    _monitor = new ParticipantMonitor();
+    _monitor = new ParticipantStatusMonitor();
 
     _timer = new Timer(true); // created as a daemon timer thread to handle task timeout
 
@@ -188,7 +188,7 @@ public class HelixTaskExecutor implements MessageListener, TaskExecutor
{
     _controller = controller;
   }
 
-  public ParticipantMonitor getParticipantMonitor() {
+  public ParticipantStatusMonitor getParticipantMonitor() {
     return _monitor;
   }
 

http://git-wip-us.apache.org/repos/asf/helix/blob/6a375071/helix-core/src/main/java/org/apache/helix/monitoring/ParticipantMonitor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/ParticipantMonitor.java
b/helix-core/src/main/java/org/apache/helix/monitoring/ParticipantMonitor.java
deleted file mode 100644
index 01b43cd..0000000
--- a/helix-core/src/main/java/org/apache/helix/monitoring/ParticipantMonitor.java
+++ /dev/null
@@ -1,111 +0,0 @@
-package org.apache.helix.monitoring;
-
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "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
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-import java.lang.management.ManagementFactory;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.TimeUnit;
-
-import javax.management.MBeanServer;
-import javax.management.MalformedObjectNameException;
-import javax.management.ObjectName;
-
-import org.apache.helix.monitoring.mbeans.StateTransitionStatMonitor;
-import org.apache.log4j.Logger;
-
-public class ParticipantMonitor {
-  private final ConcurrentHashMap<StateTransitionContext, StateTransitionStatMonitor>
_monitorMap =
-      new ConcurrentHashMap<StateTransitionContext, StateTransitionStatMonitor>();
-  private static final Logger LOG = Logger.getLogger(ParticipantMonitor.class);
-
-  private MBeanServer _beanServer;
-
-  public ParticipantMonitor() {
-    try {
-      _beanServer = ManagementFactory.getPlatformMBeanServer();
-    } catch (Exception e) {
-      LOG.warn(e);
-      e.printStackTrace();
-      _beanServer = null;
-    }
-  }
-
-  public void reportTransitionStat(StateTransitionContext cxt, StateTransitionDataPoint data)
{
-    if (_beanServer == null) {
-      LOG.warn("bean server is null, skip reporting");
-      return;
-    }
-    try {
-      if (!_monitorMap.containsKey(cxt)) {
-        synchronized (this) {
-          if (!_monitorMap.containsKey(cxt)) {
-            StateTransitionStatMonitor bean =
-                new StateTransitionStatMonitor(cxt, TimeUnit.MILLISECONDS);
-            _monitorMap.put(cxt, bean);
-            String beanName = cxt.toString();
-            register(bean, getObjectName(beanName));
-          }
-        }
-      }
-      _monitorMap.get(cxt).addDataPoint(data);
-    } catch (Exception e) {
-      LOG.warn(e);
-      e.printStackTrace();
-    }
-  }
-
-  private ObjectName getObjectName(String name) throws MalformedObjectNameException {
-    LOG.info("Registering bean: " + name);
-    return new ObjectName("CLMParticipantReport:" + name);
-  }
-
-  private void register(Object bean, ObjectName name) {
-    if (_beanServer == null) {
-      LOG.warn("bean server is null, skip reporting");
-      return;
-    }
-    try {
-      _beanServer.unregisterMBean(name);
-    } catch (Exception e1) {
-      // Swallow silently
-    }
-
-    try {
-      _beanServer.registerMBean(bean, name);
-    } catch (Exception e) {
-      LOG.warn("Could not register MBean", e);
-    }
-  }
-
-  public void shutDown() {
-    for (StateTransitionContext cxt : _monitorMap.keySet()) {
-      try {
-        ObjectName name = getObjectName(cxt.toString());
-        if (_beanServer.isRegistered(name)) {
-          _beanServer.unregisterMBean(name);
-        }
-      } catch (Exception e) {
-        LOG.warn("fail to unregister " + cxt.toString(), e);
-      }
-    }
-    _monitorMap.clear();
-
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/6a375071/helix-core/src/main/java/org/apache/helix/monitoring/ParticipantStatusMonitor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/monitoring/ParticipantStatusMonitor.java
b/helix-core/src/main/java/org/apache/helix/monitoring/ParticipantStatusMonitor.java
new file mode 100644
index 0000000..e2e0082
--- /dev/null
+++ b/helix-core/src/main/java/org/apache/helix/monitoring/ParticipantStatusMonitor.java
@@ -0,0 +1,111 @@
+package org.apache.helix.monitoring;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "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
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.lang.management.ManagementFactory;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.TimeUnit;
+
+import javax.management.MBeanServer;
+import javax.management.MalformedObjectNameException;
+import javax.management.ObjectName;
+
+import org.apache.helix.monitoring.mbeans.StateTransitionStatMonitor;
+import org.apache.log4j.Logger;
+
+public class ParticipantStatusMonitor {
+  private final ConcurrentHashMap<StateTransitionContext, StateTransitionStatMonitor>
_monitorMap =
+      new ConcurrentHashMap<StateTransitionContext, StateTransitionStatMonitor>();
+  private static final Logger LOG = Logger.getLogger(ParticipantStatusMonitor.class);
+
+  private MBeanServer _beanServer;
+
+  public ParticipantStatusMonitor() {
+    try {
+      _beanServer = ManagementFactory.getPlatformMBeanServer();
+    } catch (Exception e) {
+      LOG.warn(e);
+      e.printStackTrace();
+      _beanServer = null;
+    }
+  }
+
+  public void reportTransitionStat(StateTransitionContext cxt, StateTransitionDataPoint data)
{
+    if (_beanServer == null) {
+      LOG.warn("bean server is null, skip reporting");
+      return;
+    }
+    try {
+      if (!_monitorMap.containsKey(cxt)) {
+        synchronized (this) {
+          if (!_monitorMap.containsKey(cxt)) {
+            StateTransitionStatMonitor bean =
+                new StateTransitionStatMonitor(cxt, TimeUnit.MILLISECONDS);
+            _monitorMap.put(cxt, bean);
+            String beanName = cxt.toString();
+            register(bean, getObjectName(beanName));
+          }
+        }
+      }
+      _monitorMap.get(cxt).addDataPoint(data);
+    } catch (Exception e) {
+      LOG.warn(e);
+      e.printStackTrace();
+    }
+  }
+
+  private ObjectName getObjectName(String name) throws MalformedObjectNameException {
+    LOG.info("Registering bean: " + name);
+    return new ObjectName("CLMParticipantReport:" + name);
+  }
+
+  private void register(Object bean, ObjectName name) {
+    if (_beanServer == null) {
+      LOG.warn("bean server is null, skip reporting");
+      return;
+    }
+    try {
+      _beanServer.unregisterMBean(name);
+    } catch (Exception e1) {
+      // Swallow silently
+    }
+
+    try {
+      _beanServer.registerMBean(bean, name);
+    } catch (Exception e) {
+      LOG.warn("Could not register MBean", e);
+    }
+  }
+
+  public void shutDown() {
+    for (StateTransitionContext cxt : _monitorMap.keySet()) {
+      try {
+        ObjectName name = getObjectName(cxt.toString());
+        if (_beanServer.isRegistered(name)) {
+          _beanServer.unregisterMBean(name);
+        }
+      } catch (Exception e) {
+        LOG.warn("fail to unregister " + cxt.toString(), e);
+      }
+    }
+    _monitorMap.clear();
+
+  }
+}

http://git-wip-us.apache.org/repos/asf/helix/blob/6a375071/helix-core/src/test/java/org/apache/helix/monitoring/TestParticipantMonitor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/monitoring/TestParticipantMonitor.java
b/helix-core/src/test/java/org/apache/helix/monitoring/TestParticipantMonitor.java
index 5f44b36..0191eaa 100644
--- a/helix-core/src/test/java/org/apache/helix/monitoring/TestParticipantMonitor.java
+++ b/helix-core/src/test/java/org/apache/helix/monitoring/TestParticipantMonitor.java
@@ -33,7 +33,7 @@ import javax.management.MalformedObjectNameException;
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 
-import org.apache.helix.monitoring.ParticipantMonitor;
+import org.apache.helix.monitoring.ParticipantStatusMonitor;
 import org.apache.helix.monitoring.StateTransitionContext;
 import org.apache.helix.monitoring.StateTransitionDataPoint;
 import org.apache.helix.monitoring.mbeans.ClusterMBeanObserver;
@@ -100,7 +100,7 @@ public class TestParticipantMonitor {
   public void testReportData() throws InstanceNotFoundException, MalformedObjectNameException,
       NullPointerException, IOException, InterruptedException {
     System.out.println("START TestParticipantMonitor");
-    ParticipantMonitor monitor = new ParticipantMonitor();
+    ParticipantStatusMonitor monitor = new ParticipantStatusMonitor();
 
     int monitorNum = 0;
 


Mime
View raw message