use of com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo in project cubrid-manager by CUBRID.
the class GetReplParmetersTaskTest method testReceive.
public void testReceive() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/replication/task/test.message/GetReplicationParam_receive");
String msg = Tool.getFileContent(filepath);
TreeNode node = MessageUtil.parseResponse(msg);
GetReplicationParamTask task = new GetReplicationParamTask(serverInfo);
task.setResponse(node);
ReplicationParamInfo paramInfo = task.getReplicationParams();
assertEquals(paramInfo.getParamValue(ReplicationParamConstants.PERF_POLL_INTERVAL), "30");
assertEquals(paramInfo.getParamValue(ReplicationParamConstants.FOR_RECOVERY), "Y");
//exception case1
task.setResponse(null);
assertTrue(task.getReplicationParams() == null);
//exception case2
task.setResponse(node);
task.setErrorMsg("has error");
assertTrue(task.getReplicationParams() == null);
}
use of com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo in project cubrid-manager by CUBRID.
the class GetReplicationParamTask method getReplicationParams.
/**
* get result from the response.
*
* @return the ReplicationParamInfo obj
*/
public ReplicationParamInfo getReplicationParams() {
TreeNode response = getResponse();
if (response == null || (this.getErrorMsg() != null && getErrorMsg().trim().length() > 0)) {
return null;
}
ReplicationParamInfo replicationParamInfo = new ReplicationParamInfo();
Map<String, String> dataMap = new HashMap<String, String>();
dataMap.put(ReplicationParamConstants.PERF_POLL_INTERVAL, response.getValue(ReplicationParamConstants.PERF_POLL_INTERVAL));
dataMap.put(ReplicationParamConstants.SIZE_OF_LOG_BUFFER, response.getValue(ReplicationParamConstants.SIZE_OF_LOG_BUFFER));
dataMap.put(ReplicationParamConstants.SIZE_OF_CACHE_BUFFER, response.getValue(ReplicationParamConstants.SIZE_OF_CACHE_BUFFER));
dataMap.put(ReplicationParamConstants.SIZE_OF_COPYLOG, response.getValue(ReplicationParamConstants.SIZE_OF_COPYLOG));
dataMap.put(ReplicationParamConstants.INDEX_REPLICATION, response.getValue(ReplicationParamConstants.INDEX_REPLICATION));
dataMap.put(ReplicationParamConstants.FOR_RECOVERY, response.getValue(ReplicationParamConstants.FOR_RECOVERY));
dataMap.put(ReplicationParamConstants.LOG_APPLY_INTERVAL, response.getValue(ReplicationParamConstants.LOG_APPLY_INTERVAL));
dataMap.put(ReplicationParamConstants.RESTART_INTERVAL, response.getValue(ReplicationParamConstants.RESTART_INTERVAL));
replicationParamInfo.setParamMap(dataMap);
return replicationParamInfo;
}
use of com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo in project cubrid-manager by CUBRID.
the class ReplicationEditor method createDiagram.
/**
* create the diagram
*
* @param input IEditorInput
*/
private void createDiagram(IEditorInput input) {
diagram = new Diagram();
if (input instanceof ICubridNode) {
ICubridNode node = (ICubridNode) input;
if (NodeType.DATABASE.equals(node.getType())) {
isEditable = false;
CubridServer server = node.getServer();
int x = 100;
int y = 20;
int hostVertSpan = 100;
if (server != null) {
ReplicationInfo replicationInfo = (ReplicationInfo) node.getAdapter(ReplicationInfo.class);
if (replicationInfo != null) {
//distributor component
DistributorInfo distInfo = replicationInfo.getDistInfo();
DistributorNode dist = null;
if (distInfo != null) {
dist = new DistributorNode();
dist.setDbName(distInfo.getDistDbName());
dist.setDbPath(distInfo.getDistDbPath());
dist.setCopyLogPath(distInfo.getCopyLogPath());
dist.setErrorLogPath(distInfo.getErrorLogPath());
dist.setTrailLogPath(distInfo.getTrailLogPath());
dist.setReplAgentPort(distInfo.getAgentPort());
dist.setDelayTimeLogSize(distInfo.getDelayTimeLogSize());
dist.setRestartWhenError(distInfo.isRestartReplWhenError());
dist.setName(distInfo.getDistDbName());
dist.setLocation(new Point(30, 30));
dist.setSize(new Dimension(120, 40));
}
//master component
List<MasterInfo> masterList = replicationInfo.getMasterList();
MasterNode master = null;
for (int i = 0; masterList != null && i < masterList.size(); i++) {
MasterInfo masterInfo = masterList.get(i);
if (masterInfo != null) {
master = new MasterNode();
String ip = masterInfo.getMasterIp();
String masterDbName = masterInfo.getMasterDbName();
String replServerPort = masterInfo.getReplServerPort();
boolean isReplAll = masterInfo.isReplAllTable();
List<String> tableList = masterInfo.getReplTableList();
HostNode mdbHost = new HostNode();
mdbHost.setIp(ip);
mdbHost.setUserName("admin");
mdbHost.setName(ip);
mdbHost.setLocation(new Point(x, y));
y += mdbHost.getSize().height + hostVertSpan;
mdbHost.setParent(diagram);
diagram.addNode(mdbHost);
master.setDbName(masterDbName);
master.setReplServerPort(replServerPort);
master.setReplicateAll(isReplAll);
master.setReplicatedClassList(tableList);
master.setName(masterDbName);
master.setLocation(new Point(30, 80));
master.setSize(new Dimension(120, 40));
master.setParent(mdbHost);
mdbHost.addChildNode(master);
}
}
//distributor host component
HostNode distdbhost = new HostNode();
distdbhost.setIp(server.getHostAddress());
distdbhost.setPort(server.getMonPort());
distdbhost.setUserName(server.getUserName());
distdbhost.setPassword(server.getPassword());
distdbhost.setName(server.getHostAddress() + ":" + server.getMonPort());
distdbhost.setLocation(new Point(x, y));
distdbhost.setParent(diagram);
diagram.addNode(distdbhost);
//distributor component
if (dist != null) {
dist.setParent(distdbhost);
distdbhost.addChildNode(dist);
}
//slave component
List<SlaveInfo> slaveInfoList = replicationInfo.getSlaveList();
SlaveNode slave = null;
for (int i = 0; slaveInfoList != null && i < slaveInfoList.size(); i++) {
SlaveInfo slaveInfo = slaveInfoList.get(i);
if (slaveInfo != null) {
slave = new SlaveNode();
slave.setDbName(slaveInfo.getSlaveDbName());
slave.setDbPath(slaveInfo.getSlaveDbPath());
slave.setDbUser(slaveInfo.getDbUser());
slave.setDbPassword(slaveInfo.getPassword());
ReplicationParamInfo replParaInfo = slaveInfo.getParamInfo();
if (replParaInfo != null) {
slave.setParamMap(replParaInfo.getParamMap());
}
slave.setName(slaveInfo.getSlaveDbName());
slave.setLocation(new Point(30, 150));
slave.setSize(new Dimension(120, 40));
slave.setParent(distdbhost);
distdbhost.addChildNode(slave);
}
}
}
}
}
}
}
use of com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo 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.model.ReplicationParamInfo 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);
}
}
Aggregations