fix 1.0.x node join to mixed version cluster, other nodes >= 1.1

patch by Pavel Yaskevich; reviewed by Jonathan Ellis for CASSANDRA-4195
This commit is contained in:
Pavel Yaskevich 2012-07-09 23:27:57 +03:00
parent 84a1d6059b
commit 51a9fd131a
2 changed files with 19 additions and 12 deletions

View File

@ -9,6 +9,7 @@
sstables, such as when convertinb back from LCS (CASSANDRA-4287)
* Oversize integer in CQL throws NumberFormatException (CASSANDRA-4291)
* Set gc_grace on index CF to 0 (CASSANDRA-4314)
* fix 1.0.x node join to mixed version cluster, other nodes >= 1.1 (CASSANDRA-4195)
1.0.10

View File

@ -56,32 +56,29 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
private static volatile UUID highestKnown;
public void onJoin(InetAddress endpoint, EndpointState epState) {
public void onJoin(InetAddress endpoint, EndpointState epState)
{
VersionedValue value = epState.getApplicationState(ApplicationState.SCHEMA);
if (value != null)
{
UUID theirVersion = UUID.fromString(value.value);
rectify(theirVersion, endpoint);
}
rectify(UUID.fromString(value.value), endpoint);
}
public void onChange(InetAddress endpoint, ApplicationState state, VersionedValue value)
{
if (state != ApplicationState.SCHEMA)
return;
UUID theirVersion = UUID.fromString(value.value);
rectify(theirVersion, endpoint);
rectify(UUID.fromString(value.value), endpoint);
}
/** gets called after a this node joins a cluster */
public void onAlive(InetAddress endpoint, EndpointState state)
{
VersionedValue value = state.getApplicationState(ApplicationState.SCHEMA);
if (value != null)
{
UUID theirVersion = UUID.fromString(value.value);
rectify(theirVersion, endpoint);
}
rectify(UUID.fromString(value.value), endpoint);
}
public void onDead(InetAddress endpoint, EndpointState state) { }
@ -89,13 +86,22 @@ public class MigrationManager implements IEndpointStateChangeSubscriber
public void onRestart(InetAddress endpoint, EndpointState state) { }
public void onRemove(InetAddress endpoint) { }
/**
* will either push or pull an updating depending on who is behind.
* fat clients should never push their schemas (since they have no local storage).
*/
public static void rectify(UUID theirVersion, InetAddress endpoint)
{
if (theirVersion.version() != 1)
{
logger.warn("Can't merge remove schema because node operates in the mixed version cluster " +
"(Please upgrade all nodes to >= 1.1 to be able to perform schema migrations).");
highestKnown = Schema.instance.getVersion();
return;
}
updateHighestKnown(theirVersion);
UUID myVersion = Schema.instance.getVersion();
if (theirVersion.timestamp() < myVersion.timestamp()