helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From zzh...@apache.org
Subject git commit: [HELIX-319] refactor MonitoringClient to accommodate distributed monitoring server, minor fix
Date Fri, 28 Feb 2014 02:26:45 GMT
Repository: helix
Updated Branches:
  refs/heads/helix-monitoring 8dc50de1a -> f0367e952


[HELIX-319] refactor MonitoringClient to accommodate distributed monitoring server, minor
fix


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

Branch: refs/heads/helix-monitoring
Commit: f0367e9523f7de4e278c4a8a4f284d21d6126fef
Parents: 8dc50de
Author: zzhang <zzhang@apache.org>
Authored: Thu Feb 27 18:26:30 2014 -0800
Committer: zzhang <zzhang@apache.org>
Committed: Thu Feb 27 18:26:30 2014 -0800

----------------------------------------------------------------------
 .../org/apache/helix/monitoring/RiemannAgent.java | 18 ++++++++++++++++--
 .../monitoring/TestRiemannMonitoringServer.java   |  1 -
 2 files changed, 16 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/f0367e95/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannAgent.java
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannAgent.java
b/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannAgent.java
index 06957f4..61e3d6c 100644
--- a/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannAgent.java
+++ b/helix-monitor-server/src/main/java/org/apache/helix/monitoring/RiemannAgent.java
@@ -67,6 +67,7 @@ public class RiemannAgent {
     while ((System.currentTimeMillis() - startT) < timeout) {
       try {
         _client.connect();
+        _client.event().service("heartbeat").state("running").ttl(20).sendWithAck();
         break;
       } catch (IOException e) {
         int sleep = _random.nextInt(3000) + 3000;
@@ -95,18 +96,31 @@ public class RiemannAgent {
       @Override
       public void run() {
         try {
-          // send heartbeat metrics
+          // Send heartbeat metrics
           _client.event().service("heartbeat").state("running").ttl(20).sendWithAck();
         } catch (Exception e) {
           LOG.error("Exception in send heatbeat to local riemann server, shutdown RiemannAgent:
"
               + _instanceName, e);
-          shutdown();
+          asyncShutdown();
         }
       }
     });
 
   }
 
+  /**
+   * Do shutdown asynchronously
+   */
+  void asyncShutdown() {
+    new Thread(new Runnable() {
+
+      @Override
+      public void run() {
+        shutdown();
+      }
+    }).start();
+  }
+
   public void shutdown() {
     LOG.info("Shutting down RiemannAgent. zk: " + _zkAddr + ", cluster: " + _clusterName
         + ", instance: " + _instanceName + ", riemannPort: " + _riemannPort);

http://git-wip-us.apache.org/repos/asf/helix/blob/f0367e95/helix-monitor-server/src/test/java/org/apache/helix/monitoring/TestRiemannMonitoringServer.java
----------------------------------------------------------------------
diff --git a/helix-monitor-server/src/test/java/org/apache/helix/monitoring/TestRiemannMonitoringServer.java
b/helix-monitor-server/src/test/java/org/apache/helix/monitoring/TestRiemannMonitoringServer.java
index f7f45f9..f7d0585 100644
--- a/helix-monitor-server/src/test/java/org/apache/helix/monitoring/TestRiemannMonitoringServer.java
+++ b/helix-monitor-server/src/test/java/org/apache/helix/monitoring/TestRiemannMonitoringServer.java
@@ -29,7 +29,6 @@ import org.testng.Assert;
 import org.testng.annotations.Test;
 
 import com.aphyr.riemann.client.RiemannClient;
-import com.google.common.collect.Lists;
 
 public class TestRiemannMonitoringServer {
 


Mime
View raw message