mirror of https://github.com/apache/cassandra
rename EndPoint classes -> Endpoint, part 2.
patch by Erick Tryzelaar; reviewed by jbellis for CASSANDRA-994 git-svn-id: https://svn.apache.org/repos/asf/cassandra/trunk@935717 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a5fa451c2b
commit
7a4a7090cb
|
|
@ -49,8 +49,8 @@
|
||||||
~ EndpointSnitch: Setting this to the class that implements
|
~ EndpointSnitch: Setting this to the class that implements
|
||||||
~ AbstractEndpointSnitch, which lets Cassandra know enough
|
~ AbstractEndpointSnitch, which lets Cassandra know enough
|
||||||
~ about your network topology to route requests efficiently.
|
~ about your network topology to route requests efficiently.
|
||||||
~ Out of the box, Cassandra provides org.apache.cassandra.locator.EndPointSnitch,
|
~ Out of the box, Cassandra provides org.apache.cassandra.locator.EndpointSnitch,
|
||||||
~ and PropertyFileEndPointSnitch is available in contrib/.
|
~ and PropertyFileEndpointSnitch is available in contrib/.
|
||||||
-->
|
-->
|
||||||
<EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
|
<EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -133,7 +133,7 @@
|
||||||
~ Out of the box, Cassandra provides org.apache.cassandra.locator.EndpointSnitch,
|
~ Out of the box, Cassandra provides org.apache.cassandra.locator.EndpointSnitch,
|
||||||
~ and PropertyFileEndpointSnitch is available in contrib/.
|
~ and PropertyFileEndpointSnitch is available in contrib/.
|
||||||
-->
|
-->
|
||||||
<EndpointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndpointSnitch>
|
<EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
|
||||||
</Keyspace>
|
</Keyspace>
|
||||||
</Keyspaces>
|
</Keyspaces>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
PropertyFileEndPointSnitch
|
PropertyFileEndpointSnitch
|
||||||
==========================
|
==========================
|
||||||
|
|
||||||
Cassandra's RackAwareStrategy can be used to have replication take
|
Cassandra's RackAwareStrategy can be used to have replication take
|
||||||
data-center and/or rack location into account when placing replicas. The
|
data-center and/or rack location into account when placing replicas. The
|
||||||
ProperyFileEndPointSnitch allows you to make use of RackAwareStrategy by
|
ProperyFileEndpointSnitch allows you to make use of RackAwareStrategy by
|
||||||
specifying node locations in a standard key/value properties file.
|
specifying node locations in a standard key/value properties file.
|
||||||
|
|
||||||
|
|
||||||
Properties File
|
Properties File
|
||||||
---------------
|
---------------
|
||||||
The EndPointSnitch expects to find a file on the classapth named
|
The EndpointSnitch expects to find a file on the classapth named
|
||||||
cassandra-rack.properties in the following format:
|
cassandra-rack.properties in the following format:
|
||||||
|
|
||||||
<node IP>\:<port>=<data center name>:<rack name>
|
<node IP>\:<port>=<data center name>:<rack name>
|
||||||
|
|
@ -28,8 +28,8 @@ Installing
|
||||||
* Copy build/cassandra-propsnitch.jar to your Cassandra lib/
|
* Copy build/cassandra-propsnitch.jar to your Cassandra lib/
|
||||||
directory, or otherwise add it to the CLASSPATH
|
directory, or otherwise add it to the CLASSPATH
|
||||||
(see http://wiki.apache.org/cassandra/RunningCassandra)
|
(see http://wiki.apache.org/cassandra/RunningCassandra)
|
||||||
* Edit the EndPointSnitch element of storage-conf.xml to use
|
* Edit the EndpointSnitch element of storage-conf.xml to use
|
||||||
org.apache.cassandra.locator.PropertyFileEndPointSnitch
|
org.apache.cassandra.locator.PropertyFileEndpointSnitch
|
||||||
* Create the cassandra-rack.properties in your classpath
|
* Create the cassandra-rack.properties in your classpath
|
||||||
(e.g. in your Cassandra conf/ directory)
|
(e.g. in your Cassandra conf/ directory)
|
||||||
* Optionally set ReplicaPlacementStrategy in cassandra.xml to
|
* Optionally set ReplicaPlacementStrategy in cassandra.xml to
|
||||||
|
|
|
||||||
|
|
@ -36,18 +36,18 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PropertyFileEndPointSnitch
|
* PropertyFileEndpointSnitch
|
||||||
*
|
*
|
||||||
* PropertyFileEndPointSnitch is used by Digg to determine if two IP's are in the same
|
* PropertyFileEndpointSnitch is used by Digg to determine if two IP's are in the same
|
||||||
* datacenter or on the same rack.
|
* datacenter or on the same rack.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class PropertyFileEndPointSnitch extends EndpointSnitch implements PropertyFileEndPointSnitchMBean {
|
public class PropertyFileEndpointSnitch extends EndpointSnitch implements PropertyFileEndpointSnitchMBean {
|
||||||
/**
|
/**
|
||||||
* A list of properties with keys being host:port and values being datacenter:rack
|
* A list of properties with keys being host:port and values being datacenter:rack
|
||||||
*/
|
*/
|
||||||
private Properties hostProperties = new Properties();
|
private Properties hostProperties = new Properties();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The default rack property file to be read.
|
* The default rack property file to be read.
|
||||||
*/
|
*/
|
||||||
|
|
@ -57,13 +57,13 @@ public class PropertyFileEndPointSnitch extends EndpointSnitch implements Proper
|
||||||
* Whether to use the parent for detection of same node
|
* Whether to use the parent for detection of same node
|
||||||
*/
|
*/
|
||||||
private boolean runInBaseMode = false;
|
private boolean runInBaseMode = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reference to the logger.
|
* Reference to the logger.
|
||||||
*/
|
*/
|
||||||
private static Logger logger_ = LoggerFactory.getLogger(PropertyFileEndPointSnitch.class);
|
private static Logger logger_ = LoggerFactory.getLogger(PropertyFileEndpointSnitch.class);
|
||||||
|
|
||||||
public PropertyFileEndPointSnitch() throws ConfigurationException
|
public PropertyFileEndpointSnitch() throws ConfigurationException
|
||||||
{
|
{
|
||||||
reloadConfiguration();
|
reloadConfiguration();
|
||||||
try
|
try
|
||||||
|
|
@ -125,7 +125,7 @@ public class PropertyFileEndPointSnitch extends EndpointSnitch implements Proper
|
||||||
@Override
|
@Override
|
||||||
public boolean isInSameDataCenter(InetAddress host, InetAddress host2)
|
public boolean isInSameDataCenter(InetAddress host, InetAddress host2)
|
||||||
throws UnknownHostException {
|
throws UnknownHostException {
|
||||||
if (runInBaseMode)
|
if (runInBaseMode)
|
||||||
{
|
{
|
||||||
return super.isInSameDataCenter(host, host2);
|
return super.isInSameDataCenter(host, host2);
|
||||||
}
|
}
|
||||||
|
|
@ -135,11 +135,11 @@ public class PropertyFileEndPointSnitch extends EndpointSnitch implements Proper
|
||||||
@Override
|
@Override
|
||||||
public boolean isOnSameRack(InetAddress host, InetAddress host2)
|
public boolean isOnSameRack(InetAddress host, InetAddress host2)
|
||||||
throws UnknownHostException {
|
throws UnknownHostException {
|
||||||
if (runInBaseMode)
|
if (runInBaseMode)
|
||||||
{
|
{
|
||||||
return super.isOnSameRack(host, host2);
|
return super.isOnSameRack(host, host2);
|
||||||
}
|
}
|
||||||
if (!isInSameDataCenter(host, host2))
|
if (!isInSameDataCenter(host, host2))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -155,10 +155,10 @@ public class PropertyFileEndPointSnitch extends EndpointSnitch implements Proper
|
||||||
}
|
}
|
||||||
return configurationString.toString();
|
return configurationString.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void reloadConfiguration() throws ConfigurationException
|
public void reloadConfiguration() throws ConfigurationException
|
||||||
{
|
{
|
||||||
ClassLoader loader = PropertyFileEndPointSnitch.class.getClassLoader();
|
ClassLoader loader = PropertyFileEndpointSnitch.class.getClassLoader();
|
||||||
URL scpurl = loader.getResource(RACK_PROPERTY_FILENAME);
|
URL scpurl = loader.getResource(RACK_PROPERTY_FILENAME);
|
||||||
if (scpurl == null)
|
if (scpurl == null)
|
||||||
throw new ConfigurationException("unable to locate " + RACK_PROPERTY_FILENAME);
|
throw new ConfigurationException("unable to locate " + RACK_PROPERTY_FILENAME);
|
||||||
|
|
@ -172,7 +172,7 @@ public class PropertyFileEndPointSnitch extends EndpointSnitch implements Proper
|
||||||
hostProperties = localHostProperties;
|
hostProperties = localHostProperties;
|
||||||
runInBaseMode = false;
|
runInBaseMode = false;
|
||||||
}
|
}
|
||||||
catch (IOException ioe)
|
catch (IOException ioe)
|
||||||
{
|
{
|
||||||
throw new ConfigurationException("Could not process " + rackPropertyFilename, ioe);
|
throw new ConfigurationException("Could not process " + rackPropertyFilename, ioe);
|
||||||
}
|
}
|
||||||
|
|
@ -23,18 +23,18 @@ import java.io.IOException;
|
||||||
import org.apache.cassandra.config.ConfigurationException;
|
import org.apache.cassandra.config.ConfigurationException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PropertyFileEndPointSnitchMBean
|
* PropertyFileEndpointSnitchMBean
|
||||||
*
|
*
|
||||||
* PropertyFileEndPointSnitchMBean is the management interface for Digg's EndpointSnitch MBean
|
* PropertyFileEndpointSnitchMBean is the management interface for Digg's EndpointSnitch MBean
|
||||||
*
|
*
|
||||||
* @author Sammy Yu <syu@sammyyu.net>
|
* @author Sammy Yu <syu@sammyyu.net>
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public interface PropertyFileEndPointSnitchMBean {
|
public interface PropertyFileEndpointSnitchMBean {
|
||||||
/**
|
/**
|
||||||
* The object name of the mbean.
|
* The object name of the mbean.
|
||||||
*/
|
*/
|
||||||
public static String MBEAN_OBJECT_NAME = "org.apache.cassandra.locator:type=EndPointSnitch";
|
public static String MBEAN_OBJECT_NAME = "org.apache.cassandra.locator:type=EndpointSnitch";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reload the rack configuration
|
* Reload the rack configuration
|
||||||
|
|
@ -130,10 +130,10 @@
|
||||||
~ EndpointSnitch: Setting this to the class that implements
|
~ EndpointSnitch: Setting this to the class that implements
|
||||||
~ AbstractEndpointSnitch, which lets Cassandra know enough
|
~ AbstractEndpointSnitch, which lets Cassandra know enough
|
||||||
~ about your network topology to route requests efficiently.
|
~ about your network topology to route requests efficiently.
|
||||||
~ Out of the box, Cassandra provides org.apache.cassandra.locator.EndPointSnitch,
|
~ Out of the box, Cassandra provides org.apache.cassandra.locator.EndpointSnitch,
|
||||||
~ and PropertyFileEndPointSnitch is available in contrib/.
|
~ and PropertyFileEndpointSnitch is available in contrib/.
|
||||||
-->
|
-->
|
||||||
<EndpointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndpointSnitch>
|
<EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
|
||||||
</Keyspace>
|
</Keyspace>
|
||||||
</Keyspaces>
|
</Keyspaces>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -141,7 +141,7 @@ public class BootStrapper
|
||||||
return maxEndpoint;
|
return maxEndpoint;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** get potential sources for each range, ordered by proximity (as determined by EndPointSnitch) */
|
/** get potential sources for each range, ordered by proximity (as determined by EndpointSnitch) */
|
||||||
Multimap<Range, InetAddress> getRangesWithSources(String table)
|
Multimap<Range, InetAddress> getRangesWithSources(String table)
|
||||||
{
|
{
|
||||||
assert tokenMetadata.sortedTokens().size() > 0;
|
assert tokenMetadata.sortedTokens().size() > 0;
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,7 @@ import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This abstraction represents both the HeartBeatState and the ApplicationState in an EndPointState
|
* This abstraction represents both the HeartBeatState and the ApplicationState in an EndpointState
|
||||||
* instance. Any state for a given endpoint can be retrieved from this instance.
|
* instance. Any state for a given endpoint can be retrieved from this instance.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
@ -37,7 +37,7 @@ public class EndpointState
|
||||||
private static ICompactSerializer<EndpointState> serializer_;
|
private static ICompactSerializer<EndpointState> serializer_;
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
serializer_ = new EndPointStateSerializer();
|
serializer_ = new EndpointStateSerializer();
|
||||||
}
|
}
|
||||||
|
|
||||||
HeartBeatState hbState_;
|
HeartBeatState hbState_;
|
||||||
|
|
@ -154,9 +154,9 @@ public class EndpointState
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class EndPointStateSerializer implements ICompactSerializer<EndpointState>
|
class EndpointStateSerializer implements ICompactSerializer<EndpointState>
|
||||||
{
|
{
|
||||||
private static Logger logger_ = LoggerFactory.getLogger(EndPointStateSerializer.class);
|
private static Logger logger_ = LoggerFactory.getLogger(EndpointStateSerializer.class);
|
||||||
|
|
||||||
public void serialize(EndpointState epState, DataOutputStream dos) throws IOException
|
public void serialize(EndpointState epState, DataOutputStream dos) throws IOException
|
||||||
{
|
{
|
||||||
|
|
@ -177,7 +177,7 @@ class EndPointStateSerializer implements ICompactSerializer<EndpointState>
|
||||||
{
|
{
|
||||||
if ( Gossiper.MAX_GOSSIP_PACKET_SIZE - dos.size() < estimate )
|
if ( Gossiper.MAX_GOSSIP_PACKET_SIZE - dos.size() < estimate )
|
||||||
{
|
{
|
||||||
logger_.info("@@@@ Breaking out to respect the MTU size in EndPointState serializer. Estimate is {} @@@@", estimate);;
|
logger_.info("@@@@ Breaking out to respect the MTU size in EndpointState serializer. Estimate is {} @@@@", estimate);;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ import org.apache.cassandra.net.CompactEndpointSerializationHelper;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contains information about a specified list of EndPoints and the largest version
|
* Contains information about a specified list of Endpoints and the largest version
|
||||||
* of the state they have generated as known by the local endpoint.
|
* of the state they have generated as known by the local endpoint.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,13 +61,13 @@ class GossipDigestAck2MessageSerializer implements ICompactSerializer<GossipDige
|
||||||
{
|
{
|
||||||
public void serialize(GossipDigestAck2Message gDigestAck2Message, DataOutputStream dos) throws IOException
|
public void serialize(GossipDigestAck2Message gDigestAck2Message, DataOutputStream dos) throws IOException
|
||||||
{
|
{
|
||||||
/* Use the EndPointState */
|
/* Use the EndpointState */
|
||||||
EndPointStatesSerializationHelper.serialize(gDigestAck2Message.epStateMap_, dos);
|
EndpointStatesSerializationHelper.serialize(gDigestAck2Message.epStateMap_, dos);
|
||||||
}
|
}
|
||||||
|
|
||||||
public GossipDigestAck2Message deserialize(DataInputStream dis) throws IOException
|
public GossipDigestAck2Message deserialize(DataInputStream dis) throws IOException
|
||||||
{
|
{
|
||||||
Map<InetAddress, EndpointState> epStateMap = EndPointStatesSerializationHelper.deserialize(dis);
|
Map<InetAddress, EndpointState> epStateMap = EndpointStatesSerializationHelper.deserialize(dis);
|
||||||
return new GossipDigestAck2Message(epStateMap);
|
return new GossipDigestAck2Message(epStateMap);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -73,10 +73,10 @@ class GossipDigestAckMessageSerializer implements ICompactSerializer<GossipDiges
|
||||||
/* Use the helper to serialize the GossipDigestList */
|
/* Use the helper to serialize the GossipDigestList */
|
||||||
boolean bContinue = GossipDigestSerializationHelper.serialize(gDigestAckMessage.gDigestList_, dos);
|
boolean bContinue = GossipDigestSerializationHelper.serialize(gDigestAckMessage.gDigestList_, dos);
|
||||||
dos.writeBoolean(bContinue);
|
dos.writeBoolean(bContinue);
|
||||||
/* Use the EndPointState */
|
/* Use the EndpointState */
|
||||||
if ( bContinue )
|
if ( bContinue )
|
||||||
{
|
{
|
||||||
EndPointStatesSerializationHelper.serialize(gDigestAckMessage.epStateMap_, dos);
|
EndpointStatesSerializationHelper.serialize(gDigestAckMessage.epStateMap_, dos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -88,7 +88,7 @@ class GossipDigestAckMessageSerializer implements ICompactSerializer<GossipDiges
|
||||||
|
|
||||||
if ( bContinue )
|
if ( bContinue )
|
||||||
{
|
{
|
||||||
epStateMap = EndPointStatesSerializationHelper.deserialize(dis);
|
epStateMap = EndpointStatesSerializationHelper.deserialize(dis);
|
||||||
}
|
}
|
||||||
return new GossipDigestAckMessage(gDigestList, epStateMap);
|
return new GossipDigestAckMessage(gDigestList, epStateMap);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -112,9 +112,9 @@ class GossipDigestSerializationHelper
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class EndPointStatesSerializationHelper
|
class EndpointStatesSerializationHelper
|
||||||
{
|
{
|
||||||
private static final Logger logger_ = LoggerFactory.getLogger(EndPointStatesSerializationHelper.class);
|
private static final Logger logger_ = LoggerFactory.getLogger(EndpointStatesSerializationHelper.class);
|
||||||
|
|
||||||
static boolean serialize(Map<InetAddress, EndpointState> epStateMap, DataOutputStream dos) throws IOException
|
static boolean serialize(Map<InetAddress, EndpointState> epStateMap, DataOutputStream dos) throws IOException
|
||||||
{
|
{
|
||||||
|
|
@ -151,7 +151,7 @@ class EndPointStatesSerializationHelper
|
||||||
{
|
{
|
||||||
if ( dis.available() == 0 )
|
if ( dis.available() == 0 )
|
||||||
{
|
{
|
||||||
logger_.info("Remaining bytes zero. Stopping deserialization in EndPointState.");
|
logger_.info("Remaining bytes zero. Stopping deserialization in EndpointState.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// int length = dis.readInt();
|
// int length = dis.readInt();
|
||||||
|
|
|
||||||
|
|
@ -111,7 +111,7 @@ public class Gossiper implements IFailureDetectionEventListener, IEndpointStateC
|
||||||
private long FatClientTimeout_;
|
private long FatClientTimeout_;
|
||||||
private Random random_ = new Random();
|
private Random random_ = new Random();
|
||||||
|
|
||||||
/* subscribers for interest in EndPointState change */
|
/* subscribers for interest in EndpointState change */
|
||||||
private List<IEndpointStateChangeSubscriber> subscribers_ = new ArrayList<IEndpointStateChangeSubscriber>();
|
private List<IEndpointStateChangeSubscriber> subscribers_ = new ArrayList<IEndpointStateChangeSubscriber>();
|
||||||
|
|
||||||
/* live member set */
|
/* live member set */
|
||||||
|
|
@ -143,7 +143,7 @@ public class Gossiper implements IFailureDetectionEventListener, IEndpointStateC
|
||||||
FailureDetector.instance.registerFailureDetectionEventListener(this);
|
FailureDetector.instance.registerFailureDetectionEventListener(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Register with the Gossiper for EndPointState notifications */
|
/** Register with the Gossiper for EndpointState notifications */
|
||||||
public synchronized void register(IEndpointStateChangeSubscriber subscriber)
|
public synchronized void register(IEndpointStateChangeSubscriber subscriber)
|
||||||
{
|
{
|
||||||
subscribers_.add(subscriber);
|
subscribers_.add(subscriber);
|
||||||
|
|
@ -577,7 +577,7 @@ public class Gossiper implements IFailureDetectionEventListener, IEndpointStateC
|
||||||
* immediately mark it alive.
|
* immediately mark it alive.
|
||||||
*
|
*
|
||||||
* @param ep endpoint
|
* @param ep endpoint
|
||||||
* @param epState EndPointState for the endpoint
|
* @param epState EndpointState for the endpoint
|
||||||
* @param isKnownNode is this node familiar to us already (present in endpointStateMap)
|
* @param isKnownNode is this node familiar to us already (present in endpointStateMap)
|
||||||
*/
|
*/
|
||||||
private void handleMajorStateChange(InetAddress ep, EndpointState epState, boolean isKnownNode)
|
private void handleMajorStateChange(InetAddress ep, EndpointState epState, boolean isKnownNode)
|
||||||
|
|
@ -914,7 +914,7 @@ public class Gossiper implements IFailureDetectionEventListener, IEndpointStateC
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* These digests have their maxVersion set to the difference of the version
|
* These digests have their maxVersion set to the difference of the version
|
||||||
* of the local EndPointState and the version found in the GossipDigest.
|
* of the local EndpointState and the version found in the GossipDigest.
|
||||||
*/
|
*/
|
||||||
List<GossipDigest> diffDigests = new ArrayList<GossipDigest>();
|
List<GossipDigest> diffDigests = new ArrayList<GossipDigest>();
|
||||||
for ( GossipDigest gDigest : gDigestList )
|
for ( GossipDigest gDigest : gDigestList )
|
||||||
|
|
|
||||||
|
|
@ -27,13 +27,13 @@ public interface IEndpointStateChangePublisher
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Register for interesting state changes.
|
* Register for interesting state changes.
|
||||||
* @param subcriber module which implements the IEndPointStateChangeSubscriber
|
* @param subcriber module which implements the IEndpointStateChangeSubscriber
|
||||||
*/
|
*/
|
||||||
public void register(IEndpointStateChangeSubscriber subcriber);
|
public void register(IEndpointStateChangeSubscriber subcriber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregister interest for state changes.
|
* Unregister interest for state changes.
|
||||||
* @param subcriber module which implements the IEndPointStateChangeSubscriber
|
* @param subcriber module which implements the IEndpointStateChangeSubscriber
|
||||||
*/
|
*/
|
||||||
public void unregister(IEndpointStateChangeSubscriber subcriber);
|
public void unregister(IEndpointStateChangeSubscriber subcriber);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ package org.apache.cassandra.gms;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called by an instance of the IEndPointStateChangePublisher to notify
|
* This is called by an instance of the IEndpointStateChangePublisher to notify
|
||||||
* interested parties about changes in the the state associated with any endpoint.
|
* interested parties about changes in the the state associated with any endpoint.
|
||||||
* For instance if node A figures there is a changes in state for an endpoint B
|
* For instance if node A figures there is a changes in state for an endpoint B
|
||||||
* it notifies all interested parties of this change. It is upto to the registered
|
* it notifies all interested parties of this change. It is upto to the registered
|
||||||
|
|
|
||||||
|
|
@ -34,17 +34,17 @@ import org.apache.cassandra.utils.XMLUtils;
|
||||||
import org.xml.sax.SAXException;
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* DataCenterEndPointSnitch
|
* DataCenterEndpointSnitch
|
||||||
* <p/>
|
* <p/>
|
||||||
* This class basically reads the configuration and sets the IP Ranges to a
|
* This class basically reads the configuration and sets the IP Ranges to a
|
||||||
* hashMap which can be read later. this class also provides a way to compare 2
|
* hashMap which can be read later. this class also provides a way to compare 2
|
||||||
* EndPoints and also get details from the same.
|
* Endpoints and also get details from the same.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class DatacenterEndpointSnitch extends AbstractEndpointSnitch
|
public class DatacenterEndpointSnitch extends AbstractEndpointSnitch
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* This Map will contain the information of the EndPoints and its Location
|
* This Map will contain the information of the Endpoints and its Location
|
||||||
* (Datacenter and RAC)
|
* (Datacenter and RAC)
|
||||||
*/
|
*/
|
||||||
private Map<Byte, Map<Byte, String>> ipDC = new HashMap<Byte, Map<Byte, String>>();
|
private Map<Byte, Map<Byte, String>> ipDC = new HashMap<Byte, Map<Byte, String>>();
|
||||||
|
|
|
||||||
|
|
@ -38,7 +38,7 @@ import org.apache.cassandra.thrift.ConsistencyLevel;
|
||||||
* other Datacenter.... For example if we have 5 nodes this stategy will make
|
* other Datacenter.... For example if we have 5 nodes this stategy will make
|
||||||
* sure to make 2 copies out of 5 in other dataceneter.
|
* sure to make 2 copies out of 5 in other dataceneter.
|
||||||
* <p/>
|
* <p/>
|
||||||
* This class also caches the EndPoints and invalidates the cache if there is a
|
* This class also caches the Endpoints and invalidates the cache if there is a
|
||||||
* change in the number of tokens.
|
* change in the number of tokens.
|
||||||
*/
|
*/
|
||||||
public class DatacenterShardStategy extends AbstractReplicationStrategy
|
public class DatacenterShardStategy extends AbstractReplicationStrategy
|
||||||
|
|
@ -62,8 +62,8 @@ public class DatacenterShardStategy extends AbstractReplicationStrategy
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This Method will get the required information of the EndPoint from the
|
* This Method will get the required information of the Endpoint from the
|
||||||
* DataCenterEndPointSnitch and poopulates this singleton class.
|
* DataCenterEndpointSnitch and poopulates this singleton class.
|
||||||
*/
|
*/
|
||||||
private synchronized void loadEndpoints(TokenMetadata metadata) throws IOException
|
private synchronized void loadEndpoints(TokenMetadata metadata) throws IOException
|
||||||
{
|
{
|
||||||
|
|
@ -111,7 +111,7 @@ public class DatacenterShardStategy extends AbstractReplicationStrategy
|
||||||
super(tokenMetadata, snitch);
|
super(tokenMetadata, snitch);
|
||||||
if ((!(snitch instanceof DatacenterEndpointSnitch)))
|
if ((!(snitch instanceof DatacenterEndpointSnitch)))
|
||||||
{
|
{
|
||||||
throw new IllegalArgumentException("DatacenterShardStrategy requires DatacenterEndPointSnitch");
|
throw new IllegalArgumentException("DatacenterShardStrategy requires DatacenterEndpointSnitch");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ public class RackAwareStrategy extends AbstractReplicationStrategy
|
||||||
{
|
{
|
||||||
super(tokenMetadata, snitch);
|
super(tokenMetadata, snitch);
|
||||||
if (!(snitch instanceof EndpointSnitch))
|
if (!(snitch instanceof EndpointSnitch))
|
||||||
throw new IllegalArgumentException(("RackAwareStrategy requires EndPointSnitch."));
|
throw new IllegalArgumentException(("RackAwareStrategy requires EndpointSnitch."));
|
||||||
}
|
}
|
||||||
|
|
||||||
public ArrayList<InetAddress> getNaturalEndpoints(Token token, TokenMetadata metadata, String table)
|
public ArrayList<InetAddress> getNaturalEndpoints(Token token, TokenMetadata metadata, String table)
|
||||||
|
|
|
||||||
|
|
@ -58,13 +58,13 @@
|
||||||
<ColumnFamily ColumnType="Super" CompareSubcolumnsWith="TimeUUIDType" Name="Super4"/>
|
<ColumnFamily ColumnType="Super" CompareSubcolumnsWith="TimeUUIDType" Name="Super4"/>
|
||||||
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
|
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
|
||||||
<ReplicationFactor>1</ReplicationFactor>
|
<ReplicationFactor>1</ReplicationFactor>
|
||||||
<EndpointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndpointSnitch>
|
<EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
|
||||||
</Keyspace>
|
</Keyspace>
|
||||||
<Keyspace Name = "Keyspace3">
|
<Keyspace Name = "Keyspace3">
|
||||||
<ColumnFamily Name="Standard1"/>
|
<ColumnFamily Name="Standard1"/>
|
||||||
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
|
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
|
||||||
<ReplicationFactor>5</ReplicationFactor>
|
<ReplicationFactor>5</ReplicationFactor>
|
||||||
<EndpointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndpointSnitch>
|
<EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
|
||||||
</Keyspace>
|
</Keyspace>
|
||||||
<Keyspace Name = "Keyspace4">
|
<Keyspace Name = "Keyspace4">
|
||||||
<ColumnFamily Name="Standard1"/>
|
<ColumnFamily Name="Standard1"/>
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
<ColumnFamily ColumnType="Super" CompareSubcolumnsWith="TimeUUIDType" Name="Super4"/>
|
<ColumnFamily ColumnType="Super" CompareSubcolumnsWith="TimeUUIDType" Name="Super4"/>
|
||||||
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
|
<ReplicaPlacementStrategy>org.apache.cassandra.locator.RackUnawareStrategy</ReplicaPlacementStrategy>
|
||||||
<ReplicationFactor>3</ReplicationFactor>
|
<ReplicationFactor>3</ReplicationFactor>
|
||||||
<EndpointSnitch>org.apache.cassandra.locator.EndPointSnitch</EndpointSnitch>
|
<EndpointSnitch>org.apache.cassandra.locator.EndpointSnitch</EndpointSnitch>
|
||||||
</Keyspace>
|
</Keyspace>
|
||||||
</Keyspaces>
|
</Keyspaces>
|
||||||
<Seeds>
|
<Seeds>
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ class ThriftTester(BaseTester):
|
||||||
self.client.transport.close()
|
self.client.transport.close()
|
||||||
|
|
||||||
def define_schema(self):
|
def define_schema(self):
|
||||||
keyspace1 = Cassandra.KsDef('Keyspace1', 'org.apache.cassandra.locator.RackUnawareStrategy', 1, 'org.apache.cassandra.locator.EndPointSnitch',
|
keyspace1 = Cassandra.KsDef('Keyspace1', 'org.apache.cassandra.locator.RackUnawareStrategy', 1, 'org.apache.cassandra.locator.EndpointSnitch',
|
||||||
[
|
[
|
||||||
Cassandra.CfDef('Keyspace1', 'Standard1'),
|
Cassandra.CfDef('Keyspace1', 'Standard1'),
|
||||||
Cassandra.CfDef('Keyspace1', 'Standard2'),
|
Cassandra.CfDef('Keyspace1', 'Standard2'),
|
||||||
|
|
@ -154,7 +154,7 @@ class ThriftTester(BaseTester):
|
||||||
Cassandra.CfDef('Keyspace1', 'Super4', column_type='Super', subcomparator_type='UTF8Type')
|
Cassandra.CfDef('Keyspace1', 'Super4', column_type='Super', subcomparator_type='UTF8Type')
|
||||||
])
|
])
|
||||||
|
|
||||||
keyspace2 = Cassandra.KsDef('Keyspace2', 'org.apache.cassandra.locator.RackUnawareStrategy', 1, 'org.apache.cassandra.locator.EndPointSnitch',
|
keyspace2 = Cassandra.KsDef('Keyspace2', 'org.apache.cassandra.locator.RackUnawareStrategy', 1, 'org.apache.cassandra.locator.EndpointSnitch',
|
||||||
[
|
[
|
||||||
Cassandra.CfDef('Keyspace2', 'Standard1'),
|
Cassandra.CfDef('Keyspace2', 'Standard1'),
|
||||||
Cassandra.CfDef('Keyspace2', 'Standard3'),
|
Cassandra.CfDef('Keyspace2', 'Standard3'),
|
||||||
|
|
@ -162,12 +162,12 @@ class ThriftTester(BaseTester):
|
||||||
Cassandra.CfDef('Keyspace2', 'Super4', column_type='Super', subcomparator_type='TimeUUIDType'),
|
Cassandra.CfDef('Keyspace2', 'Super4', column_type='Super', subcomparator_type='TimeUUIDType'),
|
||||||
])
|
])
|
||||||
|
|
||||||
keyspace3 = Cassandra.KsDef('Keyspace3', 'org.apache.cassandra.locator.RackUnawareStrategy', 5, 'org.apache.cassandra.locator.EndPointSnitch',
|
keyspace3 = Cassandra.KsDef('Keyspace3', 'org.apache.cassandra.locator.RackUnawareStrategy', 5, 'org.apache.cassandra.locator.EndpointSnitch',
|
||||||
[
|
[
|
||||||
Cassandra.CfDef('Keyspace3', 'Standard1'),
|
Cassandra.CfDef('Keyspace3', 'Standard1'),
|
||||||
])
|
])
|
||||||
|
|
||||||
keyspace4 = Cassandra.KsDef('Keyspace4', 'org.apache.cassandra.locator.RackUnawareStrategy', 3, 'org.apache.cassandra.locator.EndPointSnitch',
|
keyspace4 = Cassandra.KsDef('Keyspace4', 'org.apache.cassandra.locator.RackUnawareStrategy', 3, 'org.apache.cassandra.locator.EndpointSnitch',
|
||||||
[
|
[
|
||||||
Cassandra.CfDef('Keyspace4', 'Standard1'),
|
Cassandra.CfDef('Keyspace4', 'Standard1'),
|
||||||
Cassandra.CfDef('Keyspace4', 'Standard3'),
|
Cassandra.CfDef('Keyspace4', 'Standard3'),
|
||||||
|
|
|
||||||
|
|
@ -949,7 +949,7 @@ class TestMutations(ThriftTester):
|
||||||
def test_system_keyspace_operations(self):
|
def test_system_keyspace_operations(self):
|
||||||
""" Test keyspace (add, drop, rename) operations """
|
""" Test keyspace (add, drop, rename) operations """
|
||||||
# create
|
# create
|
||||||
keyspace = KsDef('CreateKeyspace', 'org.apache.cassandra.locator.RackUnawareStrategy', 1, 'org.apache.cassandra.locator.EndPointSnitch',
|
keyspace = KsDef('CreateKeyspace', 'org.apache.cassandra.locator.RackUnawareStrategy', 1, 'org.apache.cassandra.locator.EndpointSnitch',
|
||||||
[
|
[
|
||||||
CfDef('CreateKeyspace', 'CreateKsCf')
|
CfDef('CreateKeyspace', 'CreateKsCf')
|
||||||
])
|
])
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue