Repository: cassandra Updated Branches: refs/heads/trunk 5d3855990 -> bd46463fb
Start metrics reporter before bootstrap Patch by Tommy Stendahl; reviewed by jmckenzie for CASSANDRA-9594 Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/bd46463f Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/bd46463f Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/bd46463f Branch: refs/heads/trunk Commit: bd46463fbb7d6b0998c837450ce61df13eda041d Parents: 5d38559 Author: Tommy Stendahl <tommy.stend...@ericsson.com> Authored: Wed Sep 30 15:43:43 2015 -0400 Committer: Joshua McKenzie <jmcken...@apache.org> Committed: Wed Sep 30 15:43:43 2015 -0400 ---------------------------------------------------------------------- .../cassandra/service/CassandraDaemon.java | 63 +++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/bd46463f/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 f9ee9e8..41510ea 100644 --- a/src/java/org/apache/cassandra/service/CassandraDaemon.java +++ b/src/java/org/apache/cassandra/service/CassandraDaemon.java @@ -321,20 +321,6 @@ public class CassandraDaemon SystemKeyspace.finishStartup(); - // start server internals - StorageService.instance.registerDaemon(this); - try - { - StorageService.instance.initServer(); - } - catch (ConfigurationException e) - { - System.err.println(e.getMessage() + "\nFatal configuration error; unable to start server. See log for stacktrace."); - exitOrFail(1, "Fatal configuration error", e); - } - - Mx4jTool.maybeLoad(); - // Metrics String metricsReporterConfigFile = System.getProperty("cassandra.metricsReporterConfigFile"); if (metricsReporterConfigFile != null) @@ -351,6 +337,20 @@ public class CassandraDaemon } } + // start server internals + StorageService.instance.registerDaemon(this); + try + { + StorageService.instance.initServer(); + } + catch (ConfigurationException e) + { + System.err.println(e.getMessage() + "\nFatal configuration error; unable to start server. See log for stacktrace."); + exitOrFail(1, "Fatal configuration error", e); + } + + Mx4jTool.maybeLoad(); + if (!FBUtilities.getBroadcastAddress().equals(InetAddress.getLoopbackAddress())) waitForGossipToSettle(); @@ -533,9 +533,12 @@ public class CassandraDaemon //Allow the server to start even if the bean can't be registered } - try { + try + { DatabaseDescriptor.forceStaticInitialization(); - } catch (ExceptionInInitializerError e) { + } + catch (ExceptionInInitializerError e) + { throw e.getCause(); } @@ -608,7 +611,8 @@ public class CassandraDaemon stop(); destroy(); // completely shut down cassandra - if(!runManaged) { + if(!runManaged) + { System.exit(0); } } @@ -668,21 +672,24 @@ public class CassandraDaemon instance.activate(); } - private void exitOrFail(int code, String message) { + private void exitOrFail(int code, String message) + { exitOrFail(code, message, null); } - private void exitOrFail(int code, String message, Throwable cause) { - if(runManaged) { - RuntimeException t = cause!=null ? new RuntimeException(message, cause) : new RuntimeException(message); - throw t; - } - else { - logger.error(message, cause); - System.exit(code); - } - + private void exitOrFail(int code, String message, Throwable cause) + { + if (runManaged) + { + RuntimeException t = cause!=null ? new RuntimeException(message, cause) : new RuntimeException(message); + throw t; } + else + { + logger.error(message, cause); + System.exit(code); + } + } static class NativeAccess implements NativeAccessMBean {