cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bened...@apache.org
Subject cassandra git commit: remove unnecessary anonymous class creation and generic parameters from NetworkTopologyStrategy
Date Wed, 01 Apr 2015 12:57:55 GMT
Repository: cassandra
Updated Branches:
  refs/heads/trunk d7076a4b8 -> 82a526863


remove unnecessary anonymous class creation and generic parameters from NetworkTopologyStrategy


Project: http://git-wip-us.apache.org/repos/asf/cassandra/repo
Commit: http://git-wip-us.apache.org/repos/asf/cassandra/commit/82a52686
Tree: http://git-wip-us.apache.org/repos/asf/cassandra/tree/82a52686
Diff: http://git-wip-us.apache.org/repos/asf/cassandra/diff/82a52686

Branch: refs/heads/trunk
Commit: 82a526863b03f533318cfe00d74508cd3da235f3
Parents: d7076a4
Author: Benedict Elliott Smith <benedict@apache.org>
Authored: Wed Apr 1 13:57:43 2015 +0100
Committer: Benedict Elliott Smith <benedict@apache.org>
Committed: Wed Apr 1 13:57:43 2015 +0100

----------------------------------------------------------------------
 .../locator/NetworkTopologyStrategy.java        | 29 +++++++++-----------
 1 file changed, 13 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/82a52686/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java b/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
index b0d540c..fb291b5 100644
--- a/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
+++ b/src/java/org/apache/cassandra/locator/NetworkTopologyStrategy.java
@@ -81,13 +81,12 @@ public class NetworkTopologyStrategy extends AbstractReplicationStrategy
     public List<InetAddress> calculateNaturalEndpoints(Token searchToken, TokenMetadata
tokenMetadata)
     {
         // we want to preserve insertion order so that the first added endpoint becomes primary
-        Set<InetAddress> replicas = new LinkedHashSet<InetAddress>();
+        Set<InetAddress> replicas = new LinkedHashSet<>();
         // replicas we have found in each DC
-        Map<String, Set<InetAddress>> dcReplicas = new HashMap<String, Set<InetAddress>>(datacenters.size())
-        {{
-            for (Map.Entry<String, Integer> dc : datacenters.entrySet())
-                put(dc.getKey(), new HashSet<InetAddress>(dc.getValue()));
-        }};
+        Map<String, Set<InetAddress>> dcReplicas = new HashMap<>(datacenters.size());
+        for (Map.Entry<String, Integer> dc : datacenters.entrySet())
+            dcReplicas.put(dc.getKey(), new HashSet<>(dc.getValue()));
+
         Topology topology = tokenMetadata.getTopology();
         // all endpoints in each DC, so we can check when we have exhausted all the members
of a DC
         Multimap<String, InetAddress> allEndpoints = topology.getDatacenterEndpoints();
@@ -96,18 +95,16 @@ public class NetworkTopologyStrategy extends AbstractReplicationStrategy
         assert !allEndpoints.isEmpty() && !racks.isEmpty() : "not aware of any cluster
members";
 
         // tracks the racks we have already placed replicas in
-        Map<String, Set<String>> seenRacks = new HashMap<String, Set<String>>(datacenters.size())
-        {{
-            for (Map.Entry<String, Integer> dc : datacenters.entrySet())
-                put(dc.getKey(), new HashSet<String>());
-        }};
+        Map<String, Set<String>> seenRacks = new HashMap<>(datacenters.size());
+        for (Map.Entry<String, Integer> dc : datacenters.entrySet())
+            seenRacks.put(dc.getKey(), new HashSet<>());
+
         // tracks the endpoints that we skipped over while looking for unique racks
         // when we relax the rack uniqueness we can append this to the current result so
we don't have to wind back the iterator
-        Map<String, Set<InetAddress>> skippedDcEndpoints = new HashMap<String,
Set<InetAddress>>(datacenters.size())
-        {{
-            for (Map.Entry<String, Integer> dc : datacenters.entrySet())
-                put(dc.getKey(), new LinkedHashSet<InetAddress>());
-        }};
+        Map<String, Set<InetAddress>> skippedDcEndpoints = new HashMap<>(datacenters.size());
+        for (Map.Entry<String, Integer> dc : datacenters.entrySet())
+            skippedDcEndpoints.put(dc.getKey(), new LinkedHashSet<>());
+
         Iterator<Token> tokenIter = TokenMetadata.ringIterator(tokenMetadata.sortedTokens(),
searchToken, false);
         while (tokenIter.hasNext() && !hasSufficientReplicas(dcReplicas, allEndpoints))
         {


Mime
View raw message