Interface SeedNodeProvider
-
- All Known Implementing Classes:
CloudSeedNodeProvider
,CloudStoreSeedNodeProvider
,ConsulSeedNodeProvider
,EtcdSeedNodeProvider
,FsSeedNodeProvider
,JdbcSeedNodeProvider
,KubernetesSeedNodeProvider
,MulticastSeedNodeProvider
,SeedNodeProviderGroup
,StaticSeedNodeProvider
,ZooKeeperSeedNodeProvider
public interface SeedNodeProvider
« start hereSeed node provider.Overview
Implementations of this interface are responsible for providing seed node addresses to the
ClusterService
when it starts joining to the cluster. Seed nodes in this context are nodes that are already running within the cluster and can be used by the newly joining node to send its initial contact information and start the cluster joining negotiations. Due to the decentralized cluster management algorithm any existing node within the cluster can be used as a seed node. Once new node completes its joining to the cluster then it can also be used as a seed node for other nodes.Generic usage
This interface provides API that can be used to implement various strategies of seed node discovering, f.e. based on group communications protocols (like IP multicast), shared storage (like RDBMS, distributes file system, etc) or simple pre-configured list of addresses. Below are the key points of how this interface is used by the cluster service:
- When cluster service starts joining the cluster it calls
startDiscovery(String, InetSocketAddress)
method in order to register the local node address and instruct the seed node provider to start discovering other nodes. Implementations of this method can start sending multicast advertisement messages or register the local node address within some shared central repository. - Cluster service periodically calls
findSeedNodes(String)
method and tries to contact each of the returned addresses one by one by sending a join request message. - If any of the discovered nodes replies with the join accept message then cluster service calls
suspendDiscovery()
so that seed node provider could stop all activities that are not necessary after live seed node have been discovered (f.e. stop advertising via multicast). Seed node provider should still keep its local node information registered so that other joining nodes could use the local node as seed node. - When cluster service stops it calls
stopDiscovery(String, InetSocketAddress)
method to unregister the local node address and stop the seed node provider.
Shared state and stale data
If implementation of this interface uses some kind of persistent shared storage then in case of a particular node crash it's address information can still remain registered in the shared storage. In order to clean such stale information the cluster service elects a leader that periodically scans through all registered addresses, checks their aliveness and removes addresses that are not accessible.
Time interval of stale data checking is controlled by the value of
cleanupInterval()
method. If this method returns a positive value then once per such interval thefindSeedNodes(String)
method will be called and each of the returned address will be checked for aliveness (by sending a ping message). If particular address is considered to be failed then it will be unregistered viaunregisterRemote(String, InetSocketAddress)
method. Cluster service will also compare its know topology with the list of addresses and will re-registered missing addresses viaregisterRemote(String, InetSocketAddress)
.Registration
Instances of this interface can be registered within the cluster service via
ClusterServiceFactory.setSeedNodeProvider(SeedNodeProvider)
method.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
cleanupInterval()
Returns the time interval in milliseconds for the cluster service to perform the stale data cleaning.List<InetSocketAddress>
findSeedNodes(String namespace)
Returns the list of known seed node addresses.void
registerRemote(String namespace, InetSocketAddress node)
Registered the specified addresses within this provider.void
startDiscovery(String namespace, InetSocketAddress node)
Registers the local node address and starts this provider.void
stopDiscovery(String namespace, InetSocketAddress node)
Unregisters the local node address and stops this provider.void
suspendDiscovery()
Suspends discovery activities.void
unregisterRemote(String namespace, InetSocketAddress node)
Unregisters the specified address from this provider.
-
-
-
Method Detail
-
findSeedNodes
List<InetSocketAddress> findSeedNodes(String namespace) throws HekateException
Returns the list of known seed node addresses.- Parameters:
namespace
- Cluster namespace (seeClusterServiceFactory.setNamespace(String)
).- Returns:
- List of known seed node addresses.
- Throws:
HekateException
- if failed to provide seed node addresses information due to the system failure.
-
startDiscovery
void startDiscovery(String namespace, InetSocketAddress node) throws HekateException
Registers the local node address and starts this provider.- Parameters:
namespace
- Cluster namespace (seeClusterServiceFactory.setNamespace(String)
).node
- Local node address.- Throws:
HekateException
- If failed to start discovery due to the system failure.
-
suspendDiscovery
void suspendDiscovery() throws HekateException
Suspends discovery activities.- Throws:
HekateException
- If failed to suspend discovery activities due to some system failure.
-
stopDiscovery
void stopDiscovery(String namespace, InetSocketAddress node) throws HekateException
Unregisters the local node address and stops this provider.- Parameters:
namespace
- Cluster namespace (seeClusterServiceFactory.setNamespace(String)
).node
- Local node address.- Throws:
HekateException
- If failed to stop discovery due to the system failure.
-
cleanupInterval
long cleanupInterval()
Returns the time interval in milliseconds for the cluster service to perform the stale data cleaning. If the returned value if less than or equals to zero then stale data cleaning will be disabled.- Returns:
- Time interval in milliseconds.
-
registerRemote
void registerRemote(String namespace, InetSocketAddress node) throws HekateException
Registered the specified addresses within this provider.This method is the part of a stale data cleanup activity and is performed by the cluster service if it detects that particular node is within its cluster topology but is not registered within this provider (i.e. not returned from
findSeedNodes(String)
method).- Parameters:
namespace
- Cluster namespace (seeClusterServiceFactory.setNamespace(String)
).node
- Node address that should be registered.- Throws:
HekateException
- If node couldn't be registered due to the system failure.
-
unregisterRemote
void unregisterRemote(String namespace, InetSocketAddress node) throws HekateException
Unregisters the specified address from this provider.This method is the part of a stale data cleanup activity and is called by the cluster service if it detects that there is no cluster node running at the specified address while this address is still registered within this provider (i.e. is returned from
findSeedNodes(String)
method).- Parameters:
namespace
- Cluster namespace (seeClusterServiceFactory.setNamespace(String)
).node
- Node address that should be unregistered.- Throws:
HekateException
- If node couldn't be unregistered due to the system failure.
-
-