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)

git-svn-id: https://svn.apache.org/repos/asf/hbase/trunk@1541112 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
rajeshbabu 2013-11-12 15:42:58 +00:00
parent c3fcaec3f4
commit 2d81ab63f1
2 changed files with 24 additions and 5 deletions

View File

@ -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. " +

View File

@ -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 3");
InetAddress ia3 = InetAddress.getLocalHost();
sm.regionServerStartup(ia3, 1236, -1, System.currentTimeMillis() - warningSkew * 2);
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 5");
InetAddress ia5 = InetAddress.getLocalHost();
sm.regionServerStartup(ia5, 1238, -1, System.currentTimeMillis() + warningSkew * 2);
}