Search in sources :

Example 6 with BrokerDiagData

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

the class BrokerStatusHistoryViewPart 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);
    Label sepWithResult = new Label(composite, SWT.SEPARATOR | SWT.HORIZONTAL | SWT.SHADOW_OUT);
    sepWithResult.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    BrokerDiagData brokerDiagData = new BrokerDiagData();
    ICubridNode selection = getCubridNode();
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    isNewBrokerDiag = CompatibleUtil.isNewBrokerDiag(serverInfo);
    TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
    chartPart = new ChartCompositePart(composite, map);
    for (Map.Entry<String, String> entry : map.entrySet()) {
        String key = entry.getKey();
        ShowSetting showSetting = chartPart.getSettingMap().get(key);
        ShowSettingMatching.match(key, showSetting, MonitorType.BROKER, isNewBrokerDiag);
    }
    chartPart.setChartTitle(Messages.brokerHistoryChartTtl);
    String hostAddress = serverInfo.getHostAddress();
    int monPort = serverInfo.getHostMonPort();
    String historyFileName = HistoryComposite.BROKER_HISTORY_FILE_PREFIX + 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.errBrokerHistorySettingTime);
                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);
            final 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);
            final long millisTo = calTo.getTimeInMillis();
            XYPlot plot = (XYPlot) chartPart.getChart().getPlot();
            plot.getDomainAxis().setRange(millisFrom, millisTo);
            final CounterFile countFile = chartPart.openHistoryFile();
            if (countFile == null) {
                return;
            }
            final List<String> types = new ArrayList<String>();
            for (BrokerDiagEnum enumeration : BrokerDiagEnum.values()) {
                String type = enumeration.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 : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) Label(org.eclipse.swt.widgets.Label) BrokerDiagEnum(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagEnum) 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) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) IOException(java.io.IOException) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) 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 7 with BrokerDiagData

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

the class BrokerStatusMonitorViewPart method createPartControl.

/**
	 * Creates the SWT controls for this workbench part.
	 *
	 * @param parent the parent control
	 */
public void createPartControl(Composite parent) {
    composite = new Composite(parent, SWT.RESIZE);
    composite.setLayout(new FillLayout());
    ICubridNode selection = getCubridNode();
    ServerInfo serverInfo = selection.getServer().getServerInfo();
    isNewBrokerDiag = CompatibleUtil.isNewBrokerDiag(serverInfo);
    BrokerDiagData brokerDiagData = new BrokerDiagData();
    TreeMap<String, String> map = convertMapKey(brokerDiagData.getDiagStatusResultMap());
    chartPart = new ChartCompositePart(composite, map);
    String hostAddress = serverInfo.getHostAddress();
    int monPort = serverInfo.getHostMonPort();
    String historyFileName = HistoryComposite.BROKER_HISTORY_FILE_PREFIX + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
    chartPart.setHistoryFileName(historyFileName);
    if (null == monInstaceData) {
        for (Map.Entry<String, String> entry : map.entrySet()) {
            String key = entry.getKey();
            ShowSetting showSetting = chartPart.getSettingMap().get(key);
            ShowSettingMatching.match(key, showSetting, MonitorType.BROKER, isNewBrokerDiag);
        }
        chartPart.setChartTitle(Messages.brokerMonitorChartTtl);
        IPath historyPath = CubridManagerCorePlugin.getDefault().getStateLocation();
        String sHistoryPath = historyPath.toOSString() + File.separator + historyFileName;
        chartPart.setHistoryPath(sHistoryPath);
    } else {
        String titleName = monInstaceData.getTitleName();
        chartPart.setChartTitle(titleName);
        chartPart.setSettingData(monInstaceData);
    }
    chartPart.loadContent();
    makeActions();
    new DataGenerator().start();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) IPath(org.eclipse.core.runtime.IPath) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) FillLayout(org.eclipse.swt.layout.FillLayout) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 8 with BrokerDiagData

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

the class BrokerStatusMonitorViewPart method getUpdateValue.

/**
	 * Get update value
	 *
	 * @param startRun int
	 * @return Map<String, String>
	 */
private TreeMap<String, String> getUpdateValue(int startRun) {
    ServerInfo site = cubridNode.getServer().getServerInfo();
    final CommonQueryTask<BrokerDiagData> task = new CommonQueryTask<BrokerDiagData>(site, CommonSendMsg.getGetBrokerStatusItems(), diagStatusResult);
    task.execute();
    TreeMap<String, String> resultMap = null;
    float inter = 0.0f;
    if (startRun == 0) {
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptReq) {
                return convertMapKey(diagStatusResult.getDiagStatusResultMap());
            } else {
                showErrorMsg(diagStatusResult);
            }
        }
        return convertMapKey(diagStatusResult.getDiagStatusResultMap());
    } else if (startRun == 1) {
        lastSec = Calendar.getInstance();
        diagOldOneStatusResult.copyFrom(diagStatusResult);
        BrokerDiagData brokerDiagDataDelta = new BrokerDiagData();
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptReq) {
                return convertMapKey(diagStatusResult.getDiagStatusResultMap());
            } else {
                showErrorMsg(diagStatusResult);
            }
        }
        brokerDiagDataDelta.getDelta(diagStatusResult, diagOldOneStatusResult);
        return convertMapKey(brokerDiagDataDelta.getDiagStatusResultMap());
    } else {
        nowSec = Calendar.getInstance();
        double interval = (double) (nowSec.getTimeInMillis() - lastSec.getTimeInMillis()) / 1000;
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(3);
        inter = Float.parseFloat(nf.format(interval));
        lastSec = nowSec;
        diagOldTwoStatusResult.copyFrom(diagOldOneStatusResult);
        diagOldOneStatusResult.copyFrom(diagStatusResult);
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptReq) {
                return convertMapKey(diagStatusResult.getDiagStatusResultMap());
            } else {
                showErrorMsg(diagStatusResult);
            }
        }
        BrokerDiagData diagStatusResultDelta = new BrokerDiagData();
        diagStatusResultDelta.getDelta(diagStatusResult, diagOldOneStatusResult, diagOldTwoStatusResult, inter);
        resultMap = convertMapKey(diagStatusResultDelta.getDiagStatusResultMap());
    }
    return resultMap;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) NumberFormat(java.text.NumberFormat)

Example 9 with BrokerDiagData

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

the class BrokerDashboardViewPart method performUpdate.

/**
	 * Perform update UI when data change event happen
	 * 
	 * @param dataChangedEvent the instance of DataChangedEvent
	 */
public void performUpdate(DataChangedEvent dataChangedEvent) {
    if (composite == null || composite.isDisposed()) {
        return;
    }
    if (dataChangedEvent != null) {
        String brokerName = brokerNode.getBrokerName();
        BrokerInfos brokerInfos = dataChangedEvent.getBrokerInfosMap().get(brokerName);
        BrokerStatusInfos brokerStatusInfos = dataChangedEvent.getBrokerStatusInfosMap().get(brokerName);
        BrokerDiagData brokerDiagData = dataChangedEvent.getBrokerDiagDataMap().get(brokerName);
        List<String> basicTableLst = new ArrayList<String>();
        if (brokerInfos == null) {
            for (int i = 0; i < 10; i++) {
                basicTableLst.add("");
            }
        } else {
            BrokerInfoList brokerInfoList = brokerInfos.getBorkerInfoList();
            if (brokerInfoList.getBrokerInfoList().isEmpty()) {
                for (int i = 0; i < 10; i++) {
                    basicTableLst.add("");
                }
            }
            for (BrokerInfo bi : brokerInfoList.getBrokerInfoList()) {
                if (brokerName.equals(bi.getName())) {
                    basicTableLst.add(bi.getPid());
                    basicTableLst.add(bi.getPort());
                    basicTableLst.add(bi.getJq());
                    basicTableLst.add(bi.getAuto());
                    basicTableLst.add(bi.getSqll());
                    basicTableLst.add(bi.getLong_tran_time());
                    basicTableLst.add(bi.getLong_query_time());
                    basicTableLst.add(bi.getSes());
                    basicTableLst.add(bi.getKeep_conn());
                    basicTableLst.add(bi.getAccess_mode());
                }
            }
        }
        if (brokerDiagData == null) {
            for (int i = 0; i < 3; i++) {
                basicTableLst.add("");
            }
        } else {
            basicTableLst.add(brokerDiagData.getCas_mon_active());
            basicTableLst.add(brokerDiagData.getCas_mon_session());
            basicTableLst.add(brokerDiagData.getCas_mon_tran());
        }
        //test
        List<List<String>> basicColumnLst = new ArrayList<List<String>>();
        basicColumnLst.add(basicTableLst);
        basicTableViewer.setInput(basicColumnLst);
        basicTableViewer.refresh();
        List<ApplyServerInfo> asinfoLst = null;
        List<JobInfo> jobinfoLst = null;
        if (brokerStatusInfos == null) {
            asinfoLst = new ArrayList<ApplyServerInfo>();
            jobinfoLst = new ArrayList<JobInfo>();
        } else {
            asinfoLst = brokerStatusInfos.getAsinfo();
            jobinfoLst = brokerStatusInfos.getJobinfo();
            if (asinfoLst == null) {
                asinfoLst = new ArrayList<ApplyServerInfo>();
            }
            if (jobinfoLst == null) {
                jobinfoLst = new ArrayList<JobInfo>();
            }
        }
        asTableViewer.setInput(asinfoLst);
        asTableViewer.refresh();
        jqTableViewer.setInput(jobinfoLst);
        jqTableViewer.refresh();
    }
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ArrayList(java.util.ArrayList) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) JobInfo(com.cubrid.cubridmanager.core.broker.model.JobInfo) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList)

Example 10 with BrokerDiagData

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

the class DataProvider method executeInThread.

/**
	 * 
	 * Execute task by multi-thread
	 * 
	 * @throws InterruptedException the exception
	 */
public void executeInThread() throws InterruptedException {
    //multi thread execution
    List<Runnable> runnableList = new ArrayList<Runnable>();
    if (isExecuteHostStatTask) {
        hostStatTask = new CommonQueryTask<HostStatData>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), new HostStatData());
        hostStatTask.setTimeout(TIME_OUT_MILL);
        runnableList.add(hostStatTask);
    }
    if (isExecuteBrokerStatTask) {
        brokerDiagTask = new CommonQueryTask<BrokerDiagData>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), new BrokerDiagData());
        brokerDiagTask.setTimeout(TIME_OUT_MILL);
        runnableList.add(brokerDiagTask);
    }
    List<String> dbList = new ArrayList<String>();
    for (DatabaseNode dbNode : uniqueDbNodeList) {
        dbList.add(dbNode.getDbName());
    }
    if (isExecuteHeartbeatTask) {
        getHeartbeatNodeInfoTask = new GetHeartbeatNodeInfoTask(serverInfo);
        getHeartbeatNodeInfoTask.setAllDb(false);
        getHeartbeatNodeInfoTask.setDbList(dbList);
        getHeartbeatNodeInfoTask.setTimeout(TIME_OUT_MILL);
        runnableList.add(getHeartbeatNodeInfoTask);
    }
    if (isExecuteDbModeTask) {
        getDbModeTask = new GetDbModeTask(serverInfo);
        getDbModeTask.setDbList(dbList);
        getDbModeTask.setTimeout(TIME_OUT_MILL);
        runnableList.add(getDbModeTask);
    }
    //execute broker related task
    if (!uniqueBrokerNodeList.isEmpty()) {
        runnableList.addAll(brokerDataProvider.getExecRunnableList());
    }
    if (IS_MULTI_THREAD && !runnableList.isEmpty()) {
        try {
            generator.getThreadPoolManager().execute(runnableList, true);
        } catch (ThreadCountOutOfBoundsException e) {
            LOGGER.error("", e);
        }
        join(runnableList, 350);
        runnableList.clear();
    }
    //get database status information
    List<HADatabaseStatusInfo> dbStatusInfoList = null;
    if (isExecuteDbModeTask) {
        dbStatusInfoList = getDbModeTask.getDbModes();
    }
    //execute database related task
    for (int i = 0; i < dbDataProviderList.size(); i++) {
        DatabaseNode dbNode = dbDataProviderList.get(i).getDatabaseNode();
        HADatabaseStatusInfo dbStatusInfo = HAUtil.getDatabaseStatusInfo(dbStatusInfoList, dbNode.getDbName());
        dbDataProviderList.get(i).setDbStatusInfo(dbStatusInfo);
        runnableList.addAll(dbDataProviderList.get(i).getExecRunnableList());
    }
    if (IS_MULTI_THREAD && !runnableList.isEmpty()) {
        try {
            generator.getThreadPoolManager().execute(runnableList, true);
        } catch (ThreadCountOutOfBoundsException e) {
            LOGGER.error("", e);
        }
        join(runnableList, 20);
    } else {
        execute(runnableList);
    }
}
Also used : ArrayList(java.util.ArrayList) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GetDbModeTask(com.cubrid.cubridmanager.core.mondashboard.task.GetDbModeTask) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) ThreadCountOutOfBoundsException(com.cubrid.common.ui.spi.thread.ThreadCountOutOfBoundsException) HostStatData(com.cubrid.cubridmanager.core.monitoring.model.HostStatData) HADatabaseStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)

Aggregations

BrokerDiagData (com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData)13 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)5 ShowSetting (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting)5 Map (java.util.Map)5 TreeMap (java.util.TreeMap)5 Composite (org.eclipse.swt.widgets.Composite)5 ChartCompositePart (com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart)4 GridData (org.eclipse.swt.layout.GridData)4 GridLayout (org.eclipse.swt.layout.GridLayout)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)3 ArrayList (java.util.ArrayList)3 IPath (org.eclipse.core.runtime.IPath)3 XYPlot (org.jfree.chart.plot.XYPlot)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)2 List (java.util.List)2 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 Group (org.eclipse.swt.widgets.Group)2 Label (org.eclipse.swt.widgets.Label)2 JFreeChart (org.jfree.chart.JFreeChart)2 DateAxis (org.jfree.chart.axis.DateAxis)2