Search in sources :

Example 1 with IDiagPara

use of com.cubrid.cubridmanager.core.monitoring.model.IDiagPara in project cubrid-manager by CUBRID.

the class DatabaseDashboardViewPart method performUpdate.

/**
	 * Perform the update data
	 *
	 * @param dataChangedEvent the given event including newest data
	 */
public void performUpdate(DataChangedEvent dataChangedEvent) {
    if (composite == null || composite.isDisposed()) {
        return;
    }
    if (dbNode.getParent().isConnected()) {
        HADatabaseStatusInfo haDbStatusInfo = HAUtil.getDatabaseStatusInfo(dataChangedEvent.getHaHostStatusInfoList(), dbNode.getParent().getIp(), dbNode.getDbName());
        if (haDbStatusInfo == null) {
            haDbStatusInfo = HAUtil.getDatabaseStatusInfo(dataChangedEvent.getDbStatusInfoList(), dbNode.getDbName());
            if (null == haDbStatusInfo) {
                haDbStatusInfo = new HADatabaseStatusInfo();
                haDbStatusInfo.setDbName(dbNode.getDbName());
            }
        }
        dbNode.setHaDatabaseStatus(haDbStatusInfo);
    } else {
        HADatabaseStatusInfo haDatabaseStatus = new HADatabaseStatusInfo();
        haDatabaseStatus.setDbName(dbNode.getDbName());
        dbNode.setHaDatabaseStatus(haDatabaseStatus);
    }
    Set<MondashDataResult> set = dataChangedEvent.getResultSet();
    Map<IDiagPara, String> updateMap = null;
    String hostCpuTotal = "0";
    String hostMemTotal = "0";
    for (MondashDataResult result : set) {
        if (dbNode.getDbName().equals(result.getName())) {
            updateMap = result.getUpdateMap();
        } else if (generator.getName().equals(result.getName())) {
            Map<IDiagPara, String> hostMap = result.getUpdateMap();
            if (hostMap != null) {
                hostCpuTotal = hostMap.get(HostStatEnum.CPU_TOTAL);
                hostCpuTotal = hostCpuTotal == null ? "0" : hostCpuTotal;
                hostMemTotal = hostMap.get(HostStatEnum.MEMPHY_TOTAL);
                hostMemTotal = hostMemTotal == null ? "0" : hostMemTotal;
            }
        }
    }
    performUpdate(updateMap, hostCpuTotal, hostMemTotal);
}
Also used : MondashDataResult(com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.MondashDataResult) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) Map(java.util.Map) HashMap(java.util.HashMap) TreeMap(java.util.TreeMap)

Example 2 with IDiagPara

use of com.cubrid.cubridmanager.core.monitoring.model.IDiagPara in project cubrid-manager by CUBRID.

the class DataProvider method getUpdateValue.

/**
	 * Get the newest update data
	 * 
	 * @return DataChangedEvent
	 */
public DataChangedEvent getUpdateValue() {
    setDefaultValue();
    DataChangedEvent dataChangedEvent = new DataChangedEvent(this);
    Set<MondashDataResult> resultSet = new HashSet<MondashDataResult>();
    try {
        executeInThread();
    } catch (InterruptedException e) {
        LOGGER.error("", e);
    }
    // handle with the data
    //get host status
    Map<IDiagPara, String> hostMap = new HashMap<IDiagPara, String>();
    if (isExecuteHostStatTask) {
        performHostStatTask(hostMap);
    }
    //get broker status
    if (isExecuteBrokerStatTask) {
        performBrokerDiagTask(hostMap);
    }
    if (isExecuteHostStatTask || isExecuteBrokerStatTask) {
        MondashDataResult hostResult = new MondashDataResult();
        hostResult.setName(generator.getName());
        hostResult.putUpdateMap(hostMap);
        resultSet.add(hostResult);
    }
    //get HA node status
    List<HAHostStatusInfo> haHostStatusInfoList = null;
    if (isExecuteHeartbeatTask) {
        performHeartbeatNodeInfoTask();
        haHostStatusInfoList = getHeartbeatNodeInfoTask == null ? null : getHeartbeatNodeInfoTask.getHAHostStatusList();
    }
    //get database status
    List<HADatabaseStatusInfo> dbStatusInfoList = null;
    String dbStatusErrorInfo = null;
    if (isExecuteDbModeTask) {
        dbStatusErrorInfo = getDbModeTask.getErrorMsg();
        if (dbStatusErrorInfo != null && dbStatusErrorInfo.trim().length() > 0) {
            dbStatusErrorInfo += ", can not get database status.";
        }
        dbStatusInfoList = getDbModeTask.getDbModes();
    }
    //get some broker status
    DataChangedEvent event = brokerDataProvider == null ? null : brokerDataProvider.getUpdateValue();
    for (int i = 0; i < uniqueBrokerNodeList.size(); i++) {
        BrokerNode brokerNode = uniqueBrokerNodeList.get(i);
        if (event != null) {
            String brokerName = brokerNode.getBrokerName();
            dataChangedEvent.getBrokerInfosMap().put(brokerName, event.getBrokerInfosMap().get(brokerName));
            dataChangedEvent.getBrokerStatusInfosMap().put(brokerName, event.getBrokerStatusInfosMap().get(brokerName));
            dataChangedEvent.getBrokerDiagDataMap().put(brokerName, event.getBrokerDiagDataMap().get(brokerName));
        }
    }
    //get some databases status
    for (int i = 0; i < dbDataProviderList.size(); i++) {
        Set<MondashDataResult> dbResultSet = dbDataProviderList.get(i).getUpdateValue().getResultSet();
        if (dbResultSet != null) {
            resultSet.addAll(dbResultSet);
        }
        //set error
        DatabaseNode dbNode = dbDataProviderList.get(i).getDatabaseNode();
        if (StringUtil.isNotEmpty(dbStatusErrorInfo) && dbNode.getParent().isConnected()) {
            dbNode.setErrorMsg(dbStatusErrorInfo);
        }
        HADatabaseStatusInfo dbStatusInfo = HAUtil.getDatabaseStatusInfo(dbStatusInfoList, dbNode.getDbName());
        String errorInfo = dbStatusInfo == null ? null : dbStatusInfo.getErrorInfo();
        if (StringUtil.isNotEmpty(errorInfo) && dbNode.getParent().isConnected()) {
            dbNode.setErrorMsg(errorInfo);
        }
    }
    if (requestCount < 2) {
        requestCount++;
    }
    dataChangedEvent.setResultSet(resultSet);
    dataChangedEvent.setHaHostStatusInfoList(haHostStatusInfoList);
    dataChangedEvent.setDbStatusInfoList(dbStatusInfoList);
    setErrorMsg(errorMsg);
    if (errorMsg != null && errorMsg.trim().length() > 0) {
        LOGGER.error(errorMsg);
    }
    return dataChangedEvent;
}
Also used : HashMap(java.util.HashMap) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo) HashSet(java.util.HashSet)

Example 3 with IDiagPara

use of com.cubrid.cubridmanager.core.monitoring.model.IDiagPara in project cubrid-manager by CUBRID.

the class DbStatusHistoryViewPart method createPartControl.

/**
	 * Creates the SWT controls for this workbench part.
	 * 
	 * @param parent the parent control
	 * @see IWorkbenchPart
	 */
public void createPartControl(Composite parent) {
    final Composite composite = new Composite(parent, SWT.RESIZE);
    composite.setLayout(new GridLayout());
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    final HistoryComposite historyComposite = new HistoryComposite();
    historyComposite.loadTimeSelection(composite);
    serverInfo = cubridNode.getServer().getServerInfo();
    Label sepWithResult = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    sepWithResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    DbStatDumpData dbStatDumpData = new DbStatDumpData();
    TreeMap<String, String> map = new TreeMap<String, String>();
    for (Map.Entry<IDiagPara, String> entry : dbStatDumpData.getDiagStatusResultMap().entrySet()) {
        map.put(entry.getKey().getName(), entry.getValue());
    }
    chartPart = new ChartCompositePart(composite, map);
    dbCombo = new DbComboContribution("database");
    List<String> databaseLst = new ArrayList<String>();
    List<DatabaseInfo> databaseInfoLst = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
    if (null != databaseInfoLst && !databaseInfoLst.isEmpty()) {
        for (DatabaseInfo databaseInfo : databaseInfoLst) {
            databaseLst.add(databaseInfo.getDbName());
        }
        dbCombo.setDatabaseLst(databaseLst);
        if (!databaseLst.isEmpty()) {
            dbCombo.setSelectedDb(databaseLst.get(0));
        }
    }
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = chartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.DATABASE);
    }
    chartPart.setChartTitle(Messages.databaseHistoryChartTtl);
    String dbName = dbCombo.getSelectedDb();
    String hostAddress = serverInfo.getHostAddress();
    int monPort = serverInfo.getHostMonPort();
    String historyFileName = HistoryComposite.DB_HISTORY_FILE_PREFIX + dbName + "@" + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
    chartPart.setHistoryFileName(historyFileName);
    IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
    String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
    chartPart.setHistoryPath(sHistoryPath);
    chartPart.loadContent();
    chartPart.addChartMouseListener();
    makeActions();
    historyComposite.getQueryBtn().addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent ex) {
            String date = historyComposite.getDate();
            String fromTime = historyComposite.getFromTime();
            String toTime = historyComposite.getToTime();
            // check date/fromTime/toTime
            boolean timeOrder = historyComposite.checkTime(date, fromTime, toTime);
            if (!timeOrder) {
                CommonUITool.openErrorBox(Messages.errDbHistorySettingTime);
                return;
            }
            String[] ymd = date.split("-");
            int year = Integer.valueOf(ymd[0]);
            int month = Integer.valueOf(ymd[1]);
            int day = Integer.valueOf(ymd[2]);
            String[] fromHms = fromTime.split(":");
            int fromHour = Integer.valueOf(fromHms[0]);
            int fromMinute = Integer.valueOf(fromHms[1]);
            int fromSecond = Integer.valueOf(fromHms[2]);
            Calendar calFrom = Calendar.getInstance();
            calFrom.set(year, month, day, fromHour, fromMinute, fromSecond);
            long millisFrom = calFrom.getTimeInMillis();
            String[] toHms = toTime.split(":");
            int toHour = Integer.valueOf(toHms[0]);
            int toMinute = Integer.valueOf(toHms[1]);
            int toSecond = Integer.valueOf(toHms[2]);
            Calendar calTo = Calendar.getInstance();
            calTo.set(year, month, day, toHour, toMinute, toSecond);
            long millisTo = calTo.getTimeInMillis();
            XYPlot plot = (XYPlot) chartPart.getChart().getPlot();
            plot.getDomainAxis().setRange(millisFrom, millisTo);
            CounterFile countFile = chartPart.openHistoryFile();
            if (countFile == null) {
                return;
            }
            List<String> types = new ArrayList<String>();
            for (DbStatDumpEnum diagName : DbStatDumpEnum.values()) {
                String type = diagName.getName();
                types.add(type);
            }
            chartPart.executeQueryWithBusyCursor(countFile, types, millisFrom, millisTo);
            try {
                countFile.close();
            } catch (IOException e1) {
                LOGGER.error(e1.getMessage());
            }
        }

        public void widgetSelected(SelectionEvent ex) {
            widgetDefaultSelected(ex);
        }
    });
}
Also used : DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) Label(org.eclipse.swt.widgets.Label) ArrayList(java.util.ArrayList) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) GridLayout(org.eclipse.swt.layout.GridLayout) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) ArrayList(java.util.ArrayList) List(java.util.List) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) IPath(org.eclipse.core.runtime.IPath) Calendar(java.util.Calendar) IOException(java.io.IOException) TreeMap(java.util.TreeMap) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) DbStatDumpEnum(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpEnum) XYPlot(org.jfree.chart.plot.XYPlot) CounterFile(com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterFile) GridData(org.eclipse.swt.layout.GridData) Map(java.util.Map) TreeMap(java.util.TreeMap) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with IDiagPara

use of com.cubrid.cubridmanager.core.monitoring.model.IDiagPara in project cubrid-manager by CUBRID.

the class DatabaseMonitorPartHelper method performUpdate.

/**
	 * Perform the update data
	 * 
	 * @param dataChangedEvent the given event including newest data
	 */
public void performUpdate(DataChangedEvent dataChangedEvent) {
    if (!dbNode.getParent().isConnected()) {
        HADatabaseStatusInfo haDatabaseStatus = new HADatabaseStatusInfo();
        haDatabaseStatus.setDbName(dbNode.getDbName());
        dbNode.setHaDatabaseStatus(haDatabaseStatus);
        return;
    }
    Set<MondashDataResult> set = dataChangedEvent.getResultSet();
    String dbName = dbNode.getDbName();
    Map<IDiagPara, String> updateMap = null;
    String hostCpuTotal = null;
    String hostMemTotal = null;
    for (MondashDataResult result : set) {
        if (dbName.equals(result.getName())) {
            updateMap = result.getUpdateMap();
        } else if (generator.getName().equals(result.getName())) {
            Map<IDiagPara, String> hostMap = result.getUpdateMap();
            if (hostMap != null) {
                hostCpuTotal = hostMap.get(HostStatEnum.CPU_TOTAL);
                hostMemTotal = hostMap.get(HostStatEnum.MEMPHY_TOTAL);
            }
        }
    }
    int[] value = getValues(updateMap, hostCpuTotal == null ? "0" : hostCpuTotal, hostMemTotal == null ? "0" : hostMemTotal);
    HADatabaseStatusInfo haDbStatusInfo = HAUtil.getDatabaseStatusInfo(dataChangedEvent.getHaHostStatusInfoList(), dbNode.getParent().getIp(), dbNode.getDbName());
    if (haDbStatusInfo == null) {
        haDbStatusInfo = HAUtil.getDatabaseStatusInfo(dataChangedEvent.getDbStatusInfoList(), dbNode.getDbName());
        if (null == haDbStatusInfo) {
            haDbStatusInfo = new HADatabaseStatusInfo();
            haDbStatusInfo.setDbName(dbNode.getDbName());
        }
    }
    haDbStatusInfo.setCpuUsage(value[0]);
    haDbStatusInfo.setMemUsage(value[1]);
    haDbStatusInfo.setDelay(value[2]);
    dbNode.setHaDatabaseStatus(haDbStatusInfo);
}
Also used : MondashDataResult(com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.MondashDataResult) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara) Map(java.util.Map)

Example 5 with IDiagPara

use of com.cubrid.cubridmanager.core.monitoring.model.IDiagPara in project cubrid-manager by CUBRID.

the class HostMonitorPartHelper method performUpdate.

/**
	 * Perform the update data
	 * 
	 * @param dataChangedEvent the given event including newest data
	 */
public void performUpdate(DataChangedEvent dataChangedEvent) {
    DataProvider dataProvider = (DataProvider) dataChangedEvent.getSource();
    if (dataProvider != null && dataProvider.getServerInfo() != null) {
        hostNode.setConnected(dataProvider.getServerInfo().isConnected());
    }
    if (!hostNode.isConnected()) {
        hostNode.setConnected(false);
        HAHostStatusInfo haHostStatusInfo = new HAHostStatusInfo();
        haHostStatusInfo.setIp(hostNode.getIp());
        hostNode.setHostStatusInfo(haHostStatusInfo);
        return;
    }
    HAHostStatusInfo haHostStatusInfo = HAUtil.getHostStatusInfo(dataChangedEvent.getHaHostStatusInfoList(), hostNode.getIp());
    if (haHostStatusInfo == null) {
        haHostStatusInfo = HAUtil.getHAHostStatusInfo(hostNode.getServerInfo());
        if (haHostStatusInfo == null) {
            haHostStatusInfo = new HAHostStatusInfo();
            haHostStatusInfo.setIp(hostNode.getIp());
        }
    }
    Set<MondashDataResult> set = dataChangedEvent.getResultSet();
    Map<IDiagPara, String> map = null;
    for (MondashDataResult result : set) {
        if (generator.getName().equals(result.getName())) {
            map = result.getUpdateMap();
            break;
        }
    }
    int[] value = getValues(map);
    haHostStatusInfo.setCpuUsage(value[0]);
    haHostStatusInfo.setMemUsage(value[1]);
    haHostStatusInfo.setIoWait(value[2]);
    hostNode.setHostStatusInfo(haHostStatusInfo);
}
Also used : DataProvider(com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataProvider) HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) MondashDataResult(com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.MondashDataResult) IDiagPara(com.cubrid.cubridmanager.core.monitoring.model.IDiagPara)

Aggregations

IDiagPara (com.cubrid.cubridmanager.core.monitoring.model.IDiagPara)5 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)3 MondashDataResult (com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.MondashDataResult)3 Map (java.util.Map)3 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)2 HashMap (java.util.HashMap)2 TreeMap (java.util.TreeMap)2 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)1 DbStatDumpData (com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData)1 DbStatDumpEnum (com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpEnum)1 DataProvider (com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataProvider)1 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)1 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)1 CounterFile (com.cubrid.cubridmanager.ui.monitoring.editor.count.CounterFile)1 ChartCompositePart (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart)1 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)1 ShowSetting (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 Calendar (java.util.Calendar)1