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);
}
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);
}
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;
}
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);
}
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;
}
Aggregations