use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.
the class StartReplicationAgentAction method run.
/**
* Start replication agent and refresh navigator
*/
public void run() {
Object[] obj = this.getSelectedObj();
if (obj == null || obj.length == 0 || !isSupported(obj[0])) {
setEnabled(false);
return;
}
ISchemaNode schemaNode = (ISchemaNode) obj[0];
CubridDatabase database = schemaNode.getDatabase();
String dbNames = database.getName();
String dbaPassword = database.getPassword();
ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
if (!CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmStartMasterDbAndSlaveDb, replInfo.getMasterList().get(0).getMasterDbName(), replInfo.getSlaveList().get(0).getSlaveDbName()))) {
return;
}
StartReplicationAgentTask task = new StartReplicationAgentTask(database.getServer().getServerInfo());
task.setDbName(dbNames);
task.setDbaPasswd(dbaPassword);
TaskExecutor taskExecutor = new CommonTaskExec(null);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
CommonUITool.openInformationBox(Messages.msgSuccess, Messages.bind(Messages.msgStartAgent, dbNames));
if (replInfo != null && replInfo.getDistInfo() != null) {
replInfo.getDistInfo().setAgentActive(true);
}
ActionManager.getInstance().fireSelectionChanged(getSelection());
}
}
use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.
the class StopReplicationAgentAction method isSupportedNode.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public static boolean isSupportedNode(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined()) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
if (!database.isDistributorDb()) {
return false;
}
ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
if (replInfo != null && replInfo.getDistInfo() != null) {
return replInfo.getDistInfo().isAgentActive();
}
return false;
}
return false;
}
use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo 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.model.ReplicationInfo in project cubrid-manager by CUBRID.
the class GetReplicationInfoTaskTest method testReceive.
public void testReceive() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
//case 1
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/replication/task/test.message/GetReplicationInfo_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
GetReplicationInfoTask task = new GetReplicationInfoTask(serverInfo);
task.setResponse(node);
ReplicationInfo replInfo = task.getReplicationInfo();
assertEquals(replInfo.getDistInfo().getAgentPort(), "6443");
assertEquals(replInfo.getDistInfo().getCopyLogPath(), "/home/biaozhang/cubrid/databases/dist_biaodb");
assertEquals(replInfo.getDistInfo().getTrailLogPath(), "/home/biaozhang/cubrid/databases/dist_biaodb");
assertEquals(replInfo.getDistInfo().getErrorLogPath(), "/home/biaozhang/cubrid/databases/dist_biaodb");
assertEquals(replInfo.getDistInfo().getDelayTimeLogSize(), "1090");
assertTrue(replInfo.getDistInfo().isRestartReplWhenError());
assertEquals(replInfo.getMasterList().get(0).getMasterDbName(), "src_biaodb");
assertEquals(replInfo.getMasterList().get(0).getMasterIp(), "192.168.1.132");
assertEquals(replInfo.getMasterList().get(0).getReplServerPort(), "5555");
assertEquals(replInfo.getSlaveList().get(0).getSlaveDbName(), "dest_biaodb");
assertEquals(replInfo.getSlaveList().get(0).getSlaveIP(), "192.168.1.212");
assertEquals(replInfo.getSlaveList().get(0).getDbUser(), "dba");
assertEquals(replInfo.getSlaveList().get(0).getPassword(), "123456");
//exception case1
task.setResponse(null);
assertTrue(task.getReplicationInfo() == null);
//exception case2
task.setResponse(node);
task.setErrorMsg("has error");
assertTrue(task.getReplicationInfo() == null);
}
use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.
the class ReplServerDialog method initialize.
/**
* initialize some values
*/
private void initialize() {
if (node != null) {
ReplicationInfo replInfo = (ReplicationInfo) node.getAdapter(ReplicationInfo.class);
if (replInfo != null && replInfo.getMasterList() != null && replInfo.getMasterList().size() > 0) {
MasterInfo masterInfo = replInfo.getMasterList().get(0);
ipText.setText(masterInfo.getMasterIp());
portText.setText("8001");
portText.selectAll();
userNameText.setText("admin");
passwordText.setText("");
mdbNameText.setText(masterInfo.getMasterDbName());
replServerPortText.setText(masterInfo.getReplServerPort());
}
portText.addModifyListener(this);
passwordText.addModifyListener(this);
}
}
Aggregations