Search in sources :

Example 26 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class NodeInfoTest method testNodeInfo.

public void testNodeInfo() {
    NodeType type = NodeType.MASTER;
    NodeInfo nodeInfo = new NodeInfo(type);
    assertEquals(type, nodeInfo.getType());
    String serviceName = "www.cubrid.org";
    List<String> databases = new ArrayList<String>();
    String dbName = "demodb";
    String hostName = "HA Master";
    String ip = "127.0.0.1";
    String brokerInfo = "30000:ON";
    String cmConnectName = "dev-cub-ha-001.ncl";
    String status = "Master";
    int port = 8001;
    String userName = "admin";
    ServerInfo serverInfo = ServerManager.getInstance().getServer(ip, port, userName);
    Set<NodeInfo> nodeSet = new HashSet<NodeInfo>();
    nodeInfo.setServiceName(serviceName);
    assertEquals(nodeInfo.getServiceName(), serviceName);
    nodeInfo.setDatabases(databases);
    List<String> databases2 = nodeInfo.getDatabases();
    assertEquals(databases2, databases);
    nodeInfo.addDatabase(dbName);
    assertTrue(databases2.contains(dbName));
    assertTrue(nodeInfo.findDb(dbName));
    nodeInfo.setHostName(hostName);
    assertEquals(nodeInfo.getHostName(), hostName);
    nodeInfo.setIp(ip);
    assertEquals(nodeInfo.getIp(), ip);
    nodeInfo.setBrokerInfo(brokerInfo);
    assertEquals(nodeInfo.getBrokerInfo(), brokerInfo);
    nodeInfo.setCmConnectName(cmConnectName);
    assertEquals(nodeInfo.getCmConnectName(), cmConnectName);
    nodeInfo.setStatus(status);
    assertEquals(nodeInfo.getStatus(), status);
    nodeInfo.setServerInfo(serverInfo);
    assertEquals(nodeInfo.getServerInfo(), serverInfo);
    nodeInfo.setRemoteBrokers(nodeSet);
    assertEquals(nodeInfo.getRemoteBrokers(), nodeSet);
    nodeInfo.AddRemoteBroker(nodeInfo);
    assertFalse(nodeInfo.getRemoteBrokers().contains(nodeInfo));
    NodeInfo brokerNode = new NodeInfo(NodeType.BROKER);
    nodeInfo.AddRemoteBroker(brokerNode);
    assertTrue(nodeInfo.getRemoteBrokers().contains(brokerNode));
    NodeInfo cloneNode = nodeInfo.clone(nodeInfo);
    assertFalse(cloneNode.equals(nodeInfo));
    assertEquals(nodeInfo.clone(nodeInfo).toString(), nodeInfo.toString());
    DbLocationInfo dbLocalInfo = new DbLocationInfo();
    dbLocalInfo.setDbName("demodb");
    List<DbLocationInfo> dbLocationInfoList = new ArrayList<DbLocationInfo>();
    dbLocationInfoList.add(dbLocalInfo);
    nodeInfo.setDbLocationInfoList(dbLocationInfoList);
    assertEquals(nodeInfo.getDbLocationInfoList(), dbLocationInfoList);
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet)

Example 27 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo 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 28 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo 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 29 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo 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 30 with ServerInfo

use of com.cubrid.cubridmanager.core.common.model.ServerInfo in project cubrid-manager by CUBRID.

the class HaShardDemo method registerServiceAndBuildInfo.

/**
	 * For HA, right now, we cannot get the host name from CMS, so need
	 * specified by user.
	 *
	 * @param ip
	 * @param port
	 * @param userName
	 * @param password
	 * @param serviceName
	 * @param connectName
	 * @param nodeName Node name that registered in /etc/hosts.
	 * @return
	 */
public void registerServiceAndBuildInfo(String ip, int port, String userName, String password, String serviceName, String connectName, String nodeName) {
    HaShardManager haShardManager = HaShardManager.getInstance();
    //build server info
    ServerInfo serverInfo = ServerManager.getInstance().getServer(ip, port, userName);
    if (serverInfo == null) {
        serverInfo = new ServerInfo();
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(port);
        serverInfo.setHostJSPort(port + 1);
        serverInfo.setUserName(userName);
    }
    serverInfo.setServerName(connectName);
    serverInfo.setUserPassword(password);
    serverInfo.setJdbcDriverVersion("Auto Detect");
    // connect to server
    addServer(serverInfo);
    MonitoringTask monitoringTask = serverInfo.getMonitoringTask();
    String clientVersion = "9.3.0";
    serverInfo = monitoringTask.connectServer(clientVersion, 1000);
    if (serverInfo.isConnected()) {
        addServer(serverInfo);
        GetDatabasesParameterTask getDatabasesParameterTask = new GetDatabasesParameterTask(serverInfo);
        getDatabasesParameterTask.execute();
        if (!getDatabasesParameterTask.isSuccess()) {
            return;
        }
        List<Map<String, String>> dbParamMapList = getDatabasesParameterTask.getConfParameters();
        List<DbLocationInfo> dbLocationInfoList = new ArrayList<DbLocationInfo>();
        CMServiceAnalysisUtil.addDbLocaltionInfos(dbParamMapList, dbLocationInfoList);
        // get required info from server and build NodeInfo
        NodeInfo info = getRequiredInfo(serverInfo, dbLocationInfoList);
        if (info != null) {
            info.setDbLocationInfoList(dbLocationInfoList);
            info.setServiceName(serviceName);
            info.setCmConnectName(connectName);
            info.setIp(ip);
            info.setHostName(nodeName);
            info.setServerInfo(serverInfo);
            if (info instanceof ShardNode) {
                Shards shards = ((ShardNode) info).getShards();
                Shard shard = shards.getShardList().get(0);
                List<String> connections = shard.getShardConnectionFile().getConnections();
                for (String s : connections) {
                    String[] ar = s.split(",");
                    if (ip.equals(ar[2]) || nodeName.equals(ar[2])) {
                        //???
                        ((ShardNode) info).setSeverStatus("Shard #" + ar[0]);
                        //???
                        ((ShardNode) info).genStatus();
                    }
                }
            }
            haShardManager.add(info);
        }
    } else {
        removeServer(serverInfo);
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetDatabasesParameterTask(com.cubrid.cubridmanager.core.common.task.GetDatabasesParameterTask) ArrayList(java.util.ArrayList) ShardNode(com.cubrid.cubridmanager.core.cubrid.service.model.ShardNode) NodeInfo(com.cubrid.cubridmanager.core.cubrid.service.model.NodeInfo) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) Shards(com.cubrid.cubridmanager.core.shard.model.Shards) Shard(com.cubrid.cubridmanager.core.shard.model.Shard) Map(java.util.Map) DbLocationInfo(com.cubrid.cubridmanager.core.cubrid.service.model.DbLocationInfo)

Aggregations

ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)255 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)40 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)40 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)39 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)37 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)35 ArrayList (java.util.ArrayList)30 EnvInfo (com.cubrid.cubridmanager.core.common.model.EnvInfo)29 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)28 TreeViewer (org.eclipse.jface.viewers.TreeViewer)27 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)24 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)21 SelectionEvent (org.eclipse.swt.events.SelectionEvent)20 GridData (org.eclipse.swt.layout.GridData)17 GridLayout (org.eclipse.swt.layout.GridLayout)17 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)16 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)16 ITask (com.cubrid.common.core.task.ITask)15