@AutoInitialize @AutoStart public class CuratorClusterManager extends Object implements XClusterManager
NodeWiseFailoverStrategy
GroupFailoverStrategy
When it comes to failover processing, group failover strategy has to be plugged to the cluster manager bean when configuring for the failover processing to work. Otherwise, all the above mentioned functions will be provide except failover processing.
nodeName
is kept in this class as it is required for command processing
Logger codes:
Modifier and Type | Field and Description |
---|---|
protected XEnvironment |
environment |
Constructor and Description |
---|
CuratorClusterManager() |
Modifier and Type | Method and Description |
---|---|
void |
archiveCommand(int commandVersion)
This will archive the command in the form
|
void |
destroy() |
org.apache.curator.framework.CuratorFramework |
getClient() |
XClusterLock |
getClusterLock(String path)
This will use the
as the lockPath to
create the lock. |
ClusterPaths |
getClusterPaths() |
String |
getCommandSpace()
Name of the command space to which this cluster manager is listening to.
|
int |
getCurrentCommandVersion()
Get's the current command version, which is the version of the last executed(by the command processor) command.
|
String |
getDomain() |
FailoverStrategy |
getFailoverStrategy() |
String |
getNamespace() |
Optional<Integer> |
getNextSequenceNumber(String path)
This method uses the
to keep tract of the distributed
sequence number. |
String |
getNodeName() |
CommandView |
getPublishedCommandView(int commandVersion)
Returns the
CommandView corresponding to a given command version. |
Map<Integer,CommandView> |
getPublishedCommandViews(int from,
int to)
Gets the published commands between given two command versions (inclusive).
|
org.apache.curator.RetryPolicy |
getRetryPolicy() |
Status |
getStatus()
Get the cluster manager's current
Status . |
void |
init(org.springframework.context.ApplicationContext context) |
String |
publishControlCommand(String command)
This method is to be used over the REST API.
|
String |
publishControlCommand(XControlCommand command)
Publishes a command to the cluster.
|
String |
republishControlCommand(int commandVersion)
Republish a control command which was once published.
|
void |
retryCommand(int commandVersion)
Retries a given command.
|
void |
setCommandSpace(String commandSpace) |
void |
setConnectionTimeoutMs(int connectionTimeoutMs) |
void |
setConnectString(String connectString) |
void |
setDomain(String domain) |
void |
setFailoverStrategy(FailoverStrategy failoverStrategy) |
void |
setRetryPolicy(org.apache.curator.RetryPolicy retryPolicy) |
void |
setSessionTimeoutMs(int sessionTimeoutMs) |
void |
setStartupTimeOutMs(int startupTimeOutMs) |
void |
setZkPassword(String zkPassword) |
void |
setZkUsername(String zkUsername) |
void |
start()
Starts the cluster manager.
|
void |
stop() |
@Autowired protected XEnvironment environment
public void init(org.springframework.context.ApplicationContext context)
init
in interface Initializable
public void start()
CuratorFramework
client to wait till connecting to the
zookeeper cluster or till the connection timeout.public XClusterLock getClusterLock(String path)
ClusterPaths.locksZNodeRoot
+ lockPath
as the lockPath
to
create the lock.
Returns a distributed lock unique to the given path. The returned XClusterLock
can be used to acquire a
lock which will guarantee a critical section between different instances of the cluster manager (project x/ultraESB)getClusterLock
in interface XClusterManager
path
- lock pathpublic Optional<Integer> getNextSequenceNumber(String path)
ClusterPaths.sequencesZNodeRoot
+ path
to keep tract of the distributed
sequence number.
Generates a distributed sequence number which is the next in line of a distributed sequence. this will return an
Optional
as the result. Users have to check whether the value is available.getNextSequenceNumber
in interface XClusterManager
path
- path to be used to generate the sequence numberpublic String publishControlCommand(XControlCommand command)
XControlCommand
instance should be provided as the command. The command
will be marshaled and sent to the zookeeper for publishing the command.publishControlCommand
in interface XClusterManager
command
- the command to be publishedpublic String publishControlCommand(String command)
publishControlCommand
in interface XClusterManager
command
- Marshaled XControlCommand
XClusterManager.publishControlCommand(XControlCommand)
public String republishControlCommand(int commandVersion)
republishControlCommand
in interface XClusterManager
commandVersion
- Version of the command to be republishedpublic void archiveCommand(int commandVersion)
ControlCommand_00..00{commandVersion}. Therefore, please note that the command version is always 1 unit below the CVersion of the
commands/currentZNode. Archives a given command. The command is identified by its version number which is appended to the ZNode name when a sequential node is being created
archiveCommand
in interface XClusterManager
commandVersion
- sequence number of the command which is to be archivedpublic void retryCommand(int commandVersion)
XClusterManager
retryCommand
in interface XClusterManager
commandVersion
- command version number to be retried{@inheritDoc}
public int getCurrentCommandVersion()
getCurrentCommandVersion
in interface XClusterManager
public Map<Integer,CommandView> getPublishedCommandViews(int from, int to)
getPublishedCommandViews
in interface XClusterManager
from
- starting version from which the commands to be fetchedto
- ending version up to which commands has to be fetchedpublic CommandView getPublishedCommandView(int commandVersion) throws Exception
CommandView
corresponding to a given command version. Please note that, the commandVersionis expected to be 1-based (starting from 1). This method will do the proper conversions in order to address the command version difference among the API and the implementation.
getPublishedCommandView
in interface XClusterManager
commandVersion
- command versionException
- zookeeper errorspublic Status getStatus()
Status
.getStatus
in interface XClusterManager
public void destroy()
destroy
in interface Initializable
public void setConnectString(String connectString)
public void setSessionTimeoutMs(int sessionTimeoutMs)
public void setConnectionTimeoutMs(int connectionTimeoutMs)
public void setZkUsername(String zkUsername)
public void setZkPassword(String zkPassword)
public void setStartupTimeOutMs(int startupTimeOutMs)
public String getNamespace()
public ClusterPaths getClusterPaths()
public void setFailoverStrategy(FailoverStrategy failoverStrategy)
public String getCommandSpace()
XClusterManager
getCommandSpace
in interface XClusterManager
public void setCommandSpace(String commandSpace)
public FailoverStrategy getFailoverStrategy()
public org.apache.curator.framework.CuratorFramework getClient()
public String getDomain()
getDomain
in interface XClusterManager
public void setDomain(String domain)
public String getNodeName()
getNodeName
in interface XClusterManager
public org.apache.curator.RetryPolicy getRetryPolicy()
public void setRetryPolicy(org.apache.curator.RetryPolicy retryPolicy)
Copyright © 2016–2019 AdroitLogic. All rights reserved.