Author: jbellis
Date: Wed Feb 10 02:14:47 2010
New Revision: 908319
URL: http://svn.apache.org/viewvc?rev=908319&view=rev
Log:
merge from 0.5
Modified:
incubator/cassandra/trunk/ (props changed)
incubator/cassandra/trunk/CHANGES.txt
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
Propchange: incubator/cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 10 02:14:47 2010
@@ -1,4 +1,4 @@
/incubator/cassandra/branches/cassandra-0.3:774578-796573
/incubator/cassandra/branches/cassandra-0.4:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5:888872-904679
+/incubator/cassandra/branches/cassandra-0.5:888872-908312
/incubator/cassandra/trunk:749219-888871
Modified: incubator/cassandra/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/CHANGES.txt?rev=908319&r1=908318&r2=908319&view=diff
==============================================================================
--- incubator/cassandra/trunk/CHANGES.txt (original)
+++ incubator/cassandra/trunk/CHANGES.txt Wed Feb 10 02:14:47 2010
@@ -28,6 +28,7 @@
0.5.1
* ensure all files for an sstable are streamed to the same directory.
(CASSANDRA-716)
+ * more accurate load estimate for bootstrapping (CASSANDRA-762)
0.5.0 final
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java?rev=908319&r1=908318&r2=908319&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageLoadBalancer.java
Wed Feb 10 02:14:47 2010
@@ -163,7 +163,7 @@
}
}
- private static final long BROADCAST_INTERVAL = 5 * 60 * 1000L;
+ private static final int BROADCAST_INTERVAL = 60 * 1000;
public static final StorageLoadBalancer instance = new
StorageLoadBalancer();
@@ -353,18 +353,17 @@
loadTimer_.schedule(new LoadDisseminator(), 2 *
Gossiper.intervalInMillis_, BROADCAST_INTERVAL);
}
- /** wait for node information to be available. if the rest of the cluster
just came up,
- this could be up to threshold_ ms (currently 5 minutes). */
+ /**
+ * Wait for at least BROADCAST_INTERVAL ms, to give all nodes enough time
to
+ * report in.
+ */
public void waitForLoadInfo()
{
+ int duration = BROADCAST_INTERVAL + StorageService.RING_DELAY;
try
{
- while (loadInfo_.isEmpty())
- {
- Thread.sleep(100);
- }
- // one more sleep in case there are some stragglers
- Thread.sleep(StorageService.RING_DELAY);
+ logger_.info("Sleeping " + duration + " ms to wait for load
information...");
+ Thread.sleep(duration);
}
catch (InterruptedException e)
{
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=908319&r1=908318&r2=908319&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
Wed Feb 10 02:14:47 2010
@@ -67,7 +67,7 @@
{
private static Logger logger_ = Logger.getLogger(StorageService.class);
- public static final long RING_DELAY = 30 * 1000; // delay after which we
assume ring has stablized
+ public static final int RING_DELAY = 30 * 1000; // delay after which we
assume ring has stablized
public final static String MOVE_STATE = "MOVE";
@@ -313,7 +313,7 @@
if (DatabaseDescriptor.isAutoBootstrap()
&&
!(DatabaseDescriptor.getSeeds().contains(FBUtilities.getLocalAddress()) ||
SystemTable.isBootstrapped()))
{
- logger_.info("Starting in bootstrap mode (first, sleeping to get
load information)");
+ logger_.info("Starting in bootstrap mode");
StorageLoadBalancer.instance.waitForLoadInfo();
logger_.info("... got load info");
if (tokenMetadata_.isMember(FBUtilities.getLocalAddress()))
@@ -1271,6 +1271,7 @@
throw new UnsupportedOperationException("data is currently
moving to this node; unable to leave the ring");
}
+ // leave the ring
logger_.info("DECOMMISSIONING");
startLeaving();
logger_.info("decommission sleeping " + RING_DELAY);
@@ -1362,7 +1363,7 @@
onFinish.run();
}
- public void move(String newToken) throws InterruptedException
+ public void move(String newToken) throws IOException, InterruptedException
{
move(partitioner_.getTokenFactory().fromString(newToken));
}
@@ -1377,14 +1378,17 @@
*
* @param token new token to boot to, or if null, find balanced token to
boot to
*/
- private void move(final Token token) throws InterruptedException
+ private void move(final Token token) throws IOException,
InterruptedException
{
for (String table : DatabaseDescriptor.getTables())
{
if (tokenMetadata_.getPendingRanges(table,
FBUtilities.getLocalAddress()).size() > 0)
throw new UnsupportedOperationException("data is currently
moving to this node; unable to leave the ring");
}
+ if (token != null && tokenMetadata_.sortedTokens().contains(token))
+ throw new IOException("target token " + token + " is already owned
by another node");
+ // leave the ring
logger_.info("starting move. leaving token " + getLocalToken());
startLeaving();
logger_.info("move sleeping " + RING_DELAY);
@@ -1395,8 +1399,11 @@
public void runMayThrow() throws IOException
{
Token bootstrapToken = token;
- if (bootstrapToken == null)
- bootstrapToken =
BootStrapper.getBalancedToken(tokenMetadata_,
StorageLoadBalancer.instance.getLoadInfo());
+ if (bootstrapToken == null)
+ {
+ StorageLoadBalancer.instance.waitForLoadInfo();
+ bootstrapToken =
BootStrapper.getBalancedToken(tokenMetadata_,
StorageLoadBalancer.instance.getLoadInfo());
+ }
logger_.info("re-bootstrapping to new token " +
bootstrapToken);
startBootstrap(bootstrapToken);
}
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java?rev=908319&r1=908318&r2=908319&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
Wed Feb 10 02:14:47 2010
@@ -141,7 +141,7 @@
* @param newToken token to move this node to.
* This node will unload its data onto its neighbors, and bootstrap to the
new token.
*/
- public void move(String newToken) throws InterruptedException;
+ public void move(String newToken) throws IOException, InterruptedException;
/**
* This node will unload its data onto its neighbors, and bootstrap to
share the range
Modified:
incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
URL:
http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java?rev=908319&r1=908318&r2=908319&view=diff
==============================================================================
---
incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
(original)
+++
incubator/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
Wed Feb 10 02:14:47 2010
@@ -325,7 +325,7 @@
ssProxy.loadBalance();
}
- public void move(String newToken) throws InterruptedException
+ public void move(String newToken) throws IOException, InterruptedException
{
ssProxy.move(newToken);
}