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_PROPERTYand 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_PROPERTYwhich 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.Ec2MetadataServiceConnectorconnectorprotected static org.slf4j.Loggerloggerstatic java.lang.StringZONE_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.StringgetDatacenter(InetAddressAndPort endpoint)Return the data center for which an endpoint resides injava.lang.StringgetRack(InetAddressAndPort endpoint)Return the rack for which an endpoint resides inbooleanvalidate(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, getLocalDatacenter, getLocalRack
-
-
-
-
Field Detail
-
logger
protected static final org.slf4j.Logger logger
-
ZONE_NAME_QUERY
public static final java.lang.String ZONE_NAME_QUERY
- See Also:
- Constant Field Values
-
connector
protected final org.apache.cassandra.locator.Ec2MetadataServiceConnector connector
-
-
Constructor Detail
-
Ec2Snitch
public Ec2Snitch() throws java.io.IOException, ConfigurationException- Throws:
java.io.IOExceptionConfigurationException
-
Ec2Snitch
public Ec2Snitch(SnitchProperties props) throws java.io.IOException, ConfigurationException
- Throws:
java.io.IOExceptionConfigurationException
-
-
Method Detail
-
getRack
public java.lang.String getRack(InetAddressAndPort endpoint)
Description copied from class:AbstractNetworkTopologySnitchReturn the rack for which an endpoint resides in- Specified by:
getRackin interfaceIEndpointSnitch- Specified by:
getRackin classAbstractNetworkTopologySnitch- Parameters:
endpoint- a specified endpoint- Returns:
- string of rack
-
getDatacenter
public java.lang.String getDatacenter(InetAddressAndPort endpoint)
Description copied from class:AbstractNetworkTopologySnitchReturn the data center for which an endpoint resides in- Specified by:
getDatacenterin interfaceIEndpointSnitch- Specified by:
getDatacenterin classAbstractNetworkTopologySnitch- Parameters:
endpoint- a specified endpoint- Returns:
- string of data center
-
validate
public boolean validate(java.util.Set<java.lang.String> datacenters, java.util.Set<java.lang.String> racks)Description copied from interface:IEndpointSnitchDetermine if the datacenter or rack values in the current node's snitch conflict with those passed in parameters.
-
-