hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nkey...@apache.org
Subject svn commit: r1498274 - in /hbase/trunk/hbase-server/src: main/jamon/org/apache/hadoop/hbase/tmpl/master/ main/java/org/apache/hadoop/hbase/master/ test/java/org/apache/hadoop/hbase/master/
Date Mon, 01 Jul 2013 07:42:06 GMT
Author: nkeywal
Date: Mon Jul  1 07:42:05 2013
New Revision: 1498274

URL: http://svn.apache.org/r1498274
Log:
HBASE-4360 Maintain information on the time a RS went dead (samar)

Modified:
    hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestDeadServer.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java

Modified: hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon?rev=1498274&r1=1498273&r2=1498274&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
(original)
+++ hbase/trunk/hbase-server/src/main/jamon/org/apache/hadoop/hbase/tmpl/master/MasterStatusTmpl.jamon
Mon Jul  1 07:42:05 2013
@@ -46,6 +46,7 @@ org.apache.hadoop.hbase.client.HConnecti
 org.apache.hadoop.hbase.HTableDescriptor;
 org.apache.hadoop.hbase.HBaseConfiguration;
 org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.SnapshotDescription;
+org.apache.hadoop.hbase.master.DeadServer;
 </%import>
 <%if format.equals("json") %>
   <& ../common/TaskMonitorTmpl; filter = filter; format = "json" &>
@@ -346,17 +347,21 @@ AssignmentManager assignmentManager = ma
 <h2>Dead Region Servers</h2>
 <table class="table table-striped">
     <tr>
-        <th rowspan="<% deadServers.size() + 1%>"></th>
+        <th></th>
         <th>ServerName</th>
+        <th>Stop time</th>
     </tr>
     <%java>
+       DeadServer deadServerUtil = master.getServerManager().getDeadServers();
        ServerName [] deadServerNames = deadServers.toArray(new ServerName[deadServers.size()]);
          Arrays.sort(deadServerNames);
          for (ServerName deadServerName: deadServerNames) {
            int infoPort = master.getConfiguration().getInt("hbase.regionserver.info.port",
60030);
     </%java>
     <tr>
+    	<th rowspan="<% deadServers.size() %>"></th>
         <td><% deadServerName %></td>
+        <td><% deadServerUtil.getTimeOfDeath(deadServerName) %></td>
     </tr>
     <%java>
         }
@@ -364,6 +369,7 @@ AssignmentManager assignmentManager = ma
     <tr>
         <th>Total: </th>
         <td>servers: <% deadServers.size() %></td>
+        <th></th>
     </tr>
 </table>
 </%if>

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java?rev=1498274&r1=1498273&r2=1498274&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/DeadServer.java
Mon Jul  1 07:42:05 2013
@@ -26,6 +26,7 @@ import org.apache.hadoop.hbase.util.Pair
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Comparator;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Iterator;
@@ -160,6 +161,16 @@ public class DeadServer {
     Collections.sort(res, ServerNameDeathDateComparator);
     return res;
   }
+  
+  /**
+   * Get the time when a server died
+   * @param deadServerName the dead server name
+   * @return the date when the server died 
+   */
+  public synchronized Date getTimeOfDeath(final ServerName deadServerName){
+    Long time = deadServers.get(deadServerName);
+    return time == null ? null : new Date(time);
+  }
 
   private static Comparator<Pair<ServerName, Long>> ServerNameDeathDateComparator
=
       new Comparator<Pair<ServerName, Long>>(){

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestDeadServer.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestDeadServer.java?rev=1498274&r1=1498273&r2=1498274&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestDeadServer.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestDeadServer.java
Mon Jul  1 07:42:05 2013
@@ -27,6 +27,7 @@ import org.junit.Test;
 import org.junit.experimental.categories.Category;
 
 import java.util.List;
+import java.util.Set;
 
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
@@ -62,6 +63,10 @@ public class TestDeadServer {
     assertFalse(ds.cleanPreviousInstance(deadServer));
     ds.add(deadServer);
     assertTrue(ds.isDeadServer(deadServer));
+    Set<ServerName> deadServerNames = ds.copyServerNames();
+    for (ServerName eachDeadServer : deadServerNames) {
+      Assert.assertNotNull(ds.getTimeOfDeath(eachDeadServer));
+    }
     final ServerName deadServerHostComingAlive =
       new ServerName("127.0.0.1", 9090, 223341L);
     assertTrue(ds.cleanPreviousInstance(deadServerHostComingAlive));

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java?rev=1498274&r1=1498273&r2=1498274&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestMasterStatusServlet.java
Mon Jul  1 07:42:05 2013
@@ -70,10 +70,13 @@ public class TestMasterStatusServlet {
     Mockito.doReturn(FAKE_HOST).when(master).getServerName();
     Mockito.doReturn(conf).when(master).getConfiguration();
 
+    //Fake DeadServer
+    DeadServer deadServer = Mockito.mock(DeadServer.class);
     // Fake serverManager
     ServerManager serverManager = Mockito.mock(ServerManager.class);
     Mockito.doReturn(1.0).when(serverManager).getAverageLoad();
     Mockito.doReturn(serverManager).when(master).getServerManager();
+    Mockito.doReturn(deadServer).when(serverManager).getDeadServers();
 
     // Fake AssignmentManager and RIT
     AssignmentManager am = Mockito.mock(AssignmentManager.class);
@@ -85,6 +88,7 @@ public class TestMasterStatusServlet {
     Mockito.doReturn(rs).when(am).getRegionStates();
     Mockito.doReturn(regionsInTransition).when(rs).getRegionsInTransition();
     Mockito.doReturn(am).when(master).getAssignmentManager();
+    Mockito.doReturn(serverManager).when(master).getServerManager();
 
     // Fake ZKW
     ZooKeeperWatcher zkw = Mockito.mock(ZooKeeperWatcher.class);



Mime
View raw message