Search in sources :

Example 11 with StatisticType

use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType in project cubrid-manager by CUBRID.

the class MonitorStatisticPersistManager method loadMonitorStatistic.

/**
	 *
	 * Load MonitorStatistic nodes
	 *
	 */
protected void loadMonitorStatistic() {
    synchronized (this) {
        IXMLMemento memento = PersistUtils.getXMLMemento(CubridManagerUIPlugin.PLUGIN_ID, MONITOR_STATISTIC_XML_CONTENT);
        if (memento != null) {
            IXMLMemento[] monitorsPerHost = memento.getChildren("monitorsPerHost");
            for (int i = 0; i < monitorsPerHost.length; i++) {
                boolean isMultiHost = monitorsPerHost[i].getBoolean("isMultihost");
                String hostId = HOST_ID_FOR_MULTI_HOST;
                if (!isMultiHost) {
                    hostId = monitorsPerHost[i].getString("hostId");
                }
                IXMLMemento[] children = monitorsPerHost[i].getChildren("monitor");
                List<MonitorStatistic> monitorStatisticList = new ArrayList<MonitorStatistic>();
                for (int j = 0; j < children.length; j++) {
                    String id = children[j].getString("name");
                    String label = id;
                    if (!isMultiHost && id.indexOf("@") != -1) {
                        label = id.substring(0, id.indexOf("@"));
                    }
                    MonitorStatistic node = new MonitorStatistic(id, label, iconPath);
                    node.setType(CubridNodeType.MONITOR_STATISTIC_PAGE);
                    node.setMultiHost(isMultiHost);
                    IXMLMemento[] chartChildren = children[j].getChildren("chart");
                    for (int k = 0; chartChildren != null && k < chartChildren.length; k++) {
                        String typeStr = chartChildren[k].getString("type");
                        StatisticType type = StatisticType.valueOf(typeStr);
                        int series = chartChildren[k].getInteger("series");
                        String dType = chartChildren[k].getString("dtype");
                        if (!isMultiHost) {
                            SingleHostChartItem item = new SingleHostChartItem(id, type);
                            item.setSeries(series);
                            item.setDType(dType);
                            String metrics = chartChildren[k].getString("metrics");
                            String[] metricAr = metrics.split(",");
                            for (String metric : metricAr) {
                                item.addMetric(metric);
                            }
                            String dbName = null;
                            switch(type) {
                                case DB:
                                    dbName = chartChildren[k].getString("dbname");
                                    item.setDbName(dbName);
                                    break;
                                case DB_VOL:
                                    dbName = chartChildren[k].getString("dbname");
                                    String volName = chartChildren[k].getString("volname");
                                    item.setDbName(dbName);
                                    item.setVolName(volName);
                                    break;
                                case BROKER:
                                    String brokerName = chartChildren[k].getString("bname");
                                    item.setBrokerName(brokerName);
                                    break;
                                case OS:
                                    break;
                                default:
                                    break;
                            }
                            node.addStatisticItem(item);
                        } else {
                            IXMLMemento[] hostChildren = chartChildren[k].getChildren("host");
                            MultiHostChartItem item = new MultiHostChartItem(id, type);
                            item.setSeries(series);
                            item.setDType(dType);
                            for (int m = 0; hostChildren != null && m < hostChildren.length; m++) {
                                String cubridServerId = hostChildren[m].getString("cubridServerId");
                                String ip = hostChildren[m].getString("ip");
                                int port = hostChildren[m].getInteger("port");
                                String user = hostChildren[m].getString("user");
                                String pass = hostChildren[m].getString("password");
                                StatisticChartHost host;
                                if (cubridServerId != null) {
                                    host = new StatisticChartHost(cubridServerId);
                                } else {
                                    host = new StatisticChartHost(ip, port, user, CipherUtils.decrypt(pass));
                                }
                                String metric = hostChildren[m].getString("metric");
                                host.setMetric(metric);
                                String dbName = null;
                                switch(type) {
                                    case DB:
                                        dbName = hostChildren[m].getString("dbname");
                                        host.setDbName(dbName);
                                        break;
                                    case DB_VOL:
                                        dbName = hostChildren[m].getString("dbname");
                                        String volName = hostChildren[m].getString("volname");
                                        host.setDbName(dbName);
                                        host.setVolName(volName);
                                        break;
                                    case BROKER:
                                        String brokerName = hostChildren[m].getString("bname");
                                        host.setBrokerName(brokerName);
                                        break;
                                    case OS:
                                        break;
                                    default:
                                        break;
                                }
                                item.addStatisticChartHost(host);
                            }
                            node.addStatisticItem(item);
                        }
                    }
                    monitorStatisticList.add(node);
                }
                monitorStatisticMap.put(hostId, monitorStatisticList);
            }
        }
    }
}
Also used : SingleHostChartItem(com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) ArrayList(java.util.ArrayList) MultiHostChartItem(com.cubrid.cubridmanager.core.monstatistic.model.MultiHostChartItem) StatisticType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType) MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic) StatisticChartHost(com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost)

Aggregations

StatisticType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType)11 SingleHostChartItem (com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem)3 ArrayList (java.util.ArrayList)3 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 StatisticChartHost (com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost)2 MetricType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType)2 Button (org.eclipse.swt.widgets.Button)2 Control (org.eclipse.swt.widgets.Control)2 Group (org.eclipse.swt.widgets.Group)2 MonitorStatistic (com.cubrid.common.ui.spi.model.MonitorStatistic)1 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)1 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)1 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)1 MultiHostChartItem (com.cubrid.cubridmanager.core.monstatistic.model.MultiHostChartItem)1 StatisticData (com.cubrid.cubridmanager.core.monstatistic.model.StatisticData)1 DbMetricType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.DbMetricType)1 OsMetricType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.OsMetricType)1 TimeType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType)1 GridData (org.eclipse.swt.layout.GridData)1