cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jasobr...@apache.org
Subject cassandra git commit: add check of the system wall clock time at startup
Date Fri, 14 Nov 2014 02:24:32 GMT
Repository: cassandra
Updated Branches:
  refs/heads/cassandra-2.1 feb26752b -> 1470cee58


add check of the system wall clock time at startup

patch by jasobrown; reviewed by driftx for CASSANDRA-8305


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/1470cee5
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/1470cee5
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/1470cee5

Branch: refs/heads/cassandra-2.1
Commit: 1470cee58872b89ee8ae5d2f7e287ad7f32ed50b
Parents: feb2675
Author: Jason Brown <jasedbrown@gmail.com>
Authored: Wed Nov 12 18:31:04 2014 -0800
Committer: Jason Brown <jasedbrown@gmail.com>
Committed: Thu Nov 13 18:23:46 2014 -0800

----------------------------------------------------------------------
 CHANGES.txt                                         |  1 +
 .../apache/cassandra/service/CassandraDaemon.java   | 16 ++++++++++++++++
 2 files changed, 17 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/1470cee5/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 6caa5c7..6517c6a 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,4 +1,5 @@
 2.1.3
+ * add check of the system wall clock time at startup (CASSANDRA-8305)
  * Support for frozen collections (CASSANDRA-7859)
  * Fix overflow on histogram computation (CASSANDRA-8028)
  * Have paxos reuse the timestamp generation of normal queries (CASSANDRA-7801)

http://git-wip-us.apache.org/repos/asf/cassandra/blob/1470cee5/src/java/org/apache/cassandra/service/CassandraDaemon.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/service/CassandraDaemon.java b/src/java/org/apache/cassandra/service/CassandraDaemon.java
index 38d0414..5897a22 100644
--- a/src/java/org/apache/cassandra/service/CassandraDaemon.java
+++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java
@@ -24,6 +24,7 @@ import java.lang.management.MemoryPoolMXBean;
 import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.util.Arrays;
+import java.util.Date;
 import java.util.Map;
 import java.util.UUID;
 import java.util.concurrent.TimeUnit;
@@ -72,6 +73,13 @@ public class CassandraDaemon
 
     private static final CassandraDaemon instance = new CassandraDaemon();
 
+    /**
+     * The earliest legit timestamp a casandra instance could have ever launched.
+     * Date roughly taken from http://perspectives.mvdirona.com/2008/07/12/FacebookReleasesCassandraAsOpenSource.aspx
+     * We use this to ensure the system clock is at least somewhat correct at startup.
+     */
+    private static final long EARLIEST_LAUNCH_DATE = 1215820800000L;
+
     public Server thriftServer;
     public Server nativeServer;
 
@@ -92,6 +100,14 @@ public class CassandraDaemon
         {
             logger.info("Could not resolve local host");
         }
+
+        long now = System.currentTimeMillis();
+        if (now < EARLIEST_LAUNCH_DATE)
+        {
+            logger.error("current machine time is {}, but that is seemingly incorrect. exiting
now.", new Date(now));
+            System.exit(3);
+        }
+
         // log warnings for different kinds of sub-optimal JVMs.  tldr use 64-bit Oracle
>= 1.6u32
         if (!DatabaseDescriptor.hasLargeAddressSpace())
             logger.info("32bit JVM detected.  It is recommended to run Cassandra on a 64bit
JVM for better performance.");


Mime
View raw message