Search in sources :

Example 1 with NodeInfo

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());
    }
}
Also used : NodeInfo(com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 2 with NodeInfo

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());
    }
}
Also used : NodeInfo(com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 3 with NodeInfo

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());
    }
}
Also used : NodeInfo(com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 4 with NodeInfo

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);
}
Also used : BrokerNode(com.cubrid.cubridmanager.core.cubrid.service.model.BrokerNode) HaNode(com.cubrid.cubridmanager.core.cubrid.service.model.HaNode) ShardNode(com.cubrid.cubridmanager.core.cubrid.service.model.ShardNode) NodeInfo(com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo)

Example 5 with NodeInfo

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);
}
Also used : BrokerNode(com.cubrid.cubridmanager.core.cubrid.service.model.BrokerNode) HaNode(com.cubrid.cubridmanager.core.cubrid.service.model.HaNode) NodeInfo(com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo)

Aggregations

NodeInfo (com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)5 BrokerNode (com.cubrid.cubridmanager.core.cubrid.service.model.BrokerNode)2 HaNode (com.cubrid.cubridmanager.core.cubrid.service.model.HaNode)2 ShardNode (com.cubrid.cubridmanager.core.cubrid.service.model.ShardNode)2 Map (java.util.Map)2 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)1 GetDatabasesParameterTask (com.cubrid.cubridmanager.core.common.task.GetDatabasesParameterTask)1 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)1 DbLocationInfo (com.cubrid.cubridmanager.core.cubrid.service.model.DbLocationInfo)1 HaShardDemo (com.cubrid.cubridmanager.core.cubrid.service.task.HaShardDemo)1 HaShardManager (com.cubrid.cubridmanager.core.cubrid.service.task.HaShardManager)1 Shard (com.cubrid.cubridmanager.core.shard.model.Shard)1 Shards (com.cubrid.cubridmanager.core.shard.model.Shards)1 GetShardStatusTask (com.cubrid.cubridmanager.core.shard.task.GetShardStatusTask)1 ArrayList (java.util.ArrayList)1