Author: jbellis
Date: Sun Oct 11 03:22:15 2009
New Revision: 824007
URL: http://svn.apache.org/viewvc?rev=824007&view=rev
Log:
add AutoBootstrap config option
patch by jbellis. reviewed by goffinet for CASSANDRA-385
Modified:
incubator/cassandra/trunk/conf/storage-conf.xml
incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
Modified: incubator/cassandra/trunk/conf/storage-conf.xml
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/conf/storage-conf.xml?rev=824007&r1=824006&r2=824007&view=diff
==============================================================================
--- incubator/cassandra/trunk/conf/storage-conf.xml (original)
+++ incubator/cassandra/trunk/conf/storage-conf.xml Sun Oct 11 03:22:15 2009
@@ -28,6 +28,24 @@
<ClusterName>Test Cluster</ClusterName>
<!--
+ ~ Turn on to make new [non-seed] nodes automatically migrate the right data
+ ~ to themselves. (If no InitialToken is specified, they will pick one
+ ~ such that they will get half the range of the most-loaded node.)
+ ~ If a node starts up without bootstrapping, it will mark itself
bootstrapped
+ ~ so that you can't subsequently accidently bootstrap a node with
+ ~ data on it. (You can reset this by wiping your data and commitlog
+ ~ directories.)
+ ~
+ ~ Off by default so that new clusters and upgraders from 0.4 don't
+ ~ bootstrap immediately. You should turn this on when you start adding
+ ~ new nodes to a cluster that already has data on it. (If you are upgrading
+ ~ from 0.4, start your cluster with it off once before changing it to true.
+ ~ Otherwise, no data will be lost but you will incur a lot of unnecessary
+ ~ I/O before your cluster starts up.)
+ -->
+ <AutoBootstrap>false</AutoBootstrap>
+
+ <!--
~ Keyspaces and ColumnFamilies:
~ A ColumnFamily is the Cassandra concept closest to a relational
~ table. Keyspaces are separate groups of ColumnFamilies. Except in
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java?rev=824007&r1=824006&r2=824007&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/config/DatabaseDescriptor.java
Sun Oct 11 03:22:15 2009
@@ -118,6 +118,7 @@
private static int commitLogSyncPeriodMS_;
private static boolean snapshotBeforeCompaction_;
+ private static boolean autoBootstrap_ = false;
static
{
@@ -322,6 +323,22 @@
}
}
+ /* snapshot-before-compaction. defaults to false */
+ String autoBootstrap =
xmlUtils.getNodeValue("/Storage/AutoBootstrap");
+ if (autoBootstrap != null)
+ {
+ if (autoBootstrap.equalsIgnoreCase("true") ||
autoBootstrap.equalsIgnoreCase("false"))
+ {
+ if (logger_.isDebugEnabled())
+ logger_.debug("setting autoBootstrap to " +
autoBootstrap);
+ autoBootstrap_ = Boolean.valueOf(autoBootstrap);
+ }
+ else
+ {
+ throw new ConfigurationException("Unrecognized value for
AutoBootstrap. Use 'true' or 'false'.");
+ }
+ }
+
/* Number of days to keep the memtable around w/o flushing */
String lifetime =
xmlUtils.getNodeValue("/Storage/MemtableFlushAfterMinutes");
if (lifetime != null)
@@ -954,4 +971,9 @@
{
return snapshotBeforeCompaction_;
}
+
+ public static boolean isAutoBootstrap()
+ {
+ return autoBootstrap_;
+ }
}
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=824007&r1=824006&r2=824007&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
Sun Oct 11 03:22:15 2009
@@ -254,7 +254,8 @@
storageMetadata_ = SystemTable.initMetadata();
tcpAddr_ = new EndPoint(DatabaseDescriptor.getStoragePort());
udpAddr_ = new EndPoint(DatabaseDescriptor.getControlPort());
- isBootstrapMode =
!(DatabaseDescriptor.getSeeds().contains(udpAddr_.getHost()) ||
SystemTable.isBootstrapped());
+ isBootstrapMode = DatabaseDescriptor.isAutoBootstrap()
+ &&
!(DatabaseDescriptor.getSeeds().contains(udpAddr_.getHost()) ||
SystemTable.isBootstrapped());
/* Listen for application messages */
MessagingService.instance().listen(tcpAddr_);
@@ -278,6 +279,7 @@
}
else
{
+ SystemTable.setBootstrapped();
tokenMetadata_.update(storageMetadata_.getToken(),
StorageService.tcpAddr_, isBootstrapMode);
}