Merge branch 'cassandra-1.2' into cassandra-2.0

Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/4f4b5dd1
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/4f4b5dd1
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/4f4b5dd1

Branch: refs/heads/trunk
Commit: 4f4b5dd1ec32b986aaad9ffec5b7313624b418fa
Parents: b9802ff de1f7ee
Author: Dave Brosius <dbros...@mebigfatguy.com>
Authored: Mon May 19 21:19:41 2014 -0400
Committer: Dave Brosius <dbros...@mebigfatguy.com>
Committed: Mon May 19 21:19:41 2014 -0400

----------------------------------------------------------------------
 src/java/org/apache/cassandra/service/StorageService.java | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/4f4b5dd1/src/java/org/apache/cassandra/service/StorageService.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/service/StorageService.java
index fbc1a72,9a6e67a..567bb19
--- a/src/java/org/apache/cassandra/service/StorageService.java
+++ b/src/java/org/apache/cassandra/service/StorageService.java
@@@ -629,63 -597,48 +629,64 @@@ public class StorageService extends Not
          }
      }
  
 -    private void joinTokenRing(int delay) throws ConfigurationException
 +    private boolean shouldBootstrap()
      {
 -        joined = true;
 +        return DatabaseDescriptor.isAutoBootstrap() && 
!SystemKeyspace.bootstrapComplete() && 
!DatabaseDescriptor.getSeeds().contains(FBUtilities.getBroadcastAddress());
 +    }
  
 -        Collection<Token> tokens = null;
 -        Map<ApplicationState, VersionedValue> appStates = new 
HashMap<ApplicationState, VersionedValue>();
 -
 -        if (DatabaseDescriptor.getReplaceTokens().size() > 0 || 
DatabaseDescriptor.getReplaceNode() != null)
 -            throw new RuntimeException("Replace method removed; use 
cassandra.replace_address instead");
 -        if (DatabaseDescriptor.isReplacing())
 -        {
 -            if (!DatabaseDescriptor.isAutoBootstrap())
 -                throw new RuntimeException("Trying to replace_address with 
auto_bootstrap disabled will not work, check your configuration");
 -            tokens = prepareReplacementInfo();
 -            appStates.put(ApplicationState.STATUS, 
valueFactory.hibernate(true));
 -            appStates.put(ApplicationState.TOKENS, 
valueFactory.tokens(tokens));
 -        }
 -        // have to start the gossip service before we can see any info on 
other nodes.  this is necessary
 -        // for bootstrap to get the load info it needs.
 -        // (we won't be part of the storage ring though until we add a 
counterId to our state, below.)
 -        // Seed the host ID-to-endpoint map with our own ID.
 -        UUID localHostId = SystemTable.getLocalHostId();
 -        getTokenMetadata().updateHostId(localHostId, 
FBUtilities.getBroadcastAddress());
 -        appStates.put(ApplicationState.NET_VERSION, 
valueFactory.networkVersion());
 -        appStates.put(ApplicationState.HOST_ID, 
valueFactory.hostId(localHostId));
 -        appStates.put(ApplicationState.RPC_ADDRESS, 
valueFactory.rpcaddress(DatabaseDescriptor.getRpcAddress()));
 -        appStates.put(ApplicationState.RELEASE_VERSION, 
valueFactory.releaseVersion());
 -        logger.info("Starting up server gossip");
 -        Gossiper.instance.register(this);
 -        Gossiper.instance.start(SystemTable.incrementAndGetGeneration(), 
appStates); // needed for node-ring gathering.
 -        // gossip snitch infos (local DC and rack)
 -        gossipSnitchInfo();
 -        // gossip Schema.emptyVersion forcing immediate check for schema 
updates (see MigrationManager#maybeScheduleSchemaPull)
 -        Schema.instance.updateVersionAndAnnounce(); // Ensure we know our own 
actual Schema UUID in preparation for updates
 +    private void prepareToJoin() throws ConfigurationException
 +    {
 +        if (!joined)
 +        {
 +            Map<ApplicationState, VersionedValue> appStates = new 
HashMap<ApplicationState, VersionedValue>();
  
 +            if (DatabaseDescriptor.isReplacing() && 
!(Boolean.parseBoolean(System.getProperty("cassandra.join_ring", "true"))))
 +                throw new ConfigurationException("Cannot set both 
join_ring=false and attempt to replace a node");
 +            if (DatabaseDescriptor.getReplaceTokens().size() > 0 || 
DatabaseDescriptor.getReplaceNode() != null)
 +                throw new RuntimeException("Replace method removed; use 
cassandra.replace_address instead");
 +            if (DatabaseDescriptor.isReplacing())
 +            {
 +                if (!DatabaseDescriptor.isAutoBootstrap())
 +                    throw new RuntimeException("Trying to replace_address 
with auto_bootstrap disabled will not work, check your configuration");
 +                bootstrapTokens = prepareReplacementInfo();
 +                appStates.put(ApplicationState.STATUS, 
valueFactory.hibernate(true));
 +                appStates.put(ApplicationState.TOKENS, 
valueFactory.tokens(bootstrapTokens));
 +            }
 +            else if (shouldBootstrap())
 +            {
 +                checkForEndpointCollision();
 +            }
 +            // have to start the gossip service before we can see any info on 
other nodes.  this is necessary
 +            // for bootstrap to get the load info it needs.
 +            // (we won't be part of the storage ring though until we add a 
counterId to our state, below.)
 +            // Seed the host ID-to-endpoint map with our own ID.
-             getTokenMetadata().updateHostId(SystemKeyspace.getLocalHostId(), 
FBUtilities.getBroadcastAddress());
++            UUID localHostId = SystemKeyspace.getLocalHostId();
++            getTokenMetadata().updateHostId(localHostId, 
FBUtilities.getBroadcastAddress());
 +            appStates.put(ApplicationState.NET_VERSION, 
valueFactory.networkVersion());
-             appStates.put(ApplicationState.HOST_ID, 
valueFactory.hostId(SystemKeyspace.getLocalHostId()));
++            appStates.put(ApplicationState.HOST_ID, 
valueFactory.hostId(localHostId));
 +            appStates.put(ApplicationState.RPC_ADDRESS, 
valueFactory.rpcaddress(DatabaseDescriptor.getRpcAddress()));
 +            appStates.put(ApplicationState.RELEASE_VERSION, 
valueFactory.releaseVersion());
 +            logger.info("Starting up server gossip");
 +            Gossiper.instance.register(this);
 +            
Gossiper.instance.start(SystemKeyspace.incrementAndGetGeneration(), appStates); 
// needed for node-ring gathering.
 +            // gossip snitch infos (local DC and rack)
 +            gossipSnitchInfo();
 +            // gossip Schema.emptyVersion forcing immediate check for schema 
updates (see MigrationManager#maybeScheduleSchemaPull)
 +            Schema.instance.updateVersionAndAnnounce(); // Ensure we know our 
own actual Schema UUID in preparation for updates
  
 -        if (!MessagingService.instance().isListening())
 -            MessagingService.instance().listen(FBUtilities.getLocalAddress());
 -        LoadBroadcaster.instance.startBroadcasting();
  
 -        HintedHandOffManager.instance.start();
 -        BatchlogManager.instance.start();
 +            if (!MessagingService.instance().isListening())
 +                
MessagingService.instance().listen(FBUtilities.getLocalAddress());
 +            LoadBroadcaster.instance.startBroadcasting();
 +
 +            HintedHandOffManager.instance.start();
 +            BatchlogManager.instance.start();
 +        }
 +    }
 +
 +    private void joinTokenRing(int delay) throws ConfigurationException
 +    {
 +        joined = true;
  
          // We bootstrap if we haven't successfully bootstrapped before, as 
long as we are not a seed.
          // If we are a seed, or if the user manually sets auto_bootstrap to 
false,

Reply via email to