public abstract class AbstractDiscoveryStrategy extends Object implements DiscoveryStrategy
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.Constructor and Description |
---|
AbstractDiscoveryStrategy(ILogger logger,
Map<String,Comparable> properties) |
Modifier and Type | Method and Description |
---|---|
void |
destroy()
The stop method is used to stop internal services, sockets or to destroy any
kind of internal state.
|
Map<String,Object> |
discoverLocalMetadata()
Returns a map with discovered metadata provided by the runtime environment.
|
protected ILogger |
getLogger()
Returns a
ILogger instance bound to the current class. |
protected <T extends Comparable> |
getOrDefault(PropertyDefinition property,
T defaultValue)
Returns the value of the requested
PropertyDefinition if available in the
declarative or programmatic configuration (XML or Config API), otherwise it will
return the given defaultValue. |
protected <T extends Comparable> |
getOrDefault(String prefix,
PropertyDefinition property,
T defaultValue)
Returns the value of the requested
PropertyDefinition if 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. |
protected <T extends Comparable> |
getOrNull(PropertyDefinition property)
Returns the value of the requested
PropertyDefinition if available in the
declarative or programmatic configuration (XML or Config API), otherwise it will
return null. |
protected <T extends Comparable> |
getOrNull(String prefix,
PropertyDefinition property)
Returns the value of the requested
PropertyDefinition if 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. |
PartitionGroupStrategy |
getPartitionGroupStrategy()
Returns a custom implementation of a
PartitionGroupStrategy to override
default behavior of zone aware backup strategies PartitionGroupMetaData
or 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> |
getProperties()
Returns an immutable copy of the configuration properties.
|
void |
start()
The start method is used to initialize internal state and perform any kind of
startup procedure like multicast socket creation.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
discoverNodes
public AbstractDiscoveryStrategy(ILogger logger, Map<String,Comparable> properties)
public void destroy()
DiscoveryStrategy
destroy
in interface DiscoveryStrategy
public void start()
DiscoveryStrategy
DiscoveryNode
instance passed to the DiscoveryStrategyFactory
.start
in interface DiscoveryStrategy
public PartitionGroupStrategy getPartitionGroupStrategy()
DiscoveryStrategy
PartitionGroupStrategy
to override
default behavior of zone aware backup strategies PartitionGroupMetaData
or to provide a specific behavior in case the discovery environment does not provide
information about the infrastructure to be used for automatic configuration.getPartitionGroupStrategy
in interface DiscoveryStrategy
public Map<String,Object> discoverLocalMetadata()
DiscoveryStrategy
Member
s
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
null is not permitted and will most probably result in an NullPointerException
inside the cluster system.discoverLocalMetadata
in interface DiscoveryStrategy
protected Map<String,Comparable> getProperties()
protected ILogger getLogger()
ILogger
instance bound to the current class.protected <T extends Comparable> T getOrNull(PropertyDefinition property)
PropertyDefinition
if available in the
declarative or programmatic configuration (XML or Config API), otherwise it will
return null.
This method overload won't do environment or JVM property lookup. A call to
this overload is equivalent to getOrNull(String, PropertyDefinition)
with null passed as the first parameter.T
- the type of the property, must be compatible with the conversion
result of PropertyDefinition.typeConverter()
property
- the PropertyDefinition to lookupprotected <T extends Comparable> T getOrNull(String prefix, PropertyDefinition property)
PropertyDefinition
if 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 null.
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 environmentDiscoveryStrategy
T
- the type of the property, must be compatible with the conversion
result of PropertyDefinition.typeConverter()
prefix
- the property key prefix for environment and JVM properties lookupproperty
- the PropertyDefinition to lookupprotected <T extends Comparable> T getOrDefault(PropertyDefinition property, T defaultValue)
PropertyDefinition
if available in the
declarative or programmatic configuration (XML or Config API), otherwise it will
return the given defaultValue.
This method overload won't do environment or JVM property lookup. A call to
this overload is equivalent to getOrDefault(String, PropertyDefinition, Comparable)
with null passed as the first parameter.T
- the type of the property, must be compatible with the conversion
result of PropertyDefinition.typeConverter()
property
- the PropertyDefinition to lookupprotected <T extends Comparable> T getOrDefault(String prefix, PropertyDefinition property, T defaultValue)
PropertyDefinition
if 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 given
defaultValue.
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 environmentDiscoveryStrategy
T
- the type of the property, must be compatible with the conversion
result of PropertyDefinition.typeConverter()
prefix
- the property key prefix for environment and JVM properties lookupproperty
- the PropertyDefinition to lookupCopyright © 2018 Hazelcast, Inc.. All rights reserved.