Class JdbcSeedNodeProvider
- java.lang.Object
-
- io.hekate.cluster.seed.jdbc.JdbcSeedNodeProvider
-
- All Implemented Interfaces:
SeedNodeProvider
,JmxSupport<JdbcSeedNodeProviderJmx>
,ConfigReportSupport
public class JdbcSeedNodeProvider extends Object implements SeedNodeProvider, JmxSupport<JdbcSeedNodeProviderJmx>, ConfigReportSupport
JDBC-based implementation ofSeedNodeProvider
interface.This provider uses a shared database table to store seed node addresses. When provider starts discovering other nodes it registers the local node addresses within the database table (with configurable name and columns) and uses this table to search for remote node addresses.
Please see the documentation of
JdbcSeedNodeProviderConfig
class for more details about available configuration options.
-
-
Constructor Summary
Constructors Constructor Description JdbcSeedNodeProvider(JdbcSeedNodeProviderConfig 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.DataSource
dataSource()
Returns the data source of this provider.String
deleteSql()
Returns the SQL string for inserting new records into the seed nodes table.List<InetSocketAddress>
findSeedNodes(String namespace)
Returns the list of known seed node addresses.String
insertSql()
Returns the SQL string for deleting records from the seed nodes table.JdbcSeedNodeProviderJmx
jmx()
Creates a JMX object.int
queryTimeout()
Returns the JDBC query timeout in seconds.void
registerRemote(String namespace, InetSocketAddress node)
Registered the specified addresses within this provider.void
report(ConfigReporter report)
Report configuration.String
selectSql()
Returns the SQL string for selecting records from the seed nodes table.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
-
JdbcSeedNodeProvider
public JdbcSeedNodeProvider(JdbcSeedNodeProviderConfig cfg)
Constructs new instance.- Parameters:
cfg
- Configuration.
-
-
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.
-
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.
-
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.
-
dataSource
public DataSource dataSource()
Returns the data source of this provider.- Returns:
- Data source.
- See Also:
JdbcSeedNodeProviderConfig.setDataSource(DataSource)
-
queryTimeout
public int queryTimeout()
Returns the JDBC query timeout in seconds.- Returns:
- Timeout in seconds.
- See Also:
JdbcSeedNodeProviderConfig.setQueryTimeout(int)
-
selectSql
public String selectSql()
Returns the SQL string for selecting records from the seed nodes table.- Returns:
- SQL string.
- See Also:
JdbcSeedNodeProviderConfig.setTable(String)
-
deleteSql
public String deleteSql()
Returns the SQL string for inserting new records into the seed nodes table.- Returns:
- SQL string.
- See Also:
JdbcSeedNodeProviderConfig.setTable(String)
-
insertSql
public String insertSql()
Returns the SQL string for deleting records from the seed nodes table.- Returns:
- SQL string.
- See Also:
JdbcSeedNodeProviderConfig.setTable(String)
-
jmx
public JdbcSeedNodeProviderJmx jmx()
Description copied from interface:JmxSupport
Creates a JMX object.- Specified by:
jmx
in interfaceJmxSupport<JdbcSeedNodeProviderJmx>
- Returns:
- JMX object.
-
-