public class ReplicaGroup extends Object
限定符和类型 | 方法和说明 |
---|---|
Node |
attachNode(String hostName,
int port,
BSONObject configure)
Attach node.
|
Node |
createNode(String hostName,
int port,
String dbPath)
Create node.
|
Node |
createNode(String hostName,
int port,
String dbPath,
BSONObject configure)
Create node.
|
void |
detachNode(String hostName,
int port,
BSONObject configure)
Detach node.
|
BSONObject |
getDetail()
Get detail info of current replicaGroup
|
String |
getGroupName() |
int |
getId() |
Node |
getMaster()
Get the master node of current replica group.
|
Node |
getNode(String nodeName)
Get node by node's name (IP:PORT).
|
Node |
getNode(String hostName,
int port)
Get node by hostName and port.
|
Sequoiadb |
getSequoiadb() |
Node |
getSlave()
Get the random slave node of current replica group, when have no slave node, return master node.
|
Node |
getSlave(Collection<Integer> positions)
Get the slave node in the specified positions,
when have no slave node in the specified positions, return master node.
|
Node |
getSlave(int... positions)
Get the slave node in the specified positions,
when have no slave node in the specified positions, return master node.
|
boolean |
isCatalog()
Judge whether current replicaGroup is catalog replica group or not.
|
boolean |
isNodeExist(String nodeName)
whether the specified node exists in current group or not
|
boolean |
isNodeExist(String hostName,
int port)
whether the specified node exists in current group or not
|
void |
removeNode(String hostName,
int port,
BSONObject configure)
Remove node.
|
void |
start()
Start current replica group.
|
void |
stop()
Stop current replica group.
|
public Node attachNode(String hostName, int port, BSONObject configure) throws BaseException
hostName
- host nameport
- portconfigure
- configuration for this operationBaseException
- If error happens.public Node createNode(String hostName, int port, String dbPath) throws BaseException
hostName
- host nameport
- portdbPath
- the path for nodeBaseException
- If error happens.public Node createNode(String hostName, int port, String dbPath, BSONObject configure) throws BaseException
hostName
- host nameport
- portdbPath
- the path for nodeconfigure
- configuration for this operationBaseException
- If error happens.public void detachNode(String hostName, int port, BSONObject configure) throws BaseException
hostName
- host nameport
- portconfigure
- configuration for this operationBaseException
- If error happens.public BSONObject getDetail() throws BaseException
BaseException
- If error happens.public String getGroupName()
public int getId()
public Node getMaster() throws BaseException
BaseException
- If error happens.public Node getNode(String nodeName) throws BaseException
nodeName
- The name of the nodeBaseException
public Node getNode(String hostName, int port) throws BaseException
hostName
- host nameport
- portBaseException
public Sequoiadb getSequoiadb()
public Node getSlave() throws BaseException
BaseException
- If error happens.public Node getSlave(Collection<Integer> positions) throws BaseException
positions
- the collection of nodes' positions.
The position of a node is depended on the index of the node
defined in catalog. But the beginning position of a node is start
from 1 instead of 0, so it can be 1-7.BaseException
public Node getSlave(int... positions) throws BaseException
positions
- The positions of nodes.
The position of a node is depended on the index of the node
defined in catalog. But the beginning position of a node is start
from 1 instead of 0, so it can be 1-7.BaseException
- If error happens.public boolean isCatalog()
public boolean isNodeExist(String nodeName)
nodeName
- the name of the node. e.g. "192.168.20.165:20000"public boolean isNodeExist(String hostName, int port)
hostName
- port
- public void removeNode(String hostName, int port, BSONObject configure) throws BaseException
hostName
- host nameport
- portconfigure
- configuration for this operationBaseException
- If error happens.public void start() throws BaseException
BaseException
- If error happens.public void stop() throws BaseException
BaseException
- If error happens.Copyright © 2018. All rights reserved.