use of com.cubrid.cubridmanager.core.monitoring.model.HostStatData in project cubrid-manager by CUBRID.
the class DataProvider method performHostStatTask.
/**
* Perform the task of HostStatData
*
* @param returnMap an instance of Map<IDiagPara, String>
*/
private void performHostStatTask(Map<IDiagPara, String> returnMap) {
HostStatData hostDiagStatusResult = hostStatTask == null ? null : hostStatTask.getResultModel();
if (hostDiagStatusResult == null) {
hostStatRequestCount = 0;
return;
}
if (!hostDiagStatusResult.getStatus()) {
String detailMsg = "can not get host cup and memory and iowait information.";
showErrorMsg(hostDiagStatusResult.getNote(), detailMsg);
hostStatRequestCount = 0;
return;
}
if (hostStatRequestCount == 0) {
hostDiagOldOneStatusResult = new HostStatData();
hostDiagOldTwoStatusResult = new HostStatData();
returnMap.putAll(hostStatDataProxy.getDiagStatusResultMap());
hostStatRequestCount++;
hostDiagOldOneStatusResult.copyFrom(hostDiagStatusResult);
} else if (hostStatRequestCount == 1) {
hostStatDataProxy.compute(hostDiagStatusResult, hostDiagOldOneStatusResult);
returnMap.putAll(hostStatDataProxy.getDiagStatusResultMap());
hostStatRequestCount++;
hostDiagOldTwoStatusResult.copyFrom(hostDiagOldOneStatusResult);
hostDiagOldOneStatusResult.copyFrom(hostDiagStatusResult);
} else {
hostStatDataProxy.compute(hostDiagStatusResult, hostDiagOldOneStatusResult, hostDiagOldTwoStatusResult);
returnMap.putAll(hostStatDataProxy.getDiagStatusResultMap());
hostDiagOldTwoStatusResult.copyFrom(hostDiagOldOneStatusResult);
hostDiagOldOneStatusResult.copyFrom(hostDiagStatusResult);
}
}
use of com.cubrid.cubridmanager.core.monitoring.model.HostStatData 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.cubridmanager.core.monitoring.model.HostStatData in project cubrid-manager by CUBRID.
the class DataProvider method executeInThread.
/**
*
* Execute task by multi-thread
*
* @throws InterruptedException the exception
*/
public void executeInThread() throws InterruptedException {
//multi thread execution
List<Runnable> runnableList = new ArrayList<Runnable>();
if (isExecuteHostStatTask) {
hostStatTask = new CommonQueryTask<HostStatData>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new HostStatData());
hostStatTask.setTimeout(TIME_OUT_MILL);
runnableList.add(hostStatTask);
}
if (isExecuteBrokerStatTask) {
brokerDiagTask = new CommonQueryTask<BrokerDiagData>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), new BrokerDiagData());
brokerDiagTask.setTimeout(TIME_OUT_MILL);
runnableList.add(brokerDiagTask);
}
List<String> dbList = new ArrayList<String>();
for (DatabaseNode dbNode : uniqueDbNodeList) {
dbList.add(dbNode.getDbName());
}
if (isExecuteHeartbeatTask) {
getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
getHeartbeatNodeInfoTask.setAllDb(false);
getHeartbeatNodeInfoTask.setDbList(dbList);
getHeartbeatNodeInfoTask.setTimeout(TIME_OUT_MILL);
runnableList.add(getHeartbeatNodeInfoTask);
}
if (isExecuteDbModeTask) {
getDbModeTask = new GetDbModeTask(serverInfo);
getDbModeTask.setDbList(dbList);
getDbModeTask.setTimeout(TIME_OUT_MILL);
runnableList.add(getDbModeTask);
}
//execute broker related task
if (!uniqueBrokerNodeList.isEmpty()) {
runnableList.addAll(brokerDataProvider.getExecRunnableList());
}
if (IS_MULTI_THREAD && !runnableList.isEmpty()) {
try {
generator.getThreadPoolManager().execute(runnableList, true);
} catch (ThreadCountOutOfBoundsException e) {
LOGGER.error("", e);
}
join(runnableList, 350);
runnableList.clear();
}
//get database status information
List<HADatabaseStatusInfo> dbStatusInfoList = null;
if (isExecuteDbModeTask) {
dbStatusInfoList = getDbModeTask.getDbModes();
}
//execute database related task
for (int i = 0; i < dbDataProviderList.size(); i++) {
DatabaseNode dbNode = dbDataProviderList.get(i).getDatabaseNode();
HADatabaseStatusInfo dbStatusInfo = HAUtil.getDatabaseStatusInfo(dbStatusInfoList, dbNode.getDbName());
dbDataProviderList.get(i).setDbStatusInfo(dbStatusInfo);
runnableList.addAll(dbDataProviderList.get(i).getExecRunnableList());
}
if (IS_MULTI_THREAD && !runnableList.isEmpty()) {
try {
generator.getThreadPoolManager().execute(runnableList, true);
} catch (ThreadCountOutOfBoundsException e) {
LOGGER.error("", e);
}
join(runnableList, 20);
} else {
execute(runnableList);
}
}
use of com.cubrid.cubridmanager.core.monitoring.model.HostStatData in project cubrid-manager by CUBRID.
the class ServiceDashboardEditor method setHostData.
/**
* Set Server Host Data
*/
private void setHostData(ServiceDashboardInfo sDashInfo, HostStatData hostInfo) {
double memUsed = 0, memTotal = 0, cpuUsed = 0;
if (hostInfo != null) {
HostStatDataProxy hostStatDataProxy = new HostStatDataProxy();
HostStatData hostInfo2 = new HostStatData();
hostInfo2.copyFrom(hostInfo);
hostStatDataProxy.compute(hostInfo, hostInfo2);
memUsed = Double.parseDouble(hostStatDataProxy.getMemPhyUsed());
memTotal = Double.parseDouble(hostStatDataProxy.getMemPhyTotal());
cpuUsed = Double.parseDouble(hostStatDataProxy.getUserPercent());
}
sDashInfo.setMemUsed(memUsed);
sDashInfo.setMemTotal(memTotal);
sDashInfo.setCpuUsed(cpuUsed);
}
Aggregations