Search in sources :

Example 16 with ReplicationInfo

use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.

the class ChangeTablesPage method initialize.

/**
	 * initialize some values
	 */
private void initialize() {
    MasterInfo masterInfo = null;
    if (replNode != null) {
        String type = replNode.getType();
        if (CubridNodeType.DATABASE.equals(type)) {
            ReplicationInfo replInfo = (ReplicationInfo) replNode.getAdapter(ReplicationInfo.class);
            masterInfo = replInfo != null && replInfo.getMasterList() != null && replInfo.getMasterList().size() > 0 ? replInfo.getMasterList().get(0) : null;
        }
    }
    if (masterInfo == null) {
        return;
    }
    List<String> replClassList = masterInfo.getReplTableList();
    boolean isReplAll = masterInfo.isReplAllTable();
    selectTableComp.setReplAllTables(isReplAll);
    selectTableComp.setSelectedTableList(replClassList);
}
Also used : MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)

Example 17 with ReplicationInfo

use of com.cubrid.cubridmanager.core.replication.model.ReplicationInfo in project cubrid-manager by CUBRID.

the class ViewReplicationErrorLogAction method run.

/**
	 * view replication error log
	 */
public void run() {
    final IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
    if (window == null) {
        return;
    }
    Object[] obj = this.getSelectedObj();
    if (!isSupported(obj[0])) {
        setEnabled(false);
        return;
    }
    final ISchemaNode schemaNode = (ISchemaNode) obj[0];
    cubridNode = schemaNode;
    ReplicationInfo replInfo = (ReplicationInfo) schemaNode.getAdapter(ReplicationInfo.class);
    final GetLogListTask task = new GetLogListTask(schemaNode.getServer().getServerInfo());
    TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {

        public IStatus exec(IProgressMonitor monitor) {
            if (monitor.isCanceled()) {
                cubridNode = null;
                return Status.CANCEL_STATUS;
            }
            for (ITask t : taskList) {
                t.execute();
                final String msg = t.getErrorMsg();
                if (monitor.isCanceled()) {
                    cubridNode = null;
                    return Status.CANCEL_STATUS;
                }
                if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                    cubridNode = null;
                    return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                } else {
                    Display.getDefault().syncExec(new Runnable() {

                        public void run() {
                            LogContentInfo logContentInfo = (LogContentInfo) task.getLogContent();
                            IEditorPart editorPart = LayoutUtil.getEditorPart(cubridNode, LogEditorPart.ID);
                            if (editorPart != null) {
                                window.getActivePage().closeEditor(editorPart, false);
                            }
                            try {
                                IEditorPart editor = window.getActivePage().openEditor(cubridNode, LogEditorPart.ID);
                                ((LogEditorPart) editor).setTableInfo(logContentInfo, true);
                            } catch (PartInitException e) {
                                LOGGER.error(e.getMessage(), e);
                            }
                        }
                    });
                }
                if (monitor.isCanceled()) {
                    cubridNode = null;
                    return Status.CANCEL_STATUS;
                }
            }
            cubridNode = null;
            return Status.OK_STATUS;
        }
    };
    String errPath = replInfo.getDistInfo().getCopyLogPath().substring(0, replInfo.getDistInfo().getCopyLogPath().indexOf(replInfo.getDistInfo().getDistDbName())) + replInfo.getDistInfo().getDistDbName() + schemaNode.getServer().getServerInfo().getPathSeparator() + replInfo.getDistInfo().getDistDbName() + ".err";
    task.setPath(errPath);
    task.setStart("1");
    task.setEnd("100");
    taskJobExecutor.addTask(task);
    String jobName = Messages.viewLogJobName + " - " + cubridNode.getName() + "@" + cubridNode.getServer().getName();
    taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITask(com.cubrid.common.core.task.ITask) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) IEditorPart(org.eclipse.ui.IEditorPart) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) LogContentInfo(com.cubrid.cubridmanager.core.logs.model.LogContentInfo) GetLogListTask(com.cubrid.cubridmanager.core.logs.task.GetLogListTask) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) PartInitException(org.eclipse.ui.PartInitException)

Aggregations

ReplicationInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationInfo)17 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)9 MasterInfo (com.cubrid.cubridmanager.core.replication.model.MasterInfo)6 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)5 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)5 SlaveInfo (com.cubrid.cubridmanager.core.replication.model.SlaveInfo)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 ITask (com.cubrid.common.core.task.ITask)3 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)3 DistributorInfo (com.cubrid.cubridmanager.core.replication.model.DistributorInfo)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)2 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 TreeNode (com.cubrid.cubridmanager.core.common.socket.TreeNode)2 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)2 ReplicationParamInfo (com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo)2 HashSet (java.util.HashSet)2 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)2 TreeViewer (org.eclipse.jface.viewers.TreeViewer)2