public class TcpDiscoveryZookeeperIpFinder extends TcpDiscoveryIpFinderAdapter
ServiceDiscovery recipe, which makes use of ephemeral nodes in ZK to register services.
There are several ways to instantiate the TcpDiscoveryZookeeperIpFinder:
CuratorFramework directly, in which case no ZK Connection String
is required.setZkConnectionString(String), and optionally
a RetryPolicy through the setter. If the latter is not provided, a default
ExponentialBackoffRetry policy is used, with a base sleep time of 1000ms and 10 retries.PROP_ZK_CONNECTION_STRING. If this
property is set, it overrides the ZK Connection String passed in as a property, but it does not override
the CuratorFramework if provided.BASE_PATH and
SERVICE_NAME are use respectively. You can also choose to enable or disable duplicate registrations. See
setAllowDuplicateRegistrations(boolean) for more details.| Modifier and Type | Field and Description |
|---|---|
static String |
PROP_ZK_CONNECTION_STRING
System property name to provide the ZK Connection String.
|
ignite| Constructor and Description |
|---|
TcpDiscoveryZookeeperIpFinder()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getBasePath() |
Collection<InetSocketAddress> |
getRegisteredAddresses()
Gets all addresses registered in this finder.
|
org.apache.curator.RetryPolicy |
getRetryPolicy() |
String |
getServiceName() |
String |
getZkConnectionString() |
boolean |
isAllowDuplicateRegistrations()
* @return The value of this flag.
|
void |
onSpiContextDestroyed()
Callback invoked prior to stopping grid before SPI context is destroyed.
|
void |
registerAddresses(Collection<InetSocketAddress> addrs)
Registers new addresses.
|
void |
setAllowDuplicateRegistrations(boolean allowDuplicateRegistrations) |
void |
setBasePath(String basePath) |
void |
setCurator(org.apache.curator.framework.CuratorFramework curator) |
void |
setRetryPolicy(org.apache.curator.RetryPolicy retryPolicy) |
void |
setServiceName(String serviceName) |
void |
setZkConnectionString(String zkConnectionString) |
void |
unregisterAddresses(Collection<InetSocketAddress> addrs)
Unregisters provided addresses.
|
close, discoveryClientMode, initializeLocalAddresses, isShared, onSpiContextInitialized, setShared, spiContext, toStringpublic static final String PROP_ZK_CONNECTION_STRING
public TcpDiscoveryZookeeperIpFinder()
public void onSpiContextDestroyed()
onSpiContextDestroyed in interface TcpDiscoveryIpFinderonSpiContextDestroyed in class TcpDiscoveryIpFinderAdapterpublic Collection<InetSocketAddress> getRegisteredAddresses() throws IgniteSpiException
null.IgniteSpiException - In case of error.public void registerAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException
Implementation should accept duplicates quietly, but should not register address if it is already registered.
addrs - Addresses to register. Not null and not empty.IgniteSpiException - In case of error.public void unregisterAddresses(Collection<InetSocketAddress> addrs) throws IgniteSpiException
Implementation should accept addresses that are currently not registered quietly (just no-op).
addrs - Addresses to unregister. Not null and not empty.IgniteSpiException - In case of error.public void setCurator(org.apache.curator.framework.CuratorFramework curator)
curator - A CuratorFramework instance to use. It can already be in STARTED state.public String getZkConnectionString()
public void setZkConnectionString(String zkConnectionString)
zkConnectionString - ZooKeeper connection string in case a CuratorFramework is not being set explicitly.public org.apache.curator.RetryPolicy getRetryPolicy()
public void setRetryPolicy(org.apache.curator.RetryPolicy retryPolicy)
retryPolicy - RetryPolicy to use in case a ZK Connection String is being injected, or if
using a system property.public String getBasePath()
BASE_PATH.public void setBasePath(String basePath)
basePath - Base path for service registration in ZK. If not passed, BASE_PATH will be used.public String getServiceName()
setServiceName(String) for more information.public void setServiceName(String serviceName)
serviceName - Service name to use, as defined by Curator's {#link ServiceDiscovery} recipe. In physical
ZK terms, it represents the node under basePath, under which services will be
registered.public boolean isAllowDuplicateRegistrations()
setAllowDuplicateRegistrations(boolean) for more details.public void setAllowDuplicateRegistrations(boolean allowDuplicateRegistrations)
allowDuplicateRegistrations - Whether to register each node only once, or if duplicate registrations
are allowed. Nodes will attempt to register themselves, plus those they
know about. By default, duplicate registrations are not allowed, but you
might want to set this property to true if you have multiple
network interfaces or if you are facing troubles.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.5.11 Release Date : April 8 2016