accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [04/12] accumulo git commit: ACCUMULO-3837 fetch instance name with the other data
Date Tue, 26 May 2015 15:53:28 GMT
ACCUMULO-3837 fetch instance name with the other data


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

Branch: refs/heads/master
Commit: 80a7bb182b57acc7d17215eb0e2da46d0d3350f0
Parents: 2a16771
Author: Eric C. Newton <eric.newton@gmail.com>
Authored: Tue May 26 11:08:59 2015 -0400
Committer: Eric C. Newton <eric.newton@gmail.com>
Committed: Tue May 26 11:08:59 2015 -0400

----------------------------------------------------------------------
 core/.gitignore                                 |  1 +
 examples/simple/.gitignore                      |  1 +
 fate/.gitignore                                 |  1 +
 maven-plugin/.gitignore                         |  1 +
 .../org/apache/accumulo/monitor/Monitor.java    | 22 ++++++++++++++++++++
 .../accumulo/monitor/servlets/BasicServlet.java | 21 +------------------
 server/tracer/.gitignore                        |  1 +
 trace/.gitignore                                |  1 +
 8 files changed, 29 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/80a7bb18/core/.gitignore
----------------------------------------------------------------------
diff --git a/core/.gitignore b/core/.gitignore
index 56204d2..59a826f 100644
--- a/core/.gitignore
+++ b/core/.gitignore
@@ -23,3 +23,4 @@
 /.pydevproject
 /.idea
 /*.iml
+/bin/

http://git-wip-us.apache.org/repos/asf/accumulo/blob/80a7bb18/examples/simple/.gitignore
----------------------------------------------------------------------
diff --git a/examples/simple/.gitignore b/examples/simple/.gitignore
index 56204d2..59a826f 100644
--- a/examples/simple/.gitignore
+++ b/examples/simple/.gitignore
@@ -23,3 +23,4 @@
 /.pydevproject
 /.idea
 /*.iml
+/bin/

http://git-wip-us.apache.org/repos/asf/accumulo/blob/80a7bb18/fate/.gitignore
----------------------------------------------------------------------
diff --git a/fate/.gitignore b/fate/.gitignore
index 56204d2..59a826f 100644
--- a/fate/.gitignore
+++ b/fate/.gitignore
@@ -23,3 +23,4 @@
 /.pydevproject
 /.idea
 /*.iml
+/bin/

http://git-wip-us.apache.org/repos/asf/accumulo/blob/80a7bb18/maven-plugin/.gitignore
----------------------------------------------------------------------
diff --git a/maven-plugin/.gitignore b/maven-plugin/.gitignore
index 56204d2..e7d7fb1 100644
--- a/maven-plugin/.gitignore
+++ b/maven-plugin/.gitignore
@@ -23,3 +23,4 @@
 /.pydevproject
 /.idea
 /*.iml
+/target/

http://git-wip-us.apache.org/repos/asf/accumulo/blob/80a7bb18/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
index 1b1e534..60f5772 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/Monitor.java
@@ -29,7 +29,9 @@ import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.TimerTask;
 import java.util.TreeMap;
+import java.util.concurrent.atomic.AtomicReference;
 
 import org.apache.accumulo.core.Constants;
 import org.apache.accumulo.core.client.Connector;
@@ -56,6 +58,7 @@ import org.apache.accumulo.core.zookeeper.ZooUtil;
 import org.apache.accumulo.fate.zookeeper.ZooLock.LockLossReason;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeExistsPolicy;
 import org.apache.accumulo.fate.zookeeper.ZooUtil.NodeMissingPolicy;
+import org.apache.accumulo.monitor.servlets.BasicServlet;
 import org.apache.accumulo.monitor.servlets.DefaultServlet;
 import org.apache.accumulo.monitor.servlets.GcStatusServlet;
 import org.apache.accumulo.monitor.servlets.JSONServlet;
@@ -85,6 +88,7 @@ import org.apache.accumulo.server.security.SecurityUtil;
 import org.apache.accumulo.server.security.SystemCredentials;
 import org.apache.accumulo.server.util.Halt;
 import org.apache.accumulo.server.util.TableInfoUtil;
+import org.apache.accumulo.server.util.time.SimpleTimer;
 import org.apache.accumulo.server.zookeeper.ZooLock;
 import org.apache.accumulo.server.zookeeper.ZooReaderWriter;
 import org.apache.accumulo.trace.instrument.Tracer;
@@ -167,6 +171,8 @@ public class Monitor {
 
   private ZooLock monitorLock;
 
+  public static AtomicReference<String> cachedInstanceName = new AtomicReference<String>("(Unavailable)");
+
   private static class EventCounter {
 
     Map<String,Pair<Long,Long>> prevSamples = new HashMap<String,Pair<Long,Long>>();
@@ -242,6 +248,22 @@ public class Monitor {
       return;
 
     synchronized (Monitor.class) {
+      // Learn our instance name asynchronously so we don't hang up if zookeeper is down
+      if (Monitor.cachedInstanceName.get() == null) {
+        SimpleTimer.getInstance().schedule(new TimerTask() {
+          @Override
+          public void run() {
+            synchronized (Monitor.class) {
+              if (cachedInstanceName.get() == null) {
+                cachedInstanceName.set(HdfsZooInstance.getInstance().getInstanceName());
+              }
+            }
+          }
+        }, 0);
+      }
+    }
+
+    synchronized (Monitor.class) {
       if (fetching)
         return;
       fetching = true;

http://git-wip-us.apache.org/repos/asf/accumulo/blob/80a7bb18/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java
----------------------------------------------------------------------
diff --git a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java
b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java
index ea63cf2..f39fe4d 100644
--- a/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java
+++ b/server/monitor/src/main/java/org/apache/accumulo/monitor/servlets/BasicServlet.java
@@ -26,8 +26,6 @@ import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.util.Date;
 import java.util.List;
-import java.util.TimerTask;
-import java.util.concurrent.atomic.AtomicReference;
 
 import javax.servlet.ServletException;
 import javax.servlet.http.Cookie;
@@ -41,7 +39,6 @@ import org.apache.accumulo.monitor.Monitor;
 import org.apache.accumulo.server.client.HdfsZooInstance;
 import org.apache.accumulo.server.monitor.DedupedLogEvent;
 import org.apache.accumulo.server.monitor.LogService;
-import org.apache.accumulo.server.util.time.SimpleTimer;
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
 
@@ -49,7 +46,6 @@ abstract public class BasicServlet extends HttpServlet {
 
   private static final long serialVersionUID = 1L;
   protected static final Logger log = Logger.getLogger(BasicServlet.class);
-  static AtomicReference<String> cachedInstanceName = new AtomicReference<String>("(Unavailable)");
   private static String bannerText;
   private static String bannerColor;
   private static String bannerBackground;
@@ -110,21 +106,6 @@ abstract public class BasicServlet extends HttpServlet {
         // ignore improperly formatted user cookie
       }
     }
-    synchronized (BasicServlet.class) {
-      // Learn our instance name asynchronously so we don't hang up if zookeeper is down
-      if (cachedInstanceName.get() == null) {
-        SimpleTimer.getInstance().schedule(new TimerTask() {
-          @Override
-          public void run() {
-            synchronized (BasicServlet.class) {
-              if (cachedInstanceName.get() == null) {
-                cachedInstanceName.set(HdfsZooInstance.getInstance().getInstanceName());
-              }
-            }
-          }
-        }, 0);
-      }
-    }
 
     // BEGIN PAGE
     sb.append("<!--\n");
@@ -174,7 +155,7 @@ abstract public class BasicServlet extends HttpServlet {
     }
     sb.append("<div id='headertitle'>");
     sb.append("<h1>").append(getTitle(req)).append("</h1></div>\n");
-    sb.append("<div id='subheader'>Instance&nbsp;Name:&nbsp;").append(cachedInstanceName.get()).append("&nbsp;&nbsp;&nbsp;Version:&nbsp;").append(Constants.VERSION)
+    sb.append("<div id='subheader'>Instance&nbsp;Name:&nbsp;").append(Monitor.cachedInstanceName.get()).append("&nbsp;&nbsp;&nbsp;Version:&nbsp;").append(Constants.VERSION)
         .append("\n");
     sb.append("<br><span class='smalltext'>Instance&nbsp;ID:&nbsp;").append(HdfsZooInstance.getInstance().getInstanceID()).append("</span>\n");
     sb.append("<br><span class='smalltext'>").append(new Date().toString().replace("
", "&nbsp;")).append("</span>");

http://git-wip-us.apache.org/repos/asf/accumulo/blob/80a7bb18/server/tracer/.gitignore
----------------------------------------------------------------------
diff --git a/server/tracer/.gitignore b/server/tracer/.gitignore
index 56204d2..e7d7fb1 100644
--- a/server/tracer/.gitignore
+++ b/server/tracer/.gitignore
@@ -23,3 +23,4 @@
 /.pydevproject
 /.idea
 /*.iml
+/target/

http://git-wip-us.apache.org/repos/asf/accumulo/blob/80a7bb18/trace/.gitignore
----------------------------------------------------------------------
diff --git a/trace/.gitignore b/trace/.gitignore
index 56204d2..59a826f 100644
--- a/trace/.gitignore
+++ b/trace/.gitignore
@@ -23,3 +23,4 @@
 /.pydevproject
 /.idea
 /*.iml
+/bin/


Mime
View raw message