You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cassandra.apache.org by jb...@apache.org on 2009/10/07 21:42:04 UTC

svn commit: r822877 - in /incubator/cassandra/trunk: ./ src/java/org/apache/cassandra/gms/ src/java/org/apache/cassandra/service/ src/java/org/apache/cassandra/tools/

Author: jbellis
Date: Wed Oct  7 19:42:01 2009
New Revision: 822877

URL: http://svn.apache.org/viewvc?rev=822877&view=rev
Log:
r/m nodeprobe bootstrap
patch by jbellis; reviewed by Eric Evans for CASSANDRA-438

Modified:
    incubator/cassandra/trunk/CHANGES.txt
    incubator/cassandra/trunk/src/java/org/apache/cassandra/gms/Gossiper.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

Modified: incubator/cassandra/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/CHANGES.txt?rev=822877&r1=822876&r2=822877&view=diff
==============================================================================
--- incubator/cassandra/trunk/CHANGES.txt (original)
+++ incubator/cassandra/trunk/CHANGES.txt Wed Oct  7 19:42:01 2009
@@ -1,3 +1,12 @@
+0.5 dev
+ * All non-seed nodes will attempt to bootstrap when started, until
+   bootstrap successfully completes. -b option is removed.
+ * Unless a token is manually specified in the configuration xml,
+   a bootstraping node will use a token that gives it half the
+   keys from the most-heavily-loaded node in the cluster,
+   instead of generating a random token.
+
+
 0.4.1
  * Fix FlushPeriod columnfamily configuration regression
    (CASSANDRA-455)

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/gms/Gossiper.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/gms/Gossiper.java?rev=822877&r1=822876&r2=822877&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/gms/Gossiper.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/gms/Gossiper.java Wed Oct  7 19:42:01 2009
@@ -145,6 +145,7 @@
         StageManager.registerStage( Gossiper.GOSSIP_STAGE, new SingleThreadedStage("GMFD") );
     }
 
+    /** Register with the Gossiper for EndPointState notifications */
     public void register(IEndPointStateChangeSubscriber subscriber)
     {
         subscribers_.add(subscriber);
@@ -881,6 +882,10 @@
         }
     }
 
+    /**
+     * Start the gossiper with the generation # retrieved from the System
+     * table
+     */
     public void start(EndPoint localEndPoint, int generationNbr) throws IOException
     {
         localEndPoint_ = localEndPoint;

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=822877&r1=822876&r2=822877&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 Oct  7 19:42:01 2009
@@ -83,7 +83,7 @@
     public final static String rangeVerbHandler_ = "RANGE-VERB-HANDLER";
     public final static String bootstrapTokenVerbHandler_ = "SPLITS-VERB-HANDLER";
 
-    private static StorageService instance_;
+    private static volatile StorageService instance_;
     private static EndPoint tcpAddr_;
     private static EndPoint udpAddr_;
     private static IPartitioner partitioner_;
@@ -139,15 +139,13 @@
     {
         if (instance_ == null)
         {
-            boolean bootstrap = !(DatabaseDescriptor.getSeeds().contains(getLocalControlEndPoint().getHost()) || SystemTable.isBootstrapped());
-
             synchronized (StorageService.class)
             {
                 if (instance_ == null)
                 {
                     try
                     {
-                        instance_ = new StorageService(bootstrap);
+                        instance_ = new StorageService();
                     }
                     catch (Throwable th)
                     {
@@ -248,9 +246,8 @@
         }
     }
 
-    public StorageService(boolean isBootstrapMode)
+    public StorageService()
     {
-        this.isBootstrapMode = isBootstrapMode;
         bootstrapSet = new HashSet<EndPoint>();
         init();
         storageLoadBalancer_ = new StorageLoadBalancer(this);
@@ -316,6 +313,8 @@
         storageMetadata_ = SystemTable.initMetadata();
         tcpAddr_ = new EndPoint(DatabaseDescriptor.getStoragePort());
         udpAddr_ = new EndPoint(DatabaseDescriptor.getControlPort());
+        isBootstrapMode = !(DatabaseDescriptor.getSeeds().contains(udpAddr_.getHost()) || SystemTable.isBootstrapped());
+
         /* Listen for application messages */
         MessagingService.instance().listen(tcpAddr_);
         /* Listen for control messages */
@@ -327,19 +326,6 @@
         /* starts a load timer thread */
         loadTimer_.schedule( new LoadDisseminator(), StorageService.threshold_, StorageService.threshold_);
         
-        /* Start the storage load balancer */
-        storageLoadBalancer_.start();
-        /* Register with the Gossiper for EndPointState notifications */
-        Gossiper.instance().register(this);
-        /*
-         * Start the gossiper with the generation # retrieved from the System
-         * table
-         */
-        Gossiper.instance().start(udpAddr_, storageMetadata_.getGeneration());
-        /* Make sure this token gets gossiped around. */
-        tokenMetadata_.update(storageMetadata_.getToken(), StorageService.tcpAddr_, isBootstrapMode);
-        ApplicationState state = new ApplicationState(StorageService.getPartitioner().getTokenFactory().toString(storageMetadata_.getToken()));
-        Gossiper.instance().addApplicationState(StorageService.nodeId_, state);
         if (isBootstrapMode)
         {
             logger_.info("Starting in bootstrap mode (first, sleeping to get load information)");
@@ -379,9 +365,19 @@
                     updateToken(t);
                 }
             }
-            doBootstrap(StorageService.getLocalStorageEndPoint());
+
+            BootStrapper bs = new BootStrapper(new EndPoint[] {getLocalStorageEndPoint()}, storageMetadata_.getToken());
+            bootStrapper_.submit(bs);
             Gossiper.instance().addApplicationState(BOOTSTRAP_MODE, new ApplicationState(""));
         }
+
+        storageLoadBalancer_.start();
+        Gossiper.instance().register(this);
+        Gossiper.instance().start(udpAddr_, storageMetadata_.getGeneration());
+        /* Make sure this token gets gossiped around. */
+        tokenMetadata_.update(storageMetadata_.getToken(), StorageService.tcpAddr_, isBootstrapMode);
+        ApplicationState state = new ApplicationState(StorageService.getPartitioner().getTokenFactory().toString(storageMetadata_.getToken()));
+        Gossiper.instance().addApplicationState(StorageService.nodeId_, state);
     }
 
     private Token<?> getBootstrapTokenFrom(EndPoint maxEndpoint)
@@ -659,43 +655,8 @@
 	        updateToken(newToken);
     	}
     }
-    
-    /**
-     * This method takes a colon separated string of nodes that need
-     * to be bootstrapped. * <i>nodes</i> must be specified as A:B:C.
-     * @throws UnknownHostException 
-     * 
-    */
-    private void doBootstrap(String nodes) throws UnknownHostException
-    {
-        String[] allNodes = nodes.split(":");
-        EndPoint[] endpoints = new EndPoint[allNodes.length];
-        Token[] tokens = new Token[allNodes.length];
-        
-        for ( int i = 0; i < allNodes.length; ++i )
-        {
-            String host = allNodes[i].trim();
-            InetAddress ip = InetAddress.getByName(host);
-            host = ip.getHostAddress();
-            endpoints[i] = new EndPoint( host, DatabaseDescriptor.getStoragePort() );
-            tokens[i] = tokenMetadata_.getToken(endpoints[i]);
-        }
-        
-        /* Start the bootstrap algorithm */
-        bootStrapper_.submit( new BootStrapper(endpoints, tokens) );
-    }
 
     /**
-     * Starts the bootstrap operations for the specified endpoint.
-     * @param endpoint
-     */
-    public final void doBootstrap(EndPoint endpoint)
-    {
-        Token token = tokenMetadata_.getToken(endpoint);
-        bootStrapper_.submit(new BootStrapper(new EndPoint[]{endpoint}, token));
-    }
-    
-    /**
      * Deliver hints to the specified node when it has crashed
      * and come back up/ marked as alive after a network partition
     */
@@ -757,11 +718,6 @@
         return Gossiper.instance().getCurrentGenerationNumber(udpAddr_);
     }
 
-    public void bootstrapNodes(String nodes) throws UnknownHostException
-    {        
-        doBootstrap(nodes);
-    }
-    
     public void forceTableCleanup() throws IOException
     {
         List<String> tables = DatabaseDescriptor.getTables();
@@ -772,9 +728,6 @@
         }
     }
     
-    /**
-     * Trigger the immediate compaction of all tables.
-     */
     public void forceTableCompaction() throws IOException
     {
         List<String> tables = DatabaseDescriptor.getTables();

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=822877&r1=822876&r2=822877&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 Oct  7 19:42:01 2009
@@ -78,20 +78,7 @@
      * Forces major compaction (all sstable files compacted)
      */
     public void forceTableCompaction() throws IOException;
-    
-    /**
-     * This method will cause the local node initiate
-     * the bootstrap process for all the nodes specified
-     * in the string parameter passed in. This local node
-     * will calculate who gives what ranges to the nodes
-     * and then instructs the nodes to do so.
-     * 
-     * @param nodes colon delimited list of endpoints that need
-     *              to be bootstrapped
-     * @throws UnknownHostException 
-    */
-    public void bootstrapNodes(String nodes) throws UnknownHostException;
-    
+
     /**
      * Trigger a cleanup of keys on all tables.
      */

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=822877&r1=822876&r2=822877&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 Oct  7 19:42:01 2009
@@ -178,11 +178,6 @@
         ssProxy.forceTableCleanup();
     }
     
-    public void bootstrapNodes(String nodeList) throws UnknownHostException
-    {
-        ssProxy.bootstrapNodes(nodeList);
-    }
-    
     public void forceTableCompaction() throws IOException
     {
         ssProxy.forceTableCompaction();
@@ -469,7 +464,7 @@
     {
         HelpFormatter hf = new HelpFormatter();
         String header = String.format(
-                "%nAvailable commands: ring, cluster, info, cleanup, compact, cfstats, snapshot [name], clearsnapshot, bootstrap, tpstats, flush_binary, " +
+                "%nAvailable commands: ring, cluster, info, cleanup, compact, cfstats, snapshot [name], clearsnapshot, tpstats, flush_binary, " +
                 " getcompactionthreshold, setcompactionthreshold [minthreshold] ([maxthreshold])");
         String usage = String.format("java %s -host <arg> <command>%n", NodeProbe.class.getName());
         hf.printHelp(usage, "", options, header);
@@ -541,19 +536,6 @@
         {
             probe.clearSnapshot();
         }
-        else if (cmdName.equals("bootstrap"))
-        {
-            if (arguments.length == 2)
-            {
-                probe.bootstrapNodes(arguments[1]);
-            }
-            else
-            {
-                System.err.println(cmdName + " needs a node to work with");
-                NodeProbe.printUsage();
-                System.exit(1);
-            }
-        }
         else if (cmdName.equals("tpstats"))
         {
             probe.printThreadPoolStats(System.out);