Return-Path: X-Original-To: apmail-cassandra-commits-archive@www.apache.org Delivered-To: apmail-cassandra-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 4279310793 for ; Wed, 25 Jun 2014 15:43:00 +0000 (UTC) Received: (qmail 15304 invoked by uid 500); 25 Jun 2014 15:43:00 -0000 Delivered-To: apmail-cassandra-commits-archive@cassandra.apache.org Received: (qmail 15195 invoked by uid 500); 25 Jun 2014 15:43:00 -0000 Mailing-List: contact commits-help@cassandra.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cassandra.apache.org Delivered-To: mailing list commits@cassandra.apache.org Received: (qmail 15109 invoked by uid 99); 25 Jun 2014 15:43:00 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 25 Jun 2014 15:43:00 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id AB8BA93ABEC; Wed, 25 Jun 2014 15:42:59 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tylerhobbs@apache.org To: commits@cassandra.apache.org Date: Wed, 25 Jun 2014 15:43:00 -0000 Message-Id: <68f7260ffa754e6489764c7c90eed782@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/3] git commit: Merge branch 'cassandra-1.2' into cassandra-2.0 Merge branch 'cassandra-1.2' into cassandra-2.0 Conflicts: src/java/org/apache/cassandra/config/DatabaseDescriptor.java src/java/org/apache/cassandra/service/StorageService.java Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/2ab7b07a Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/2ab7b07a Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/2ab7b07a Branch: refs/heads/cassandra-2.1 Commit: 2ab7b07accf43c6831339ad80646220d9c1821ae Parents: c656ffe d84b692 Author: Tyler Hobbs Authored: Wed Jun 25 10:40:35 2014 -0500 Committer: Tyler Hobbs Committed: Wed Jun 25 10:40:35 2014 -0500 ---------------------------------------------------------------------- src/java/org/apache/cassandra/config/DatabaseDescriptor.java | 2 -- src/java/org/apache/cassandra/service/StorageService.java | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/2ab7b07a/src/java/org/apache/cassandra/config/DatabaseDescriptor.java ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cassandra/blob/2ab7b07a/src/java/org/apache/cassandra/service/StorageService.java ---------------------------------------------------------------------- diff --cc src/java/org/apache/cassandra/service/StorageService.java index 13dd3b7,1f3d1e1..77ad4f0 --- a/src/java/org/apache/cassandra/service/StorageService.java +++ b/src/java/org/apache/cassandra/service/StorageService.java @@@ -627,64 -597,50 +627,66 @@@ 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 tokens = null; - Map appStates = new HashMap(); - - if (DatabaseDescriptor.getReplaceTokens().size() > 0 || DatabaseDescriptor.getReplaceNode() != null) - throw new RuntimeException("Replace method removed; use cassandra.replace_address instead"); - if (DatabaseDescriptor.isReplacing()) - { - if (SystemTable.bootstrapComplete()) - throw new RuntimeException("Cannot replace address with a node that is already bootstrapped"); - 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 appStates = new HashMap(); + + 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 (SystemKeyspace.bootstrapComplete()) ++ throw new RuntimeException("Cannot replace address with a node that is already bootstrapped"); + 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. + UUID localHostId = SystemKeyspace.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(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(); + if (!MessagingService.instance().isListening()) + MessagingService.instance().listen(FBUtilities.getLocalAddress()); + LoadBroadcaster.instance.startBroadcasting(); + + HintedHandOffManager.instance.start(); + BatchlogManager.instance.start(); + } + } - 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,