Search in sources :

Example 36 with CommonUpdateTask

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

the class CreateReplicationJobExecutor method createSlave.

/**
	 * create slave database
	 * 
	 * @param dbName String
	 * @param monitor IProgressMonitor
	 * @param taskList List<ITask>
	 * @return status
	 */
private IStatus createSlave(String dbName, final IProgressMonitor monitor, List<ITask> taskList) {
    monitor.subTask(Messages.bind(Messages.createSlaveJobName, dbName));
    Display display = Display.getDefault();
    MonitoringTask monitoringTask = null;
    boolean isExecuteStopDbTask = true;
    MonitorDashboardPreference monPref = new MonitorDashboardPreference();
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            monitoringTask = (MonitoringTask) task;
            ServerInfo serverInfo = monitoringTask.getServerInfo();
            CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
            monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
        } else if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.STOP_DB_TASK_NAME)) {
            if (isDeleteDb && isExecuteStopDbTask) {
                task.execute();
            } else {
                continue;
            }
        } else if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.DELETE_DATABASE_TASK_NAME)) {
            if (isDeleteDb) {
                task.execute();
            } else {
                continue;
            }
        } else {
            task.execute();
        }
        if (monitor.isCanceled()) {
            disConnect(monitoringTask);
            return Status.CANCEL_STATUS;
        }
        final String msg = task.getErrorMsg();
        if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
            disConnect(monitoringTask);
            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
        }
        if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            final String sdbName = (String) getDatabaseListTask.getData("dbName");
            List<DatabaseInfo> dbInfoList = getDatabaseListTask.loadDatabaseInfo();
            boolean isDbExist = false;
            for (int i = 0; i < dbInfoList.size(); i++) {
                DatabaseInfo dbInfo = dbInfoList.get(i);
                if (dbName.equalsIgnoreCase(dbInfo.getDbName())) {
                    isDbExist = true;
                    display.syncExec(new Runnable() {

                        public void run() {
                            isDeleteDb = CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmDeleteDb, sdbName));
                        }
                    });
                    if (dbInfo.getRunningType() == DbRunningType.CS) {
                        isExecuteStopDbTask = true;
                    }
                    break;
                }
            }
            if (isDbExist && !isDeleteDb) {
                disConnect(monitoringTask);
                return Status.CANCEL_STATUS;
            }
        }
    }
    disConnect(monitoringTask);
    isDeleteDb = false;
    return Status.OK_STATUS;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) 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) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) Display(org.eclipse.swt.widgets.Display)

Example 37 with CommonUpdateTask

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

the class CreateReplicationUtil method createMasterTaskGroup.

/**
	 * 
	 * Fill in the related tasks of creating master to executor according master
	 * information
	 * 
	 * @param master MasterNode
	 * @param slaveList List<SlaveNode>
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createMasterTaskGroup(MasterNode master, List<SlaveNode> slaveList, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_MASTER);
    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);
    }
    GetReplServerStatusTask getReplServerStatusTask = new GetReplServerStatusTask(serverInfo);
    getReplServerStatusTask.setDbName(master.getDbName());
    taskGroup.addTask(getReplServerStatusTask);
    StopReplServerTask stopReplServerTask = new StopReplServerTask(serverInfo);
    stopReplServerTask.setDbName(master.getDbName());
    taskGroup.addTask(stopReplServerTask);
    GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    getCubridConfParameterTask.putData("dbName", master.getDbName());
    taskGroup.addTask(getCubridConfParameterTask);
    SetCubridConfParameterTask setCubridConfParameterTask = new SetCubridConfParameterTask(serverInfo);
    taskGroup.addTask(setCubridConfParameterTask);
    GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
    getDatabaseListTask.putData("dbName", master.getDbName());
    taskGroup.addTask(getDatabaseListTask);
    CommonUpdateTask stopDbTask = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
    stopDbTask.setDbName(master.getDbName());
    taskGroup.addTask(stopDbTask);
    CommonUpdateTask startDbTask = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
    startDbTask.setDbName(master.getDbName());
    taskGroup.addTask(startDbTask);
    BackupDbTask backupDbTask = new BackupDbTask(serverInfo);
    backupDbTask.setDbName(master.getDbName());
    backupDbTask.setLevel("0");
    backupDbTask.setVolumeName(master.getDbName() + "_bk0v000");
    backupDbTask.setBackupDir(master.getDbPath());
    backupDbTask.setRemoveLog(false);
    backupDbTask.setCheckDatabaseConsist(true);
    backupDbTask.setThreadCount(String.valueOf(0));
    backupDbTask.setZiped(false);
    backupDbTask.setSafeReplication(false);
    taskGroup.addTask(backupDbTask);
    CancelTransFileTask cancelTransFileTask = new CancelTransFileTask(serverInfo);
    taskGroup.addTask(cancelTransFileTask);
    for (int i = 0; i < slaveList.size(); i++) {
        SlaveNode slave = slaveList.get(i);
        HostNode slaveHost = (HostNode) slave.getParent();
        TransFileTask transFileTask = new TransFileTask(serverInfo);
        transFileTask.setMasterDbDir(master.getDbPath());
        List<String> fileList = new ArrayList<String>();
        fileList.add(master.getDbName() + "_bk0v000");
        fileList.add(master.getDbName() + "_bkvinf");
        transFileTask.setBackupFileList(fileList);
        transFileTask.setSlaveDbHost(slaveHost.getIp());
        transFileTask.setSlaveCmServerPort(String.valueOf(Integer.parseInt(slaveHost.getPort()) + 1));
        transFileTask.setSlaveDbDir(slave.getDbPath());
        taskGroup.addTask(transFileTask);
        GetTransferProgressTask getTransferProgressTask = new GetTransferProgressTask(serverInfo);
        taskGroup.addTask(getTransferProgressTask);
    }
    executor.addGroupTask(taskGroup);
    return null;
}
Also used : SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) SetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask) ArrayList(java.util.ArrayList) BackupDbTask(com.cubrid.cubridmanager.core.cubrid.database.task.BackupDbTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetReplServerStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask) StopReplServerTask(com.cubrid.cubridmanager.core.replication.task.StopReplServerTask) CancelTransFileTask(com.cubrid.cubridmanager.core.replication.task.CancelTransFileTask) CancelTransFileTask(com.cubrid.cubridmanager.core.replication.task.CancelTransFileTask) TransFileTask(com.cubrid.cubridmanager.core.replication.task.TransFileTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup) GetTransferProgressTask(com.cubrid.cubridmanager.core.replication.task.GetTransferProgressTask)

Example 38 with CommonUpdateTask

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

the class CreateReplicationUtil method addCheckDbTaskGroup.

/**
	 * 
	 * Fill in the related tasks of check database to executor
	 * 
	 * @param serverInfo ServerInfo
	 * @param dbName String
	 * @param taskGroup TaskGroup
	 */
public static void addCheckDbTaskGroup(ServerInfo serverInfo, String dbName, TaskGroup taskGroup) {
    GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
    getDatabaseListTask.putData("dbName", dbName);
    taskGroup.addTask(getDatabaseListTask);
    CommonUpdateTask stopDbTask = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
    stopDbTask.setDbName(dbName);
    taskGroup.addTask(stopDbTask);
    CommonUpdateTask deleteDbTask = new CommonUpdateTask(CommonTaskName.DELETE_DATABASE_TASK_NAME, serverInfo, CommonSendMsg.getDeletedbSendMsg());
    deleteDbTask.setDbName(dbName);
    deleteDbTask.setDelbackup(YesNoType.Y);
    taskGroup.addTask(deleteDbTask);
}
Also used : GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)

Example 39 with CommonUpdateTask

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

the class SetupEnvTestCase method stopTestDatabase.

protected void stopTestDatabase() {
    if (databaseInfo.getRunningType() == DbRunningType.CS) {
        CommonUpdateTask startTask = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
        startTask.setDbName(databaseInfo.getDbName());
        startTask.execute();
        assertEquals(null, startTask.getErrorMsg());
        databaseInfo.setRunningType(DbRunningType.STANDALONE);
    }
}
Also used : CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)

Example 40 with CommonUpdateTask

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

the class SetupEnvTestCase method startTestDatabase.

protected void startTestDatabase() {
    if (databaseInfo.getRunningType() == DbRunningType.STANDALONE) {
        CommonUpdateTask startTask = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
        startTask.setDbName(databaseInfo.getDbName());
        startTask.execute();
        assertEquals(null, startTask.getErrorMsg());
        databaseInfo.setRunningType(DbRunningType.CS);
    }
}
Also used : CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)

Aggregations

CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)40 ITask (com.cubrid.common.core.task.ITask)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)7 Display (org.eclipse.swt.widgets.Display)7 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)5 JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)5 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)5 SetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask)5 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)4 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)4 GetReplServerStatusTask (com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask)4 StopReplServerTask (com.cubrid.cubridmanager.core.replication.task.StopReplServerTask)4 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)3 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)3 MonitorDashboardPreference (com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference)3