public class GcpDiscoveryStrategyFactory extends Object implements DiscoveryStrategyFactory
GcpDiscoveryStrategy
to Discovery SPI.DiscoveryStrategyFactory.DiscoveryStrategyLevel
Constructor and Description |
---|
GcpDiscoveryStrategyFactory() |
Modifier and Type | Method and Description |
---|---|
DiscoveryStrategyFactory.DiscoveryStrategyLevel |
discoveryStrategyLevel()
Level of the discovery strategy.
|
Collection<PropertyDefinition> |
getConfigurationProperties()
Returns a set of the expected configuration properties.
|
Class<? extends DiscoveryStrategy> |
getDiscoveryStrategyType()
Returns the type of the
DiscoveryStrategy itself. |
boolean |
isAutoDetectionApplicable()
Checks if Hazelcast is running on GCP.
|
DiscoveryStrategy |
newDiscoveryStrategy(DiscoveryNode discoveryNode,
ILogger logger,
Map<String,Comparable> properties)
Instantiates a new instance of the
DiscoveryStrategy with the given configuration
properties. |
public Class<? extends DiscoveryStrategy> getDiscoveryStrategyType()
DiscoveryStrategyFactory
DiscoveryStrategy
itself.getDiscoveryStrategyType
in interface DiscoveryStrategyFactory
public DiscoveryStrategy newDiscoveryStrategy(DiscoveryNode discoveryNode, ILogger logger, Map<String,Comparable> properties)
DiscoveryStrategyFactory
DiscoveryStrategy
with the given configuration
properties. The provided HazelcastInstance
can be used to register instances in
a service registry whenever the discovery strategy is started.newDiscoveryStrategy
in interface DiscoveryStrategyFactory
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 instanceproperties
- the properties parsed from the configurationpublic Collection<PropertyDefinition> getConfigurationProperties()
DiscoveryStrategyFactory
getConfigurationProperties
in interface DiscoveryStrategyFactory
public boolean isAutoDetectionApplicable()
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.
isAutoDetectionApplicable
in interface DiscoveryStrategyFactory
public DiscoveryStrategyFactory.DiscoveryStrategyLevel discoveryStrategyLevel()
DiscoveryStrategyFactory
discoveryStrategyLevel
in interface DiscoveryStrategyFactory
Copyright © 2021 Hazelcast, Inc.. All rights reserved.