Class AzureDiscoveryStrategyFactory

    • Constructor Detail

      • AzureDiscoveryStrategyFactory

        public AzureDiscoveryStrategyFactory()
    • Method Detail

      • newDiscoveryStrategy

        public DiscoveryStrategy newDiscoveryStrategy​(DiscoveryNode node,
                                                      ILogger logger,
                                                      java.util.Map<java.lang.String,​java.lang.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
        Parameters:
        node - 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
      • 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 interface DiscoveryStrategyFactory
        Returns:
        a set of expected configuration properties
      • isAutoDetectionApplicable

        public boolean isAutoDetectionApplicable()
        Checks if Hazelcast is running on Azure.

        To check if Hazelcast is running on Azure, we first check whether "internal.cloudapp.net" is present in the file "/etc/resolv.conf". Such an approach is not officially documented but seems like a good enough heuristic to detect an Azure Compute VM Instance. Since it's not the official method, we still need to make an API call to a local, non-routable address http://169.254.169.254/metadata/instance.

        Specified by:
        isAutoDetectionApplicable in interface DiscoveryStrategyFactory
        Returns:
        true if running on Azure Instance
        See Also:
        Azure Instance Metadata API