Search in sources :

Example 11 with GetDatabaseListTask

use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.

the class SetHostInfoDialog method connect.

/**
	 * connect the host
	 * 
	 * @param buttonId int
	 */
private void connect(final int buttonId) {
    final String ip = ipText.getText();
    final String port = portText.getText();
    final String userName = userNameText.getText();
    final String password = passwordText.getText();
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    if (isConnected && hostInfo != null) {
        ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
        if (!serverInfo.getLoginedUserInfo().isAdmin()) {
            CommonUITool.openErrorBox(Messages.bind(Messages.errInvalidUser, ip));
            return;
        }
        hostInfo.setIp(ip);
        hostInfo.setPort(port);
        hostInfo.setUserName(userName);
        hostInfo.setPassword(password);
        hostInfo.setName(ip + ":" + port);
        List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
        hostInfo.setDatabaseInfoList(databaseInfoList);
        hostInfo.setDbPath(serverInfo.getEnvInfo().getDatabaseDir());
        hostInfo.setOsInfoType(serverInfo.getServerOsInfo());
        setReturnCode(buttonId);
        close();
        return;
    }
    if (!isConnected) {
        final ServerInfo serverInfo = new ServerInfo();
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        TaskExecutor taskExcutor = new ConnectHostTaskExecutor(serverInfo, buttonId);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        taskExcutor.addTask(monitoringTask);
        GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
        taskExcutor.addTask(getEnvInfoTask);
        GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
        taskExcutor.addTask(getCMConfParameterTask);
        GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        taskExcutor.addTask(getDatabaseListTask);
        new ExecTaskWithProgress(taskExcutor).exec(true, true);
    }
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)

Example 12 with GetDatabaseListTask

use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.

the class CubridDatabasesFolderLoader method load.

/**
	 *
	 * Load children object for parent
	 *
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        final GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
        monitorCancel(monitor, new ITask[] { getUserInfoTask, getDatabaseListTask });
        getUserInfoTask.execute();
        final String msg1 = getUserInfoTask.getErrorMsg();
        if (!monitor.isCanceled() && msg1 != null && msg1.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(msg1);
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
        List<DatabaseInfo> oldDatabaseInfoList = null;
        if (serverInfo.getLoginedUserInfo() != null) {
            oldDatabaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
        }
        for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
            ServerUserInfo userInfo = serverUserInfoList.get(i);
            if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
                serverInfo.setLoginedUserInfo(userInfo);
                break;
            }
        }
        getDatabaseListTask.execute();
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        final String msg2 = getDatabaseListTask.getErrorMsg();
        if (!monitor.isCanceled() && msg2 != null && msg2.trim().length() > 0) {
            parent.removeAllChild();
            openErrorBox(msg2);
            setLoaded(true);
            return;
        }
        List<DatabaseInfo> newDatabaseInfoList = getDatabaseListTask.loadDatabaseInfo();
        List<ICubridNode> oldNodeList = new ArrayList<ICubridNode>();
        oldNodeList.addAll(parent.getChildren());
        parent.removeAllChild();
        //Construct the database folder children
        buildDatabasesFolder(parent, monitor, serverInfo, oldDatabaseInfoList, newDatabaseInfoList, oldNodeList);
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 13 with GetDatabaseListTask

use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.

the class SetupEnvTestCase method setupDatabaseInfo831.

/**
	 * * Setup database 8.3.1
	 *
	 */
private void setupDatabaseInfo831() {
    /*Setting Cubrid 8.3.1*/
    serverInfo831 = new ServerInfo();
    serverInfo831.setHostAddress(host831);
    serverInfo831.setHostMonPort(monport831);
    serverInfo831.setHostJSPort(jpport831);
    serverInfo831.setUserName(userName831);
    serverInfo831.setUserPassword(passwd831);
    serverInfo831.setJdbcDriverVersion(serverVersion831);
    ServerManager.getInstance().addServer(host831, monport831, userName831, serverInfo831);
    MonitoringTask monTask = new MonitoringTask(serverInfo831);
    serverInfo831 = monTask.connectServer(serverVersion831, 1000);
    // get the latest token
    token831 = serverInfo831.getHostToken();
    //get evnInfo
    if (envInfo831 == null) {
        GetEnvInfoTask envTask = new GetEnvInfoTask(serverInfo831);
        envTask.loadEnvInfo();
        envTask.execute();
        envInfo831 = envTask.loadEnvInfo();
        serverInfo831.setEnvInfo(envInfo831);
    }
    assertNotNull(envInfo831);
    serverPath831 = envInfo831.getRootDir();
    dbRootDir831 = envInfo831.getDatabaseDir();
    //get server type
    GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo831);
    getCMConfParameterTask.execute();
    assertEquals(null, getCMConfParameterTask.getErrorMsg());
    Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
    ServerType serverType = ServerType.BOTH;
    if (confParameters != null) {
        String target = confParameters.get(ConfConstants.CM_TARGET);
        if (target != null) {
            if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
                serverType = ServerType.BOTH;
            } else if (target.indexOf("broker") >= 0) {
                serverType = ServerType.BROKER;
            } else if (target.indexOf("server") >= 0) {
                serverType = ServerType.DATABASE;
            }
        }
    }
    if (serverInfo831 != null) {
        serverInfo831.setServerType(serverType);
    }
    //Get database list task
    if (serverType == ServerType.DATABASE || serverType == ServerType.BOTH) {
        final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo831);
        getDatabaseListTask.execute();
        assertEquals(null, getDatabaseListTask.getErrorMsg());
        List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
        for (DatabaseInfo dbInfo : databaseInfoList) {
            if (dbInfo.getDbName().equals(testDbName831)) {
                databaseInfo831 = dbInfo;
                break;
            }
        }
        if (databaseInfo831 == null) {
            return;
        }
    }
    //get CubridManager user list task
    GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo831);
    getUserInfoTask.execute();
    assertEquals(null, getUserInfoTask.getErrorMsg());
    List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
    for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
        ServerUserInfo userInfo = serverUserInfoList.get(i);
        if (userInfo != null && userInfo.getUserName().equals(serverInfo831.getUserName())) {
            serverInfo831.setLoginedUserInfo(userInfo);
            break;
        }
    }
    List<DatabaseInfo> databaseInfoList = serverInfo831.getLoginedUserInfo().getDatabaseInfoList();
    String dbDir = databaseInfo831.getDbDir();
    DbRunningType type = databaseInfo831.getRunningType();
    for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
        if (testDbName831.equalsIgnoreCase(databaseInfoList.get(i).getDbName())) {
            databaseInfo831 = databaseInfoList.get(i);
            databaseInfo831.setDbDir(dbDir);
            databaseInfo831.setBrokerIP(host831);
            databaseInfo831.setBrokerPort(port831);
            databaseInfo831.setCharSet(charset831);
            databaseInfo831.setRunningType(type);
            break;
        }
    }
    //get CUBRID conf parameter
    GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo831);
    getCubridConfParameterTask.execute();
    assertEquals(null, getCubridConfParameterTask.getErrorMsg());
    Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
    if (serverInfo831 != null) {
        serverInfo831.setCubridConfParaMap(confParas);
    }
    //get broker Info
    GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo831);
    getBrokerConfParameterTask.execute();
    assertEquals(null, getBrokerConfParameterTask.getErrorMsg());
    confParas = getBrokerConfParameterTask.getConfParameters();
    if (serverInfo831 != null) {
        serverInfo831.setBrokerConfParaMap(confParas);
    }
    //Set JDBC driver
    String filePath = this.getFilePathInPlugin("/lib/JDBC-8.3.0.1004-cubrid.jar");
    if (filePath != null) {
        String version = JdbcClassLoaderFactory.validateJdbcFile(filePath);
        if (version != null) {
            JdbcClassLoaderFactory.registerClassLoader(filePath);
            serverInfo831.setJdbcDriverVersion(version);
        }
    }
    filePath = this.getFilePathInPlugin("/lib/JDBC-8.3.1.0173-cubrid.jar");
    if (filePath != null) {
        String version = JdbcClassLoaderFactory.validateJdbcFile(filePath);
        if (version != null) {
            JdbcClassLoaderFactory.registerClassLoader(filePath);
            serverInfo831.setJdbcDriverVersion(version);
        }
    }
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) DbRunningType(com.cubrid.cubridmanager.core.common.model.DbRunningType) HashMap(java.util.HashMap) Map(java.util.Map)

Example 14 with GetDatabaseListTask

use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.

the class DBSpaceLabelProvider method loadDbData.

public void loadDbData() {
    final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
    final GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            List<String> orignAutoStartDBList = getCubridConfParameterTask.getAutoStartDb(false);
            setDatabaseData(databaseInfoList, orignAutoStartDBList);
            finishedCount++;
            updateToolBar();
            //after get database data ,load volumn data
            loadVolumeData();
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(getDatabaseListTask);
    taskJobExec.addTask(getCubridConfParameterTask);
    String serverName = serverInfo.getServerName();
    String jobName = Messages.taskGetDBInfo + serverName;
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverName);
    taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 15 with GetDatabaseListTask

use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.

the class CubridDatabaseLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        CubridDatabase database = (CubridDatabase) parent;
        database.getDatabaseInfo().clear();
        if (!database.isLogined()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        //when refresh,firstly check whether this database exist
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        ParamDumpTask paramDumpTask = null;
        if (CompatibleUtil.isSupportGetParamDump(serverInfo)) {
            paramDumpTask = new ParamDumpTask(serverInfo);
            paramDumpTask.setDbName(database.getLabel());
            paramDumpTask.setBoth(YesNoType.N);
        }
        monitorCancel(monitor, new ITask[] { getDatabaseListTask, paramDumpTask });
        getDatabaseListTask.execute();
        if (!checkResult(getDatabaseListTask, monitor)) {
            parent.removeAllChild();
            return;
        }
        List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
        ParamDumpInfo paraDumpInfo = null;
        if (paramDumpTask != null) {
            paramDumpTask.execute();
            if (!checkResult(paramDumpTask, monitor)) {
                parent.removeAllChild();
                return;
            }
            paraDumpInfo = paramDumpTask.getContent();
        }
        String databaseName = database.getLabel();
        boolean isExist = false;
        for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
            DatabaseInfo dbInfo = databaseInfoList.get(i);
            if (dbInfo.getDbName().equalsIgnoreCase(databaseName)) {
                database.setRunningType(dbInfo.getRunningType());
                isExist = true;
            }
        }
        if (!isExist) {
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(Messages.errDatabaseNoExist);
                    CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
                    TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
                    if (treeViewer != null) {
                        CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
                    }
                }
            });
            setLoaded(true);
            return;
        }
        if (!loadReplication(parent, monitor)) {
            setLoaded(true);
            return;
        }
        // add tables folder
        addTableFolder(monitor, database);
        // add views folder
        addViewFolder(monitor, database);
        // add serials folder
        addSerialFolder(monitor, database);
        // add user folder
        addUserFolder(monitor, database);
        // add triggers folder
        addTriggerFolder(monitor, database);
        // add stored procedure folder
        addProcedureFolder(monitor, database);
        // add job automation folder
        addJobAutoFolder(monitor, database);
        // add database space folder
        addSpaceFolder(monitor, database);
        // set parameter dump information
        database.getDatabaseInfo().setParaDumpInfo(paraDumpInfo);
        // set charset info
        setDbCollation(database);
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) TreeViewer(org.eclipse.jface.viewers.TreeViewer) ParamDumpInfo(com.cubrid.cubridmanager.core.cubrid.database.model.ParamDumpInfo) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) ParamDumpTask(com.cubrid.cubridmanager.core.cubrid.database.task.ParamDumpTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) CubridNavigatorView(com.cubrid.common.ui.common.navigator.CubridNavigatorView) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) Display(org.eclipse.swt.widgets.Display)

Aggregations

GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)26 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)18 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)17 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)14 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)13 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)11 ArrayList (java.util.ArrayList)11 ITask (com.cubrid.common.core.task.ITask)10 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)9 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)9 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)9 Map (java.util.Map)9 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)8 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)7 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)7 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)6 List (java.util.List)6 IStatus (org.eclipse.core.runtime.IStatus)6 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)5 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)5