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;
}
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());
}
}
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;
}
}
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;
}
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;
}
Aggregations