Author: jbellis
Date: Fri Oct 22 14:51:17 2010
New Revision: 1026349
URL: http://svn.apache.org/viewvc?rev=1026349&view=rev
Log:
clean up stringify methods. patch by jbellis
Modified:
cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
cassandra/trunk/src/java/org/apache/cassandra/tools/ClusterCmd.java
cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java
cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java?rev=1026349&r1=1026348&r2=1026349&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageService.java Fri Oct 22 14:51:17
2010
@@ -1181,37 +1181,27 @@ public class StorageService implements I
return FBUtilities.getReleaseVersionString();
}
- public Set<String> getLeavingNodes()
+ public List<String> getLeavingNodes()
{
return stringify(tokenMetadata_.getLeavingEndpoints());
}
- public Set<String> getJoiningNodes()
+ public List<String> getJoiningNodes()
{
return stringify(tokenMetadata_.getBootstrapTokens().values());
}
- public Set<String> getLiveNodes()
+ public List<String> getLiveNodes()
{
return stringify(Gossiper.instance.getLiveMembers());
}
- public Set<String> getUnreachableNodes()
+ public List<String> getUnreachableNodes()
{
return stringify(Gossiper.instance.getUnreachableMembers());
}
- private Set<String> stringify(Collection<InetAddress> endpoints)
- {
- Set<String> stringEndpoints = new HashSet<String>();
- for (InetAddress ep : endpoints)
- {
- stringEndpoints.add(ep.getHostAddress());
- }
- return stringEndpoints;
- }
-
- private List<String> stringify(List<InetAddress> endpoints)
+ private List<String> stringify(Iterable<InetAddress> endpoints)
{
List<String> stringEndpoints = new ArrayList<String>();
for (InetAddress ep : endpoints)
Modified: cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java?rev=1026349&r1=1026348&r2=1026349&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/service/StorageServiceMBean.java Fri Oct
22 14:51:17 2010
@@ -42,7 +42,7 @@ public interface StorageServiceMBean
*
* @return set of IP addresses, as Strings
*/
- public Set<String> getLiveNodes();
+ public List<String> getLiveNodes();
/**
* Retrieve the list of unreachable nodes in the cluster, as determined
@@ -50,21 +50,21 @@ public interface StorageServiceMBean
*
* @return set of IP addresses, as Strings
*/
- public Set<String> getUnreachableNodes();
+ public List<String> getUnreachableNodes();
/**
* Retrieve the list of nodes currently bootstrapping into the ring.
*
* @return set of IP addresses, as Strings
*/
- public Set<String> getJoiningNodes();
+ public List<String> getJoiningNodes();
/**
* Retrieve the list of nodes currently leaving the ring.
*
* @return set of IP addresses, as Strings
*/
- public Set<String> getLeavingNodes();
+ public List<String> getLeavingNodes();
/**
* Fetch a string representation of the token.
Modified: cassandra/trunk/src/java/org/apache/cassandra/tools/ClusterCmd.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/tools/ClusterCmd.java?rev=1026349&r1=1026348&r2=1026349&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/tools/ClusterCmd.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/tools/ClusterCmd.java Fri Oct 22 14:51:17
2010
@@ -160,30 +160,18 @@ public class ClusterCmd {
*/
public void takeGlobalSnapshot(String snapshotName) throws IOException, InterruptedException
{
- Set<String> liveNodes = probe.getLiveNodes();
- try
- {
- probe.takeSnapshot(snapshotName);
- System.out.println(host + " snapshot taken");
- }
- catch (IOException e)
- {
- System.out.println(host + " snapshot FAILED: " + e.getMessage());
- }
- liveNodes.remove(this.host);
- for (String liveNode : liveNodes)
+ for (String liveNode : probe.getLiveNodes())
{
try
{
- this.host = liveNode;
- probe = new NodeProbe(host, port);
- probe.takeSnapshot(snapshotName);
- System.out.println(host + " snapshot taken");
+ NodeProbe hostProbe = new NodeProbe(liveNode, port);
+ hostProbe.takeSnapshot(snapshotName);
+ System.out.println(liveNode + " snapshot taken");
}
catch (IOException e)
{
- System.out.println(host + " snapshot FAILED: " + e.getMessage());
+ System.out.println(liveNode + " snapshot FAILED: " + e.getMessage());
}
}
}
@@ -193,30 +181,17 @@ public class ClusterCmd {
*/
public void clearGlobalSnapshot() throws IOException, InterruptedException
{
- Set<String> liveNodes = probe.getLiveNodes();
- try
- {
- probe.clearSnapshot();
- System.out.println(host + " snapshot cleared");
- }
- catch (IOException e)
- {
- System.out.println(host + " snapshot clear FAILED: " + e.getMessage());
- }
-
- liveNodes.remove(this.host);
- for (String liveNode : liveNodes)
+ for (String liveNode : probe.getLiveNodes())
{
try
{
- this.host = liveNode;
- probe = new NodeProbe(host, port);
- probe.clearSnapshot();
- System.out.println(host + " snapshot cleared");
+ NodeProbe hostProbe = new NodeProbe(liveNode, port);
+ hostProbe.clearSnapshot();
+ System.out.println(liveNode + " snapshot cleared");
}
catch (IOException e)
{
- System.out.println(host + " snapshot clear FAILED: " + e.getMessage());
+ System.out.println(liveNode + " snapshot clear FAILED: " + e.getMessage());
}
}
}
Modified: cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java?rev=1026349&r1=1026348&r2=1026349&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/tools/NodeCmd.java Fri Oct 22 14:51:17 2010
@@ -88,10 +88,10 @@ public class NodeCmd {
List<Token> sortedTokens = new ArrayList<Token>(tokenToEndpoint.keySet());
Collections.sort(sortedTokens);
- Set<String> liveNodes = probe.getLiveNodes();
- Set<String> deadNodes = probe.getUnreachableNodes();
- Set<String> joiningNodes = probe.getJoiningNodes();
- Set<String> leavingNodes = probe.getLeavingNodes();
+ Collection<String> liveNodes = probe.getLiveNodes();
+ Collection<String> deadNodes = probe.getUnreachableNodes();
+ Collection<String> joiningNodes = probe.getJoiningNodes();
+ Collection<String> leavingNodes = probe.getLeavingNodes();
Map<String, String> loadMap = probe.getLoadMap();
outs.printf("%-16s%-7s%-8s%-16s%-44s\n", "Address", "Status", "State", "Load", "Token");
Modified: cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java
URL: http://svn.apache.org/viewvc/cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java?rev=1026349&r1=1026348&r2=1026349&view=diff
==============================================================================
--- cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java (original)
+++ cassandra/trunk/src/java/org/apache/cassandra/tools/NodeProbe.java Fri Oct 22 14:51:17
2010
@@ -166,22 +166,22 @@ public class NodeProbe
return ssProxy.getTokenToEndpointMap();
}
- public Set<String> getLiveNodes()
+ public List<String> getLiveNodes()
{
return ssProxy.getLiveNodes();
}
- public Set<String> getJoiningNodes()
+ public List<String> getJoiningNodes()
{
return ssProxy.getJoiningNodes();
}
- public Set<String> getLeavingNodes()
+ public List<String> getLeavingNodes()
{
return ssProxy.getLeavingNodes();
}
- public Set<String> getUnreachableNodes()
+ public List<String> getUnreachableNodes()
{
return ssProxy.getUnreachableNodes();
}
|