Package com.hazelcast.gcp
Class GcpDiscoveryStrategyFactory
java.lang.Object
com.hazelcast.gcp.GcpDiscoveryStrategyFactory
- All Implemented Interfaces:
- DiscoveryStrategyFactory
Factory class which returns 
GcpDiscoveryStrategy to Discovery SPI.- 
Nested Class SummaryNested classes/interfaces inherited from interface com.hazelcast.spi.discovery.DiscoveryStrategyFactoryDiscoveryStrategyFactory.DiscoveryStrategyLevel
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionLevel of the discovery strategy.Returns a set of the expected configuration properties.Class<? extends DiscoveryStrategy>Returns the type of theDiscoveryStrategyitself.booleanChecks if Hazelcast is running on GCP.newDiscoveryStrategy(DiscoveryNode discoveryNode, ILogger logger, Map<String, Comparable> properties) Instantiates a new instance of theDiscoveryStrategywith the given configuration properties.
- 
Constructor Details- 
GcpDiscoveryStrategyFactorypublic GcpDiscoveryStrategyFactory()
 
- 
- 
Method Details- 
getDiscoveryStrategyTypeDescription copied from interface:DiscoveryStrategyFactoryReturns the type of theDiscoveryStrategyitself.- Specified by:
- getDiscoveryStrategyTypein interface- DiscoveryStrategyFactory
- Returns:
- the type of the discovery strategy
 
- 
newDiscoveryStrategypublic DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode, ILogger logger, Map<String, Comparable> properties) Description copied from interface:DiscoveryStrategyFactoryInstantiates a new instance of theDiscoveryStrategywith the given configuration properties. The providedHazelcastInstancecan be used to register instances in a service registry whenever the discovery strategy is started.- Specified by:
- newDiscoveryStrategyin interface- DiscoveryStrategyFactory
- Parameters:
- discoveryNode- the current local- DiscoveryNode, representing the local connection information if running on a Hazelcast member, otherwise on Hazelcast clients always- null
- logger- the logger instance
- properties- the properties parsed from the configuration
- Returns:
- a new instance of the discovery strategy
 
- 
getConfigurationPropertiesDescription copied from interface:DiscoveryStrategyFactoryReturns 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:
- getConfigurationPropertiesin interface- DiscoveryStrategyFactory
- Returns:
- a set of expected configuration properties
 
- 
isAutoDetectionApplicablepublic boolean isAutoDetectionApplicable()Checks if Hazelcast is running on GCP.To check if Hazelcast is running on GCP, we first check whether the internal DNS is configured for "google.internal" in either "/etc/resolv.conf" or "/etc/hosts". Such an approach is not officially documented but seems like a good enough heuristic to detect a GCP Compute VM Instance. Since it's not the official method, we still need to make an API call to "metadata.google.internal" which will resolve to a local, non-routable address http://169.254.169.254/. Finally, we check if there is a service account attached for this instance because without a service account Hazelcast GCP discovery will not work. - Specified by:
- isAutoDetectionApplicablein interface- DiscoveryStrategyFactory
- Returns:
- true if running on GCP Instance which has a service account attached
- See Also:
 
- 
discoveryStrategyLevelDescription copied from interface:DiscoveryStrategyFactoryLevel of the discovery strategy.- Specified by:
- discoveryStrategyLevelin interface- DiscoveryStrategyFactory
 
 
-