Search in sources :

Example 1 with StatisticType

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

the class StatisticChartItemTest method testStatisticChartItem.

public void testStatisticChartItem() {
    String nodeId = "demo";
    StatisticType type = StatisticType.OS;
    StatisticChartItem statisticChartItem = new SingleHostChartItem(nodeId, type);
    String dtype = TimeType.DAILY.getType();
    statisticChartItem.setDType(dtype);
    assertEquals(statisticChartItem.getDType(), dtype);
    assertFalse(statisticChartItem.isMultiHost());
    String name = "";
    statisticChartItem.setName(name);
    assertEquals(statisticChartItem.getName(), "");
    assertEquals(statisticChartItem.getNodeId(), nodeId);
    int series = 10;
    statisticChartItem.setSeries(series);
    assertEquals(statisticChartItem.getSeries(), series);
    statisticChartItem.setType(StatisticType.DB);
    assertEquals(statisticChartItem.getType(), StatisticType.DB);
}
Also used : StatisticType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType)

Example 2 with StatisticType

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

the class SingleHostChartItemTest method testSingleHostChartItem.

public void testSingleHostChartItem() {
    String nodeId = "demo";
    StatisticType type = StatisticType.OS;
    SingleHostChartItem singleHostChartItem = new SingleHostChartItem(nodeId, type);
    String brokerName = "query_editor";
    singleHostChartItem.setBrokerName(brokerName);
    assertEquals(singleHostChartItem.getBrokerName(), brokerName);
    String dtype = TimeType.DAILY.getType();
    singleHostChartItem.setDType(dtype);
    assertEquals(singleHostChartItem.getDType(), dtype);
    String dbName = "demodb";
    singleHostChartItem.setDbName(dbName);
    assertEquals(singleHostChartItem.getDbName(), dbName);
    List<String> metricList = new ArrayList<String>();
    String metric = MetricType.OS_CPU_IDLE.getMetric();
    String metric2 = MetricType.OS_CPU_USER.getMetric();
    metricList.add(metric);
    singleHostChartItem.setMetricList(metricList);
    assertEquals(singleHostChartItem.getMetricList(), metricList);
    assertTrue(singleHostChartItem.getMetricList().contains(metric));
    singleHostChartItem.addMetric(metric2);
    assertTrue(singleHostChartItem.getMetricList().contains(metric2));
    assertFalse(singleHostChartItem.isMultiHost());
    assertNotNull(singleHostChartItem.getName());
    assertEquals(singleHostChartItem.getNodeId(), nodeId);
    int series = 10;
    singleHostChartItem.setSeries(series);
    assertEquals(singleHostChartItem.getSeries(), series);
    assertEquals(singleHostChartItem.getType(), type);
    singleHostChartItem.setType(type);
    String volName = "demodb_lgat";
    singleHostChartItem.setVolName(volName);
    assertEquals(singleHostChartItem.getVolName(), volName);
}
Also used : StatisticType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType) ArrayList(java.util.ArrayList)

Example 3 with StatisticType

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

the class EditSingleHostStatisticItemDialog method okPressed.

/**
	 * When press "ok" button, call it.
	 */
public void okPressed() {
    StatisticType type = StatisticType.getEnumByMessage(comboDataType.getText());
    String timeType = getTimeType();
    int series = 0;
    if (!isNew) {
        series = statisticChartItem.getSeries();
    }
    statisticChartItem = new SingleHostChartItem(editor.getNodeId(), type);
    statisticChartItem.setDType(timeType);
    switch(type) {
        case DB:
            ((SingleHostChartItem) statisticChartItem).setDbName(comboDbName.getText());
            break;
        case DB_VOL:
            ((SingleHostChartItem) statisticChartItem).setDbName(comboDbName.getText());
            ((SingleHostChartItem) statisticChartItem).setVolName(comboVolName.getText());
            break;
        case BROKER:
            ((SingleHostChartItem) statisticChartItem).setBrokerName(comboBrokerName.getText());
            break;
        case OS:
            break;
        default:
    }
    for (Group grp : grpMetricList) {
        if (grp.getChildren() == null) {
            continue;
        }
        for (Control control : grp.getChildren()) {
            if (control instanceof Button) {
                if (((Button) control).getSelection()) {
                    ((SingleHostChartItem) statisticChartItem).addMetric(MetricType.getEnumByMessage(((Button) control).getText()).getMetric());
                }
            }
        }
    }
    if (!isNew) {
        statisticChartItem.setSeries(series);
    }
    super.okPressed();
}
Also used : Group(org.eclipse.swt.widgets.Group) Control(org.eclipse.swt.widgets.Control) SingleHostChartItem(com.cubrid.cubridmanager.core.monstatistic.model.SingleHostChartItem) Button(org.eclipse.swt.widgets.Button) StatisticType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType)

Example 4 with StatisticType

use of com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType 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 5 with StatisticType

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

the class EditStatisticHostDialog method okPressed.

/**
	 * When press "ok" button, call it.
	 */
public void okPressed() {
    StatisticType type = StatisticType.getEnumByMessage(comboDataType.getText());
    if (isFirstHost) {
        ((EditMultiHostStatisticItemDialog) parentDialog).setType(type);
        ((EditMultiHostStatisticItemDialog) parentDialog).setTimeType(getTimeType());
    }
    String cubridServerId = comboHost.getText();
    hostItem = new StatisticChartHost(cubridServerId);
    ServerInfo serverInfo = hostNodePersistManager.getServer(cubridServerId).getServerInfo();
    hostItem.setServerInfo(serverInfo);
    hostItem.setIp(serverInfo.getHostAddress());
    hostItem.setPort(serverInfo.getHostMonPort());
    hostItem.setUser(serverInfo.getUserName());
    hostItem.setPassword(serverInfo.getUserPassword());
    switch(type) {
        case DB:
            hostItem.setDbName(comboDbName.getText());
            break;
        case DB_VOL:
            hostItem.setDbName(comboDbName.getText());
            hostItem.setVolName(comboVolName.getText());
            break;
        case BROKER:
            hostItem.setBrokerName(comboBrokerName.getText());
            break;
        case OS:
            break;
        default:
    }
    hostItem.setMetric(MetricType.getEnumByMessage(comboMetric.getText()).getMetric());
    boolean isDuplicated = ((EditMultiHostStatisticItemDialog) parentDialog).isDuplicatedHostInfo(hostItem, oldHostItem);
    if (isDuplicated) {
        CommonUITool.openWarningBox(Messages.errDuplicateHost);
        return;
    }
    super.okPressed();
}
Also used : StatisticType(com.cubrid.cubridmanager.core.monstatistic.model.StatisticParamUtil.StatisticType) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) 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