- All Implemented Interfaces:
public class AwsDiscoveryStrategyFactory extends Object implements DiscoveryStrategyFactory
AwsDiscoveryStrategyto Discovery SPI
Nested Class Summary
Constructors Constructor Description
Modifier and Type Method Description
()Level of the discovery strategy.
()Returns a set of the expected configuration properties.
Class<? extends DiscoveryStrategy>
()Returns the type of the
()Checks if Hazelcast is running on an AWS EC2 instance.
DiscoveryNode discoveryNode, ILogger logger, Map<String,Comparable> properties)(Instantiates a new instance of the
DiscoveryStrategywith the given configuration properties.
getDiscoveryStrategyTypeReturns the type of the
newDiscoveryStrategypublic DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode, ILogger logger, Map<String,Comparable> properties)Instantiates a new instance of the
DiscoveryStrategywith the given configuration properties. The provided
HazelcastInstancecan be used to register instances in a service registry whenever the discovery strategy is started.
- Specified by:
discoveryNode- the current local
DiscoveryNode, representing the local connection information if running on a Hazelcast member, otherwise on Hazelcast clients always
logger- the logger instance
properties- the properties parsed from the configuration
- a new instance of the discovery strategy
getConfigurationPropertiesReturns a set of the expected configuration properties. These properties contain information about the value type of the property, if it is required and a possible validator to automatically test and convert values from the XML configuration.
isAutoDetectionApplicablepublic boolean isAutoDetectionApplicable()Checks if Hazelcast is running on an AWS EC2 instance.
Note that this method returns
falsefor any ECS environment, since currently there is no way to auto-configure Hazelcast network interfaces (required for ECS).
To check if Hazelcast is running on EC2, we first check that the machine uuid starts with "ec2" or "EC2". There is a small chance that a non-AWS machine has uuid starting with the mentioned prefix. That is why, to be sure, we make an API call to a local, non-routable address http://169.254.169.254/latest/dynamic/instance-identity/. Finally, we also check if an IAM Role is attached to the EC2 instance, because without any IAM Role the Hazelcast AWS discovery won't work.
discoveryStrategyLevelpublic DiscoveryStrategyFactory.DiscoveryStrategyLevel discoveryStrategyLevel()Level of the discovery strategy.