Permalink
Browse files

Admin

Fixed bug showing if a Node is available and when was checked last time
  • Loading branch information...
1 parent 1264e12 commit 125e1f39e5dd8499ded63a964c099548aa26d9dd @ctasada committed Feb 28, 2012
@@ -16,7 +16,9 @@
package voldemort.cluster.failuredetector;
+import java.text.DateFormat;
import java.util.ArrayList;
+import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@@ -144,6 +146,12 @@ public long getLastChecked(Node node) {
}
}
+ public String getLastCheckedFormatted(Node node) {
+ long ms = getLastChecked(node);
+ DateFormat format = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
+ return format.format(new Date(ms));
+ }
+
public void destroy() {}
protected void setAvailable(Node node) {
@@ -24,8 +24,10 @@
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import voldemort.server.ServiceType;
import voldemort.server.VoldemortServer;
import voldemort.server.http.VoldemortServletContextListener;
+import voldemort.server.storage.StorageService;
import voldemort.utils.Utils;
import com.google.common.collect.Maps;
@@ -41,6 +43,7 @@
private VoldemortServer server;
private VelocityEngine velocityEngine;
+ private StorageService storageService;
/* For use by servlet container */
public AdminServlet() {}
@@ -54,17 +57,19 @@ public AdminServlet(VoldemortServer server, VelocityEngine engine) {
public void init() throws ServletException {
super.init();
this.server = (VoldemortServer) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.SERVER_KEY));
+ this.storageService = (StorageService) server.getService(ServiceType.STORAGE);
this.velocityEngine = (VelocityEngine) Utils.notNull(getServletContext().getAttribute(VoldemortServletContextListener.VELOCITY_ENGINE_KEY));
}
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
Map<String, Object> params = Maps.newHashMap();
+
params.put("cluster", server.getMetadataStore().getCluster());
params.put("repository", server.getStoreRepository());
params.put("services", server.getServices());
+ params.put("failureDetector", storageService.getFailureDetector());
velocityEngine.render("admin.vm", params, response.getOutputStream());
}
-
}
@@ -60,17 +60,16 @@
<th>ID</th>
<th>Host</th>
<th>HTTP Port</th>
- <th>Mina Port</th>
<th>Available</th>
- <th>Last Check (ms)</th>
+ <th>Last Check</th>
</tr>
#foreach($node in $cluster.nodes)
<tr>
<td>$node.id</td>
<td>$node.host</td>
<td>$node.httpPort</td>
- <td>$node.status.isAvailable()</td>
- <td>$node.status.msSinceLastCheck</td>
+ <td>$failureDetector.isAvailable($node)</td>
+ <td>$failureDetector.getLastCheckedFormatted($node)</td>
</tr>
#end
</table>
@@ -169,6 +169,10 @@ public StorageService(StoreRepository storeRepository,
this.dynThrottleLimit = null;
}
+ public FailureDetector getFailureDetector() {
+ return failureDetector;
+ }
+
private void initStorageConfig(String configClassName) {
try {
Class<?> configClass = ReflectUtils.loadClass(configClassName);

0 comments on commit 125e1f3

Please sign in to comment.