use of com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo in project cubrid-manager by CUBRID.
the class HaShardDemoTest method testBrokerNode.
public void testBrokerNode() {
try {
demo.registerServiceAndBuildInfo(brokerIp, brokerCmPort, brokerCmUser, brokerCmPass, serviceName, brokerConnName, brokerHost);
NodeInfo node = manager.findByIp(brokerIp);
assertEquals(node.getType(), NodeType.BROKER);
assertEquals(node.getServiceName(), serviceName);
assertEquals(node.getHostName(), brokerHost);
assertEquals(node.getCmConnectName(), brokerConnName);
} finally {
ServerInfo serverInfo = ServerManager.getInstance().getServer(brokerIp, brokerCmPort, brokerCmUser);
ServerManager.getInstance().removeServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName());
}
}
use of com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo in project cubrid-manager by CUBRID.
the class HaShardDemoTest method testShardNode.
public void testShardNode() {
try {
demo.registerServiceAndBuildInfo(shardIp, shardCmPort, shardCmUser, shardCmPass, serviceName, shardConnName, shardHost);
NodeInfo node = manager.findByIp(shardIp);
assertEquals(node.getType(), NodeType.SHARD);
assertEquals(node.getServiceName(), serviceName);
assertEquals(node.getHostName(), shardHost);
assertEquals(node.getCmConnectName(), shardConnName);
} finally {
ServerInfo serverInfo = ServerManager.getInstance().getServer(shardIp, shardCmPort, shardCmUser);
ServerManager.getInstance().removeServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName());
}
}
use of com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo in project cubrid-manager by CUBRID.
the class HaShardDemoTest method testHaNode.
public void testHaNode() {
try {
demo.registerServiceAndBuildInfo(haIp, haCmPort, haCmUser, haCmPass, serviceName, haConnName, haHost);
NodeInfo node = manager.findByIp(haIp);
assertTrue(NodeType.MASTER == node.getType() || NodeType.SLAVE == node.getType());
assertEquals(node.getServiceName(), serviceName);
assertEquals(node.getHostName(), haHost);
assertEquals(node.getCmConnectName(), haConnName);
} finally {
ServerInfo serverInfo = ServerManager.getInstance().getServer(haIp, haCmPort, haCmUser);
ServerManager.getInstance().removeServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName());
}
}
use of com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo in project cubrid-manager by CUBRID.
the class HaShardManagerTest method testShard.
public void testShard() {
HaShardManager manager = HaShardManager.getInstance();
assertNotNull(manager);
HaNode replicaNode = new HaNode(NodeType.REPLICA);
replicaNode.setIp(replicaIp);
replicaNode.setServiceName(haServiceName);
ShardNode shardNode = new ShardNode();
shardNode.setIp(shardIp);
shardNode.setServiceName(shardServiceName);
BrokerNode brokerNode = new BrokerNode();
brokerNode.setIp(brokerIp);
brokerNode.setHostName(brokerHost);
brokerNode.setServiceName(haServiceName);
manager.add(brokerNode);
manager.add(shardNode);
manager.add(replicaNode);
List<NodeInfo> nodeList = manager.getNodeList();
assertTrue(nodeList.contains(replicaNode));
assertTrue(nodeList.contains(shardNode));
assertTrue(nodeList.contains(brokerNode));
int index = manager.find(brokerNode);
assertEquals(nodeList.get(index), brokerNode);
BrokerNode brokerNode2 = new BrokerNode();
String brokerIp2 = "127.0.0.1";
brokerNode2.setIp(brokerIp2);
assertTrue(manager.find(brokerNode2) == -1);
assertEquals(manager.findByIp(shardIp), shardNode);
assertNull(manager.findByIp(brokerIp2));
List<NodeInfo> haGroups = manager.findGroupByIp(replicaIp);
assertTrue(haGroups.size() == 2);
assertTrue(haGroups.contains(replicaNode));
assertTrue(haGroups.contains(brokerNode));
assertFalse(haGroups.contains(shardNode));
List<NodeInfo> shardGroups = manager.findGroupByServiceName(shardServiceName);
assertTrue(shardGroups.size() == 1);
assertTrue(shardGroups.contains(shardNode));
assertFalse(shardGroups.contains(replicaNode));
List<NodeInfo> haList = manager.getHaNodes();
assertTrue(haList.size() == 1);
assertTrue(haList.contains(replicaNode));
assertFalse(haList.contains(brokerNode));
List<NodeInfo> shardList = manager.getShardNodes();
assertTrue(shardList.size() == 1);
assertTrue(shardList.contains(shardNode));
assertFalse(shardList.contains(brokerNode));
List<NodeInfo> brokerList = manager.getBrokerNodes();
assertTrue(brokerList.size() == 1);
assertTrue(brokerList.contains(brokerNode));
assertFalse(brokerList.contains(shardNode));
int haIndex = manager.find(replicaNode);
int shardIndex = manager.find(shardNode);
assertTrue(haIndex > shardIndex);
manager.sort();
int haIndex2 = manager.find(replicaNode);
int shardIndex2 = manager.find(shardNode);
assertTrue(haIndex2 < shardIndex2);
//test remove method
manager.remove(shardNode);
assertTrue(manager.find(shardNode) == -1);
assertNull(manager.findByIp(shardIp));
manager.add(shardNode);
manager.remove(brokerNode);
testRegisterBrokerHostInHaShard(manager);
}
use of com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo in project cubrid-manager by CUBRID.
the class HaShardManagerTest method testHa.
// test ha/shard separately because of use only 3 node to install cubrid
// we suppose that: HA/shard node on the same machine
public void testHa() {
HaShardManager manager = HaShardManager.getInstance();
assertNotNull(manager);
HaNode haNode = new HaNode(NodeType.SLAVE);
haNode.setIp(haIp);
haNode.setHostName(haHost);
haNode.setServiceName(haServiceName);
HaNode replicaNode = new HaNode(NodeType.REPLICA);
replicaNode.setIp(replicaIp);
replicaNode.setServiceName(haServiceName);
BrokerNode brokerNode = new BrokerNode();
brokerNode.setIp(brokerIp);
brokerNode.setHostName(brokerHost);
brokerNode.setServiceName(haServiceName);
manager.add(brokerNode);
manager.add(replicaNode);
manager.add(haNode);
List<NodeInfo> nodeList = manager.getNodeList();
assertTrue(nodeList.contains(haNode));
assertTrue(nodeList.contains(replicaNode));
assertTrue(nodeList.contains(brokerNode));
int index = manager.find(brokerNode);
assertEquals(nodeList.get(index), brokerNode);
BrokerNode brokerNode2 = new BrokerNode();
String brokerIp2 = "127.0.0.1";
brokerNode2.setIp(brokerIp2);
assertTrue(manager.find(brokerNode2) == -1);
assertEquals(manager.findByIp(brokerIp), brokerNode);
assertNull(manager.findByIp(brokerIp2));
assertEquals(manager.findByHostName(haHost), haNode);
assertNull(manager.findByHostName("localhost"));
List<NodeInfo> haGroups = manager.findGroupByIp(haIp);
assertTrue(haGroups.size() == 3);
assertTrue(haGroups.contains(haNode));
assertTrue(haGroups.contains(replicaNode));
assertTrue(haGroups.contains(brokerNode));
List<NodeInfo> haGroups2 = manager.findGroupByHostName(haHost);
assertTrue(haGroups2.size() == 3);
assertTrue(haGroups2.contains(haNode));
assertTrue(haGroups2.contains(replicaNode));
assertTrue(haGroups2.contains(brokerNode));
List<NodeInfo> shardGroups = manager.findGroupByServiceName(shardServiceName);
assertTrue(shardGroups.size() == 0);
List<NodeInfo> haList = manager.getHaNodes();
assertTrue(haList.size() == 2);
assertTrue(haList.contains(haNode));
assertTrue(haList.contains(replicaNode));
assertFalse(haList.contains(brokerNode));
List<NodeInfo> shardList = manager.getShardNodes();
assertTrue(shardList.size() == 0);
List<NodeInfo> brokerList = manager.getBrokerNodes();
assertTrue(brokerList.size() == 1);
assertTrue(brokerList.contains(brokerNode));
assertFalse(brokerList.contains(haNode));
int haIndex = manager.find(haNode);
int brokerIndex = manager.find(brokerNode);
assertTrue(haIndex > brokerIndex);
manager.sort();
int haIndex2 = manager.find(haNode);
int brokerIndex2 = manager.find(brokerNode);
assertTrue(haIndex2 < brokerIndex2);
//test remove method
manager.remove(brokerNode);
assertTrue(manager.find(brokerNode) == -1);
assertNull(manager.findByIp(brokerIp));
testRegisterBrokerHostInHaShard(manager);
}
Aggregations