Package org.apache.cassandra.locator
Class Ec2Snitch
- java.lang.Object
-
- org.apache.cassandra.locator.AbstractEndpointSnitch
-
- org.apache.cassandra.locator.AbstractNetworkTopologySnitch
-
- org.apache.cassandra.locator.Ec2Snitch
-
- All Implemented Interfaces:
IEndpointSnitch
- Direct Known Subclasses:
Ec2MultiRegionSnitch
public class Ec2Snitch extends AbstractNetworkTopologySnitch
A snitch that assumes an EC2 region is a DC and an EC2 availability_zone is a rack. This information is available in the config for the node. Since CASSANDRA-16555, it is possible to choose version of AWS IMDS. By default, since CASSANDRA-16555, IMDSv2 is used. The version of IMDS is driven by propertyEc2MetadataServiceConnector.EC2_METADATA_TYPE_PROPERTY
and can be of value either 'v1' or 'v2'. It is possible to specify custom URL of IMDS byEc2MetadataServiceConnector.EC2_METADATA_URL_PROPERTY
. A user is not meant to change this under normal circumstances, it is suitable for testing only. IMDSv2 is secured by a token which needs to be fetched from IDMSv2 first, and it has to be passed in a header for the actual queries to IDMSv2. Ec2Snitch is doing this automatically. The only configuration parameter exposed to a user isEc2MetadataServiceConnector.V2Connector.AWS_EC2_METADATA_TOKEN_TTL_SECONDS_HEADER_PROPERTY
which is by default set toEc2MetadataServiceConnector.V2Connector.MAX_TOKEN_TIME_IN_SECONDS
. TTL has to be an integer from the range [30, 21600].
-
-
Field Summary
Fields Modifier and Type Field Description protected org.apache.cassandra.locator.AbstractCloudMetadataServiceConnector
connector
static java.lang.String
ZONE_NAME_QUERY
-
Constructor Summary
Constructors Constructor Description Ec2Snitch()
Ec2Snitch(SnitchProperties props)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String
getDatacenter(InetAddressAndPort endpoint)
Return the data center for which an endpoint resides injava.lang.String
getLocalDatacenter()
returns a String representing the datacenter current endpoint belongs tojava.lang.String
getLocalRack()
returns a String representing the rack current endpoint belongs tojava.lang.String
getRack(InetAddressAndPort endpoint)
Return the rack for which an endpoint resides inboolean
validate(java.util.Set<java.lang.String> datacenters, java.util.Set<java.lang.String> racks)
Determine if the datacenter or rack values in the current node's snitch conflict with those passed in parameters.-
Methods inherited from class org.apache.cassandra.locator.AbstractNetworkTopologySnitch
compareEndpoints
-
Methods inherited from class org.apache.cassandra.locator.AbstractEndpointSnitch
gossiperStarting, isWorthMergingForRangeQuery, sortedByProximity
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.cassandra.locator.IEndpointSnitch
getDatacenter, getDatacenter
-
-
-
-
Field Detail
-
ZONE_NAME_QUERY
public static final java.lang.String ZONE_NAME_QUERY
- See Also:
- Constant Field Values
-
connector
protected final org.apache.cassandra.locator.AbstractCloudMetadataServiceConnector connector
-
-
Constructor Detail
-
Ec2Snitch
public Ec2Snitch() throws java.io.IOException, ConfigurationException
- Throws:
java.io.IOException
ConfigurationException
-
Ec2Snitch
public Ec2Snitch(SnitchProperties props) throws java.io.IOException, ConfigurationException
- Throws:
java.io.IOException
ConfigurationException
-
-
Method Detail
-
validate
public boolean validate(java.util.Set<java.lang.String> datacenters, java.util.Set<java.lang.String> racks)
Description copied from interface:IEndpointSnitch
Determine if the datacenter or rack values in the current node's snitch conflict with those passed in parameters.
-
getLocalRack
public final java.lang.String getLocalRack()
Description copied from interface:IEndpointSnitch
returns a String representing the rack current endpoint belongs to
-
getLocalDatacenter
public final java.lang.String getLocalDatacenter()
Description copied from interface:IEndpointSnitch
returns a String representing the datacenter current endpoint belongs to
-
getRack
public final java.lang.String getRack(InetAddressAndPort endpoint)
Description copied from class:AbstractNetworkTopologySnitch
Return the rack for which an endpoint resides in- Specified by:
getRack
in interfaceIEndpointSnitch
- Specified by:
getRack
in classAbstractNetworkTopologySnitch
- Parameters:
endpoint
- a specified endpoint- Returns:
- string of rack
-
getDatacenter
public final java.lang.String getDatacenter(InetAddressAndPort endpoint)
Description copied from class:AbstractNetworkTopologySnitch
Return the data center for which an endpoint resides in- Specified by:
getDatacenter
in interfaceIEndpointSnitch
- Specified by:
getDatacenter
in classAbstractNetworkTopologySnitch
- Parameters:
endpoint
- a specified endpoint- Returns:
- string of data center
-
-