Search in sources :

Example 21 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class ServiceDashboardEditor method loadServerBrokerInfo.

/**
	 * Load Server Broker Info
	 */
private void loadServerBrokerInfo(final ServerInfo serverInfo, final String key) {
    final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new BrokerInfos());
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            Object input = serviceTreeViewer.getInput();
            ServiceDashboardInfo sDashInfo = getSelectedDashInfo(input, serverInfo.getServerName(), key);
            BrokerInfos brokerInfos = task.getResultModel();
            setBrokerData(sDashInfo, brokerInfos);
            serviceTreeViewer.refresh(input);
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(task);
    executeTask(taskJobExec, serverInfo.getServerName(), Messages.taskGetServerBrokerInfo);
}
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) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 22 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class BrokerStatusView method initValue.

/**
	 * Initializes the parameters of this view
	 */
public void initValue() {
    if (null == getCubridNode() || !CubridNodeType.BROKER.equals(getCubridNode().getType())) {
        return;
    }
    brokerNode = (CubridBroker) getCubridNode();
    nodeName = brokerNode.getLabel().trim();
    serverName = brokerNode.getServer().getLabel();
    port = brokerNode.getServer().getMonPort();
    ServerInfo serverInfo = brokerNode.getServer().getServerInfo();
    //get basic info
    BrokerInfos brokerInfos = new BrokerInfos();
    //brokerInfos.setBname(nodeName);
    final GetBrokerStatusInfosTask<BrokerInfos> basicTask = new GetBrokerStatusInfosTask<BrokerInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerInfos);
    basicTask.setBrokerName(nodeName);
    //get status
    BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
    final GetBrokerStatusInfosTask<BrokerStatusInfos> statisTask = new GetBrokerStatusInfosTask<BrokerStatusInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerStatusInfos);
    statisTask.setBrokerName(nodeName);
    TaskExecutor taskExecutor = new CommonTaskExec(Messages.showBrokerStatusTaskName);
    taskExecutor.addTask(basicTask);
    taskExecutor.addTask(statisTask);
    new ExecTaskWithProgress(taskExecutor).exec();
    if (!taskExecutor.isSuccess()) {
        return;
    }
    brokerInfos = basicTask.getResultModel();
    if (null != brokerInfos) {
        BrokerInfoList list = brokerInfos.getBorkerInfoList();
        if (list != null && list.getBrokerInfoList() != null) {
            basicInfoLst = list.getBrokerInfoList();
        }
    }
    brokerStatusInfos = statisTask.getResultModel();
    if (brokerStatusInfos != null) {
        asinfoLst = brokerStatusInfos.getAsinfo();
        jobinfoLst = brokerStatusInfos.getJobinfo();
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 23 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class BrokerStatusView method refreshBasicTable.

/**
	 * refresh the basic info table viewer
	 * 
	 * @param serverInfo the instance of ServerInfo
	 */
private void refreshBasicTable(ServerInfo serverInfo) {
    BrokerInfos brokerInfos = new BrokerInfos();
    final GetBrokerStatusInfosTask<BrokerInfos> basicTask = new GetBrokerStatusInfosTask<BrokerInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerInfos);
    basicTask.setBrokerName(nodeName);
    basicTask.execute();
    brokerInfos = basicTask.getResultModel();
    if (null != brokerInfos) {
        BrokerInfoList list = brokerInfos.getBorkerInfoList();
        if (list != null && list.getBrokerInfoList() != null) {
            basicInfoLst = list.getBrokerInfoList();
        }
    }
    if (basicTableViewer != null) {
        basicTableViewer.setInput(basicInfoLst);
        basicTableViewer.refresh();
    }
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)

Example 24 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class DBSpaceLabelProvider method run.

/**
	 * Thread run method
	 */
public void run() {
    int sleepTime = smallSpaceTime;
    long startTime = System.currentTimeMillis();
    while (runFlag) {
        // It should be stopped when it have exceed 5 minutes because of server load
        if (System.currentTimeMillis() - startTime > timeout) {
            break;
        }
        getUpdateValue(startRun);
        if (startRun == 0) {
            startRun++;
            continue;
        }
        if (startRun < 15) {
            startRun++;
        } else {
            sleepTime = bigSpaceTime;
        }
        HostStatus hostStatus = new HostStatus();
        hostStatus.setCpu(StringUtil.doubleValue(hostStatDataProxy.getUserPercent(), 0));
        hostStatus.setMemoryUsed(StringUtil.doubleValue(hostStatDataProxy.getMemPhyUsed(), 0));
        hostStatus.setMemoryPhy(StringUtil.doubleValue(hostStatDataProxy.getMemPhyTotal(), 0));
        task.execute();
        BrokerInfos brokerInfos = task.getResultModel();
        double qps = 0;
        double tps = 0;
        List<BrokerInfo> newBrokerInfoList = null;
        if (null != brokerInfos) {
            BrokerInfoList list = brokerInfos.getBorkerInfoList();
            if (list != null && list.getBrokerInfoList() != null) {
                newBrokerInfoList = list.getBrokerInfoList();
            }
        }
        if (newBrokerInfoList != null) {
            for (BrokerInfo brokerInfo : newBrokerInfoList) {
                tps += StringUtil.doubleValue(brokerInfo.getTran(), 0);
                qps += StringUtil.doubleValue(brokerInfo.getQuery(), 0);
            }
        }
        hostStatus.setTps(tps);
        hostStatus.setQps(qps);
        hostDataManager.addData(hostStatus);
        final List<HostStatus> serverDataList = new ArrayList<HostStatus>();
        HostStatus hostStatusNow = new HostStatus();
        hostStatusNow.setLabel(Messages.lblNow);
        hostStatusNow.setMemoryUsed(1.0d * hostDataManager.getMemeryUsed());
        hostStatusNow.setMemoryPhy(1.0d * hostDataManager.getMemoryPhy());
        hostStatusNow.setCpu(hostDataManager.getCpu());
        hostStatusNow.setQps(hostDataManager.getQps());
        hostStatusNow.setTps(hostDataManager.getTps());
        hostStatusNow.setFreespaceOnStorage(editorPart.getFreespaceOnStorage());
        serverDataList.add(hostStatusNow);
        HostStatus hostStatusAvg = new HostStatus();
        hostStatusAvg.setLabel(Messages.lbl5MinAvg);
        hostStatusAvg.setMemoryUsed(hostDataManager.getAvgMemeryUsed());
        hostStatusAvg.setMemoryPhy(1.0d * hostDataManager.getMemoryPhy());
        hostStatusAvg.setCpu(hostDataManager.getAvgCpu());
        hostStatusAvg.setQps(hostDataManager.getAvgQps());
        hostStatusAvg.setTps(hostDataManager.getAvgTps());
        hostStatusAvg.setFreespaceOnStorage(-1);
        serverDataList.add(hostStatusAvg);
        Display.getDefault().syncExec(new Runnable() {

            public void run() {
                if (editorPart.getServerTableViewer() != null && !editorPart.getServerTableViewer().getTable().isDisposed()) {
                    editorPart.getServerTableViewer().setInput(serverDataList);
                    editorPart.getServerTableViewer().refresh();
                }
            }
        });
        try {
            Thread.sleep(sleepTime);
        } catch (Exception e) {
        }
    }
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ArrayList(java.util.ArrayList) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) PartInitException(org.eclipse.ui.PartInitException) ParseException(java.text.ParseException) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 25 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos in project cubrid-manager by CUBRID.

the class CubridStatusLineContrItem method updateStatusLine.

/**
	 *
	 * Update the status line information
	 *
	 * @param statusLineManager StatusLineManager
	 * @param cubridNode The selected ICubridNode object
	 */
protected void updateStatusLine(StatusLineManager statusLineManager, ICubridNode cubridNode) {
    clearStatusLine();
    updateStatusLineForRestoreQueryEditor();
    if (cubridNode == null || cubridNode.getServer() == null || cubridNode.getServer().getServerInfo() == null) {
        return;
    }
    String serverInfoStr = cubridNode.getServer().getLabel();
    if (!DatabaseNavigatorMenu.SELF_DATABASE_ID.equals(cubridNode.getId())) {
        ServerUserInfo userInfo = cubridNode.getServer().getServerInfo().getLoginedUserInfo();
        if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().trim().length() > 0) {
            serverInfoStr = userInfo.getUserName() + "@" + serverInfoStr;
        }
        String monPort = cubridNode.getServer().getMonPort();
        if (monPort != null && monPort.trim().length() > 0) {
            serverInfoStr = serverInfoStr + ":" + monPort;
        }
    }
    StringBuffer dbInfoStrBuffer = new StringBuffer();
    if (cubridNode instanceof ISchemaNode) {
        ISchemaNode schemaNode = (ISchemaNode) cubridNode;
        CubridDatabase database = schemaNode.getDatabase();
        dbInfoStrBuffer.append(database.getDatabaseInfo().getDbName());
        DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
        if (database.isLogined() && dbUserInfo != null && dbUserInfo.getName() != null && dbUserInfo.getName().trim().length() > 0) {
            dbInfoStrBuffer = new StringBuffer(dbUserInfo.getName() + "@" + dbInfoStrBuffer.toString());
        }
        String brokerPort = QueryOptions.getBrokerPort(database.getDatabaseInfo());
        BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
        List<BrokerInfo> brokerInfoList = brokerInfos == null || brokerInfos.getBorkerInfoList() == null ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
        boolean isExist = false;
        for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
            BrokerInfo brokerInfo = brokerInfoList.get(i);
            if (brokerPort == null || brokerInfo.getPort() == null || brokerInfo.getPort().trim().length() == 0 || !brokerPort.equals(brokerInfo.getPort())) {
                continue;
            }
            if (brokerPort.equals(brokerInfo.getPort())) {
                isExist = true;
                String status = brokerInfo.getState() == null || brokerInfo.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
                String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
                dbInfoStrBuffer.append(":").append(text);
                break;
            }
        }
        if (!isExist && brokerPort != null && brokerPort.trim().length() > 0) {
            dbInfoStrBuffer.append(":").append(brokerPort);
        }
        String charset = database.getDatabaseInfo().getCharSet();
        if (charset != null && charset.trim().length() > 0) {
            dbInfoStrBuffer.append(":charset=").append(charset);
        }
    }
    String numberStr = getChilderenNumStr(cubridNode);
    if (numberStr != null && numberStr.length() > 0) {
        StatusLineContributionItem item = new StatusLineContributionItem(OBJ_NUM_INFO_CONTR_ID, numberStr.length() + 4);
        statusLineManager.add(item);
        item.setText(numberStr);
    }
    int addedWidth = 3;
    if (dbInfoStrBuffer == null || dbInfoStrBuffer.length() == 0) {
        addedWidth = 30;
    }
    StatusLineContributionItem item = new StatusLineContributionItem(SERVER_INFO_CONTR_ID, serverInfoStr.length() + addedWidth);
    statusLineManager.add(item);
    item.setText(serverInfoStr);
    if (dbInfoStrBuffer != null && dbInfoStrBuffer.length() > 0) {
        item = new StatusLineContributionItem(DB_INFO_CONTR_ID, dbInfoStrBuffer.length() + 3);
        statusLineManager.add(item);
        item.setText(dbInfoStrBuffer.toString());
    }
}
Also used : DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) StatusLineContributionItem(org.eclipse.jface.action.StatusLineContributionItem) ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Aggregations

BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)30 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)16 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)13 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)12 ArrayList (java.util.ArrayList)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 List (java.util.List)7 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)6 ITask (com.cubrid.common.core.task.ITask)5 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)5 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)5 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)5 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)5 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)5 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)5