public class Ha extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
IA_CLIENT_HA |
| Constructor and Description |
|---|
Ha(Socket socket,
String token)
Constructor for management of a HA Cluster node This constructor
implicitly connect a HA socket which can be used to control a ConfD HA
node.
|
| Modifier and Type | Method and Description |
|---|---|
void |
beMaster(ConfValue myNodeId)
Instruct a HA node to be master and also give the node a name.
|
void |
beNone()
Instruct a node to resume the initial state, i.e.
|
void |
beRelay()
Instruct a slave node to be a relay for other slaves.
|
void |
beSlave(ConfValue myNodeId,
ConfHaNode master,
boolean waitForReply)
Instruct a HA node to be slave with a named master.
|
void |
slaveDead(ConfValue nodeId)
This function must be used by the application to inform HA subsystem that
another node which is possibly connected to the server is dead.
|
HaStatus |
status()
Query a HA node for its status.
|
public static final int IA_CLIENT_HA
public Ha(Socket socket, String token) throws IOException, HaException
Ha ha = new Ha(new Socket("localhost", Conf.PORT), "xyz");
If encrypted communication towards ConfD/NCS is desired,
an environment variable "CONFD_IPC_ACCESS_FILE" or "NCS_IPC_ACCESS_FILE"
need to be set.
This variable is expected to point to a file containing a secret salt.
example:
export CONFD_IPC_ACCESS_FILE=./secret_file.txt
An alternative to the environment variable is to set an java system
property with the same name pointing to the file.
Note, if this constructor fails the socket must be closed and a new
socket created before the call is re-attempted.
socket - Ha control sockettoken - cluster common shared secretIOExceptionHaExceptionpublic void beMaster(ConfValue myNodeId) throws IOException, HaException
myNodeId - ConfValue naming the ha nodeIOExceptionHaExceptionpublic void beNone()
throws IOException,
HaException
IOExceptionHaExceptionpublic void beRelay()
throws IOException,
HaException
IOExceptionHaExceptionpublic void beSlave(ConfValue myNodeId, ConfHaNode master, boolean waitForReply) throws IOException, HaException
myNodeId - ConfValue naming the ha nodemaster - Master ConfHaNodewaitForReply - boolean, set true if call should block until responseIOExceptionHaExceptionpublic void slaveDead(ConfValue nodeId) throws IOException, HaException
nodeId - ConfValue naming the cluster nodeIOExceptionHaExceptionpublic HaStatus status() throws IOException, HaException
IOExceptionHaException