Search in sources :

Example 36 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class ParamDumpDialog method buttonPressed.

/**
	 * When press button in button bar,call this method
	 * 
	 * @param buttonId the button id
	 */
protected void buttonPressed(int buttonId) {
    if (buttonId == IDialogConstants.OK_ID) {
        if (!verify()) {
            return;
        }
        task = new ParamDumpTask(database.getServer().getServerInfo());
        task.setDbName(database.getName());
        task.setBoth(repairButton.getSelection() ? YesNoType.Y : YesNoType.N);
        String serverName = database.getServer().getName();
        String dbName = database.getName();
        jobName = Messages.titleParamDumpDialog + " - " + dbName + "@" + serverName;
        TaskJobExecutor taskExec = new CommonTaskJobExec(this);
        taskExec.addTask(task);
        JobFamily jobFamily = new JobFamily();
        jobFamily.setServerName(serverName);
        jobFamily.setDbName(dbName);
        taskExec.schedule(jobName, jobFamily, true, Job.SHORT);
        return;
    }
    super.buttonPressed(buttonId);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) ParamDumpTask(com.cubrid.cubridmanager.core.cubrid.database.task.ParamDumpTask)

Example 37 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class ReplicationEditor method createReplication.

/**
	 * create the replication
	 * 
	 * @param replicationsList List<List<Node>>
	 */
private void createReplication(List<List<Node>> replicationsList) {
    List<String> tempList = new ArrayList<String>();
    CreateReplicationJobExecutor executor = new CreateReplicationJobExecutor(this);
    for (int i = 0; i < replicationsList.size(); i++) {
        List<Node> replicationList = replicationsList.get(i);
        MasterNode masterDb = null;
        DistributorNode distDb = null;
        SlaveNode slaveDb = null;
        for (int j = 0; j < replicationList.size(); j++) {
            Node node = replicationList.get(j);
            if (node instanceof MasterNode) {
                masterDb = (MasterNode) node;
            } else if (node instanceof DistributorNode) {
                distDb = (DistributorNode) node;
            } else if (node instanceof SlaveNode) {
                slaveDb = (SlaveNode) node;
            }
            HostNode host = (HostNode) node.getParent();
            String str = host.getIp() + ":" + host.getPort() + ":" + node.getName();
            if (isExist(str, tempList)) {
                continue;
            }
            tempList.add(str);
            String errorMsg = null;
            if (node instanceof MasterNode) {
                errorMsg = CreateReplicationUtil.createMasterTaskGroup(masterDb, CreateReplicationUtil.getAllSlaveOfMaster((MasterNode) node, replicationsList), executor);
                if (errorMsg == null) {
                    errorMsg = CreateReplicationUtil.createReplServerTaskGroup(masterDb, executor);
                }
            } else if (node instanceof DistributorNode) {
                if (j > 2) {
                    errorMsg = CreateReplicationUtil.createDistributorTaskGroup(masterDb, slaveDb, distDb, executor);
                } else {
                    errorMsg = CreateReplicationUtil.createDistributorTaskGroup(masterDb, distDb, executor);
                }
                if (errorMsg == null) {
                    errorMsg = CreateReplicationUtil.createAgentTaskGroup(distDb, executor);
                }
            } else if (node instanceof SlaveNode) {
                errorMsg = CreateReplicationUtil.createSlaveTaskGroup(masterDb, distDb, slaveDb, executor);
                if (j > 2 && errorMsg == null) {
                    errorMsg = CreateReplicationUtil.createSlaveMasterTaskGroup(masterDb, slaveDb, executor);
                    if (errorMsg == null) {
                        errorMsg = CreateReplicationUtil.createReplServerTaskGroup(masterDb, executor);
                    }
                }
            }
            if (errorMsg != null) {
                CommonUITool.openErrorBox(errorMsg);
                isEditable = true;
                setDirty(true);
                return;
            }
        }
    }
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(JobFamily.ALL_SERVER);
    jobFamily.setDbName(JobFamily.ALL_DB);
    executor.schedule(Messages.createReplicationJobName, jobFamily, true, Job.SHORT);
}
Also used : MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) ContainerNode(com.cubrid.cubridmanager.ui.replication.editor.model.ContainerNode) SlaveNode(com.cubrid.cubridmanager.ui.replication.editor.model.SlaveNode) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) MasterNode(com.cubrid.cubridmanager.ui.replication.editor.model.MasterNode) Node(com.cubrid.cubridmanager.ui.replication.editor.model.Node) LeafNode(com.cubrid.cubridmanager.ui.replication.editor.model.LeafNode) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) HostNode(com.cubrid.cubridmanager.ui.replication.editor.model.HostNode) ArrayList(java.util.ArrayList) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Point(org.eclipse.draw2d.geometry.Point) DistributorNode(com.cubrid.cubridmanager.ui.replication.editor.model.DistributorNode)

Example 38 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class ChangeReplTablesWizard method performFinish.

/**
	 * Called when user clicks Finish
	 *
	 * @return boolean
	 */
public boolean performFinish() {
    String mdbName = setDatabaseInfoPage.getMasterDbName();
    String distdbName = setDatabaseInfoPage.getDistributorDbName();
    String distdbPassword = setDatabaseInfoPage.getDistdbPassword();
    boolean isReplAllTables = changeTablesPage.isReplAllTables();
    List<String> replTableList = changeTablesPage.getReplTableList();
    TaskJobExecutor taskExcutor = new TaskJobExecutor() {

        public void closeUI() {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    dialog.close();
                }
            });
        }

        public void setVisible(final boolean isVisible) {
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    dialog.getShell().setVisible(isVisible);
                }
            });
        }

        public IStatus exec(final IProgressMonitor monitor) {
            setVisible(false);
            for (ITask task : taskList) {
                task.execute();
                if (monitor.isCanceled()) {
                    closeUI();
                    return Status.CANCEL_STATUS;
                }
                final String msg = task.getErrorMsg();
                if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
                    return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
                }
            }
            closeUI();
            return Status.OK_STATUS;
        }
    };
    ServerInfo serverInfo = replicationNode.getServer().getServerInfo();
    ChangeReplTablesTask task = new ChangeReplTablesTask(serverInfo);
    task.setMdbName(mdbName);
    task.setDistdbName(distdbName);
    task.setDistdbPassword(distdbPassword);
    task.setReplAllClasses(isReplAllTables);
    task.setReplicatedClasses(replTableList);
    taskExcutor.addTask(task);
    JobFamily jobFamily = new JobFamily();
    String serverName = replicationNode.getServer().getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(distdbName);
    String jobName = Messages.bind(Messages.changeReplicationSchemaJobName, new String[] { distdbName, serverName });
    taskExcutor.schedule(jobName, jobFamily, true, Job.SHORT);
    return false;
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ChangeReplTablesTask(com.cubrid.cubridmanager.core.replication.task.ChangeReplTablesTask) TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ITask(com.cubrid.common.core.task.ITask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Display(org.eclipse.swt.widgets.Display)

Example 39 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class DatabaseLogListDialog method initial.

/**
	 * 
	 * Initial the value of dialog field
	 * 
	 */
private void initial() {
    DbLogInfos dbLogInfos = new DbLogInfos();
    final CommonQueryTask<DbLogInfos> task = new CommonQueryTask<DbLogInfos>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), dbLogInfos);
    task.setDbName(dbName);
    CommonTaskJobExec jobExecutor = new CommonTaskJobExec(this) {

        /**
			 * Close the dialog
			 */
        protected void closeDialog() {
        //empty
        }

        /**
			 * Set the dialog visible or invisible.
			 * 
			 * @param flag whether it is visible
			 */
        protected void setDialogVisible(boolean flag) {
        //empty
        }
    };
    jobExecutor.addTask(task);
    JobFamily jobFamily = new JobFamily();
    String serverName = serverInfo.getServerName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    jobExecutor.schedule(Messages.jobGetLogList, jobFamily, false, Job.SHORT);
}
Also used : DbLogInfos(com.cubrid.cubridmanager.core.logs.model.DbLogInfos) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily)

Example 40 with JobFamily

use of com.cubrid.common.ui.spi.progress.JobFamily in project cubrid-manager by CUBRID.

the class CQBConnectionUtils method processConnectionDeleted.

/**
	 * 
	 * Process resource when delete database
	 * 
	 * @param database CubridDatabase
	 * @return boolean
	 */
public static boolean processConnectionDeleted(CubridDatabase database) {
    final JobFamily jobFamily = new JobFamily();
    String serverName = database.getServer().getName();
    String dbName = database.getName();
    jobFamily.setServerName(serverName);
    jobFamily.setDbName(dbName);
    Job[] jobs = Job.getJobManager().find(jobFamily);
    if (jobs.length > 0) {
        boolean isLogout = CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmDeleteConnwithJob, dbName));
        if (!isLogout) {
            return false;
        }
    }
    // check the query editor in this database
    if (!LayoutUtil.checkAllQueryEditor(database)) {
        return false;
    }
    cancelJob(jobFamily);
    database.setLogined(false);
    database.removeAllChild();
    CQBDBNodePersistManager.getInstance().removeDatabase(database);
    QueryOptions.removePref(database.getDatabaseInfo().getServerInfo());
    return true;
}
Also used : JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) Job(org.eclipse.core.runtime.jobs.Job)

Aggregations

JobFamily (com.cubrid.common.ui.spi.progress.JobFamily)44 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)24 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)19 ITask (com.cubrid.common.core.task.ITask)14 Job (org.eclipse.core.runtime.jobs.Job)14 ArrayList (java.util.ArrayList)12 IStatus (org.eclipse.core.runtime.IStatus)12 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)8 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)8 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)7 List (java.util.List)7 CheckDirTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckDirTask)6 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)5 CommonUpdateTask (com.cubrid.cubridmanager.core.common.task.CommonUpdateTask)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)5 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)4 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 CheckFileTask (com.cubrid.cubridmanager.core.cubrid.database.task.CheckFileTask)4