use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class DatabaseDashboardEditor method loadVolumnsInfo.
/**
* load volumns information
*/
public void loadVolumnsInfo() {
// if database is stop, do not get data
if (database.getRunningType() != DbRunningType.CS) {
return;
}
final DbSpaceInfoList dbSpaceInfoList = new DbSpaceInfoList();
final CommonQueryTask<DbSpaceInfoList> loadVolumnTask = new CommonQueryTask<DbSpaceInfoList>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfoList);
loadVolumnTask.setDbName(database.getName());
new Thread(new Runnable() {
public void run() {
loadVolumnTask.execute();
if (!loadVolumnTask.isSuccess()) {
loadVolumnTask.finish();
return;
}
Display.getDefault().asyncExec(new Runnable() {
public void run() {
process();
}
});
}
private void process() {
volumnInfoListData.clear();
DbSpaceInfoList dbSpaceInfoList = loadVolumnTask.getResultModel();
if (dbSpaceInfoList != null) {
long archiveSize = 0;
for (DbSpaceInfo dbSpaceInfo : dbSpaceInfoList.getSpaceinfo()) {
if (StringUtil.isEmpty(dbSpaceInfo.getType())) {
continue;
}
if (dbSpaceInfo.getType().equals(VolumeType.ARCHIVE_LOG.getText())) {
archiveSize += dbSpaceInfo.getTotalpage() * dbSpaceInfoList.getPagesize();
continue;
}
boolean isLogVolumn = VolumeType.ACTIVE_LOG.getText().equals(dbSpaceInfo.getType()) || VolumeType.ARCHIVE_LOG.getText().equals(dbSpaceInfo.getType());
Map<String, String> volumnMap = new HashMap<String, String>();
volumnMap.put("0", dbSpaceInfo.getSpacename());
volumnMap.put("1", dbSpaceInfo.getType());
String freeSize = getSpaceDesc(Long.valueOf(dbSpaceInfo.getFreepage()) * Long.valueOf(dbSpaceInfoList.getPagesize()));
String totalSize = getSpaceDesc(Long.valueOf(dbSpaceInfo.getTotalpage()) * Long.valueOf(dbSpaceInfoList.getPagesize()));
if (isLogVolumn) {
volumnMap.put("2", "-");
} else {
volumnMap.put("2", freeSize);
}
volumnMap.put("3", totalSize);
volumnMap.put("4", dbSpaceInfo.getDate());
volumnMap.put("5", dbSpaceInfo.getLocation());
volumnInfoListData.add(volumnMap);
}
if (archiveSize > 0) {
Map<String, String> volumnMap = new HashMap<String, String>();
volumnMap.put("0", "Total Archives");
volumnMap.put("1", "Archive log");
volumnMap.put("2", "-");
volumnMap.put("3", getSpaceDesc(archiveSize));
volumnMap.put("4", "-");
volumnMap.put("5", "-");
volumnInfoListData.add(volumnMap);
}
}
setVolumnInfoData();
loadVolumnTask.finish();
}
}).start();
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class AddAndDelStatusTemplateTaskTest method testExec.
public void testExec() {
StatusTemplateInfo info = new StatusTemplateInfo();
info.setDb_name(testDbName);
info.setDesc("testStatus");
info.setName("newStatus");
TargetConfigInfo targetConfigInfo = new TargetConfigInfo();
targetConfigInfo.setCas_st_long_tran(new String[] { "aaa", "dd", "dd" });
info.addTarget_config(targetConfigInfo);
info.setSampling_term("1");
AddStatusTemplateTask task = new AddStatusTemplateTask(serverInfo);
task.setStatusTemplateInfo(info);
task.buildMsg();
task.execute();
assertNull(task.getErrorMsg());
StatusTemplateInfos bean = new StatusTemplateInfos();
final CommonQueryTask<StatusTemplateInfos> showTask = new CommonQueryTask<StatusTemplateInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), bean);
showTask.execute();
bean.getStatusTemplateInfoList();
assertEquals(bean.getTaskName(), "getstatustemplate");
DelStatusTemplateTask delTsk = new DelStatusTemplateTask(serverInfo);
delTsk.setTemplateName("newStatus");
delTsk.execute();
assertNull(delTsk.getErrorMsg());
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask 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.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class AutoAddVolumeLogDialog method loadData.
/**
* load the data
*
* @return boolean
*/
public boolean loadData() {
CommonQueryTask<AutoAddVolumeLogList> task = new CommonQueryTask<AutoAddVolumeLogList>(server.getServerInfo(), CommonSendMsg.getCommonSimpleSendMsg(), new AutoAddVolumeLogList());
TaskExecutor taskExecutor = new CommonTaskExec(Messages.getAuotAddedVolLogTaskName);
taskExecutor.addTask(task);
new ExecTaskWithProgress(taskExecutor).busyCursorWhile();
if (!taskExecutor.isSuccess()) {
return false;
}
volumeLogList = task.getResultModel();
return true;
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class DatabaseStatusEditor method loadData.
/**
*
* Load data
*
* @return <code>true</code> whether it is successful;<code>false</code>
* otherwise
*/
public boolean loadData() {
TaskJobExecutor taskJobExecutor = new TaskJobExecutor() {
@SuppressWarnings("unchecked")
@Override
public IStatus exec(IProgressMonitor monitor) {
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
for (ITask t : taskList) {
t.execute();
final String msg = t.getErrorMsg();
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
} else {
final DbSpaceInfoList dbSpaceInfoList = ((CommonQueryTask<? extends DbSpaceInfoList>) t).getResultModel();
Display.getDefault().syncExec(new Runnable() {
public void run() {
database.getDatabaseInfo().setDbSpaceInfoList(dbSpaceInfoList);
if (scrolledComp == null || scrolledComp.isDisposed()) {
return;
}
initial();
paintComp();
scrolledComp.setContent(parentComp);
scrolledComp.setExpandHorizontal(true);
scrolledComp.setExpandVertical(true);
}
});
}
if (monitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
}
return Status.OK_STATUS;
}
};
CommonQueryTask<? extends DbSpaceInfoList> task = DbSpaceInfoList.useOld(database.getServer().getServerInfo().getEnvInfo()) ? new CommonQueryTask<DbSpaceInfoListOld>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListOld()) : new CommonQueryTask<DbSpaceInfoListNew>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DbSpaceInfoListNew());
task.setDbName(database.getName());
taskJobExecutor.addTask(task);
String serverName = database.getServer().getName();
String dbName = database.getName();
String jobName = Messages.viewDbStatusJobName + " - " + dbName + "@" + serverName;
taskJobExecutor.schedule(jobName, null, false, Job.SHORT);
return true;
}
Aggregations