Search in sources :

Example 1 with HostNode

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);
                        }
                    }
                }
            }
        }
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) DistributorInfo(com.cubrid.cubridmanager.core.replication.model.DistributorInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) Point(org.eclipse.draw2d.geometry.Point) Dimension(org.eclipse.draw2d.geometry.Dimension) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) Point(org.eclipse.draw2d.geometry.Point) Diagram(com.cubrid.cubridmanager.ui.replication.editor.model.Diagram) MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) SlaveInfo(com.cubrid.cubridmanager.core.replication.model.SlaveInfo) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 2 with HostNode

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;
}
Also used : GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) StopReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StopReplicationAgentTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) StartReplicationAgentTask(com.cubrid.cubridmanager.core.replication.task.StartReplicationAgentTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup)

Example 3 with HostNode

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;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) SetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask) BackupDbTask(com.cubrid.cubridmanager.core.cubrid.database.task.BackupDbTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetReplServerStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask) StopReplServerTask(com.cubrid.cubridmanager.core.replication.task.StopReplServerTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) TaskGroup(com.cubrid.common.ui.spi.progress.TaskGroup)

Example 4 with HostNode

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();
    }
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) SetHostInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetHostInfoDialog) ReplicationEditor(com.cubrid.cubridmanager.ui.replication.editor.ReplicationEditor) Shell(org.eclipse.swt.widgets.Shell) IWorkbenchPart(org.eclipse.ui.IWorkbenchPart) SetDistributorDbInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetDistributorDbInfoDialog) NodePart(com.cubrid.cubridmanager.ui.replication.editor.parts.NodePart) SetMasterDbInfoWizard(com.cubrid.cubridmanager.ui.replication.editor.dialog.wizard.SetMasterDbInfoWizard) CMWizardDialog(com.cubrid.common.ui.spi.dialog.CMWizardDialog) SetSlaveDbInfoDialog(com.cubrid.cubridmanager.ui.replication.editor.dialog.SetSlaveDbInfoDialog) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 5 with HostNode

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"));
    }
}
Also used : ContainerNodeFigure(com.cubrid.cubridmanager.ui.replication.editor.figures.ContainerNodeFigure) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)

Aggregations

HostNode (com.cubrid.cubridmanager.ui.replication.editor.model.HostNode)15 TaskGroup (com.cubrid.common.ui.spi.progress.TaskGroup)7 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)7 SlaveNode (com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode)5 DistributorNode (com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)4 MasterNode (com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode)4 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 ContainerNode (com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode)3 ArrayList (java.util.ArrayList)3 Point (org.eclipse.draw2d.geometry.Point)3 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)2 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)2 SetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.SetCubridConfParameterTask)2 BackupDbTask (com.cubrid.cubridmanager.core.cubrid.database.task.BackupDbTask)2 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)2 CreateDistributorTask (com.cubrid.cubridmanager.core.replication.task.CreateDistributorTask)2 GetReplServerStatusTask (com.cubrid.cubridmanager.core.replication.task.GetReplServerStatusTask)2 StopReplServerTask (com.cubrid.cubridmanager.core.replication.task.StopReplServerTask)2 SetHostInfoDialog (com.cubrid.cubridmanager.ui.replication.editor.dialog.SetHostInfoDialog)2