add check of the system wall clock time at startup

patch by jasobrown; reviewed by driftx for CASSANDRA-8305
This commit is contained in:
Jason Brown 2014-11-12 18:31:04 -08:00
parent feb26752b2
commit 1470cee588
2 changed files with 17 additions and 0 deletions

View File

@ -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)

View File

@ -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.");