Search in sources :

Example 6 with BrokerInfoList

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

the class CubridDatabasesFolderLoader method getDefaultPort.

/**
	 *
	 * Get default port
	 *
	 * @param serverInfo ServerInfo
	 * @return String
	 */
private static String getDefaultPort(ServerInfo serverInfo) {
    // FIXME extract
    String defaultBrokerPort = "30000";
    BrokerInfos brokerInfos = serverInfo.getBrokerInfos();
    if (brokerInfos != null) {
        BrokerInfoList brokerInfoList = brokerInfos.getBorkerInfoList();
        if (brokerInfoList != null) {
            List<BrokerInfo> list = brokerInfoList.getBrokerInfoList();
            for (int i = 0; list != null && i < list.size(); i++) {
                BrokerInfo brokerInfo = list.get(i);
                if (i == 0) {
                    defaultBrokerPort = brokerInfo.getPort();
                }
                if (brokerInfo.getName().equals("query_editor")) {
                    defaultBrokerPort = brokerInfo.getPort();
                    break;
                }
            }
        }
    }
    return defaultBrokerPort;
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 7 with BrokerInfoList

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

the class CubridBrokerLogFolderLoader method load.

/**
	 * 
	 * Load children object for parent
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor object
	 */
public void load(ICubridNode parent, final IProgressMonitor monitor) {
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        // add access and error and admin log folder to broker logs folder
        String[] brokerLogIdArr = { ACCESS_LOG_FOLDER_ID, ERROR_LOG_FOLDER_ID, ADMIN_LOG_FOLDER_ID };
        String[] brokerLogNameArr = { ACCESS_LOG_FOLDER_NAME, ERROR_LOG_FOLDER_NAME, ADMIN_LOG_FOLDER_NAME };
        String[] brokerLogTypeArr = { CubridNodeType.LOGS_BROKER_ACCESS_LOG_FOLDER, CubridNodeType.LOGS_BROKER_ERROR_LOG_FOLDER, CubridNodeType.LOGS_BROKER_ADMIN_LOG_FOLDER };
        String[] iconArr = { "icons/navigator/folder.png", "icons/navigator/folder.png", "icons/navigator/folder.png" };
        ICubridNode[] logFoldrNodeArr = new ICubridNode[3];
        for (int i = 0; i < brokerLogNameArr.length; i++) {
            String id = parent.getId() + NODE_SEPARATOR + brokerLogIdArr[i];
            logFoldrNodeArr[i] = parent.getChild(id);
            if (logFoldrNodeArr[i] == null) {
                logFoldrNodeArr[i] = new DefaultCubridNode(id, brokerLogNameArr[i], iconArr[i]);
                logFoldrNodeArr[i].setType(brokerLogTypeArr[i]);
                logFoldrNodeArr[i].setContainer(true);
                parent.addChild(logFoldrNodeArr[i]);
                if (i == 2) {
                    ICubridNodeLoader loader = new CubridAdminLogFolderLoader();
                    loader.setLevel(getLevel());
                    logFoldrNodeArr[i].setLoader(loader);
                    if (getLevel() == DEFINITE_LEVEL) {
                        logFoldrNodeArr[i].getChildren(monitor);
                    }
                }
            } else {
                if (logFoldrNodeArr[i].getLoader() != null) {
                    logFoldrNodeArr[i].getLoader().setLoaded(false);
                    logFoldrNodeArr[i].getChildren(monitor);
                }
            }
        }
        ServerInfo serverInfo = parent.getServer().getServerInfo();
        BrokerInfos brokerInfos = serverInfo.getBrokerInfos();
        Shards shards = serverInfo.getShards();
        monitorCancel(monitor, new ITask[] { loadBrokersTask, loadBrokrLogInfoTask });
        if (brokerInfos == null && !monitor.isCanceled()) {
            // load all borkers
            brokerInfos = new BrokerInfos();
            loadBrokersTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
            loadBrokersTask.execute();
            final String errorMsg = loadBrokersTask.getErrorMsg();
            if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
                logFoldrNodeArr[0].removeAllChild();
                logFoldrNodeArr[1].removeAllChild();
                openErrorBox(errorMsg);
                setLoaded(true);
                return;
            }
            brokerInfos = loadBrokersTask.getResultModel();
            serverInfo.setBrokerInfos(brokerInfos);
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        // load broker log file information
        List<BrokerLogInfos> brokerLogInfosList = new ArrayList<BrokerLogInfos>();
        if (brokerInfos != null) {
            BrokerInfoList list = brokerInfos.getBorkerInfoList();
            if (list != null && list.getBrokerInfoList() != null) {
                List<BrokerInfo> brokerInfoList = list.getBrokerInfoList();
                for (int i = 0; !monitor.isCanceled() && brokerInfoList != null && i < brokerInfoList.size(); i++) {
                    BrokerInfo brokerInfo = brokerInfoList.get(i);
                    BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
                    loadBrokrLogInfoTask = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
                    loadBrokrLogInfoTask.setBroker(brokerInfo.getName());
                    loadBrokrLogInfoTask.execute();
                    final String errorMsg = loadBrokrLogInfoTask.getErrorMsg();
                    if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
                        logFoldrNodeArr[0].removeAllChild();
                        logFoldrNodeArr[1].removeAllChild();
                        openErrorBox(errorMsg);
                        setLoaded(true);
                        return;
                    }
                    brokerLogInfos = loadBrokrLogInfoTask.getResultModel();
                    brokerLogInfosList.add(brokerLogInfos);
                }
            }
        }
        // load shard broker log file information
        if (shards != null) {
            List<Shard> shardList = shards.getShardList();
            if (shardList != null) {
                for (int i = 0; i < shardList.size(); i++) {
                    Shard shard = shardList.get(i);
                    BrokerLogInfos brokerLogInfos = new BrokerLogInfos();
                    loadBrokrLogInfoTask = new CommonQueryTask<BrokerLogInfos>(serverInfo, CommonSendMsg.getGetBrokerLogFileInfoMSGItems(), brokerLogInfos);
                    loadBrokrLogInfoTask.setBroker(shard.getName());
                    loadBrokrLogInfoTask.execute();
                    final String errorMsg = loadBrokrLogInfoTask.getErrorMsg();
                    if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
                        logFoldrNodeArr[0].removeAllChild();
                        logFoldrNodeArr[1].removeAllChild();
                        openErrorBox(errorMsg);
                        setLoaded(true);
                        return;
                    }
                    brokerLogInfos = loadBrokrLogInfoTask.getResultModel();
                    brokerLogInfosList.add(brokerLogInfos);
                }
            }
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        logFoldrNodeArr[0].removeAllChild();
        logFoldrNodeArr[1].removeAllChild();
        for (BrokerLogInfos brokerLogInfos : brokerLogInfosList) {
            List<LogInfo> logInfoList = brokerLogInfos.getBrokerLogInfoList().getLogFileInfoList();
            if (logInfoList != null && !logInfoList.isEmpty()) {
                for (LogInfo logInfo : logInfoList) {
                    ICubridNode logInfoNode = new DefaultCubridNode("", logInfo.getName(), "");
                    logInfoNode.setContainer(false);
                    logInfoNode.setModelObj(logInfo);
                    logInfoNode.setEditorId(LogEditorPart.ID);
                    if (LogType.ACCESS.getText().toLowerCase().equals(logInfo.getType())) {
                        String id = logFoldrNodeArr[0].getId() + NODE_SEPARATOR + logInfo.getName();
                        logInfoNode.setId(id);
                        logInfoNode.setType(CubridNodeType.LOGS_BROKER_ACCESS_LOG);
                        logInfoNode.setIconPath("icons/navigator/log_item.png");
                        logFoldrNodeArr[0].addChild(logInfoNode);
                    } else if (LogType.ERROR.getText().toLowerCase().equals(logInfo.getType())) {
                        String id = logFoldrNodeArr[1].getId() + NODE_SEPARATOR + logInfo.getName();
                        logInfoNode.setId(id);
                        logInfoNode.setType(CubridNodeType.LOGS_BROKER_ERROR_LOG);
                        logInfoNode.setIconPath("icons/navigator/log_item.png");
                        logFoldrNodeArr[1].addChild(logInfoNode);
                    }
                }
            }
        }
        Collections.sort(logFoldrNodeArr[0].getChildren());
        Collections.sort(logFoldrNodeArr[1].getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(logFoldrNodeArr[0], CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(logFoldrNodeArr[1], CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) BrokerLogInfos(com.cubrid.cubridmanager.core.logs.model.BrokerLogInfos) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ArrayList(java.util.ArrayList) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) Shards(com.cubrid.cubridmanager.core.shard.model.Shards) Shard(com.cubrid.cubridmanager.core.shard.model.Shard)

Example 8 with BrokerInfoList

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

the class BrokerNodeTest method testBrokerNode.

public void testBrokerNode() {
    BrokerNode brokerNode = new BrokerNode();
    BrokerInfoList brokerInfoList = new BrokerInfoList();
    brokerNode.setBrokerInfoList(brokerInfoList);
    Map<String, BrokerStatusInfos> brokerStatusMap = new HashMap<String, BrokerStatusInfos>();
    brokerNode.setBrokerStatusMap(brokerStatusMap);
    assertEquals(brokerNode.getBrokerInfoList(), brokerInfoList);
    assertEquals(brokerNode.getBrokerStatusMap(), brokerStatusMap);
    brokerNode.setBrokerStatusMap(null);
    assertNull(brokerNode.getBrokerStatusMap());
    String port = "30000";
    BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
    brokerNode.addBrokerStatus(port, brokerStatusInfos);
    assertNotNull(brokerNode.getBrokerStatusMap());
    BrokerStatusInfos brokerStatusInfos2 = brokerNode.getBrokerStatusMap().get(port);
    assertEquals(brokerStatusInfos, brokerStatusInfos2);
    brokerNode.setRemoteBrokers(new HashSet<NodeInfo>());
    brokerNode.AddRemoteBroker(new NodeInfo(NodeType.BROKER));
    assertNull(brokerNode.getRemoteBrokers());
    brokerNode.genBrokerInfo();
    assertNotNull(brokerNode.getBrokerInfo());
    assertNotNull(brokerNode.getStatus());
    buildFakeData(brokerNode);
    assertNotNull(brokerNode.getHostSet());
    //		assertNotNull(brokerNode.getDbSet());
    assertNotNull(brokerNode.getAccessedHosts());
    assertNotNull(brokerNode.getAccessedHostDbMap());
    assertNotNull(brokerNode.getAccessedDbInfo());
}
Also used : HashMap(java.util.HashMap) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 9 with BrokerInfoList

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfoList 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 10 with BrokerInfoList

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfoList 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)

Aggregations

BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)16 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)13 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)11 ArrayList (java.util.ArrayList)7 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)5 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)4 ApplyServerInfo (com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)3 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)3 List (java.util.List)3 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 HashMap (java.util.HashMap)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Combo (org.eclipse.swt.widgets.Combo)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2