use of com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask in project cubrid-manager by CUBRID.
the class SetReplicationParamDialog method createBasicGroup.
/**
* Creates basic group
*
* @param parent Composite
*/
private void createBasicGroup(Composite parent) {
final Group group = new Group(parent, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
group.setText(Messages.repparm0grpReplicationInfo);
final GridLayout gridLayout = new GridLayout();
gridLayout.numColumns = 5;
group.setLayout(gridLayout);
Label slaveDbNameLabel = new Label(group, SWT.NONE);
slaveDbNameLabel.setText(Messages.repparm0lblSlaveDbName);
slaveDbNameLabel.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false));
slaveDbNameCombo = new Combo(group, SWT.NONE | SWT.READ_ONLY);
slaveDbNameCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
Button connectButton = new Button(group, SWT.RIGHT);
connectButton.setText(Messages.repparm0btnConnect);
connectButton.setLayoutData(new GridData());
connectButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
GetReplicationParamTask task = new GetReplicationParamTask(database.getServer().getServerInfo());
task.setMasterDbName(replInfo.getMasterList().get(0).getMasterDbName());
task.setSlaveDbName(slaveDbNameCombo.getText());
task.setDistDbName(database.getLabel());
task.setDistDbDbaPasswd(database.getPassword());
task.setRunningMode(database.getRunningType() == DbRunningType.CS);
TaskExecutor taskExecutor = new CommonTaskExec(null);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
ReplicationParamInfo paramInfo = task.getReplicationParams();
Map<String, String> paramMap = paramInfo.getParamMap();
paramEditor.setReplicationParamMap(paramMap);
}
}
});
}
use of com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask in project cubrid-manager by CUBRID.
the class SetReplicationParamDialog method initial.
/**
*
* initial the page content
*
*/
private void initial() {
setReplInfo((ReplicationInfo) database.getAdapter(ReplicationInfo.class));
for (int j = 0; j < replInfo.getSlaveList().size(); j++) {
slaveDbNameCombo.add(replInfo.getSlaveList().get(j).getSlaveDbName());
}
slaveDbNameCombo.setText(replInfo.getSlaveList().get(0).getSlaveDbName());
GetReplicationParamTask task = new GetReplicationParamTask(database.getServer().getServerInfo());
task.setMasterDbName(replInfo.getMasterList().get(0).getMasterDbName());
task.setSlaveDbName(slaveDbNameCombo.getText());
task.setDistDbName(database.getLabel());
task.setDistDbDbaPasswd(database.getPassword());
task.setRunningMode(database.getRunningType() == DbRunningType.CS);
TaskExecutor taskExecutor = new CommonTaskExec(null);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).exec();
if (taskExecutor.isSuccess()) {
ReplicationParamInfo paramInfo = task.getReplicationParams();
Map<String, String> paramMap = paramInfo.getParamMap();
paramEditor.setReplicationParamMap(paramMap);
}
}
use of com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask in project cubrid-manager by CUBRID.
the class CubridDatabaseLoader method loadReplication.
/**
*
* Load replication function
*
* @param parent the parent node
* @param monitor the monitor object
* @return <code>true</code> it can be loaded;<code>false</code> otherwise
*/
private boolean loadReplication(final ICubridNode parent, final IProgressMonitor monitor) {
CubridDatabase database = (CubridDatabase) parent;
ServerInfo serverInfo = parent.getServer().getServerInfo();
ServerUserInfo serverUserInfo = serverInfo.getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return true;
}
DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
if (dbUserInfo == null || dbUserInfo.getName() == null || !dbUserInfo.getName().trim().equalsIgnoreCase("DBA")) {
return true;
}
String dbPassword = dbUserInfo.getNoEncryptPassword();
//add for replication support,only can be supported after version 8.2.2 and in linux OS
if (serverInfo.isSupportReplication() == 0) {
final CheckDistributorDbTask checkDistributorDbTask = new CheckDistributorDbTask(serverInfo);
checkDistributorDbTask.setDistDbName(database.getLabel());
checkDistributorDbTask.setDbaPassword(dbPassword);
checkDistributorDbTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
final GetReplicationInfoTask getReplicationInfoTask = new GetReplicationInfoTask(serverInfo);
getReplicationInfoTask.setDistDbName(database.getLabel());
getReplicationInfoTask.setDbaPassword(dbPassword);
getReplicationInfoTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
final GetReplicatedTablesTask getReplicatedTablesTask = new GetReplicatedTablesTask(serverInfo);
getReplicatedTablesTask.setDistdbName(database.getLabel());
getReplicatedTablesTask.setDistdbPassword(dbPassword);
getReplicatedTablesTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
final GetReplicationParamTask getReplicationParamTask = new GetReplicationParamTask(serverInfo);
getReplicationParamTask.setDistDbName(database.getLabel());
getReplicationParamTask.setDistDbDbaPasswd(dbPassword);
getReplicationParamTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
final GetReplAgentStatusTask getReplAgentStatusTask = new GetReplAgentStatusTask(serverInfo);
getReplAgentStatusTask.setDbName(database.getLabel());
monitorCancel(monitor, new ITask[] { checkDistributorDbTask, getReplicationInfoTask, getReplicatedTablesTask, getReplicationParamTask, getReplAgentStatusTask });
checkDistributorDbTask.execute();
if (!checkResult(checkDistributorDbTask, monitor)) {
return false;
}
boolean isDistdb = checkDistributorDbTask.isDistributorDb();
database.getDatabaseInfo().setDistributorDb(isDistdb);
if (isDistdb) {
getReplicationInfoTask.execute();
if (!checkResult(getReplicationInfoTask, monitor)) {
return false;
}
ReplicationInfo replInfo = getReplicationInfoTask.getReplicationInfo();
database.getDatabaseInfo().setReplInfo(replInfo);
if (replInfo != null && replInfo.getDistInfo() != null) {
replInfo.getDistInfo().setDistDbPath(database.getDatabaseInfo().getDbDir());
}
if (replInfo != null && replInfo.getMasterList() != null && replInfo.getMasterList().size() > 0 && replInfo.getSlaveList() != null && replInfo.getSlaveList().size() > 0) {
MasterInfo masterInfo = replInfo.getMasterList().get(0);
SlaveInfo slaveInfo = replInfo.getSlaveList().get(0);
getReplicatedTablesTask.setMasterdbName(masterInfo.getMasterDbName());
getReplicatedTablesTask.setSlavedbName(slaveInfo.getSlaveDbName());
getReplicatedTablesTask.execute();
if (!checkResult(getReplicatedTablesTask, monitor)) {
return false;
}
String[] classNames = getReplicatedTablesTask.getReplicatedTables();
boolean isReplAll = getReplicatedTablesTask.isReplicateAll();
if (classNames != null && classNames.length > 0) {
masterInfo.setReplTableList(Arrays.asList(classNames));
}
masterInfo.setReplAllTable(isReplAll);
getReplicationParamTask.setMasterDbName(masterInfo.getMasterDbName());
getReplicationParamTask.setSlaveDbName(replInfo.getSlaveList().get(0).getSlaveDbName());
getReplicationParamTask.execute();
if (!checkResult(getReplicationParamTask, monitor)) {
return false;
}
ReplicationParamInfo paramInfo = getReplicationParamTask.getReplicationParams();
slaveInfo.setParamInfo(paramInfo);
}
getReplAgentStatusTask.execute();
if (!checkResult(getReplAgentStatusTask, monitor)) {
return false;
}
boolean isActive = getReplAgentStatusTask.isActive();
replInfo.getDistInfo().setAgentActive(isActive);
}
}
return true;
}
Aggregations