Search in sources :

Example 1 with TimeType

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

the class EditSingleHostStatisticItemDialog method createDialogArea.

/**
	 * Creates and returns the contents of the upper part of this dialog (above
	 * the button bar).
	 * 
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    final Composite parentComp = (Composite) super.createDialogArea(parent);
    parentComp.setLayout(new GridLayout(1, false));
    GridData gdParent = new GridData(SWT.FILL);
    gdParent.widthHint = DIALOG_AREA_WIDTH;
    gdParent.heightHint = LINE_HEIGHT * 11;
    parentComp.setLayoutData(gdParent);
    //init data
    StatisticType statisticType = StatisticType.DB;
    if (!isNew && statisticChartItem != null) {
        statisticType = statisticChartItem.getType();
        oldDataType = statisticType;
        dataTypeValue = statisticType.getMessage();
        TimeType timeType = TimeType.getEnumByType(statisticChartItem.getDType());
        timeValue = timeType == null ? TimeType.DAILY.getMessage() : timeType.getMessage();
        switch(statisticType) {
            case DB:
                dbNameValue = ((SingleHostChartItem) statisticChartItem).getDbName();
                break;
            case DB_VOL:
                dbNameValue = ((SingleHostChartItem) statisticChartItem).getDbName();
                dbVolNameValue = ((SingleHostChartItem) statisticChartItem).getVolName();
                break;
            case BROKER:
                brokerNameValue = ((SingleHostChartItem) statisticChartItem).getBrokerName();
                break;
            case OS:
                break;
            default:
        }
    }
    compDataType = new Composite(parentComp, SWT.RESIZE);
    GridLayout layoutCompDataType = new GridLayout(4, false);
    compDataType.setLayout(layoutCompDataType);
    final Label lblDataType = new Label(compDataType, SWT.NONE);
    GridData gdlblDataType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdlblDataType.widthHint = 120;
    lblDataType.setText(Messages.lblDataType);
    comboDataType = new Combo(compDataType, SWT.NONE | SWT.READ_ONLY);
    GridData gdComboDataType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdComboDataType.widthHint = 180;
    comboDataType.setLayoutData(gdComboDataType);
    comboDataType.setItems(itemsDataType);
    comboDataType.setText(dataTypeValue);
    comboDataType.addSelectionListener(new ComboDataTypeSelectionAdapter());
    final Label lblTimeType = new Label(compDataType, SWT.NONE);
    GridData gdlblTimeType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdlblTimeType.widthHint = 120;
    lblTimeType.setText(Messages.lblTimeType);
    comboTimeType = new Combo(compDataType, SWT.NONE | SWT.READ_ONLY);
    GridData gdComboTimeType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdComboTimeType.widthHint = 180;
    comboTimeType.setLayoutData(gdComboTimeType);
    comboTimeType.setItems(itemsTimeType);
    comboTimeType.setText(timeValue);
    compMetrics = new Composite(parentComp, SWT.RESIZE);
    refreshChangeableItems(statisticType);
    if (!isNew && statisticChartItem != null) {
        List<String> metricList = ((SingleHostChartItem) statisticChartItem).getMetricList();
        for (Group grp : grpMetricList) {
            if (grp.getChildren() == null) {
                continue;
            }
            boolean isFindInGroup = false;
            for (Control control : grp.getChildren()) {
                if (control instanceof Button) {
                    Button btn = ((Button) control);
                    btn.setEnabled(false);
                    String msg = btn.getText();
                    MetricType metricType = MetricType.getEnumByMessage(msg);
                    for (String metric : metricList) {
                        if (metric.equals(metricType.getMetric())) {
                            btn.setSelection(true);
                            isFindInGroup = true;
                            break;
                        }
                    }
                }
            }
            if (isFindInGroup) {
                for (Control control : grp.getChildren()) {
                    if (control instanceof Button) {
                        ((Button) control).setEnabled(true);
                    }
                }
            }
        }
    }
    //add btn
    final Composite btnComp = new Composite(parentComp, SWT.NONE);
    btnComp.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    {
        GridLayout layout = new GridLayout();
        layout.marginRight = 5;
        layout.numColumns = 1;
        layout.marginWidth = 0;
        btnComp.setLayout(layout);
    }
    btnClearAll = new Button(btnComp, SWT.NONE);
    btnClearAll.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false));
    btnClearAll.setText(Messages.btnCleanSelected);
    btnClearAll.addSelectionListener(new ButtonCleanAllSelectionAdapter());
    return parentComp;
}
Also used : Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) SingleHostChartItem(com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem) MetricType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) TimeType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType) GridLayout(org.eclipse.swt.layout.GridLayout) Control(org.eclipse.swt.widgets.Control) Button(org.eclipse.swt.widgets.Button) StatisticType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType) GridData(org.eclipse.swt.layout.GridData)

Example 2 with TimeType

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

the class EditSingleHostStatisticItemDialog method getTimeType.

private String getTimeType() {
    String text = comboTimeType.getText();
    TimeType timeType = TimeType.getEnumByMessage(text);
    return timeType == null ? null : timeType.getType();
}
Also used : TimeType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType)

Example 3 with TimeType

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

the class EditStatisticHostDialog method getTimeType.

private TimeType getTimeType() {
    String text = comboTimeType.getText();
    TimeType timeType = TimeType.getEnumByMessage(text);
    return timeType;
}
Also used : TimeType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType)

Example 4 with TimeType

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

the class EditStatisticHostDialog method createDialogArea.

/**
	 * Creates and returns the contents of the upper part of this dialog (above
	 * the button bar).
	 *
	 * @param parent The parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    final Composite parentComp = (Composite) super.createDialogArea(parent);
    compRoot = new Composite(parentComp, SWT.RESIZE);
    GridLayout layoutCompDataType = new GridLayout(4, false);
    compRoot.setLayout(layoutCompDataType);
    compRoot.setLayoutData(new GridData(GridData.FILL_BOTH));
    final Label lblHost = new Label(compRoot, SWT.NONE);
    lblHost.setText(Messages.lblHost);
    comboHost = new Combo(compRoot, SWT.NONE | SWT.READ_ONLY);
    GridData gdComboHost = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdComboHost.widthHint = 168;
    comboHost.setLayoutData(gdComboHost);
    comboHost.setItems(itemsHost);
    comboHost.setText(hostValue);
    //initial latest comboHost selection index
    for (int i = 0; i < itemsHost.length; i++) {
        if (itemsHost[i].equals(hostValue)) {
            oldHostIndex = i;
            break;
        }
        oldHostIndex = -1;
    }
    comboHost.addSelectionListener(new ComboHostSelectionAdapter());
    final Label lblHostStatus = new Label(compRoot, SWT.NONE);
    lblHostStatus.setText(Messages.lblStatus);
    comboHostStatus = new Text(compRoot, SWT.BORDER);
    GridData gdComboHostStatus = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdComboHostStatus.widthHint = 168;
    comboHostStatus.setLayoutData(gdComboHostStatus);
    comboHostStatus.setText(hostStatusValue);
    comboHostStatus.setEditable(false);
    final Label lblDataType = new Label(compRoot, SWT.NONE);
    lblDataType.setText(Messages.lblDataType);
    comboDataType = new Combo(compRoot, SWT.NONE | SWT.READ_ONLY);
    GridData gdComboDataType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdComboDataType.widthHint = 168;
    comboDataType.setLayoutData(gdComboDataType);
    comboDataType.setItems(itemsDataType);
    //init data type value
    if (dataType == null && !isFirstHost && !StringUtil.isEmpty(firstMetric)) {
        dataType = StatisticParamUtil.getTypeByMetric(firstMetric);
    }
    dataType = dataType == null ? StatisticType.DB : dataType;
    dataTypeValue = dataType.getMessage();
    comboDataType.setText(dataTypeValue);
    //initial latest comboDataType selection index
    for (int i = 0; i < itemsHost.length; i++) {
        if (itemsDataType[i].equals(dataTypeValue)) {
            oldDataTypeIndex = i;
            break;
        }
    }
    comboDataType.addSelectionListener(new ComboDataTypeSelectionAdapter());
    final Label lblTimeType = new Label(compRoot, SWT.NONE);
    lblTimeType.setText(Messages.lblTimeType);
    comboTimeType = new Combo(compRoot, SWT.NONE | SWT.READ_ONLY);
    GridData gdComboTimeType = new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1);
    gdComboTimeType.widthHint = 168;
    comboTimeType.setLayoutData(gdComboTimeType);
    comboTimeType.setItems(itemsTimeType);
    if (!isFirstHost && firstTime != null) {
        TimeType timeType = firstTime;
        timeValue = timeType.getMessage();
    }
    comboTimeType.setText(timeValue);
    refreshChangeableItems(dataType, false);
    if (!isNewHost && serverInfo != null) {
        refreshDbAndBrokerData(serverInfo.isSupportMonitorStatistic(), true);
        boolean isSupportMonitorStatistic = serverInfo.isSupportMonitorStatistic();
        boolean isSupportByVersion = CompatibleUtil.isSupportMonitorStatistic(serverInfo);
        isOkEnable[0] = isSupportMonitorStatistic || isSupportByVersion;
        isOkEnable[5] = isSupportMonitorStatistic && isSupportByVersion;
    }
    refreshMetricData(dataType, isNewHost);
    comboDataType.setEnabled(isFirstHost);
    comboTimeType.setEnabled(isFirstHost);
    return parentComp;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Combo(org.eclipse.swt.widgets.Combo) Text(org.eclipse.swt.widgets.Text) TimeType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType)

Example 5 with TimeType

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

the class MonitorStatisticChart method createDataset.

private XYDataset createDataset() {
    TimeSeriesCollection dataset = new TimeSeriesCollection();
    if (statisticDataList == null) {
        return dataset;
    }
    double maxForRang = 0;
    List<StatisticData> dataItemWithoutDataList = new ArrayList<StatisticData>();
    TimeType timeType = null;
    Date current = new Date();
    long interalMillisecs = 0;
    for (StatisticData statisticData : statisticDataList) {
        if (statisticData == null) {
            continue;
        }
        MetricType metricType = MetricType.getEnumByMetric(statisticData.getMetric());
        if (metricType == null) {
            continue;
        }
        int size = statisticData.getData().size();
        if (size == 0) {
            dataItemWithoutDataList.add(statisticData);
            continue;
        } else if (dataSize == 0) {
            //record data size for build invalid data
            dataSize = size;
        }
        //check data type, record 'isHasValidData = true'
        if (!isHasValidData) {
            isHasValidData = true;
            chartType = getChartType(statisticData.getMetric());
            if (chartType == ChartType.PERCENT) {
                rangMax = 100;
            }
            String dateType = statisticData.getDtype();
            timeType = TimeType.getEnumByType(dateType);
            //CMS return -1 for invalid data, so for invalid data(<0), display as -1.
            switch(timeType) {
                case DAILY:
                    interalMillisecs = 1000 * 60 * 60 * 24 / size;
                    break;
                case WEEKLY:
                    interalMillisecs = 1000 * 60 * 60;
                    break;
                case MONTHLY:
                    interalMillisecs = 1000 * 60 * 60;
                    break;
                case YEARLY:
                    interalMillisecs = 1000 * 60 * 60 * 24;
                    break;
                default:
                    break;
            }
        }
        TimeSeries series = null;
        if (isDetailView) {
            series = new TimeSeries(statisticData.getDescription(isMultiHost));
        } else {
            series = new TimeSeries(statisticData.getSimpleDescription(isMultiHost));
        }
        Date point = (Date) current.clone();
        long curMillisecs = current.getTime();
        int count = 0;
        int max = 0;
        int min = 0;
        boolean isInitMinVal = false;
        for (int val : statisticData.getData()) {
            point.setTime(curMillisecs - (size - count) * interalMillisecs);
            switch(timeType) {
                case DAILY:
                    if (val < 0) {
                        series.add(new Second(point), -1);
                    } else {
                        series.add(new Second(point), val / 100);
                    }
                    break;
                case WEEKLY:
                    if (val < 0) {
                        series.add(new Hour(point), -1);
                    } else {
                        series.add(new Hour(point), val / 100);
                    }
                    break;
                case MONTHLY:
                    if (val < 0) {
                        series.add(new Hour(point), -1);
                    } else {
                        series.add(new Hour(point), val / 100);
                    }
                    break;
                case YEARLY:
                    if (val < 0) {
                        series.add(new Day(point), -1);
                    } else {
                        series.add(new Day(point), val / 100);
                    }
                    break;
                default:
                    break;
            }
            if (chartType != ChartType.PERCENT && val > maxForRang) {
                maxForRang = val;
            }
            if (!isInitMinVal && val >= 0) {
                min = val;
                isInitMinVal = true;
            }
            if (val > max) {
                max = val;
            }
            if (val < min && val >= 0) {
                min = val;
            }
            count++;
        }
        maxValueMap.put(statisticData, max / 100d);
        minValueMap.put(statisticData, min / 100d);
        dataset.addSeries(series);
    }
    if (!isHasValidData) {
        return dataset;
    }
    if (chartType != ChartType.PERCENT) {
        decideRangMax(maxForRang / 100);
    }
    /*[TOOLS-3742] Build invalid data for StatisticData which has no data*/
    buildInvalidData(dataset, timeType, dataItemWithoutDataList, current, interalMillisecs);
    if (isDetailView) {
        chartTitle = Messages.monStatisticDetailChartTitle;
        timeAxisLabel = Messages.lblChartTime;
        valueAxisLabel = Messages.lblChartValue;
        switch(chartType) {
            case PERCENT:
                valueAxisLabel += " (%)";
                break;
            case MEMORY:
            case SPACE:
                valueAxisLabel += " (MB)";
                break;
            case OTHERS:
                break;
            default:
                break;
        }
    }
    return dataset;
}
Also used : TimeSeries(org.jfree.data.time.TimeSeries) Hour(org.jfree.data.time.Hour) MetricType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType) ArrayList(java.util.ArrayList) StatisticData(com.cubrid.cubridmanager.core.monstatistic.model.StatisticData) Date(java.util.Date) TimeType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType) Second(org.jfree.data.time.Second) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) Day(org.jfree.data.time.Day)

Aggregations

TimeType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.TimeType)6 MetricType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.MetricType)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 Label (org.eclipse.swt.widgets.Label)2 SingleHostChartItem (com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem)1 StatisticData (com.cubrid.cubridmanager.core.monstatistic.model.StatisticData)1 StatisticType (com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Button (org.eclipse.swt.widgets.Button)1 Control (org.eclipse.swt.widgets.Control)1 Group (org.eclipse.swt.widgets.Group)1 Text (org.eclipse.swt.widgets.Text)1 Day (org.jfree.data.time.Day)1 Hour (org.jfree.data.time.Hour)1 Second (org.jfree.data.time.Second)1 TimeSeries (org.jfree.data.time.TimeSeries)1