hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rajeshb...@apache.org
Subject svn commit: r1541112 - in /hbase/trunk/hbase-server/src: main/java/org/apache/hadoop/hbase/master/ServerManager.java test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java
Date Tue, 12 Nov 2013 15:42:58 GMT
Author: rajeshbabu
Date: Tue Nov 12 15:42:58 2013
New Revision: 1541112

URL: http://svn.apache.org/r1541112
Log:
HBASE-9902 Region Server is starting normally even if clock skew is more than default 30 seconds(or
any configured). -> Regionserver node time is greater than master node time(Kashif)

Modified:
    hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
    hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java

Modified: hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java?rev=1541112&r1=1541111&r2=1541112&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
(original)
+++ hbase/trunk/hbase-server/src/main/java/org/apache/hadoop/hbase/master/ServerManager.java
Tue Nov 12 15:42:58 2013
@@ -305,7 +305,7 @@ public class ServerManager {
    */
   private void checkClockSkew(final ServerName serverName, final long serverCurrentTime)
   throws ClockOutOfSyncException {
-    long skew = System.currentTimeMillis() - serverCurrentTime;
+    long skew = Math.abs(System.currentTimeMillis() - serverCurrentTime);
     if (skew > maxSkew) {
       String message = "Server " + serverName + " has been " +
         "rejected; Reported time is too far out of sync with master.  " +

Modified: hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java
URL: http://svn.apache.org/viewvc/hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java?rev=1541112&r1=1541111&r2=1541112&view=diff
==============================================================================
--- hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java
(original)
+++ hbase/trunk/hbase-server/src/test/java/org/apache/hadoop/hbase/master/TestClockSkewDetection.java
Tue Nov 12 15:42:58 2013
@@ -86,19 +86,38 @@ public class TestClockSkewDetection {
     long warningSkew = c.getLong("hbase.master.warningclockskew", 1000);
 
     try {
+    	//Master Time > Region Server Time
+      LOG.debug("Test: Master Time > Region Server Time");
       LOG.debug("regionServerStartup 2");
       InetAddress ia2 = InetAddress.getLocalHost();
       sm.regionServerStartup(ia2, 1235, -1, System.currentTimeMillis() - maxSkew * 2);
-      fail("HMaster should have thrown an ClockOutOfSyncException but didn't.");
+      fail("HMaster should have thrown a ClockOutOfSyncException but didn't.");
     } catch(ClockOutOfSyncException e) {
       //we want an exception
       LOG.info("Recieved expected exception: "+e);
     }
     
+    try {
+      // Master Time < Region Server Time
+      LOG.debug("Test: Master Time < Region Server Time");
+      LOG.debug("regionServerStartup 3");
+      InetAddress ia3 = InetAddress.getLocalHost();
+      sm.regionServerStartup(ia3, 1236, -1, System.currentTimeMillis() + maxSkew * 2);
+      fail("HMaster should have thrown a ClockOutOfSyncException but didn't.");
+    } catch (ClockOutOfSyncException e) {
+      // we want an exception
+      LOG.info("Recieved expected exception: " + e);
+    }
+    
+    // make sure values above warning threshold but below max threshold don't kill
+    LOG.debug("regionServerStartup 4");
+    InetAddress ia4 = InetAddress.getLocalHost();
+    sm.regionServerStartup(ia4, 1237, -1, System.currentTimeMillis() - warningSkew * 2);
+    
     // make sure values above warning threshold but below max threshold don't kill
-    LOG.debug("regionServerStartup 3");
-    InetAddress ia3 = InetAddress.getLocalHost();
-    sm.regionServerStartup(ia3, 1236, -1, System.currentTimeMillis() - warningSkew * 2);
+    LOG.debug("regionServerStartup 5");
+    InetAddress ia5 = InetAddress.getLocalHost();
+    sm.regionServerStartup(ia5, 1238, -1, System.currentTimeMillis() + warningSkew * 2);
     
   }
 



Mime
View raw message