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
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 property
Ec2MetadataServiceConnector.EC2_METADATA_TYPE_PROPERTY and
can be of value either 'v1' or 'v2'.
It is possible to specify custom URL of IMDS by Ec2MetadataServiceConnector.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 is Ec2MetadataServiceConnector.V2Connector.AWS_EC2_METADATA_TOKEN_TTL_SECONDS_HEADER_PROPERTY
which is by default set to Ec2MetadataServiceConnector.V2Connector.MAX_TOKEN_TIME_IN_SECONDS. TTL has
to be an integer from the range [30, 21600].-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final org.apache.cassandra.locator.AbstractCloudMetadataServiceConnectorstatic final String -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfinal StringgetDatacenter(InetAddressAndPort endpoint) Return the data center for which an endpoint resides infinal Stringreturns a String representing the datacenter current endpoint belongs tofinal Stringreturns a String representing the rack current endpoint belongs tofinal StringgetRack(InetAddressAndPort endpoint) Return the rack for which an endpoint resides inbooleanDetermine 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
compareEndpointsMethods inherited from class org.apache.cassandra.locator.AbstractEndpointSnitch
gossiperStarting, isWorthMergingForRangeQuery, sortedByProximityMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.apache.cassandra.locator.IEndpointSnitch
getDatacenter, getDatacenter
-
Field Details
-
ZONE_NAME_QUERY
- See Also:
-
connector
protected final org.apache.cassandra.locator.AbstractCloudMetadataServiceConnector connector
-
-
Constructor Details
-
Ec2Snitch
- Throws:
IOExceptionConfigurationException
-
Ec2Snitch
- Throws:
IOExceptionConfigurationException
-
-
Method Details
-
validate
Description copied from interface:IEndpointSnitchDetermine if the datacenter or rack values in the current node's snitch conflict with those passed in parameters. -
getLocalRack
Description copied from interface:IEndpointSnitchreturns a String representing the rack current endpoint belongs to -
getLocalDatacenter
Description copied from interface:IEndpointSnitchreturns a String representing the datacenter current endpoint belongs to -
getRack
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
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
-