Search in sources :

Example 1 with StopReplicationAgentTask

use of com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask in project cubrid-manager by CUBRID.

the class CreateReplicationUtil method createAgentTaskGroup.

/**
	 * 
	 * Fill in the related tasks of agent to executor
	 * 
	 * @param dist DistributorNode
	 * @param executor CreateReplicationJobExecutor
	 * @return null or error message
	 */
public static String createAgentTaskGroup(DistributorNode dist, CreateReplicationJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_START_AGENT);
    taskGroup.setTarget(dist.getDbName());
    HostNode distdbHost = (HostNode) dist.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);
    }
    GetReplAgentStatusTask getReplAgentStatusTask = new GetReplAgentStatusTask(serverInfo);
    getReplAgentStatusTask.setDbName(dist.getDbName());
    taskGroup.addTask(getReplAgentStatusTask);
    StopReplicationAgentTask stopReplicationAgentTask = new StopReplicationAgentTask(serverInfo);
    stopReplicationAgentTask.setDbName(dist.getDbName());
    taskGroup.addTask(stopReplicationAgentTask);
    StartReplicationAgentTask startReplicationAgentTask = new StartReplicationAgentTask(serverInfo);
    startReplicationAgentTask.setDbName(dist.getDbName());
    startReplicationAgentTask.setDbaPasswd(dist.getDbaPassword());
    taskGroup.addTask(startReplicationAgentTask);
    executor.addGroupTask(taskGroup);
    return null;
}
Also used : GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) StartReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StartReplicationAgentTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup)

Example 2 with StopReplicationAgentTask

use of com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask in project cubrid-manager by CUBRID.

the class StopReplicationAgentAction method run.

/**
	 * Start database and refresh navigator
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    ISchemaNode schemaNode = (ISchemaNode) obj[0];
    CubridDatabase database = schemaNode.getDatabase();
    String dbNames = database.getName();
    boolean isStop = CommonUITool.openConfirmBox(getShell(), Messages.bind(Messages.msgConfirmStopAgent, dbNames));
    if (!isStop) {
        return;
    }
    ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
    StopReplicationAgentTask task = new StopReplicationAgentTask(database.getServer().getServerInfo());
    task.setDbName(dbNames);
    TaskExecutor taskExecutor = new CommonTaskExec(null);
    taskExecutor.addTask(task);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (taskExecutor.isSuccess()) {
        CommonUITool.openInformationBox(Messages.msgSuccess, Messages.bind(Messages.msgStopAgent, dbNames));
        replInfo.getDistInfo().setAgentActive(false);
        ActionManager.getInstance().fireSelectionChanged(getSelection());
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 3 with StopReplicationAgentTask

use of com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask in project cubrid-manager by CUBRID.

the class DeleteDatabaseDialog method deleteDatabase.

/**
	 * 
	 * Delete the database
	 * 
	 * @return <code>true</code> if successful;<code>false</code> otherwise
	 */
private boolean deleteDatabase() {
    TaskExecutor taskExcutor = new TaskExecutor() {

        public boolean exec(final IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                return false;
            }
            String taskName = Messages.bind(Messages.delDbTaskName, database.getName());
            monitor.beginTask(taskName, IProgressMonitor.UNKNOWN);
            boolean isActiveReplServer = false;
            boolean isActiveReplAgent = false;
            List<String> cubridConfContentList = null;
            for (ITask task : taskList) {
                if (task instanceof GetReplServerStatusTask) {
                    GetReplServerStatusTask getReplServerStatusTask = (GetReplServerStatusTask) task;
                    getReplServerStatusTask.execute();
                    isActiveReplServer = getReplServerStatusTask.isActive();
                } else if (task instanceof StopReplServerTask) {
                    if (isActiveReplServer) {
                        task.execute();
                    }
                } else if (task instanceof GetReplAgentStatusTask) {
                    GetReplAgentStatusTask getReplAgentStatusTask = (GetReplAgentStatusTask) task;
                    getReplAgentStatusTask.execute();
                    isActiveReplAgent = getReplAgentStatusTask.isActive();
                } else if (task instanceof StopReplicationAgentTask) {
                    if (isActiveReplAgent) {
                        task.execute();
                    }
                } else if (task instanceof SetCubridConfParameterTask) {
                    if (cubridConfContentList == null) {
                        continue;
                    } else {
                        SetCubridConfParameterTask setParaTask = (SetCubridConfParameterTask) task;
                        setParaTask.setConfContents(cubridConfContentList);
                        setParaTask.execute();
                    }
                } else {
                    task.execute();
                }
                final String msg = task.getErrorMsg();
                if (openErrorBox(getShell(), msg, monitor)) {
                    return false;
                }
                if (monitor.isCanceled()) {
                    return false;
                }
                if (task instanceof GetCubridConfParameterTask) {
                    GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
                    cubridConfContentList = CoreUtils.deleteDatabaseFromServiceServer(getCubridConfParameterTask, cubridConfContentList, database.getName());
                }
            }
            return true;
        }
    };
    ServerInfo serverInfo = database.getServer().getServerInfo();
    //check the replication server and agent
    if (serverInfo.isSupportReplication() == 0) {
        if (database.isDistributorDb()) {
            GetReplAgentStatusTask getReplAgentStatusTask = new GetReplAgentStatusTask(serverInfo);
            getReplAgentStatusTask.setDbName(database.getLabel());
            taskExcutor.addTask(getReplAgentStatusTask);
            StopReplicationAgentTask stopReplAgentTask = new StopReplicationAgentTask(serverInfo);
            stopReplAgentTask.setDbName(database.getLabel());
            taskExcutor.addTask(stopReplAgentTask);
        } else {
            GetReplServerStatusTask getReplServerStatusTask = new GetReplServerStatusTask(serverInfo);
            getReplServerStatusTask.setDbName(database.getLabel());
            taskExcutor.addTask(getReplServerStatusTask);
            StopReplServerTask stopReplServerTask = new StopReplServerTask(serverInfo);
            stopReplServerTask.setDbName(database.getLabel());
            taskExcutor.addTask(stopReplServerTask);
        }
    }
    CommonUpdateTask deleteDbtask = new CommonUpdateTask(CommonTaskName.DELETE_DATABASE_TASK_NAME, serverInfo, CommonSendMsg.getDeletedbSendMsg());
    deleteDbtask.setDbName(database.getName());
    if (deleteBackupVolumesButton.getSelection()) {
        deleteDbtask.setDelbackup(YesNoType.Y);
    } else {
        deleteDbtask.setDelbackup(YesNoType.N);
    }
    taskExcutor.addTask(deleteDbtask);
    GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
    taskExcutor.addTask(getCubridConfParameterTask);
    SetCubridConfParameterTask setCubridConfParameterTask = new SetCubridConfParameterTask(serverInfo);
    taskExcutor.addTask(setCubridConfParameterTask);
    new ExecTaskWithProgress(taskExcutor).exec(true, false);
    if (taskExcutor.isSuccess()) {
        setReturnCode(DELETE_ID);
        close();
        return true;
    } else {
        return false;
    }
}
Also used : ITask(com.cubrid.common.core.task.ITask) GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) SetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) GetReplServerStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask) StopReplServerTask(com.cubrid.cubridmanager.core.replication.task.StopReplServerTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)

Example 4 with StopReplicationAgentTask

use of com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask in project cubrid-manager by CUBRID.

the class CreateReplicationJobExecutor method startAgent.

/**
	 * start agent service
	 * 
	 * @param agentName String
	 * @param monitor IProgressMonitor
	 * @param taskList List<ITask>
	 * @return status
	 */
private IStatus startAgent(String agentName, final IProgressMonitor monitor, List<ITask> taskList) {
    monitor.subTask(Messages.bind(Messages.startAgentJobName, agentName));
    MonitoringTask monitoringTask = null;
    boolean isExecuteStopAgentTask = 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 StopReplicationAgentTask) {
            if (isExecuteStopAgentTask) {
                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 GetReplAgentStatusTask) {
            GetReplAgentStatusTask getReplAgentStatusTask = (GetReplAgentStatusTask) task;
            isExecuteStopAgentTask = getReplAgentStatusTask.isActive();
        }
    }
    disConnect(monitoringTask);
    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) GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask)

Example 5 with StopReplicationAgentTask

use of com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask in project cubrid-manager by CUBRID.

the class ChangeSlaveDbWizard method createSlaveTaskGroup.

/**
	 * create slave database task group
	 * 
	 * @param executor CreateReplicationSlaveDbJobExecutor
	 * @return boolean
	 */
public boolean createSlaveTaskGroup(CreateReplicationSlaveDbJobExecutor executor) {
    TaskGroup taskGroup = new TaskGroup(REPL_GROUP_NAME_CREATE_SLAVE);
    taskGroup.setTarget(slaveDbInfoPage.getSlaveDbName());
    CreateReplicationUtil.addCheckDbTaskGroup(database.getServer().getServerInfo(), slaveDbInfoPage.getSlaveDbName(), taskGroup);
    GetReplAgentStatusTask getReplAgentStatusTask = new GetReplAgentStatusTask(database.getServer().getServerInfo());
    getReplAgentStatusTask.setDbName(database.getLabel());
    taskGroup.addTask(getReplAgentStatusTask);
    StopReplicationAgentTask stopReplicationAgentTask = new StopReplicationAgentTask(database.getServer().getServerInfo());
    stopReplicationAgentTask.setDbName(database.getLabel());
    taskGroup.addTask(stopReplicationAgentTask);
    CreateSlaveDbTask createSlaveDbTask = new CreateSlaveDbTask(database.getServer().getServerInfo());
    createSlaveDbTask.setSlaveDbName(slaveDbInfoPage.getSlaveDbName());
    createSlaveDbTask.setSlaveDbPath(slaveDbInfoPage.getSlaveDbPath());
    createSlaveDbTask.setSlaveDbUser(slaveDbInfoPage.getSlaveDbUser());
    createSlaveDbTask.setSlaveDbPassword(slaveDbInfoPage.getSlaveDbaPassword());
    createSlaveDbTask.setMasterDbName(slaveDbInfoPage.getMasterDbName());
    createSlaveDbTask.setMasterDbPassword(slaveDbInfoPage.getMasterDbDbaPassword());
    createSlaveDbTask.setDistDbName(database.getLabel());
    createSlaveDbTask.setDistDbaPassword(database.getPassword());
    taskGroup.addTask(createSlaveDbTask);
    SetReplicationParamTask setReplicationParamTask = new SetReplicationParamTask(database.getServer().getServerInfo());
    setReplicationParamTask.setMasterDbName(slaveDbInfoPage.getMasterDbName());
    setReplicationParamTask.setSlaveDbName(slaveDbInfoPage.getSlaveDbName());
    setReplicationParamTask.setDistDbName(database.getLabel());
    setReplicationParamTask.setDistDbDbaPasswd(database.getPassword());
    setReplicationParamTask.setParameterMap(setReplicationParamPage.getParamMap());
    setReplicationParamTask.setRunningMode(true);
    taskGroup.addTask(setReplicationParamTask);
    ChangeReplTablesTask changeReplTablesTask = new ChangeReplTablesTask(database.getServer().getServerInfo());
    changeReplTablesTask.setDistdbName(database.getLabel());
    changeReplTablesTask.setDistdbPassword(database.getPassword());
    changeReplTablesTask.setMdbName(slaveDbInfoPage.getMasterDbName());
    changeReplTablesTask.setMdbUserId("dba");
    changeReplTablesTask.setMdbPass(slaveDbInfoPage.getMasterDbDbaPassword());
    if (selectTablesPage.isReplAllTables()) {
        changeReplTablesTask.setReplAllClasses(selectTablesPage.isReplAllTables());
    } else if (selectTablesPage.getReplTableList() != null && selectTablesPage.getReplTableList().size() > 0) {
        changeReplTablesTask.setReplicatedClasses(selectTablesPage.getReplTableList());
    } else {
        changeReplTablesTask.setReplNoneClasses(true);
    }
    taskGroup.addTask(changeReplTablesTask);
    executor.addGroupTask(taskGroup);
    return true;
}
Also used : ChangeReplTablesTask(com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask) CreateSlaveDbTask(com.cubrid.cubridmanager.core.replication.task.CreateSlaveDbTask) GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup) SetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.SetReplicationParamTask)

Aggregations

StopReplicationAgentTask (com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask)5 GetReplAgentStatusTask (com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 ITask (com.cubrid.common.core.task.ITask)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 TaskGroup (com.cubrid.common.ui.spi.progress.TaskGroup)2 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)2 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)1 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)1 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)1 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)1 SetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask)1 ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)1 ChangeReplTablesTask (com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask)1 CreateSlaveDbTask (com.cubrid.cubridmanager.core.replication.task.CreateSlaveDbTask)1 GetReplServerStatusTask (com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask)1 SetReplicationParamTask (com.cubrid.cubridmanager.core.replication.task.SetReplicationParamTask)1 StartReplicationAgentTask (com.cubrid.cubridmanager.core.replication.task.StartReplicationAgentTask)1