@Beta 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.
|
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. |
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
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 © 2016 Hazelcast, Inc.. All Rights Reserved.