Package com.hazelcast.aws
Class AwsDiscoveryStrategyFactory
- java.lang.Object
-
- com.hazelcast.aws.AwsDiscoveryStrategyFactory
-
- All Implemented Interfaces:
DiscoveryStrategyFactory
public class AwsDiscoveryStrategyFactory extends java.lang.Object implements DiscoveryStrategyFactory
Factory class which returnsAwsDiscoveryStrategy
to Discovery SPI
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface com.hazelcast.spi.discovery.DiscoveryStrategyFactory
DiscoveryStrategyFactory.DiscoveryStrategyLevel
-
-
Constructor Summary
Constructors Constructor Description AwsDiscoveryStrategyFactory()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description DiscoveryStrategyFactory.DiscoveryStrategyLevel
discoveryStrategyLevel()
Level of the discovery strategy.java.util.Collection<PropertyDefinition>
getConfigurationProperties()
Returns a set of the expected configuration properties.java.lang.Class<? extends DiscoveryStrategy>
getDiscoveryStrategyType()
Returns the type of theDiscoveryStrategy
itself.boolean
isAutoDetectionApplicable()
Checks if Hazelcast is running on an AWS EC2 instance.DiscoveryStrategy
newDiscoveryStrategy(DiscoveryNode discoveryNode, ILogger logger, java.util.Map<java.lang.String,java.lang.Comparable> properties)
Instantiates a new instance of theDiscoveryStrategy
with the given configuration properties.
-
-
-
Method Detail
-
getDiscoveryStrategyType
public java.lang.Class<? extends DiscoveryStrategy> getDiscoveryStrategyType()
Description copied from interface:DiscoveryStrategyFactory
Returns the type of theDiscoveryStrategy
itself.- Specified by:
getDiscoveryStrategyType
in interfaceDiscoveryStrategyFactory
- Returns:
- the type of the discovery strategy
-
newDiscoveryStrategy
public DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode, ILogger logger, java.util.Map<java.lang.String,java.lang.Comparable> properties)
Description copied from interface:DiscoveryStrategyFactory
Instantiates a new instance of theDiscoveryStrategy
with the given configuration properties. The providedHazelcastInstance
can be used to register instances in a service registry whenever the discovery strategy is started.- Specified by:
newDiscoveryStrategy
in interfaceDiscoveryStrategyFactory
- Parameters:
discoveryNode
- the current localDiscoveryNode
, representing the local connection information if running on a Hazelcast member, otherwise on Hazelcast clients alwaysnull
logger
- the logger instanceproperties
- the properties parsed from the configuration- Returns:
- a new instance of the discovery strategy
-
getConfigurationProperties
public java.util.Collection<PropertyDefinition> getConfigurationProperties()
Description copied from interface:DiscoveryStrategyFactory
Returns 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.- Specified by:
getConfigurationProperties
in interfaceDiscoveryStrategyFactory
- Returns:
- a set of expected configuration properties
-
isAutoDetectionApplicable
public boolean isAutoDetectionApplicable()
Checks if Hazelcast is running on an AWS EC2 instance.Note that this method returns
false
for 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.
- Specified by:
isAutoDetectionApplicable
in interfaceDiscoveryStrategyFactory
- Returns:
- true if running on EC2 Instance which has an IAM Role attached
- See Also:
-
discoveryStrategyLevel
public DiscoveryStrategyFactory.DiscoveryStrategyLevel discoveryStrategyLevel()
Description copied from interface:DiscoveryStrategyFactory
Level of the discovery strategy.- Specified by:
discoveryStrategyLevel
in interfaceDiscoveryStrategyFactory
-
-