use of com.cubrid.cubridmanager.ui.replication.editor.model.HostNode 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.ui.replication.editor.model.HostNode 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.ui.replication.editor.model.HostNode in project cubrid-manager by CUBRID.
the class CreateReplicationUtil method createSlaveMasterTaskGroup.
/**
*
* Fill in the related tasks of creating master to executor according to
* slave and master information,this slave node is also master node.
*
* @param master MasterNode
* @param slave SlaveNode
* @param executor CreateReplicationJobExecutor
* @return null or error message
*/
public static String createSlaveMasterTaskGroup(MasterNode master, SlaveNode slave, CreateReplicationJobExecutor executor) {
TaskGroup taskGroup = new TaskGroup(IConstants.REPL_GROUP_NAME_CREATE_MASTER);
taskGroup.setTarget(master.getDbName());
HostNode slaveHost = (HostNode) slave.getParent();
final String ip = slaveHost.getIp();
final String port = slaveHost.getPort();
final String userName = slaveHost.getUserName();
final String password = slaveHost.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);
}
GetReplServerStatusTask getReplServerStatusTask = new GetReplServerStatusTask(serverInfo);
getReplServerStatusTask.setDbName(slave.getDbName());
taskGroup.addTask(getReplServerStatusTask);
StopReplServerTask stopReplServerTask = new StopReplServerTask(serverInfo);
stopReplServerTask.setDbName(slave.getDbName());
taskGroup.addTask(stopReplServerTask);
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
getCubridConfParameterTask.putData("dbName", slave.getDbName());
taskGroup.addTask(getCubridConfParameterTask);
SetCubridConfParameterTask setCubridConfParameterTask = new SetCubridConfParameterTask(serverInfo);
taskGroup.addTask(setCubridConfParameterTask);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
getDatabaseListTask.putData("dbName", slave.getDbName());
taskGroup.addTask(getDatabaseListTask);
CommonUpdateTask stopDbTask = new CommonUpdateTask(CommonTaskName.STOP_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
stopDbTask.setDbName(slave.getDbName());
taskGroup.addTask(stopDbTask);
CommonUpdateTask startDbTask = new CommonUpdateTask(CommonTaskName.START_DB_TASK_NAME, serverInfo, CommonSendMsg.getCommonDatabaseSendMsg());
startDbTask.setDbName(slave.getDbName());
taskGroup.addTask(startDbTask);
BackupDbTask backupDbTask = new BackupDbTask(serverInfo);
backupDbTask.setDbName(slave.getDbName());
backupDbTask.setLevel("0");
backupDbTask.setVolumeName(slave.getDbName() + "_bk0v000");
backupDbTask.setBackupDir(slave.getDbPath());
backupDbTask.setRemoveLog(false);
backupDbTask.setCheckDatabaseConsist(true);
backupDbTask.setThreadCount(String.valueOf(0));
backupDbTask.setZiped(false);
backupDbTask.setSafeReplication(false);
taskGroup.addTask(backupDbTask);
executor.addGroupTask(taskGroup);
return null;
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.HostNode in project cubrid-manager by CUBRID.
the class EditAction method run.
/**
* @see org.eclipse.jface.action.Action#run()
*/
public void run() {
IWorkbenchPart workbenchPart = this.getWorkbenchPart();
if (!(workbenchPart instanceof ReplicationEditor) || !isEnabled()) {
return;
}
ReplicationEditor replEditor = (ReplicationEditor) workbenchPart;
Shell shell = replEditor.getSite().getShell();
NodePart nodePart = (NodePart) getSelectedObjects().get(0);
if (nodePart.getModel() instanceof MasterNode) {
SetMasterDbInfoWizard wizard = new SetMasterDbInfoWizard((MasterNode) nodePart.getModel());
wizard.setEditable(replEditor.isEditable());
CMWizardDialog dialog = new CMWizardDialog(shell, wizard);
dialog.setPageSize(560, 300);
dialog.open();
} else if (nodePart.getModel() instanceof DistributorNode) {
SetDistributorDbInfoDialog dialog = new SetDistributorDbInfoDialog(shell);
dialog.setDistributor((DistributorNode) nodePart.getModel());
dialog.setEditable(replEditor.isEditable());
dialog.open();
} else if (nodePart.getModel() instanceof SlaveNode) {
SetSlaveDbInfoDialog dialog = new SetSlaveDbInfoDialog(shell);
dialog.setSlave((SlaveNode) nodePart.getModel());
dialog.setEditable(replEditor.isEditable());
dialog.open();
} else if (nodePart.getModel() instanceof HostNode) {
SetHostInfoDialog dialog = new SetHostInfoDialog(shell);
dialog.setHostInfo((HostNode) nodePart.getModel());
dialog.setEditable(replEditor.isEditable());
dialog.open();
}
}
use of com.cubrid.cubridmanager.ui.replication.editor.model.HostNode in project cubrid-manager by CUBRID.
the class ContainerNodePart method refreshVisuals.
/**
* @see com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart#refreshVisuals()
*/
protected void refreshVisuals() {
super.refreshVisuals();
ContainerNodeFigure figure = (ContainerNodeFigure) getFigure();
figure.setName(((Node) this.getModel()).getName());
if (getContainerNode() instanceof HostNode) {
figure.setIcon(CubridManagerUIPlugin.getImage("icons/navigator/host.png"));
}
}
Aggregations