use of com.cubrid.common.ui.spi.progress.CommonTaskJobExec in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadServerDbInfo.
/**
* Load Server Database Info
*/
private void loadServerDbInfo(final ServerInfo serverInfo, final String key) {
if (serverInfo.isConnected() == false) {
return;
}
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
Object input = serviceTreeViewer.getInput();
ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
setDbData(sDashInfo, databaseInfoList);
serviceTreeViewer.refresh(input);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(getDatabaseListTask);
executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerDbInfo);
}
use of com.cubrid.common.ui.spi.progress.CommonTaskJobExec in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadServerVolumeData.
/**
* Load Server Volume Info
*/
private void loadServerVolumeData(final ServerInfo serverInfo, final String key) {
List<String> dbList = serverInfo.getAllDatabaseList();
if (dbList == null || dbList.size() == 0) {
return;
}
final List<CommonQueryTask<DbSpaceInfoList>> getVolumnTaskList = new ArrayList<CommonQueryTask<DbSpaceInfoList>>();
for (String dbname : dbList) {
CommonQueryTask<DbSpaceInfoList> task = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoList());
task.setDbName(dbname);
getVolumnTaskList.add(task);
}
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
Object input = serviceTreeViewer.getInput();
ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
setVolumeData(sDashInfo, getVolumnTaskList);
serviceTreeViewer.refresh(input);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
for (CommonQueryTask<DbSpaceInfoList> task : getVolumnTaskList) {
taskJobExec.addTask(task);
}
executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerVolumeInfo);
}
use of com.cubrid.common.ui.spi.progress.CommonTaskJobExec in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method loadServerHostInfo.
/**
* Load Server Host Info
*/
private void loadServerHostInfo(final ServerInfo serverInfo, final String key) {
final CommonQueryTask<HostStatData> task = new CommonQueryTask<HostStatData>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new HostStatData());
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
Object input = serviceTreeViewer.getInput();
ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
HostStatData hostInfo = task.getResultModel();
setHostData(sDashInfo, hostInfo);
serviceTreeViewer.refresh(input);
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(task);
executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerHostInfo);
}
use of com.cubrid.common.ui.spi.progress.CommonTaskJobExec in project cubrid-manager by CUBRID.
the class PstmtOneDataDialog method updateData.
/**
*
* Update the data
*
* @param parameterList List<PstmtParameter>
*/
private void updateData(List<PstmtParameter> parameterList) {
beginTimestamp = System.currentTimeMillis();
String jobName = Messages.executeSqlJobName;
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getServerInfo().getServerName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
TaskJobExecutor taskExec = new CommonTaskJobExec(this);
PstmtDataTask task = new PstmtDataTask(sqlTxt.getText(), database, parameterList, null);
taskExec.addTask(task);
taskExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
use of com.cubrid.common.ui.spi.progress.CommonTaskJobExec in project cubrid-manager by CUBRID.
the class ImportDataFromFileDialog method updateData.
/**
*
* Update data
*
* @param parameterList List<PstmtParameter>
*/
private void updateData(List<PstmtParameter> parameterList) {
taskList.clear();
String fileName = fileNameTxt.getText();
String charset = fileCharsetCombo.getText();
int threadCount = threadCountSpinner.getSelection();
int commitedLineOnce = commitLineSpinner.getSelection();
int totalLine = Integer.parseInt(totalLinesText.getText());
int threadLine = totalLine / threadCount;
int line = totalLine % threadCount;
int startRow = 0;
int totalProgress = 0;
boolean isIgnoreError = importErrorControl.isIgoreOrBreak();
if (isIgnoreError) {
errorLogDir = PstmtDataTask.makeErrorLogDir();
} else {
errorLogDir = null;
}
if (importFileHandler == null) {
importFileHandler = ImportFileHandlerFactory.getHandler(fileName, charset);
}
for (int i = 0; i < threadCount; i++) {
// FIXME move this logic to core module
int rowCount = threadLine;
if (i == threadCount - 1) {
rowCount = threadLine + line;
}
int commitCount = rowCount / commitedLineOnce + (rowCount % commitedLineOnce > 0 ? 1 : 0);
int taskProgress = commitCount * PstmtDataTask.PROGRESS_COMMIT + rowCount * PstmtDataTask.PROGRESS_ROW;
totalProgress = totalProgress + taskProgress + PstmtDataTask.PROGRESS_ROW;
PstmtDataTask task = new PstmtDataTask(sqlTxt.getText(), database, fileNameTxt.getText(), parameterList, startRow, rowCount, commitedLineOnce, charset, firstRowAsColumnBtn.getSelection(), isIgnoreError, errorLogDir, importFileHandler);
task.setTotalProgress(taskProgress);
taskList.add(task);
startRow += rowCount;
}
getShell().setVisible(false);
beginTimestamp = System.currentTimeMillis();
String jobName = Messages.executeSqlJobName;
JobFamily jobFamily = new JobFamily();
String serverName = database.getServer().getServerInfo().getServerName();
String dbName = database.getName();
jobFamily.setServerName(serverName);
jobFamily.setDbName(dbName);
final IProgressMonitor pmGroup = Job.getJobManager().createProgressGroup();
pmGroup.beginTask(jobName, totalProgress);
setStartShowResult(false);
final CountDownLatch cdl = new CountDownLatch(taskList.size());
final List<PstmtDataTask> threadTaskList = taskList;
for (PstmtDataTask task : taskList) {
TaskJobExecutor taskExec = new CommonTaskJobExec() {
public IStatus exec(IProgressMonitor monitor) {
IStatus status = super.exec(monitor);
if (Status.CANCEL_STATUS == status) {
return status;
}
return Status.OK_STATUS;
}
public void done(IJobChangeEvent event) {
if (event.getResult() == Status.CANCEL_STATUS) {
for (PstmtDataTask task : threadTaskList) {
if (!task.isCancel()) {
task.cancel();
}
}
}
countDownAndAwait(cdl);
Display.getDefault().syncExec(new Runnable() {
public void run() {
pmGroup.done();
finish();
}
});
}
};
taskExec.addTask(task);
TaskJob job = new TaskJob(jobName, taskExec);
if (jobFamily != null) {
job.setJobFamily(jobFamily);
}
job.setPriority(Job.LONG);
job.setUser(false);
job.setProgressGroup(pmGroup, task.getTotalProgress());
job.schedule();
try {
Thread.sleep(30);
} catch (InterruptedException e) {
}
pmGroup.worked(PstmtDataTask.PROGRESS_ROW);
}
}
Aggregations