cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r902873 - in /incubator/cassandra/trunk: ./ interface/gen-java/org/apache/cassandra/service/ src/java/org/ src/java/org/apache/cassandra/db/ src/java/org/apache/cassandra/locator/ test/unit/org/
Date Mon, 25 Jan 2010 16:55:07 GMT
Author: jbellis
Date: Mon Jan 25 16:55:06 2010
New Revision: 902873

URL: http://svn.apache.org/viewvc?rev=902873&view=rev
Log:
merge from 0.5

Modified:
    incubator/cassandra/trunk/   (props changed)
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Cassandra.java
  (props changed)
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Column.java
  (props changed)
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java
  (props changed)
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/NotFoundException.java
  (props changed)
    incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SuperColumn.java
  (props changed)
    incubator/cassandra/trunk/src/java/org/   (props changed)
    incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
    incubator/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
    incubator/cassandra/trunk/test/unit/org/   (props changed)

Propchange: incubator/cassandra/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 25 16:55:06 2010
@@ -1,3 +1,3 @@
 /incubator/cassandra/branches/cassandra-0.3:774578-796573
 /incubator/cassandra/branches/cassandra-0.4:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5:888872-901913
+/incubator/cassandra/branches/cassandra-0.5:888872-902868

Propchange: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 25 16:55:06 2010
@@ -1,4 +1,4 @@
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/Cassandra.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/Cassandra.java:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/Cassandra.java:888872-901913
+/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/Cassandra.java:888872-902868
 /incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Cassandra.java:749219-768588

Propchange: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 25 16:55:06 2010
@@ -1,5 +1,5 @@
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/column_t.java:774578-792198
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/Column.java:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/Column.java:888872-901913
+/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/Column.java:888872-902868
 /incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/Column.java:749219-794428
 /incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/column_t.java:749219-768588

Propchange: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 25 16:55:06 2010
@@ -1,4 +1,4 @@
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:888872-901913
+/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:888872-902868
 /incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/InvalidRequestException.java:749219-768588

Propchange: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 25 16:55:06 2010
@@ -1,4 +1,4 @@
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:888872-901913
+/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:888872-902868
 /incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/NotFoundException.java:749219-768588

Propchange: incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 25 16:55:06 2010
@@ -1,5 +1,5 @@
 /incubator/cassandra/branches/cassandra-0.3/interface/gen-java/org/apache/cassandra/service/superColumn_t.java:774578-792198
 /incubator/cassandra/branches/cassandra-0.4/interface/gen-java/org/apache/cassandra/service/SuperColumn.java:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/SuperColumn.java:888872-901913
+/incubator/cassandra/branches/cassandra-0.5/interface/gen-java/org/apache/cassandra/service/SuperColumn.java:888872-902868
 /incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/SuperColumn.java:749219-794428
 /incubator/cassandra/trunk/interface/gen-java/org/apache/cassandra/service/superColumn_t.java:749219-768588

Propchange: incubator/cassandra/trunk/src/java/org/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 25 16:55:06 2010
@@ -1,4 +1,4 @@
 /incubator/cassandra/branches/cassandra-0.3/src/java/org:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/src/java/org:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5/src/java/org:888872-901913
+/incubator/cassandra/branches/cassandra-0.5/src/java/org:888872-902868
 /incubator/cassandra/trunk/src/java/org:749219-769885

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java?rev=902873&r1=902872&r2=902873&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java (original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/db/Table.java Mon Jan 25 16:55:06
2010
@@ -35,6 +35,7 @@
 
 import org.apache.cassandra.utils.*;
 import org.apache.cassandra.db.filter.*;
+import org.cliffc.high_scale_lib.NonBlockingHashMap;
 
 import org.apache.log4j.Logger;
 
@@ -165,10 +166,10 @@
             return FBUtilities.mapToString(tableMetadataMap);
         }
     }
-    
-    /* Used to lock the factory for creation of Table instance */
-    private static final Lock createLock = new ReentrantLock();
-    private static final Map<String, Table> instances = new HashMap<String, Table>();
+
+    /** Table objects, one per keyspace.  only one instance should ever exist for any given
keyspace. */
+    private static final Map<String, Table> instances = new NonBlockingHashMap<String,
Table>();
+
     /* Table name. */
     public final String name;
     /* Handle to the Table Metadata */
@@ -181,26 +182,19 @@
     public static Table open(String table) throws IOException
     {
         Table tableInstance = instances.get(table);
-        /*
-         * Read the config and figure the column families for this table.
-         * Set the isConfigured flag so that we do not read config all the
-         * time.
-        */
         if (tableInstance == null)
         {
-            Table.createLock.lock();
-            try
+            // instantiate the Table.  we could use putIfAbsent but it's important to making
sure it is only done once
+            // per keyspace, so we synchronize and re-check before doing it.
+            synchronized (Table.class)
             {
+                tableInstance = instances.get(table);
                 if (tableInstance == null)
                 {
                     tableInstance = new Table(table);
                     instances.put(table, tableInstance);
                 }
             }
-            finally
-            {
-                createLock.unlock();
-            }
         }
         return tableInstance;
     }

Modified: incubator/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
URL: http://svn.apache.org/viewvc/incubator/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java?rev=902873&r1=902872&r2=902873&view=diff
==============================================================================
--- incubator/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
(original)
+++ incubator/cassandra/trunk/src/java/org/apache/cassandra/locator/AbstractReplicationStrategy.java
Mon Jan 25 16:55:06 2010
@@ -29,7 +29,9 @@
 import org.apache.cassandra.dht.Token;
 import org.apache.cassandra.gms.FailureDetector;
 import org.apache.cassandra.service.ConsistencyLevel;
+import org.apache.cassandra.gms.Gossiper;
 import org.apache.cassandra.service.WriteResponseHandler;
+import org.apache.cassandra.service.StorageService;
 import org.apache.cassandra.utils.FBUtilities;
 
 /**
@@ -110,6 +112,9 @@
         Set<InetAddress> usedEndpoints = new HashSet<InetAddress>();
         Map<InetAddress, InetAddress> map = new HashMap<InetAddress, InetAddress>();
 
+        IEndPointSnitch endPointSnitch = StorageService.instance.getEndPointSnitch();
+        Set<InetAddress> liveNodes = Gossiper.instance.getLiveMembers();
+
         for (InetAddress ep : targets)
         {
             if (FailureDetector.instance.isAlive(ep))
@@ -119,25 +124,21 @@
             }
             else
             {
+                // Ignore targets that have died when bootstrapping
+                if (!tokenMetadata_.isMember(ep))
+                    continue;
+
                 // find another endpoint to store a hint on.  prefer endpoints that aren't
already in use
                 InetAddress hintLocation = null;
-                List tokens = tokenMetadata_.sortedTokens();
-                Token token = tokenMetadata_.getToken(ep);
-                int index = Collections.binarySearch(tokens, token);
-                if (index < 0)
-                {
-                    index = (index + 1) * (-1);
-                    if (index >= tokens.size()) // handle wrap
-                        index = 0;
-                }
-                int totalNodes = tokens.size();
-                int startIndex = (index + 1) % totalNodes;
-                for (int i = startIndex, count = 1; count < totalNodes; ++count, i = (i
+ 1) % totalNodes)
+                List<InetAddress> preferred = endPointSnitch.getSortedListByProximity(ep,
liveNodes);
+
+                for (InetAddress hintCandidate : preferred)
                 {
-                    InetAddress tmpEndPoint = tokenMetadata_.getEndPoint((Token) tokens.get(i));
-                    if (FailureDetector.instance.isAlive(tmpEndPoint) && !targets.contains(tmpEndPoint)
&& !usedEndpoints.contains(tmpEndPoint))
+                    if (!targets.contains(hintCandidate)
+                        && !usedEndpoints.contains(hintCandidate)
+                        && tokenMetadata_.isMember(hintCandidate))
                     {
-                        hintLocation = tmpEndPoint;
+                        hintLocation = hintCandidate;
                         break;
                     }
                 }

Propchange: incubator/cassandra/trunk/test/unit/org/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Mon Jan 25 16:55:06 2010
@@ -1,4 +1,4 @@
 /incubator/cassandra/branches/cassandra-0.3/test/unit/org:774578-796573
 /incubator/cassandra/branches/cassandra-0.4/test/unit/org:810145-834239,834349-834350
-/incubator/cassandra/branches/cassandra-0.5/test/unit/org:888872-901913
+/incubator/cassandra/branches/cassandra-0.5/test/unit/org:888872-902868
 /incubator/cassandra/trunk/test/unit/org:749219-768583



Mime
View raw message