Class AbstractDiscoveryStrategy
- All Implemented Interfaces:
DiscoveryStrategy
- Direct Known Subclasses:
AwsDiscoveryStrategy,AzureDiscoveryStrategy,GcpDiscoveryStrategy,MulticastDiscoveryStrategy
DiscoveryStrategy implementations,
offering convenient access to configuration properties (which may be overridden
on the system's environment or JVM properties), as well as a ILogger instance.- Since:
- 3.6
-
Constructor Summary
ConstructorsConstructorDescriptionAbstractDiscoveryStrategy(ILogger logger, Map<String, Comparable> properties) -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Thestopmethod is used to stop internal services, sockets or to destroy any kind of internal state.Returns a map with discovered metadata provided by the runtime environment.protected ILoggerReturns aILoggerinstance bound to the current class.protected <T extends Comparable>
TgetOrDefault(PropertyDefinition property, T defaultValue) Returns the value of the requestedPropertyDefinitionif available in the declarative or programmatic configuration (XML or Config API), otherwise it will return the givendefaultValue.protected <T extends Comparable>
TgetOrDefault(String prefix, PropertyDefinition property, T defaultValue) Returns the value of the requestedPropertyDefinitionif available in the declarative or programmatic configuration (XML or Config API), can be found in the system's environment, or passed as a JVM property. otherwise it will return the givendefaultValue.protected <T extends Comparable>
TgetOrNull(PropertyDefinition property) Returns the value of the requestedPropertyDefinitionif available in the declarative or programmatic configuration (XML or Config API), otherwise it will returnnull.protected <T extends Comparable>
TgetOrNull(String prefix, PropertyDefinition property) Returns the value of the requestedPropertyDefinitionif available in the declarative or programmatic configuration (XML or Config API), can be found in the system's environment, or passed as a JVM property.getPartitionGroupStrategy(Collection<? extends Member> allMembers) Returns a custom implementation of aPartitionGroupStrategyto override default behavior of zone aware backup strategiesPartitionGroupMetaDataor to provide a specific behavior in case the discovery environment does not provide information about the infrastructure to be used for automatic configuration.protected Map<String,Comparable> Returns an immutable copy of the configuration properties.voidstart()Thestartmethod is used to initialize internal state and perform any kind of startup procedure like multicast socket creation.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.hazelcast.spi.discovery.DiscoveryStrategy
discoverNodes, getUnhealthyEndpoints, markEndpointAsUnhealthy
-
Constructor Details
-
AbstractDiscoveryStrategy
-
-
Method Details
-
destroy
public void destroy()Description copied from interface:DiscoveryStrategyThestopmethod is used to stop internal services, sockets or to destroy any kind of internal state.- Specified by:
destroyin interfaceDiscoveryStrategy
-
start
public void start()Description copied from interface:DiscoveryStrategyThestartmethod is used to initialize internal state and perform any kind of startup procedure like multicast socket creation. The behavior of this method might change based on theDiscoveryNodeinstance passed to theDiscoveryStrategyFactory.- Specified by:
startin interfaceDiscoveryStrategy
-
getPartitionGroupStrategy
- Specified by:
getPartitionGroupStrategyin interfaceDiscoveryStrategy- Returns:
- a custom implementation of a
PartitionGroupStrategyotherwisenullin case of the default implementation is to be used
-
getPartitionGroupStrategy
Description copied from interface:DiscoveryStrategyReturns a custom implementation of aPartitionGroupStrategyto override default behavior of zone aware backup strategiesPartitionGroupMetaDataor to provide a specific behavior in case the discovery environment does not provide information about the infrastructure to be used for automatic configuration.- Specified by:
getPartitionGroupStrategyin interfaceDiscoveryStrategy- Parameters:
allMembers- Current state of Cluster data members, excluding lite members- Returns:
- a custom implementation of a
PartitionGroupStrategyotherwisenullin case of the default implementation is to be used
-
discoverLocalMetadata
Description copied from interface:DiscoveryStrategyReturns a map with discovered metadata provided by the runtime environment. Those information may include, but are not limited, to location information like datacenter, node name or additional tags to be used for custom purpose.Information discovered from this method are shaded into the
Members attributes. Existing attributes will not be overridden, that way local attribute configuration overrides provided metadata.The default implementation provides an empty map with no further metadata configured. Returning
nullis not permitted and will most probably result in anNullPointerExceptioninside the cluster system.- Specified by:
discoverLocalMetadatain interfaceDiscoveryStrategy- Returns:
- a map of discovered metadata as provided by the runtime environment
-
getProperties
Returns an immutable copy of the configuration properties.- Returns:
- the configuration properties
-
getLogger
Returns aILoggerinstance bound to the current class.- Returns:
- a ILogger instance
-
getOrNull
Returns the value of the requestedPropertyDefinitionif available in the declarative or programmatic configuration (XML or Config API), otherwise it will returnnull.This method overload won't do environment or JVM property lookup. A call to this overload is equivalent to
getOrNull(String, PropertyDefinition)withnullpassed as the first parameter.- Type Parameters:
T- the type of the property, must be compatible with the conversion result ofPropertyDefinition.typeConverter()- Parameters:
property- the PropertyDefinition to lookup- Returns:
- the value of the given property if available in the configuration, otherwise null
-
getOrNull
Returns the value of the requestedPropertyDefinitionif available in the declarative or programmatic configuration (XML or Config API), can be found in the system's environment, or passed as a JVM property. Otherwise it will returnnull.This overload will resolve the requested property in the following order, whereas the higher priority is from top to bottom:
System.getProperty(String): JVM propertiesSystem.getenv(String): System environment- Configuration properties of this
DiscoveryStrategy
prefix, therefore a prefix of com.hazelcast.discovery and a property key of hostname will result in a property lookup of com.hazelcast.discovery.hostname in the system environment and JVM properties.- Type Parameters:
T- the type of the property, must be compatible with the conversion result ofPropertyDefinition.typeConverter()- Parameters:
prefix- the property key prefix for environment and JVM properties lookupproperty- the PropertyDefinition to lookup- Returns:
- the value of the given property if available in the configuration, system environment or JVM properties, otherwise null
-
getOrDefault
Returns the value of the requestedPropertyDefinitionif available in the declarative or programmatic configuration (XML or Config API), otherwise it will return the givendefaultValue.This method overload won't do environment or JVM property lookup. A call to this overload is equivalent to
getOrDefault(String, PropertyDefinition, Comparable)withnullpassed as the first parameter.- Type Parameters:
T- the type of the property, must be compatible with the conversion result ofPropertyDefinition.typeConverter()- Parameters:
property- the PropertyDefinition to lookup- Returns:
- the value of the given property if available in the configuration, otherwise the given default value
-
getOrDefault
protected <T extends Comparable> T getOrDefault(String prefix, PropertyDefinition property, T defaultValue) Returns the value of the requestedPropertyDefinitionif available in the declarative or programmatic configuration (XML or Config API), can be found in the system's environment, or passed as a JVM property. otherwise it will return the givendefaultValue.This overload will resolve the requested property in the following order, whereas the higher priority is from top to bottom:
System.getProperty(String): JVM propertiesSystem.getenv(String): System environment- Configuration properties of this
DiscoveryStrategy
prefix, therefore a prefix of com.hazelcast.discovery and a property key of hostname will result in a property lookup of com.hazelcast.discovery.hostname in the system environment and JVM properties.- Type Parameters:
T- the type of the property, must be compatible with the conversion result ofPropertyDefinition.typeConverter()- Parameters:
prefix- the property key prefix for environment and JVM properties lookupproperty- the PropertyDefinition to lookup- Returns:
- the value of the given property if available in the configuration, system environment or JVM properties, otherwise the given default value
-