cassandra-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From vi...@apache.org
Subject [2/2] git commit: Merge branch 'cassandra-1.2' into cassandra-2.0
Date Wed, 12 Mar 2014 03:32:39 GMT
Merge branch 'cassandra-1.2' into cassandra-2.0

Conflicts:
	src/java/org/apache/cassandra/tools/NodeCmd.java


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

Branch: refs/heads/cassandra-2.0
Commit: fc9cad90d532a3af89dbbf1b004bfd333a85b33e
Parents: f7eca98 91d220b
Author: Vijay <vijay2win@gmail.com>
Authored: Tue Mar 11 20:32:07 2014 -0700
Committer: Vijay <vijay2win@gmail.com>
Committed: Tue Mar 11 20:32:07 2014 -0700

----------------------------------------------------------------------
 .../org/apache/cassandra/tools/NodeCmd.java     | 194 +++++++++----------
 1 file changed, 93 insertions(+), 101 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cassandra/blob/fc9cad90/src/java/org/apache/cassandra/tools/NodeCmd.java
----------------------------------------------------------------------
diff --cc src/java/org/apache/cassandra/tools/NodeCmd.java
index 89cfb94,85afdc1..0e7ff2a
--- a/src/java/org/apache/cassandra/tools/NodeCmd.java
+++ b/src/java/org/apache/cassandra/tools/NodeCmd.java
@@@ -27,22 -27,25 +27,23 @@@ import java.text.SimpleDateFormat
  import java.util.*;
  import java.util.Map.Entry;
  import java.util.concurrent.ExecutionException;
 +import javax.management.openmbean.TabularData;
  
  import com.google.common.base.Joiner;
+ import com.google.common.collect.ArrayListMultimap;
  import com.google.common.collect.LinkedHashMultimap;
  import com.google.common.collect.Maps;
+ 
  import org.apache.cassandra.config.DatabaseDescriptor;
  import org.apache.cassandra.utils.FBUtilities;
  import org.apache.commons.cli.*;
 -import org.yaml.snakeyaml.Loader;
 -import org.yaml.snakeyaml.TypeDescription;
  import org.yaml.snakeyaml.Yaml;
  import org.yaml.snakeyaml.constructor.Constructor;
- 
  import org.apache.cassandra.concurrent.JMXEnabledThreadPoolExecutorMBean;
  import org.apache.cassandra.db.ColumnFamilyStoreMBean;
 -import org.apache.cassandra.db.Table;
 +import org.apache.cassandra.db.Keyspace;
  import org.apache.cassandra.db.compaction.CompactionManagerMBean;
  import org.apache.cassandra.db.compaction.OperationType;
 -import org.apache.cassandra.exceptions.ConfigurationException;
  import org.apache.cassandra.io.util.FileUtils;
  import org.apache.cassandra.locator.EndpointSnitchInfoMBean;
  import org.apache.cassandra.net.MessagingServiceMBean;
@@@ -318,18 -299,23 +310,17 @@@ public class NodeCm
  
          // get the total amount of replicas for this dc and the last token in this dc's
ring
          List<String> tokens = new ArrayList<String>();
 -        float totalReplicas = 0f;
          String lastToken = "";
  
-         for (Map.Entry<InetAddress, Float> entry : filteredOwnerships.entrySet())
+         for (HostStat stat : hoststats)
          {
-             tokens.addAll(endpointsToTokens.get(entry.getKey().getHostAddress()));
+             tokens.addAll(endpointsToTokens.get(stat.ip));
              lastToken = tokens.get(tokens.size() - 1);
 -            if (stat.owns != null)
 -                totalReplicas += stat.owns;
          }
  
- 
 -        if (keyspaceSelected)
 -            outs.print("Replicas: " + (int) totalReplicas + "\n\n");
 -
          outs.printf(format, "Address", "Rack", "Status", "State", "Load", "Owns", "Token");
  
-         if (filteredOwnerships.size() > 1)
+         if (hoststats.size() > 1)
              outs.printf(format, "", "", "", "", "", "", lastToken);
          else
              outs.println();
@@@ -584,7 -508,70 +513,70 @@@
          }
      }
  
+     private Map<String, SetHostStat> getOwnershipByDc(boolean resolveIp, Map<String,
String> tokenToEndpoint, 
+                                                       Map<InetAddress, Float> ownerships)
throws UnknownHostException
+     {
+         Map<String, SetHostStat> ownershipByDc = Maps.newLinkedHashMap();
+         EndpointSnitchInfoMBean epSnitchInfo = probe.getEndpointSnitchInfoProxy();
+ 
+         for (Entry<String, String> tokenAndEndPoint : tokenToEndpoint.entrySet())
+         {
+             String dc = epSnitchInfo.getDatacenter(tokenAndEndPoint.getValue());
+             if (!ownershipByDc.containsKey(dc))
+                 ownershipByDc.put(dc, new SetHostStat(resolveIp));
+             ownershipByDc.get(dc).add(tokenAndEndPoint.getKey(), tokenAndEndPoint.getValue(),
ownerships);
+         }
+ 
+         return ownershipByDc;
+     }
+ 
+     static class SetHostStat implements Iterable<HostStat> {
+         final List<HostStat> hostStats = new ArrayList<HostStat>();
+         final boolean resolveIp;
+ 
+         public SetHostStat(boolean resolveIp)
+         {
+             this.resolveIp = resolveIp;
+         }
+ 
+         public int size()
+         {
+             return hostStats.size();
+         }
+ 
+         @Override
+         public Iterator<HostStat> iterator() {
+             return hostStats.iterator();
+         }
+ 
+         public void add(String token, String host, Map<InetAddress, Float> ownerships)
throws UnknownHostException {
+             InetAddress endpoint = InetAddress.getByName(host);
+             Float owns = ownerships.get(endpoint);
+             hostStats.add(new HostStat(token, endpoint, resolveIp, owns));
+         }
+     }
+ 
+     static class HostStat {
+         public final String ip;
+         public final String dns;
+         public final Float owns;
+         public final String token;
+ 
+         public HostStat(String token, InetAddress endPoint, boolean resolveIp, Float owns)

+         {
+             this.token = token;
+             this.ip = endPoint.getHostAddress();
+             this.dns = resolveIp ? endPoint.getHostName() : null;
+             this.owns = owns;
+         }
+ 
+         public String ipOrDns()
+         {
+             return (dns != null) ? dns : ip;
+         }
+     }
+ 
 -    /** Writes a table of cluster-wide node information to a PrintStream
 +    /** Writes a keyspaceName of cluster-wide node information to a PrintStream
       * @throws UnknownHostException */
      public void printClusterStatus(PrintStream outs, String keyspace, boolean resolveIp)
throws UnknownHostException
      {


Mime
View raw message