accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject [01/12] accumulo git commit: ACCUMULO-3837 shorten the time to fetch the instance name and use a more reasonable default
Date Tue, 26 May 2015 15:53:25 GMT
Repository: accumulo
Updated Branches:
  refs/heads/master 43c383165 -> f453ecaa1


ACCUMULO-3837 shorten the time to fetch the instance name and use a more reasonable default


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

Branch: refs/heads/master
Commit: 2a167712690aa3957332c9503790e7936cbca90c
Parents: c4eff0c
Author: Eric C. Newton <eric.newton@gmail.com>
Authored: Tue May 26 10:23:54 2015 -0400
Committer: Eric C. Newton <eric.newton@gmail.com>
Committed: Tue May 26 10:23:54 2015 -0400

----------------------------------------------------------------------
 .../apache/accumulo/monitor/servlets/BasicServlet.java | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/accumulo/blob/2a167712/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 7812603..ea63cf2 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
@@ -27,6 +27,7 @@ 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;
@@ -48,7 +49,7 @@ abstract public class BasicServlet extends HttpServlet {
 
   private static final long serialVersionUID = 1L;
   protected static final Logger log = Logger.getLogger(BasicServlet.class);
-  static String cachedInstanceName = null;
+  static AtomicReference<String> cachedInstanceName = new AtomicReference<String>("(Unavailable)");
   private static String bannerText;
   private static String bannerColor;
   private static String bannerBackground;
@@ -111,17 +112,17 @@ abstract public class BasicServlet extends HttpServlet {
     }
     synchronized (BasicServlet.class) {
       // Learn our instance name asynchronously so we don't hang up if zookeeper is down
-      if (cachedInstanceName == null) {
+      if (cachedInstanceName.get() == null) {
         SimpleTimer.getInstance().schedule(new TimerTask() {
           @Override
           public void run() {
             synchronized (BasicServlet.class) {
-              if (cachedInstanceName == null) {
-                cachedInstanceName = HdfsZooInstance.getInstance().getInstanceName();
+              if (cachedInstanceName.get() == null) {
+                cachedInstanceName.set(HdfsZooInstance.getInstance().getInstanceName());
               }
             }
           }
-        }, 1000);
+        }, 0);
       }
     }
 
@@ -173,7 +174,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).append("&nbsp;&nbsp;&nbsp;Version:&nbsp;").append(Constants.VERSION)
+    sb.append("<div id='subheader'>Instance&nbsp;Name:&nbsp;").append(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>");


Mime
View raw message