Search in sources :

Example 26 with MonitoringTask

use of com.cubrid.cubridmanager.core.common.task.MonitoringTask in project cubrid-manager by CUBRID.

the class GetAllClassesTaskExecutor method init.

/**
	 * initialize some values
	 */
private void init() {
    ServerInfo serverInfo = new ServerInfo();
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    DatabaseInfo dbInfo = null;
    OnOffType status = OnOffType.OFF;
    if (isConnected) {
        serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
        dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(dbName);
        if (dbInfo.getRunningType() == DbRunningType.CS) {
            status = OnOffType.ON;
        }
    } else {
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        CMHostNodePersistManager.getInstance().addServer(ip, Integer.parseInt(port), userName, serverInfo);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        addTask(monitoringTask);
        GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
        addTask(getDatabaseListTask);
        GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
        addTask(getUserInfoTask);
    }
    if (dbInfo == null || (dbInfo != null && !dbInfo.isLogined())) {
        LoginDatabaseTask loginDbTask = new LoginDatabaseTask(serverInfo);
        loginDbTask.setCMUser("admin");
        loginDbTask.setDbName(dbName);
        loginDbTask.setDbUser("dba");
        loginDbTask.setDbPassword(dbaPassword);
        addTask(loginDbTask);
        UpdateCMUserTask updateCMUserTask = new UpdateCMUserTask(serverInfo);
        updateCMUserTask.setCmUserName("admin");
        updateCMUserTask.setCasAuth(CasAuthType.AUTH_ADMIN.getText());
        updateCMUserTask.setDbCreator(DbCreateAuthType.AUTH_ADMIN.getText());
        updateCMUserTask.setStatusMonitorAuth(StatusMonitorAuthType.AUTH_ADMIN.getText());
        addTask(updateCMUserTask);
    }
    GetClassListTask getClassListTask = new GetClassListTask(serverInfo);
    getClassListTask.setDbName(dbName);
    getClassListTask.setDbStatus(status);
    addTask(getClassListTask);
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) LoginDatabaseTask(com.cubrid.cubridmanager.core.cubrid.database.task.LoginDatabaseTask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) OnOffType(com.cubrid.cubridmanager.core.common.model.OnOffType) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetClassListTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)

Example 27 with MonitoringTask

use of com.cubrid.cubridmanager.core.common.task.MonitoringTask in project cubrid-manager by CUBRID.

the class GetAllClassesTaskExecutor method exec.

/**
	 * @see com.cubrid.common.ui.spi.progress.TaskExecutor#exec(org.eclipse.core.runtime.IProgressMonitor)
	 * @param monitor IProgressMonitor
	 * @return boolean
	 */
public boolean exec(final IProgressMonitor monitor) {
    if (monitor.isCanceled()) {
        return false;
    }
    boolean isConnected = false;
    OnOffType status = OnOffType.OFF;
    MonitorDashboardPreference monPref = new MonitorDashboardPreference();
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            MonitoringTask monitoringTask = (MonitoringTask) task;
            monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
            isConnected = true;
        } else if (task instanceof UpdateCMUserTask) {
            UpdateCMUserTask updateCMUserTask = (UpdateCMUserTask) task;
            ServerInfo serverInfo = updateCMUserTask.getServerInfo();
            if (serverInfo != null && serverInfo.isConnected()) {
                List<String> dbNameList = new ArrayList<String>();
                List<String> dbUserList = new ArrayList<String>();
                List<String> dbPasswordList = new ArrayList<String>();
                List<String> dbBrokerPortList = new ArrayList<String>();
                ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
                if (userInfo != null) {
                    List<DatabaseInfo> authDatabaseList = userInfo.getDatabaseInfoList();
                    if (authDatabaseList != null && !authDatabaseList.isEmpty()) {
                        int size = authDatabaseList.size();
                        for (int i = 0; i < size; i++) {
                            DatabaseInfo databaseInfo = authDatabaseList.get(i);
                            dbNameList.add(databaseInfo.getDbName());
                            dbBrokerPortList.add(QueryOptions.getBrokerIp(databaseInfo) + "," + databaseInfo.getBrokerPort());
                            String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
                            if (databaseInfo.getDbName().equalsIgnoreCase(dbName)) {
                                password = dbaPassword;
                                dbUserList.add("dba");
                            } else {
                                dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
                            }
                            dbPasswordList.add(password == null ? "" : password);
                        }
                    }
                }
                String[] dbNameArr = new String[dbNameList.size()];
                String[] dbUserArr = new String[dbUserList.size()];
                String[] dbPasswordArr = new String[dbPasswordList.size()];
                String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
                updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
                updateCMUserTask.execute();
            }
        } else if (task instanceof GetClassListTask) {
            GetClassListTask getClassListTask = (GetClassListTask) task;
            if (status != OnOffType.OFF) {
                getClassListTask.setDbStatus(status);
            }
            getClassListTask.execute();
            dbClasses = getClassListTask.getDbClassInfo();
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (monitor.isCanceled()) {
            if (isConnected) {
                disConnect();
            }
            return false;
        }
        if (openErrorBox(shell, msg, monitor)) {
            if (isConnected) {
                disConnect();
            }
            return false;
        }
        if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
                DatabaseInfo dbInfo = databaseInfoList.get(i);
                if (dbName.equalsIgnoreCase(dbInfo.getDbName())) {
                    DbRunningType type = dbInfo.getRunningType();
                    if (type == DbRunningType.CS) {
                        status = OnOffType.ON;
                    }
                }
            }
        } else if (task instanceof GetCMUserListTask) {
            ServerInfo serverInfo = ((GetCMUserListTask) task).getServerInfo();
            if (serverInfo != null && serverInfo.isConnected()) {
                GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
                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(serverInfo.getUserName())) {
                        serverInfo.setLoginedUserInfo(userInfo);
                        break;
                    }
                }
            }
        }
    }
    if (isConnected) {
        disConnect();
    }
    return true;
}
Also used : MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) 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) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) OnOffType(com.cubrid.cubridmanager.core.common.model.OnOffType) GetClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetClassListTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ArrayList(java.util.ArrayList) List(java.util.List) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) DbRunningType(com.cubrid.cubridmanager.core.common.model.DbRunningType)

Example 28 with MonitoringTask

use of com.cubrid.cubridmanager.core.common.task.MonitoringTask in project cubrid-manager by CUBRID.

the class CreateReplicationUtil method createReplServerTaskGroup.

/**
	 * 
	 * Fill in the related tasks of replication server to executor
	 * 
	 * @param master MasterNode
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createReplServerTaskGroup(MasterNode master, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_START_REPL_SERVER);
    taskGroup.setTarget(master.getDbName());
    HostNode masterHost = (HostNode) master.getParent();
    final String ip = masterHost.getIp();
    final String port = masterHost.getPort();
    final String userName = masterHost.getUserName();
    final String password = masterHost.getPassword();
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    ServerInfo serverInfo = new ServerInfo();
    if (isConnected) {
        serverInfo = ServerManager.getInstance().getServer(ip, Integer.parseInt(port), userName);
        if (!serverInfo.getLoginedUserInfo().isAdmin()) {
            return Messages.bind(Messages.errInvalidUser, ip);
        }
    } else {
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        taskGroup.addTask(monitoringTask);
    }
    StartReplServerTask startReplServerTask = new StartReplServerTask(serverInfo);
    startReplServerTask.setDbName(master.getDbName());
    startReplServerTask.setServerPort(master.getReplServerPort());
    taskGroup.addTask(startReplServerTask);
    executor.addGroupTask(taskGroup);
    return null;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) StartReplServerTask(com.cubrid.cubridmanager.core.replication.task.StartReplServerTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup)

Example 29 with MonitoringTask

use of com.cubrid.cubridmanager.core.common.task.MonitoringTask in project cubrid-manager by CUBRID.

the class CreateReplicationUtil method createDistributorTaskGroup.

/**
	 * 
	 * Fill in the related task of creating distributor to executor
	 * 
	 * @param master MasterNode
	 * @param dist DistributorNode
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createDistributorTaskGroup(MasterNode master, DistributorNode dist, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_DIST);
    taskGroup.setTarget(dist.getDbName());
    HostNode distdbHost = (HostNode) dist.getParent();
    HostNode masterHost = (HostNode) master.getParent();
    final String ip = distdbHost.getIp();
    final String port = distdbHost.getPort();
    final String userName = distdbHost.getUserName();
    final String password = distdbHost.getPassword();
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    ServerInfo serverInfo = new ServerInfo();
    if (isConnected) {
        serverInfo = ServerManager.getInstance().getServer(ip, Integer.parseInt(port), userName);
        if (!serverInfo.getLoginedUserInfo().isAdmin()) {
            return Messages.bind(Messages.errInvalidUser, ip);
        }
    } else {
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        taskGroup.addTask(monitoringTask);
    }
    addCheckDbTaskGroup(serverInfo, dist.getDbName(), taskGroup);
    CreateDistributorTask createDistributorTask = new CreateDistributorTask(serverInfo);
    createDistributorTask.setDistDbName(dist.getDbName());
    createDistributorTask.setDistDbPath(dist.getDbPath());
    createDistributorTask.setDbaPassword(dist.getDbaPassword());
    createDistributorTask.setReplAgentPort(dist.getReplAgentPort());
    createDistributorTask.setMasterDbName(master.getDbName());
    createDistributorTask.setMasterDbIp(masterHost.getIp());
    createDistributorTask.setReplServerPort(master.getReplServerPort());
    createDistributorTask.setCopyLogPath(dist.getCopyLogPath());
    createDistributorTask.setErrorLogPath(dist.getErrorLogPath());
    createDistributorTask.setTrailLogPath(dist.getTrailLogPath());
    createDistributorTask.setDelayTimeLogSize(dist.getDelayTimeLogSize());
    createDistributorTask.setRestartRepl(dist.isRestartWhenError());
    taskGroup.addTask(createDistributorTask);
    executor.addGroupTask(taskGroup);
    return null;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CreateDistributorTask(com.cubrid.cubridmanager.core.replication.task.CreateDistributorTask) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup)

Example 30 with MonitoringTask

use of com.cubrid.cubridmanager.core.common.task.MonitoringTask in project cubrid-manager by CUBRID.

the class CreateReplicationUtil method createSlaveTaskGroup.

/**
	 * 
	 * Create the related task of creating slave database to executor
	 * 
	 * @param masterDb MasterNode
	 * @param distDb DistributorNode
	 * @param slaveDb SlaveNode
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createSlaveTaskGroup(MasterNode masterDb, DistributorNode distDb, SlaveNode slaveDb, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_SLAVE);
    taskGroup.setTarget(slaveDb.getDbName());
    HostNode slaveHost = (HostNode) slaveDb.getParent();
    final String ip = slaveHost.getIp();
    final String port = slaveHost.getPort();
    final String userName = slaveHost.getUserName();
    final String password = slaveHost.getPassword();
    boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
    ServerInfo serverInfo = new ServerInfo();
    if (isConnected) {
        serverInfo = ServerManager.getInstance().getServer(ip, Integer.parseInt(port), userName);
        if (!serverInfo.getLoginedUserInfo().isAdmin()) {
            return Messages.bind(Messages.errInvalidUser, ip);
        }
    } else {
        serverInfo.setHostAddress(ip);
        serverInfo.setHostMonPort(Integer.parseInt(port));
        serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
        serverInfo.setUserName(userName);
        serverInfo.setUserPassword(password);
        MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
        taskGroup.addTask(monitoringTask);
    }
    addCheckDbTaskGroup(serverInfo, slaveDb.getDbName(), taskGroup);
    CreateSlaveDbTask createSlaveDbTask = new CreateSlaveDbTask(serverInfo);
    createSlaveDbTask.setSlaveDbName(slaveDb.getDbName());
    createSlaveDbTask.setSlaveDbPath(slaveDb.getDbPath());
    createSlaveDbTask.setSlaveDbUser(slaveDb.getDbUser());
    createSlaveDbTask.setSlaveDbPassword(slaveDb.getDbPassword());
    createSlaveDbTask.setMasterDbName(masterDb.getDbName());
    createSlaveDbTask.setMasterDbPassword(masterDb.getDbaPassword());
    createSlaveDbTask.setDistDbName(distDb.getDbName());
    createSlaveDbTask.setDistDbaPassword(distDb.getDbaPassword());
    taskGroup.addTask(createSlaveDbTask);
    SetReplicationParamTask setReplicationParamTask = new SetReplicationParamTask(serverInfo);
    setReplicationParamTask.setMasterDbName(masterDb.getDbName());
    setReplicationParamTask.setSlaveDbName(slaveDb.getDbName());
    setReplicationParamTask.setDistDbName(distDb.getDbName());
    setReplicationParamTask.setDistDbDbaPasswd(distDb.getDbaPassword());
    setReplicationParamTask.setParameterMap(slaveDb.getParamMap());
    setReplicationParamTask.setRunningMode(true);
    taskGroup.addTask(setReplicationParamTask);
    ChangeReplTablesTask changeReplTablesTask = new ChangeReplTablesTask(serverInfo);
    changeReplTablesTask.setDistdbName(distDb.getDbName());
    changeReplTablesTask.setDistdbPassword(distDb.getDbaPassword());
    changeReplTablesTask.setMdbName(masterDb.getDbName());
    changeReplTablesTask.setMdbUserId("dba");
    changeReplTablesTask.setMdbPass(masterDb.getDbaPassword());
    if (masterDb.isReplicateAll()) {
        changeReplTablesTask.setReplAllClasses(masterDb.isReplicateAll());
    } else if (masterDb.getReplicatedClassList() != null && masterDb.getReplicatedClassList().size() > 0) {
        changeReplTablesTask.setReplicatedClasses(masterDb.getReplicatedClassList());
    } else {
        changeReplTablesTask.setReplNoneClasses(true);
    }
    taskGroup.addTask(changeReplTablesTask);
    executor.addGroupTask(taskGroup);
    return null;
}
Also used : ChangeReplTablesTask(com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask) CreateSlaveDbTask(com.cubrid.cubridmanager.core.replication.task.CreateSlaveDbTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup) SetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.SetReplicationParamTask)

Aggregations

MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)30 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)24 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)17 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)12 ITask (com.cubrid.common.core.task.ITask)11 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)11 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)10 MonitorDashboardPreference (com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference)10 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)9 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)9 TaskGroup (com.cubrid.common.ui.spi.progress.TaskGroup)8 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)8 ArrayList (java.util.ArrayList)8 Map (java.util.Map)8 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)7 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)7 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)7 HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)7 IStatus (org.eclipse.core.runtime.IStatus)6 Status (org.eclipse.core.runtime.Status)6