Search in sources :

Example 11 with StatisticChartItem

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

the class MonitorStatisticPersistManager method saveStatistic.

/**
	 *
	 * Save MonitorStatistic nodes
	 *
	 */
public void saveStatistic() {
    synchronized (this) {
        XMLMemento memento = XMLMemento.createWriteRoot("monitors");
        Iterator<String> keySetIterator = monitorStatisticMap.keySet().iterator();
        while (keySetIterator.hasNext()) {
            String hostId = keySetIterator.next();
            boolean isMultiHost = HOST_ID_FOR_MULTI_HOST.equals(hostId);
            IXMLMemento monsPerHostMemento = memento.createChild("monitorsPerHost");
            monsPerHostMemento.putBoolean("isMultihost", isMultiHost);
            if (!isMultiHost) {
                monsPerHostMemento.putString("hostId", hostId);
            }
            List<MonitorStatistic> monitorStatisticList = monitorStatisticMap.get(hostId);
            if (monitorStatisticList == null) {
                continue;
            }
            Iterator<MonitorStatistic> nodeIterator = monitorStatisticList.iterator();
            while (nodeIterator.hasNext()) {
                MonitorStatistic node = nodeIterator.next();
                IXMLMemento monMemento = monsPerHostMemento.createChild("monitor");
                monMemento.putString("name", node.getId());
                //save StatisticItem list
                List<StatisticChartItem> statisticItemList = node.getStatisticItemList();
                Iterator<StatisticChartItem> itemIterator = statisticItemList.iterator();
                while (itemIterator.hasNext()) {
                    if (!node.isMultiHost()) {
                        SingleHostChartItem item = (SingleHostChartItem) itemIterator.next();
                        IXMLMemento chartMemento = monMemento.createChild("chart");
                        chartMemento.putInteger("series", item.getSeries());
                        chartMemento.putString("name", item.getName());
                        chartMemento.putString("type", item.getType().toString());
                        chartMemento.putString("dtype", item.getDType());
                        chartMemento.putString("metrics", ArrayUtil.collectionToCSString(item.getMetricList()));
                        switch(item.getType()) {
                            case DB:
                                chartMemento.putString("dbname", item.getDbName());
                                break;
                            case DB_VOL:
                                chartMemento.putString("dbname", item.getDbName());
                                chartMemento.putString("volname", item.getVolName());
                                break;
                            case BROKER:
                                chartMemento.putString("bname", item.getBrokerName());
                                break;
                            case OS:
                                break;
                            default:
                                break;
                        }
                    } else {
                        MultiHostChartItem item = (MultiHostChartItem) itemIterator.next();
                        IXMLMemento chartMemento = monMemento.createChild("chart");
                        chartMemento.putInteger("series", item.getSeries());
                        chartMemento.putString("name", item.getName());
                        chartMemento.putString("type", item.getType().toString());
                        chartMemento.putString("dtype", item.getDType());
                        //save HostInfo list
                        List<StatisticChartHost> hostList = item.getHostList();
                        Iterator<StatisticChartHost> hostIterator = hostList.iterator();
                        while (hostIterator.hasNext()) {
                            StatisticChartHost host = (StatisticChartHost) hostIterator.next();
                            IXMLMemento hostMemento = chartMemento.createChild("host");
                            hostMemento.putString("cubridServerId", host.getCubridServerId());
                            hostMemento.putString("ip", host.getIp());
                            hostMemento.putInteger("port", host.getPort());
                            hostMemento.putString("user", host.getUser());
                            hostMemento.putString("password", CipherUtils.encrypt(host.getPassword()));
                            hostMemento.putString("metric", host.getMetric());
                            switch(item.getType()) {
                                case DB:
                                    hostMemento.putString("dbname", host.getDbName());
                                    break;
                                case DB_VOL:
                                    hostMemento.putString("dbname", host.getDbName());
                                    hostMemento.putString("volname", host.getVolName());
                                    break;
                                case BROKER:
                                    hostMemento.putString("bname", host.getBrokerName());
                                    break;
                                case OS:
                                    break;
                                default:
                                    break;
                            }
                        }
                    }
                }
            }
        }
        PersistUtils.saveXMLMemento(CubridManagerUIPlugin.PLUGIN_ID, MONITOR_STATISTIC_XML_CONTENT, memento);
    }
}
Also used : SingleHostChartItem(com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) StatisticChartItem(com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartItem) MultiHostChartItem(com.cubrid.cubridmanager.core.monstatistic.model.MultiHostChartItem) XMLMemento(com.cubrid.cubridmanager.core.common.xml.XMLMemento) IXMLMemento(com.cubrid.cubridmanager.core.common.xml.IXMLMemento) MonitorStatistic(com.cubrid.common.ui.spi.model.MonitorStatistic) StatisticChartHost(com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost)

Aggregations

StatisticChartItem (com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartItem)11 ArrayList (java.util.ArrayList)7 MonitorStatisticChart (com.cubrid.cubridmanager.ui.monstatistic.editor.internal.MonitorStatisticChart)5 List (java.util.List)5 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)4 Composite (org.eclipse.swt.widgets.Composite)4 GridData (org.eclipse.swt.layout.GridData)3 MultiHostChartItem (com.cubrid.cubridmanager.core.monstatistic.model.MultiHostChartItem)2 SingleHostChartItem (com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem)2 StatisticChartHost (com.cubrid.cubridmanager.core.monstatistic.model.StatisticChartHost)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 MonitorStatistic (com.cubrid.common.ui.spi.model.MonitorStatistic)1 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)1 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)1 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)1 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)1 StatisticData (com.cubrid.cubridmanager.core.monstatistic.model.StatisticData)1 GetMonitorStatisticDataTask (com.cubrid.cubridmanager.core.monstatistic.task.GetMonitorStatisticDataTask)1 EditMultiHostStatisticItemDialog (com.cubrid.cubridmanager.ui.monstatistic.dialog.EditMultiHostStatisticItemDialog)1 EditSingleHostStatisticItemDialog (com.cubrid.cubridmanager.ui.monstatistic.dialog.EditSingleHostStatisticItemDialog)1