cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r935725 - in /cassandra/trunk: conf/ contrib/property_snitch/ contrib/property_snitch/conf/ contrib/property_snitch/src/java/org/apache/cassandra/locator/ src/java/org/apache/cassandra/locator/ test/conf/ test/unit/org/apache/cassandra/loca...
Date Mon, 19 Apr 2010 20:10:56 GMT
Author: jbellis
Date: Mon Apr 19 20:10:56 2010
New Revision: 935725

URL: http://svn.apache.org/viewvc?rev=935725&view=rev
Log:
rename snitches to emphasize that RackAware is adding extra functionality that is not needed
for simpler replication strategies.
patch by Erick Tryzelaar; reviewed by jbellis for CASSANDRA-994

Added:
    cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractRackAwareSnitch.java
      - copied, changed from r935717, cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractEndpointSnitch.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java
      - copied, changed from r935717, cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitch.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitchMBean.java
      - copied, changed from r935717, cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitchMBean.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/RackInferringSnitch.java
      - copied, changed from r935717, cassandra/trunk/src/java/org/apache/cassandra/locator/EndpointSnitch.java
Removed:
    cassandra/trunk/contrib/property_snitch/README.txt
    cassandra/trunk/contrib/property_snitch/build.xml
    cassandra/trunk/contrib/property_snitch/conf/cassandra-rack.properties
    cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitch.java
    cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitchMBean.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractEndpointSnitch.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/EndpointSnitch.java
Modified:
    cassandra/trunk/conf/cassandra.xml
    cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterEndpointSnitch.java
    cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java
    cassandra/trunk/test/conf/cassandra.xml
    cassandra/trunk/test/unit/org/apache/cassandra/locator/RackAwareStrategyTest.java

Modified: cassandra/trunk/conf/cassandra.xml
URL: http://svn.apache.org/viewvc/cassandra/trunk/conf/cassandra.xml?rev=935725&r1=935724&r2=935725&view=diff
==============================================================================
--- cassandra/trunk/conf/cassandra.xml (original)
+++ cassandra/trunk/conf/cassandra.xml Mon Apr 19 20:10:56 2010
@@ -47,12 +47,13 @@
 
   <!--
    ~ EndpointSnitch: Setting this to the class that implements
-   ~ AbstractEndpointSnitch, which lets Cassandra know enough
+   ~ IEndpointSnitch, which lets Cassandra know enough
    ~ about your network topology to route requests efficiently.
-   ~ Out of the box, Cassandra provides org.apache.cassandra.locator.EndpointSnitch,
-   ~ and PropertyFileEndpointSnitch is available in contrib/.
+   ~ Out of the box, Cassandra provides
+   ~ org.apache.cassandra.locator.RackInferringSnitch and
+   ~ org.apache.cassandra.locator.PropertyFileSnitch.
   -->
-  <EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
+  <EndpointSnitch>org.apache.cassandra.locator.RackInferringSnitch</EndpointSnitch>
 
   <!--
    ~ Keyspaces and ColumnFamilies:

Copied: cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractRackAwareSnitch.java
(from r935717, cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractEndpointSnitch.java)
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractRackAwareSnitch.java?p2=cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractRackAwareSnitch.java&p1=cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractEndpointSnitch.java&r1=935717&r2=935725&rev=935725&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractEndpointSnitch.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractRackAwareSnitch.java Mon
Apr 19 20:10:56 2010
@@ -1,6 +1,6 @@
 package org.apache.cassandra.locator;
 /*
- * 
+ *
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -8,16 +8,16 @@ package org.apache.cassandra.locator;
  * to you under the Apache License, Version 2.0 (the
  * "License"); you may not use this file except in compliance
  * with the License.  You may obtain a copy of the License at
- * 
+ *
  *   http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing,
  * software distributed under the License is distributed on an
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  * KIND, either express or implied.  See the License for the
  * specific language governing permissions and limitations
  * under the License.
- * 
+ *
  */
 
 
@@ -30,7 +30,7 @@ import java.util.*;
  * requests more efficiently (with "sortByProximity").  Of the abstract methods, isOnSameRack
  * and isInSameDataCenter are always required; getLocation is only used by DatacenterShardStrategy.
  */
-public abstract class AbstractEndpointSnitch implements IEndpointSnitch
+public abstract class AbstractRackAwareSnitch implements IEndpointSnitch
 {
     /**
      * Determines if 2 nodes are in the same rack in the data center.

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterEndpointSnitch.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterEndpointSnitch.java?rev=935725&r1=935724&r2=935725&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterEndpointSnitch.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/DatacenterEndpointSnitch.java Mon
Apr 19 20:10:56 2010
@@ -41,7 +41,7 @@ import org.xml.sax.SAXException;
  * Endpoints and also get details from the same.
  */
 
-public class DatacenterEndpointSnitch extends AbstractEndpointSnitch
+public class DatacenterEndpointSnitch extends AbstractRackAwareSnitch
 {
     /**
      * This Map will contain the information of the Endpoints and its Location

Copied: cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java (from
r935717, cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitch.java)
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java?p2=cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java&p1=cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitch.java&r1=935717&r2=935725&rev=935725&view=diff
==============================================================================
--- cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitch.java
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitch.java Mon Apr
19 20:10:56 2010
@@ -36,13 +36,13 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 /**
- * PropertyFileEndpointSnitch
+ * PropertyFileSnitch
  *
- * PropertyFileEndpointSnitch is used by Digg to determine if two IP's are in the same
+ * PropertyFileSnitch is used by Digg to determine if two IP's are in the same
  * datacenter or on the same rack.
  *
  */
-public class PropertyFileEndpointSnitch extends EndpointSnitch implements PropertyFileEndpointSnitchMBean
{
+public class PropertyFileSnitch extends RackInferringSnitch implements PropertyFileSnitchMBean
{
     /**
      * A list of properties with keys being host:port and values being datacenter:rack
      */
@@ -61,9 +61,9 @@ public class PropertyFileEndpointSnitch 
     /**
      * Reference to the logger.
      */
-    private static Logger logger_ = LoggerFactory.getLogger(PropertyFileEndpointSnitch.class);
+    private static Logger logger_ = LoggerFactory.getLogger(PropertyFileSnitch.class);
 
-    public PropertyFileEndpointSnitch() throws ConfigurationException
+    public PropertyFileSnitch() throws ConfigurationException
     {
         reloadConfiguration();
         try
@@ -158,7 +158,7 @@ public class PropertyFileEndpointSnitch 
 
     public void reloadConfiguration() throws ConfigurationException
     {
-        ClassLoader loader = PropertyFileEndpointSnitch.class.getClassLoader();
+        ClassLoader loader = PropertyFileSnitch.class.getClassLoader();
         URL scpurl = loader.getResource(RACK_PROPERTY_FILENAME);
         if (scpurl == null)
             throw new ConfigurationException("unable to locate " + RACK_PROPERTY_FILENAME);

Copied: cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitchMBean.java
(from r935717, cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitchMBean.java)
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitchMBean.java?p2=cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitchMBean.java&p1=cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitchMBean.java&r1=935717&r2=935725&rev=935725&view=diff
==============================================================================
--- cassandra/trunk/contrib/property_snitch/src/java/org/apache/cassandra/locator/PropertyFileEndpointSnitchMBean.java
(original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/PropertyFileSnitchMBean.java Mon
Apr 19 20:10:56 2010
@@ -23,24 +23,24 @@ import java.io.IOException;
 import org.apache.cassandra.config.ConfigurationException;
 
 /**
- * PropertyFileEndpointSnitchMBean
- * 
- * PropertyFileEndpointSnitchMBean is the management interface for Digg's EndpointSnitch
MBean
- * 
+ * PropertyFileSnitchMBean
+ *
+ * PropertyFileSnitchMBean is the management interface for Digg's EndpointSnitch MBean
+ *
  * @author Sammy Yu <syu@sammyyu.net>
- * 
+ *
  */
-public interface PropertyFileEndpointSnitchMBean {
+public interface PropertyFileSnitchMBean {
     /**
      * The object name of the mbean.
      */
     public static String MBEAN_OBJECT_NAME = "org.apache.cassandra.locator:type=EndpointSnitch";
-    
+
     /**
      * Reload the rack configuration
      */
     public void reloadConfiguration() throws ConfigurationException;
-    
+
     /**
      * Display the current configuration
      */

Modified: cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java?rev=935725&r1=935724&r2=935725&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/RackAwareStrategy.java Mon Apr 19
20:10:56 2010
@@ -39,8 +39,8 @@ public class RackAwareStrategy extends A
     public RackAwareStrategy(TokenMetadata tokenMetadata, IEndpointSnitch snitch)
     {
         super(tokenMetadata, snitch);
-        if (!(snitch instanceof EndpointSnitch))
-            throw new IllegalArgumentException(("RackAwareStrategy requires EndpointSnitch."));
+        if (!(snitch instanceof AbstractRackAwareSnitch))
+            throw new IllegalArgumentException(("RackAwareStrategy requires AbstractRackAwareSnitch."));
     }
 
     public ArrayList<InetAddress> getNaturalEndpoints(Token token, TokenMetadata metadata,
String table)
@@ -64,7 +64,7 @@ public class RackAwareStrategy extends A
             {
                 // First try to find one in a different data center
                 Token t = iter.next();
-                if (!((EndpointSnitch)snitch_).isInSameDataCenter(metadata.getEndpoint(primaryToken),
metadata.getEndpoint(t)))
+                if (!((AbstractRackAwareSnitch)snitch_).isInSameDataCenter(metadata.getEndpoint(primaryToken),
metadata.getEndpoint(t)))
                 {
                     // If we have already found something in a diff datacenter no need to
find another
                     if (!bDataCenter)
@@ -75,8 +75,8 @@ public class RackAwareStrategy extends A
                     continue;
                 }
                 // Now  try to find one on a different rack
-                if (!((EndpointSnitch)snitch_).isOnSameRack(metadata.getEndpoint(primaryToken),
metadata.getEndpoint(t)) &&
-                    ((EndpointSnitch)snitch_).isInSameDataCenter(metadata.getEndpoint(primaryToken),
metadata.getEndpoint(t)))
+                if (!((AbstractRackAwareSnitch)snitch_).isOnSameRack(metadata.getEndpoint(primaryToken),
metadata.getEndpoint(t)) &&
+                    ((AbstractRackAwareSnitch)snitch_).isInSameDataCenter(metadata.getEndpoint(primaryToken),
metadata.getEndpoint(t)))
                 {
                     // If we have already found something in a diff rack no need to find
another
                     if (!bOtherRack)

Copied: cassandra/trunk/src/java/org/apache/cassandra/locator/RackInferringSnitch.java (from
r935717, cassandra/trunk/src/java/org/apache/cassandra/locator/EndpointSnitch.java)
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/locator/RackInferringSnitch.java?p2=cassandra/trunk/src/java/org/apache/cassandra/locator/RackInferringSnitch.java&p1=cassandra/trunk/src/java/org/apache/cassandra/locator/EndpointSnitch.java&r1=935717&r2=935725&rev=935725&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/locator/EndpointSnitch.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/locator/RackInferringSnitch.java Mon Apr
19 20:10:56 2010
@@ -26,14 +26,14 @@ import java.util.*;
  * A simple endpoint snitch implementation that assumes rack and dc information is encoded
  * in the ip address.
  */
-public class EndpointSnitch extends AbstractEndpointSnitch
+public class RackInferringSnitch extends AbstractRackAwareSnitch
 {
     public boolean isOnSameRack(InetAddress host, InetAddress host2) throws UnknownHostException
     {
         /*
-         * Look at the IP Address of the two hosts. Compare 
+         * Look at the IP Address of the two hosts. Compare
          * the 3rd octet. If they are the same then the hosts
-         * are in the same rack else different racks. 
+         * are in the same rack else different racks.
         */
         byte[] ip = host.getAddress();
         byte[] ip2 = host2.getAddress();
@@ -44,9 +44,9 @@ public class EndpointSnitch extends Abst
     public boolean isInSameDataCenter(InetAddress host, InetAddress host2) throws UnknownHostException
     {
         /*
-         * Look at the IP Address of the two hosts. Compare 
+         * Look at the IP Address of the two hosts. Compare
          * the 2nd octet. If they are the same then the hosts
-         * are in the same datacenter else different datacenter. 
+         * are in the same datacenter else different datacenter.
         */
         byte[] ip = host.getAddress();
         byte[] ip2 = host2.getAddress();

Modified: cassandra/trunk/test/conf/cassandra.xml
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/conf/cassandra.xml?rev=935725&r1=935724&r2=935725&view=diff
==============================================================================
--- cassandra/trunk/test/conf/cassandra.xml (original)
+++ cassandra/trunk/test/conf/cassandra.xml Mon Apr 19 20:10:56 2010
@@ -37,7 +37,7 @@
    <DiskAccessMode>mmap</DiskAccessMode>
    <MemtableThroughputInMB>1</MemtableThroughputInMB>
    <MemtableOperationsInMillions>0.00002</MemtableOperationsInMillions> <!--
20 -->
-   <EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
+   <EndpointSnitch>org.apache.cassandra.locator.RackInferringSnitch</EndpointSnitch>
    <Keyspaces>
      <Keyspace Name = "Keyspace1">
        <ColumnFamily Name="Standard1" RowsCached="10%" KeysCached="0"/>
@@ -58,13 +58,11 @@
        <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="TimeUUIDType" Name="Super4"/>
        <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
        <ReplicationFactor>1</ReplicationFactor>
-       <EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
      </Keyspace>
      <Keyspace Name = "Keyspace3">
        <ColumnFamily Name="Standard1"/>
        <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
        <ReplicationFactor>5</ReplicationFactor>
-       <EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
      </Keyspace>
      <Keyspace Name = "Keyspace4">
        <ColumnFamily Name="Standard1"/>
@@ -73,7 +71,6 @@
        <ColumnFamily ColumnType="Super" CompareSubcolumnsWith="TimeUUIDType" Name="Super4"/>
        <ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
        <ReplicationFactor>3</ReplicationFactor>
-       <EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
      </Keyspace>
    </Keyspaces>
    <Seeds>

Modified: cassandra/trunk/test/unit/org/apache/cassandra/locator/RackAwareStrategyTest.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/test/unit/org/apache/cassandra/locator/RackAwareStrategyTest.java?rev=935725&r1=935724&r2=935725&view=diff
==============================================================================
--- cassandra/trunk/test/unit/org/apache/cassandra/locator/RackAwareStrategyTest.java (original)
+++ cassandra/trunk/test/unit/org/apache/cassandra/locator/RackAwareStrategyTest.java Mon
Apr 19 20:10:56 2010
@@ -58,7 +58,7 @@ public class RackAwareStrategyTest
     @Test
     public void testBigIntegerEndpointsA() throws UnknownHostException
     {
-        EndpointSnitch endpointSnitch = new EndpointSnitch();
+        RackInferringSnitch endpointSnitch = new RackInferringSnitch();
 
         AbstractReplicationStrategy strategy = new RackAwareStrategy(tmd, endpointSnitch);
         addEndpoint("0", "5", "254.0.0.1");
@@ -83,7 +83,7 @@ public class RackAwareStrategyTest
     @Test
     public void testBigIntegerEndpointsB() throws UnknownHostException
     {
-        EndpointSnitch endpointSnitch = new EndpointSnitch();
+        RackInferringSnitch endpointSnitch = new RackInferringSnitch();
 
         AbstractReplicationStrategy strategy = new RackAwareStrategy(tmd, endpointSnitch);
         addEndpoint("0", "5", "254.0.0.1");
@@ -109,7 +109,7 @@ public class RackAwareStrategyTest
     @Test
     public void testBigIntegerEndpointsC() throws UnknownHostException
     {
-        EndpointSnitch endpointSnitch = new EndpointSnitch();
+        RackInferringSnitch endpointSnitch = new RackInferringSnitch();
 
         AbstractReplicationStrategy strategy = new RackAwareStrategy(tmd, endpointSnitch);
         addEndpoint("0", "5", "254.0.0.1");



Mime
View raw message