Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E891010A2B for ; Tue, 12 Nov 2013 15:43:29 +0000 (UTC) Received: (qmail 3514 invoked by uid 500); 12 Nov 2013 15:43:29 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 3297 invoked by uid 500); 12 Nov 2013 15:43:24 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 3289 invoked by uid 99); 12 Nov 2013 15:43:22 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Nov 2013 15:43:22 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 12 Nov 2013 15:43:20 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id D250123888E2; Tue, 12 Nov 2013 15:42:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@hbase.apache.org From: rajeshbabu@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131112154258.D250123888E2@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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); }