cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jbel...@apache.org
Subject svn commit: r1053697 - in /cassandra/branches/cassandra-0.7.0: ./ interface/thrift/gen-java/org/apache/cassandra/thrift/ src/java/org/apache/cassandra/dht/ src/java/org/apache/cassandra/locator/ src/java/org/apache/cassandra/utils/
Date Wed, 29 Dec 2010 18:27:54 GMT
Author: jbellis
Date: Wed Dec 29 18:27:54 2010
New Revision: 1053697

URL: http://svn.apache.org/viewvc?rev=1053697&view=rev
Log:
merge r1053450, r1053457 from 0.7

Modified:
    cassandra/branches/cassandra-0.7.0/   (props changed)
    cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
  (props changed)
    cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
  (props changed)
    cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
  (props changed)
    cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
  (props changed)
    cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
  (props changed)
    cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/dht/RandomPartitioner.java
    cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/locator/TokenMetadata.java
    cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/utils/FBUtilities.java

Propchange: cassandra/branches/cassandra-0.7.0/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 29 18:27:54 2010
@@ -1,5 +1,5 @@
 /cassandra/branches/cassandra-0.6:922689-1053244
-/cassandra/branches/cassandra-0.7:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409
+/cassandra/branches/cassandra-0.7:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409,1053450,1053457
 /cassandra/trunk:1026516-1026734,1028929
 /incubator/cassandra/branches/cassandra-0.3:774578-796573
 /incubator/cassandra/branches/cassandra-0.4:810145-834239,834349-834350

Propchange: cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 29 18:27:54 2010
@@ -1,5 +1,5 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:922689-1053244
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409,1053450,1053457
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Cassandra.java:1026516-1026734,1028929
 /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

Propchange: cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 29 18:27:54 2010
@@ -1,5 +1,5 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:922689-1053244
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409,1053450,1053457
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/Column.java:1026516-1026734,1028929
 /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

Propchange: cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 29 18:27:54 2010
@@ -1,5 +1,5 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:922689-1053244
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409,1053450,1053457
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/InvalidRequestException.java:1026516-1026734,1028929
 /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

Propchange: cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 29 18:27:54 2010
@@ -1,5 +1,5 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:922689-1053244
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409,1053450,1053457
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/NotFoundException.java:1026516-1026734,1028929
 /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

Propchange: cassandra/branches/cassandra-0.7.0/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Dec 29 18:27:54 2010
@@ -1,5 +1,5 @@
 /cassandra/branches/cassandra-0.6/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:922689-1053244
-/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409
+/cassandra/branches/cassandra-0.7/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1052002,1052021,1052027,1052355,1052358,1052545,1053219-1053220,1053245,1053247,1053409,1053450,1053457
 /cassandra/trunk/interface/thrift/gen-java/org/apache/cassandra/thrift/SuperColumn.java:1026516-1026734,1028929
 /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

Modified: cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/dht/RandomPartitioner.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/dht/RandomPartitioner.java?rev=1053697&r1=1053696&r2=1053697&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/dht/RandomPartitioner.java
(original)
+++ cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/dht/RandomPartitioner.java
Wed Dec 29 18:27:54 2010
@@ -80,7 +80,7 @@ public class RandomPartitioner implement
 
     public BigIntegerToken getRandomToken()
     {
-        BigInteger token = FBUtilities.md5hash(GuidGenerator.guidAsBytes());
+        BigInteger token = FBUtilities.hashToBigInteger(GuidGenerator.guidAsBytes());
         if ( token.signum() == -1 )
             token = token.multiply(BigInteger.valueOf(-1L));
         return new BigIntegerToken(token);
@@ -126,7 +126,7 @@ public class RandomPartitioner implement
     {
         if (key.remaining() == 0)
             return MINIMUM;
-        return new BigIntegerToken(FBUtilities.md5hash(key));
+        return new BigIntegerToken(FBUtilities.hashToBigInteger(key));
     }
 
     public Map<Token, Float> describeOwnership(List<Token> sortedTokens)

Modified: cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/locator/TokenMetadata.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/locator/TokenMetadata.java?rev=1053697&r1=1053696&r2=1053697&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/locator/TokenMetadata.java
(original)
+++ cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/locator/TokenMetadata.java
Wed Dec 29 18:27:54 2010
@@ -323,13 +323,15 @@ public class TokenMetadata
         }
     }
 
-    private synchronized Multimap<Range, InetAddress> getPendingRangesMM(String table)
+    private Multimap<Range, InetAddress> getPendingRangesMM(String table)
     {
         Multimap<Range, InetAddress> map = pendingRanges.get(table);
         if (map == null)
         {
-             map = HashMultimap.create();
-            pendingRanges.put(table, map);
+            map = HashMultimap.create();
+            Multimap<Range, InetAddress> priorMap = pendingRanges.putIfAbsent(table,
map);
+            if (priorMap != null)
+                map = priorMap;
         }
         return map;
     }
@@ -556,12 +558,13 @@ public class TokenMetadata
      */
     public Collection<InetAddress> getWriteEndpoints(Token token, String table, Collection<InetAddress>
naturalEndpoints)
     {
-        if (getPendingRanges(table).isEmpty())
+        Map<Range, Collection<InetAddress>> ranges = getPendingRanges(table);
+        if (ranges.isEmpty())
             return naturalEndpoints;
 
         List<InetAddress> endpoints = new ArrayList<InetAddress>(naturalEndpoints);
 
-        for (Map.Entry<Range, Collection<InetAddress>> entry : getPendingRanges(table).entrySet())
+        for (Map.Entry<Range, Collection<InetAddress>> entry : ranges.entrySet())
         {
             if (entry.getKey().contains(token))
             {

Modified: cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/utils/FBUtilities.java
URL: http://svn.apache.org/viewvc/cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/utils/FBUtilities.java?rev=1053697&r1=1053696&r2=1053697&view=diff
==============================================================================
--- cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/utils/FBUtilities.java
(original)
+++ cassandra/branches/cassandra-0.7.0/src/java/org/apache/cassandra/utils/FBUtilities.java
Wed Dec 29 18:27:54 2010
@@ -29,6 +29,7 @@ import java.net.UnknownHostException;
 import java.nio.ByteBuffer;
 import java.nio.charset.CharacterCodingException;
 import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
 import java.util.*;
 import java.util.concurrent.ExecutionException;
 import java.util.concurrent.Future;
@@ -64,6 +65,22 @@ public class FBUtilities
     
     private static volatile InetAddress localInetAddress_;
 
+    private static final ThreadLocal<MessageDigest> localMessageDigest = new ThreadLocal<MessageDigest>()
+    {
+        @Override
+        protected MessageDigest initialValue()
+        {
+            try
+            {
+                return MessageDigest.getInstance("MD5");
+            }
+            catch (NoSuchAlgorithmException e)
+            {
+                throw new AssertionError(e);
+            }
+        }
+    };
+
     public static final int MAX_UNSIGNED_SHORT = 0xFFFF;
 
     /**
@@ -218,19 +235,20 @@ public class FBUtilities
         return out;
     }
 
-    public static BigInteger md5hash(ByteBuffer data)
+    public static BigInteger hashToBigInteger(ByteBuffer data)
     {
-        byte[] result = hash("MD5", data);
+        byte[] result = hash(data);
         BigInteger hash = new BigInteger(result);
         return hash.abs();        
     }
 
-    public static byte[] hash(String type, ByteBuffer... data)
+    public static byte[] hash(ByteBuffer... data)
     {
     	byte[] result;
     	try
         {
-            MessageDigest messageDigest = MessageDigest.getInstance(type);
+            MessageDigest messageDigest = localMessageDigest.get();
+            messageDigest.reset();
             for(ByteBuffer block : data)
                 messageDigest.update(block.array(),block.position()+block.arrayOffset(),block.remaining());
             result = messageDigest.digest();



Mime
View raw message