Search in sources :

Example 81 with ServerInfo

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

the class LoginDatabaseTaskTest method testCancel.

public void testCancel() {
    ServerInfo serverInfo = new ServerInfo();
    DatabaseInfo dbInfo = new DatabaseInfo("dbname", serverInfo);
    ServerUserInfo serverUserInfo = new ServerUserInfo();
    List<DatabaseInfo> dbInfoList = new ArrayList<DatabaseInfo>();
    dbInfoList.add(dbInfo);
    serverUserInfo.setDatabaseInfoList(dbInfoList);
    serverInfo.setLoginedUserInfo(serverUserInfo);
    LoginDatabaseTask task = new LoginDatabaseTask(serverInfo);
    task.setDbName("dbname");
    task.cancel();
    assertFalse(serverInfo.getLoginedUserInfo().getDatabaseInfo("dbname").isLogined());
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 82 with ServerInfo

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

the class LoginDatabaseTaskTest method testSetCMUser.

public void testSetCMUser() {
    ServerInfo serverInfo = new ServerInfo();
    serverInfo.setServerVersion("8.2.0");
    LoginDatabaseTask task = new LoginDatabaseTask(serverInfo);
    task.setCMUser("user");
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Example 83 with ServerInfo

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

the class TestRawScript method connect.

public static void connect() {
    serverInfo = new ServerInfo();
    serverInfo.setHostAddress(SERVER_IP);
    serverInfo.setHostMonPort(SERVER_AUTH_PORT);
    serverInfo.setHostJSPort(SERVER_TASK_PORT);
    serverInfo.setUserName(MAN_USERID);
    serverInfo.setUserPassword(MAN_PASSWD);
    MonitoringTask monTask = new MonitoringTask(serverInfo);
    serverInfo = monTask.connectServer(CLIENT_VERSION, 1000);
    if (monTask.getErrorMsg() != null) {
        System.exit(-1);
    }
    ServerManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
    ServerManager.getInstance().setConnected(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), true);
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask)

Example 84 with ServerInfo

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

the class GetHeartbeatNodeInfoTaskTest method testSend.

public void testSend() throws Exception {
    if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
        return;
    String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/mondashboard/task/test.message/GetHeartbeatNodeInfoTask_send");
    String msg = Tool.getFileContent(filepath);
    //replace "token" field with the latest value
    msg = msg.replaceFirst("token:.*\n", "token:" + token + "\n");
    //composite message
    GetHeartbeatNodeInfoTask task = new GetHeartbeatNodeInfoTask(serverInfo);
    task.setAllDb(false);
    List<String> dbList = new ArrayList<String>();
    dbList.add("demodb");
    dbList.add("tb1");
    task.setDbList(dbList);
    //compare 
    assertEquals(msg, task.getRequest());
    //test special case1
    ServerInfo server = new ServerInfo();
    server.setConnected(true);
    EnvInfo envInfo = new EnvInfo();
    envInfo.setServerVersion("CUBRID 2008 R2.0(8.2.0.1150)");
    envInfo.setOsInfo("NT");
    server.setEnvInfo(envInfo);
    task = new GetHeartbeatNodeInfoTask(server);
    task.execute();
    //test special case2
    envInfo.setServerVersion("CUBRID 2008 R2.0(8.3.1.1150)");
    task.execute();
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 85 with ServerInfo

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

the class JDBCConnectionManager method testShardBroker.

public static boolean testShardBroker(DatabaseInfo dbInfo, int shardId) {
    String dbName = dbInfo.getDbName();
    ServerInfo serverInfo = dbInfo.getServerInfo();
    String brokerIP = dbInfo.getBrokerIP();
    DbUserInfo userInfo = dbInfo.getAuthLoginedDbUserInfo();
    String url = "jdbc:cubrid:" + brokerIP + ":" + dbInfo.getBrokerPort() + ":" + dbName + ":::";
    Driver cubridDriver = CubridClassLoaderPool.getCubridDriver(serverInfo.getJdbcDriverVersion());
    if (cubridDriver == null) {
        LOGGER.error("The cubridDriver is a null.");
        return false;
    }
    Properties props = new Properties();
    props.put("user", userInfo.getName());
    props.put("password", userInfo.getNoEncryptPassword() == null ? "" : userInfo.getNoEncryptPassword());
    Connection conn = null;
    Statement stmt = null;
    try {
        conn = cubridDriver.connect(url, props);
        conn.setAutoCommit(true);
        stmt = conn.createStatement();
        stmt.executeQuery("/*+ shard_id(" + shardId + ") */ SELECT * FROM db_root");
    } catch (Exception e) {
        LOGGER.error("", e);
        return false;
    } finally {
        QueryUtil.freeQuery(conn, stmt);
    }
    return true;
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) Statement(java.sql.Statement) Connection(java.sql.Connection) Driver(java.sql.Driver) Properties(java.util.Properties) SQLException(java.sql.SQLException)

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