Search in sources :

Example 1 with HostStatData

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);
    }
}
Also used : HostStatData(com.cubrid.cubridmanager.core.monitoring.model.HostStatData)

Example 2 with HostStatData

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);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) HostStatData(com.cubrid.cubridmanager.core.monitoring.model.HostStatData)

Example 3 with HostStatData

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);
    }
}
Also used : ArrayList(java.util.ArrayList) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GetDbModeTask(com.cubrid.cubridmanager.core.mondashboard.task.GetDbModeTask) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) ThreadCountOutOfBoundsException(com.cubrid.common.ui.spi.thread.ThreadCountOutOfBoundsException) HostStatData(com.cubrid.cubridmanager.core.monitoring.model.HostStatData) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)

Example 4 with HostStatData

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);
}
Also used : HostStatData(com.cubrid.cubridmanager.core.monitoring.model.HostStatData) HostStatDataProxy(com.cubrid.cubridmanager.core.monitoring.model.HostStatDataProxy)

Aggregations

HostStatData (com.cubrid.cubridmanager.core.monitoring.model.HostStatData)4 ITask (com.cubrid.common.core.task.ITask)1 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)1 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)1 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)1 ThreadCountOutOfBoundsException (com.cubrid.common.ui.spi.thread.ThreadCountOutOfBoundsException)1 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)1 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)1 GetDbModeTask (com.cubrid.cubridmanager.core.mondashboard.task.GetDbModeTask)1 GetHeartbeatNodeInfoTask (com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask)1 BrokerDiagData (com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData)1 HostStatDataProxy (com.cubrid.cubridmanager.core.monitoring.model.HostStatDataProxy)1 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)1 ArrayList (java.util.ArrayList)1 IStatus (org.eclipse.core.runtime.IStatus)1