T
- Type of the FailoverClusterPaths
instance used by the extending classpublic abstract class FailoverStrategy<T extends FailoverClusterPaths> extends Object implements org.apache.curator.framework.state.ConnectionStateListener
This is the abstract class representing a failover strategy. Any class willing to implement a new strategy to provide
failover should extend from this class. Each failover strategy should have an associated FailoverClusterPaths
instance which is to be used as the ZNode structure for the given strategy.
This class also listens for connection state changes too. Whenever the connection gets disconnected, this class will
take actions to reset the tags put into the XEnvironment
by the child class.
Modifier and Type | Field and Description |
---|---|
protected org.apache.curator.framework.CuratorFramework |
client |
protected XEnvironment |
environment |
protected T |
failoverClusterPaths |
protected Logger |
logger |
protected Status |
status |
Constructor and Description |
---|
FailoverStrategy() |
Modifier and Type | Method and Description |
---|---|
protected void |
addTags(XTag... tags)
Adds a set of
XTag s to the XEnvironment . |
T |
getFailoverClusterPaths() |
abstract Map<String,?> |
getFailoverMatrix() |
void |
initialize(org.apache.curator.framework.CuratorFramework client,
ClusterPaths clusterPaths) |
protected abstract void |
initStrategy() |
protected abstract T |
newFailoverClusterPaths() |
protected abstract void |
refresh()
This method is called whenever the failover strategy believes that the connection state became unstable and again
re became stable.
|
protected void |
removeTags(XTag... tags)
Removes a set of tags from the
XEnvironment . |
protected abstract void |
resetTags()
Whenever the connection state changes to lost or suspended, this method will be called in order to remove the tags
added by the extending concrete strategy.
|
void |
start() |
protected abstract void |
startStrategy() |
void |
stateChanged(org.apache.curator.framework.CuratorFramework client,
org.apache.curator.framework.state.ConnectionState newState) |
void |
stop() |
protected abstract void |
stopStrategy() |
abstract String |
toString() |
protected final Logger logger
@Autowired protected XEnvironment environment
protected Status status
protected T extends FailoverClusterPaths failoverClusterPaths
protected org.apache.curator.framework.CuratorFramework client
public void initialize(org.apache.curator.framework.CuratorFramework client, ClusterPaths clusterPaths)
public void start()
public void stop()
public void stateChanged(org.apache.curator.framework.CuratorFramework client, org.apache.curator.framework.state.ConnectionState newState)
stateChanged
in interface org.apache.curator.framework.state.ConnectionStateListener
protected void addTags(XTag... tags)
XTag
s to the XEnvironment
. This method allows multiple tags to be added at a time.
That is to allow failover processing based on multiple tags at a given time. Each strategy should take care of how
it is going to add and remove tags from the tag container.tags
- tags to be addedprotected void removeTags(XTag... tags)
XEnvironment
.tags
- tags to be removedaddTags(XTag...)
public T getFailoverClusterPaths()
protected abstract void initStrategy()
protected abstract void startStrategy()
protected abstract void stopStrategy()
protected abstract void refresh()
protected abstract void resetTags()
protected abstract T newFailoverClusterPaths()
Copyright © 2016–2019 AdroitLogic. All rights reserved.