Merge from 0.8

git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@1153686 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Brandon Williams 2011-08-03 22:06:14 +00:00
parent c715b6d9be
commit 032b476c52
5 changed files with 28 additions and 7 deletions

View File

@ -31,6 +31,7 @@ public enum ApplicationState
RELEASE_VERSION,
REMOVAL_COORDINATOR,
INTERNAL_IP,
RPC_ADDRESS,
// pad to allow adding new states to existing cluster
X1,
X2,

View File

@ -21,6 +21,7 @@ package org.apache.cassandra.gms;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.util.UUID;
import org.apache.cassandra.dht.IPartitioner;
@ -157,6 +158,11 @@ public class VersionedValue implements Comparable<VersionedValue>
return new VersionedValue(rackId);
}
public VersionedValue rpcaddress(InetAddress endpoint)
{
return new VersionedValue(endpoint.toString());
}
public VersionedValue releaseVersion()
{
return new VersionedValue(FBUtilities.getReleaseVersionString());

View File

@ -450,6 +450,12 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
Gossiper.instance.register(this);
Gossiper.instance.register(migrationManager);
Gossiper.instance.start(SystemTable.incrementAndGetGeneration()); // needed for node-ring gathering.
// add rpc listening info
if (DatabaseDescriptor.getRpcAddress() == null)
Gossiper.instance.addLocalApplicationState(ApplicationState.RPC_ADDRESS, valueFactory.rpcaddress(FBUtilities.getLocalAddress()));
else
Gossiper.instance.addLocalApplicationState(ApplicationState.RPC_ADDRESS, valueFactory.rpcaddress(DatabaseDescriptor.getRpcAddress()));
MessagingService.instance().listen(FBUtilities.getLocalAddress());
StorageLoadBalancer.instance.startBroadcasting();
MigrationManager.passiveAnnounce(DatabaseDescriptor.getDefsVersion());
@ -574,11 +580,11 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
}
/**
* for a keyspace, return the ranges and corresponding hosts for a given keyspace.
* for a keyspace, return the ranges and corresponding RPC addresses for a given keyspace.
* @param keyspace
* @return
*/
public Map<Range, List<String>> getRangeToEndpointMap(String keyspace)
public Map<Range, List<String>> getRangeToRpcaddressMap(String keyspace)
{
// some people just want to get a visual representation of things. Allow null and set it to the first
// non-system table.
@ -589,7 +595,15 @@ public class StorageService implements IEndpointStateChangeSubscriber, StorageSe
Map<Range, List<String>> map = new HashMap<Range, List<String>>();
for (Map.Entry<Range,List<InetAddress>> entry : getRangeToAddressMap(keyspace).entrySet())
{
map.put(entry.getKey(), stringify(entry.getValue()));
List<String> rpcaddrs = new ArrayList<String>();
for (InetAddress endpoint: entry.getValue())
{
if (endpoint.equals(FBUtilities.getLocalAddress()))
rpcaddrs.add(DatabaseDescriptor.getRpcAddress().toString());
else
rpcaddrs.add(Gossiper.instance.getEndpointStateForEndpoint(endpoint).getApplicationState(ApplicationState.RPC_ADDRESS).value);
}
map.put(entry.getKey(), rpcaddrs);
}
return map;
}

View File

@ -111,12 +111,12 @@ public interface StorageServiceMBean
public String getSavedCachesLocation();
/**
* Retrieve a map of range to end points that describe the ring topology
* Retrieve a map of range to rpc addresses that describe the ring topology
* of a Cassandra cluster.
*
* @return mapping of ranges to end points
* @return mapping of ranges to rpc addresses
*/
public Map<Range, List<String>> getRangeToEndpointMap(String keyspace);
public Map<Range, List<String>> getRangeToRpcaddressMap(String keyspace);
/**
* Retrieve a map of pending ranges to endpoints that describe the ring topology

View File

@ -786,7 +786,7 @@ public class CassandraServer implements Cassandra.Iface
throw new InvalidRequestException("There is no ring for the keyspace: " + keyspace);
List<TokenRange> ranges = new ArrayList<TokenRange>();
Token.TokenFactory tf = StorageService.getPartitioner().getTokenFactory();
for (Map.Entry<Range, List<String>> entry : StorageService.instance.getRangeToEndpointMap(keyspace).entrySet())
for (Map.Entry<Range, List<String>> entry : StorageService.instance.getRangeToRpcaddressMap(keyspace).entrySet())
{
Range range = entry.getKey();
List<String> endpoints = entry.getValue();