avoid making local node part of the token ring until bootstrap completes; fix other buglets

patch by jbellis; reviewed by Jaakko Laine for CASSANDRA-536

git-svn-id: https://svn.apache.org/repos/asf/incubator/cassandra/trunk@835213 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Jonathan Ellis 2009-11-12 03:37:15 +00:00
parent 1bf797b943
commit 2b8c1cec9a
3 changed files with 29 additions and 9 deletions

View File

@ -132,7 +132,8 @@ public abstract class SSTable
/** @return full paths to all the files associated w/ this SSTable */
public List<String> getAllFilenames()
{
return Arrays.asList(getFilename(), indexFilename(), filterFilename());
// TODO streaming relies on the -Data (getFilename) file to be last, this is clunky
return Arrays.asList(indexFilename(), filterFilename(), getFilename());
}
public String getColumnFamilyName()

View File

@ -83,9 +83,9 @@ public class Streaming
{
File file = new File(filename);
streamContexts[i++] = new StreamContextManager.StreamContext(file.getAbsolutePath(), file.length(), table);
if (logger.isDebugEnabled())
logger.debug("Stream context metadata " + streamContexts[i]);
}
if (logger.isDebugEnabled())
logger.debug("Stream context metadata " + StringUtils.join(streamContexts, ", "));
StreamManager.instance(target).addFilesToStream(streamContexts);
StreamInitiateMessage biMessage = new StreamInitiateMessage(streamContexts);

View File

@ -169,13 +169,19 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
if (bootstrapSet.isEmpty())
{
isBootstrapMode = false;
SystemTable.setBootstrapped();
Gossiper.instance().addApplicationState(StorageService.STATE_NORMAL, new ApplicationState(partitioner_.getTokenFactory().toString(getLocalToken())));
logger_.info("Bootstrap completed! Now serving reads.");
finishBootstrapping();
}
}
private void finishBootstrapping()
{
isBootstrapMode = false;
SystemTable.setBootstrapped();
setToken(getLocalToken());
Gossiper.instance().addApplicationState(StorageService.STATE_NORMAL, new ApplicationState(partitioner_.getTokenFactory().toString(getLocalToken())));
logger_.info("Bootstrap completed! Now serving reads.");
}
private void updateForeignToken(Token token, InetAddress endpoint)
{
tokenMetadata_.update(token, endpoint);
@ -276,9 +282,22 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
logger_.info("Starting in bootstrap mode (first, sleeping to get load information)");
StorageLoadBalancer.instance().waitForLoadInfo();
logger_.info("... got load info");
setToken(BootStrapper.getBootstrapToken(tokenMetadata_, StorageLoadBalancer.instance().getLoadInfo()));
Token token = BootStrapper.getBootstrapToken(tokenMetadata_, StorageLoadBalancer.instance().getLoadInfo());
SystemTable.updateToken(token); // DON'T use setToken, that makes us part of the ring locally which is incorrect until we are done bootstrapping
Gossiper.instance().addApplicationState(StorageService.STATE_BOOTSTRAPPING, new ApplicationState(partitioner_.getTokenFactory().toString(getLocalToken())));
new BootStrapper(replicationStrategy_, FBUtilities.getLocalAddress(), getLocalToken(), tokenMetadata_).startBootstrap(); // handles token update
// don't finish startup (enabling thrift) until after bootstrap is done
while (isBootstrapMode)
{
try
{
Thread.sleep(100);
}
catch (InterruptedException e)
{
throw new AssertionError(e);
}
}
}
else
{
@ -517,7 +536,7 @@ public final class StorageService implements IEndPointStateChangeSubscriber, Sto
public Token getLocalToken()
{
return tokenMetadata_.getToken(FBUtilities.getLocalAddress());
return storageMetadata_.getToken();
}
/* This methods belong to the MBean interface */