Class StaticSeedNodeProvider
- java.lang.Object
-
- io.hekate.cluster.seed.StaticSeedNodeProvider
-
- All Implemented Interfaces:
SeedNodeProvider
,ConfigReportSupport
public class StaticSeedNodeProvider extends Object implements SeedNodeProvider, ConfigReportSupport
Seed node provider with a pre-configured static list of seed node addresses.This provider uses a fixed set of addresses that can be specified at construction time via
StaticSeedNodeProviderConfig
configuration object and can't be changed at runtime. Addresses can be specified viaStaticSeedNodeProviderConfig.setAddresses(List)
method that accepts a list of strings in a form of<host>:<port>
(f.e.192.168.39.41:10012
).Below is the configuration example:
StaticSeedNodeProviderConfig cfg = new StaticSeedNodeProviderConfig() .withAddress("192.168.39.41:10021") // Using IPv4 address .withAddress("my-host.my-company.com:10021") // Using host name .withAddress("[fe80::b573:dd7b:589:e010%17]:10021"); // Using IPv6 address StaticSeedNodeProvider provider = new StaticSeedNodeProvider(cfg);
-
-
Constructor Summary
Constructors Constructor Description StaticSeedNodeProvider(StaticSeedNodeProviderConfig cfg)
Constructs new instance.
-
Method Summary
All Methods Instance Methods Concrete 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.List<InetSocketAddress>
getAddresses()
Returns the unmodifiable list of seed node addresses (seeStaticSeedNodeProviderConfig.setAddresses(List)
).void
registerRemote(String namespace, InetSocketAddress node)
Registered the specified addresses within this provider.void
report(ConfigReporter report)
Report configuration.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.String
toString()
void
unregisterRemote(String namespace, InetSocketAddress node)
Unregisters the specified address from this provider.
-
-
-
Constructor Detail
-
StaticSeedNodeProvider
public StaticSeedNodeProvider(StaticSeedNodeProviderConfig cfg) throws UnknownHostException
Constructs new instance.- Parameters:
cfg
- Configuration.- Throws:
UnknownHostException
- If one of the configured addresses couldn't be resolved.
-
-
Method Detail
-
report
public void report(ConfigReporter report)
Description copied from interface:ConfigReportSupport
Report configuration.- Specified by:
report
in interfaceConfigReportSupport
- Parameters:
report
- Reporter.
-
findSeedNodes
public List<InetSocketAddress> findSeedNodes(String namespace) throws HekateException
Description copied from interface:SeedNodeProvider
Returns the list of known seed node addresses.- Specified by:
findSeedNodes
in interfaceSeedNodeProvider
- 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
public void startDiscovery(String namespace, InetSocketAddress node) throws HekateException
Description copied from interface:SeedNodeProvider
Registers the local node address and starts this provider.- Specified by:
startDiscovery
in interfaceSeedNodeProvider
- Parameters:
namespace
- Cluster namespace (seeClusterServiceFactory.setNamespace(String)
).node
- Local node address.- Throws:
HekateException
- If failed to start discovery due to the system failure.
-
suspendDiscovery
public void suspendDiscovery() throws HekateException
Description copied from interface:SeedNodeProvider
Suspends discovery activities.- Specified by:
suspendDiscovery
in interfaceSeedNodeProvider
- Throws:
HekateException
- If failed to suspend discovery activities due to some system failure.
-
stopDiscovery
public void stopDiscovery(String namespace, InetSocketAddress node) throws HekateException
Description copied from interface:SeedNodeProvider
Unregisters the local node address and stops this provider.- Specified by:
stopDiscovery
in interfaceSeedNodeProvider
- Parameters:
namespace
- Cluster namespace (seeClusterServiceFactory.setNamespace(String)
).node
- Local node address.- Throws:
HekateException
- If failed to stop discovery due to the system failure.
-
cleanupInterval
public long cleanupInterval()
Description copied from interface:SeedNodeProvider
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.- Specified by:
cleanupInterval
in interfaceSeedNodeProvider
- Returns:
- Time interval in milliseconds.
-
registerRemote
public void registerRemote(String namespace, InetSocketAddress node) throws HekateException
Description copied from interface:SeedNodeProvider
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
SeedNodeProvider.findSeedNodes(String)
method).- Specified by:
registerRemote
in interfaceSeedNodeProvider
- 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
public void unregisterRemote(String namespace, InetSocketAddress node) throws HekateException
Description copied from interface:SeedNodeProvider
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
SeedNodeProvider.findSeedNodes(String)
method).- Specified by:
unregisterRemote
in interfaceSeedNodeProvider
- 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.
-
getAddresses
public List<InetSocketAddress> getAddresses()
Returns the unmodifiable list of seed node addresses (seeStaticSeedNodeProviderConfig.setAddresses(List)
).- Returns:
- Unmodifiable list of seed node addresses.
-
-