public class NodeDiscovery extends Object implements Runnable
startWithFixedDelay(long)
or
startWithFixedDelay(long, long, TimeUnit)
, periodically connects to
a Scalaris node and gets information about other Scalaris nodes. These will
then be added to the given ConnectionFactory
where old nodes with
connection failures will be removed in favour of newly discovered nodes.Modifier and Type | Class and Description |
---|---|
static interface |
NodeDiscovery.NewNodeHandler
Handler that is invoked whenever a new node is found by the
NodeDiscovery thread. |
Constructor and Description |
---|
NodeDiscovery(ConnectionFactory cf)
Constructor
|
NodeDiscovery(ConnectionPool cPool)
Constructor
|
Modifier and Type | Method and Description |
---|---|
ConnectionFactory |
getCf()
Gets the
ConnectionFactory to work with. |
int |
getMaxNodes()
Gets the maximum number of nodes that should remain in the
ConnectionFactory cf . |
int |
getMinAgeToRemove()
Gets the minimum time in seconds since the last successful connection for
a node to be removed in favour of newly discovered nodes.
|
void |
run()
Executed a single call to a known Scalaris node asking for other known
nodes.
|
void |
setMaxNodes(int maxNodes)
Sets the maximum number of nodes that should remain in the
ConnectionFactory cf . |
void |
setMinAgeToRemove(int minAgeToRemove)
Sets the minimum time in seconds since the last successful connection for
a node to be removed in favour of newly discovered nodes.
|
void |
startWithFixedDelay(long delay)
Starts the node discovery service at the given fixed delay.
|
void |
startWithFixedDelay(long initialDelay,
long delay,
TimeUnit unit)
Starts the node discovery service at the given fixed delay.
|
public NodeDiscovery(ConnectionFactory cf)
cf
- the ConnectionFactory
to add nodes to / remove nodes
frompublic NodeDiscovery(ConnectionPool cPool)
cPool
- the ConnectionPool
to interact withpublic void startWithFixedDelay(long delay)
delay
- the delay between the termination of one execution and the
commencement of the nextpublic void startWithFixedDelay(long initialDelay, long delay, TimeUnit unit)
initialDelay
- the time to delay first executiondelay
- the delay between the termination of one execution and the
commencement of the nextunit
- the time unit of the initialDelay and delay parameterspublic void run()
ConnectionFactory
cf
.public final int getMaxNodes()
ConnectionFactory
cf
.public final void setMaxNodes(int maxNodes)
ConnectionFactory
cf
.maxNodes
- the maxNodes to setpublic final int getMinAgeToRemove()
public final void setMinAgeToRemove(int minAgeToRemove)
minAgeToRemove
- the minAgeToRemove to setpublic final ConnectionFactory getCf()
ConnectionFactory
to work with.