Class GcpDiscoveryStrategyFactory

All Implemented Interfaces:

public class GcpDiscoveryStrategyFactory
extends Object
implements DiscoveryStrategyFactory
Factory class which returns GcpDiscoveryStrategy to Discovery SPI.
  • Constructor Details

    • GcpDiscoveryStrategyFactory

      public GcpDiscoveryStrategyFactory()
  • Method Details

    • getDiscoveryStrategyType

      public Class<? extends DiscoveryStrategy> getDiscoveryStrategyType()
      Description copied from interface: DiscoveryStrategyFactory
      Returns the type of the DiscoveryStrategy itself.
      Specified by:
      getDiscoveryStrategyType in interface DiscoveryStrategyFactory
      the type of the discovery strategy
    • newDiscoveryStrategy

      public DiscoveryStrategy newDiscoveryStrategy​(DiscoveryNode discoveryNode, ILogger logger, Map<String,​Comparable> properties)
      Description copied from interface: DiscoveryStrategyFactory
      Instantiates a new instance of the 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.
      Specified by:
      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 instance
      properties - the properties parsed from the configuration
      a new instance of the discovery strategy
    • getConfigurationProperties

      public 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 interface DiscoveryStrategyFactory
      a set of expected configuration properties
    • isAutoDetectionApplicable

      public 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 "" which will resolve to a local, non-routable address 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:
      isAutoDetectionApplicable in interface DiscoveryStrategyFactory
      true if running on GCP Instance which has a service account attached
      See Also:
      GCP Managing Instances
    • discoveryStrategyLevel

      public DiscoveryStrategyFactory.DiscoveryStrategyLevel discoveryStrategyLevel()
      Description copied from interface: DiscoveryStrategyFactory
      Level of the discovery strategy.
      Specified by:
      discoveryStrategyLevel in interface DiscoveryStrategyFactory