Author: ivol37 at gmail.com
Date: Wed Jan 19 09:57:20 2011
New Revision: 676
Log:
[AMDATU-254] Added more logging and added wait mode for daemon to reach
operation mode 'normal'. This in general only effects nodes starting in
autobootstrap mode.
Modified:
trunk/amdatu-cassandra/cassandra-application/src/main/java/org/amdatu/cassandra/application/service/CassandraDaemonServiceImpl.java
Modified:
trunk/amdatu-cassandra/cassandra-application/src/main/java/org/amdatu/cassandra/application/service/CassandraDaemonServiceImpl.java
==============================================================================
---
trunk/amdatu-cassandra/cassandra-application/src/main/java/org/amdatu/cassandra/application/service/CassandraDaemonServiceImpl.java
(original)
+++
trunk/amdatu-cassandra/cassandra-application/src/main/java/org/amdatu/cassandra/application/service/CassandraDaemonServiceImpl.java
Wed Jan 19 09:57:20 2011
@@ -51,6 +51,7 @@
// Timeout for the initial Thrift connection
private final int THRIFT_RETRIES = 3;
private final int THRIFT_TIMEOUT = 3000;
+ private final int DAEMON_TIMEOUT = 5000;
// The default placement strategy
private final String DEFAULT_PLACEMENT_STRATEGY =
"org.apache.cassandra.locator.SimpleStrategy";
@@ -93,6 +94,14 @@
throw new RuntimeException("CassandraDaemon has already been
shutdown and cannot be restarted.");
}
+ m_logService.log(LogService.LOG_INFO, "Starting Cassandra Daemon with
configuration: ");
+ m_logService.log(LogService.LOG_INFO, " Auto bootstrap mode = " +
m_configuration.isAutoBootstrapMode());
+ m_logService.log(LogService.LOG_INFO, " Default replication factor =
" + m_configuration.getDefaultReplicationFactor());
+ m_logService.log(LogService.LOG_INFO, " Read consistency level= " +
m_configuration.getReadConsistencyLevel());
+ m_logService.log(LogService.LOG_INFO, " Write consistency level = " +
m_configuration.getWriteConsistencyLevel());
+ m_logService.log(LogService.LOG_INFO, " RPC address = " +
m_configuration.getRPCAddress());
+ m_logService.log(LogService.LOG_INFO, " RPC Port = " +
m_configuration.getRPCPort());
+
// Activate the daemon from a separate thread, as the activate()
method never returns
new CassandraDaemonActivateThread().start();
try {
@@ -100,17 +109,30 @@
// as the daemon is running.
testThriftConnection();
+ // Now wait until the operation mode of Cassandra becomes
"Normal". In auto bootstrap mode this can take quite a
+ // while (2 minutes minimum). In a single node cluster this will
be amost immediately. Unfortunately the operation
+ // mode is not covered by any enum value.
+ String prevOperationMode = "";
+ String operationMode = StorageService.instance.getOperationMode();
+ while (!operationMode.equals("Normal")) {
+ if (!operationMode.equals(prevOperationMode)) {
+ m_logService.log(LogService.LOG_INFO, "Current Cassandra
Daemon operation mode is '" + operationMode
+ + "', waiting for daemon to reach operation mode
'Normal'");
+ }
+ Thread.sleep(DAEMON_TIMEOUT);
+ }
+ m_logService.log(LogService.LOG_INFO, "Operation mode is now '" +
StorageService.instance.getOperationMode()
+ + "', continuing starting Cassandra");
+
// Create the cassandra server
m_cassandraServer = new CassandraServer();
-
- m_logService.log(LogService.LOG_INFO, "Cassandra Daemon started
with configuration: ");
- m_logService.log(LogService.LOG_INFO, "> Default replication
factor: " + m_configuration.getDefaultReplicationFactor());
- m_logService.log(LogService.LOG_INFO, "> Read consistency level: "
+ m_configuration.getReadConsistencyLevel());
- m_logService.log(LogService.LOG_INFO, "> Write consistency level:
" + m_configuration.getWriteConsistencyLevel());
}
catch (TTransportException e) {
m_logService.log(LogService.LOG_INFO, "Could not establish a
Thrift connection to the Cassandra Daemon", e);
}
+ catch (InterruptedException e) {
+ m_logService.log(LogService.LOG_INFO, "Waiting for Cassandra
Daemon to reach normal operation mode interrupted", e);
+ }
}
public void stop() {