Search in sources :

Example 1 with BrokerDiagEnum

use of com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagEnum 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 2 with BrokerDiagEnum

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

the class HostDashboardViewPart method init.

/**
	 * Initializes
	 *
	 * @param hostNode The HostNode
	 */
public void init(HostNode hostNode) {
    this.hostNode = hostNode;
    String partName = getPartName();
    String postfix = " - " + hostNode.getIp() + ":" + hostNode.getPort();
    if (!partName.endsWith(postfix)) {
        setPartName(partName + postfix);
    }
    ServerInfo serverInfo = hostNode.getServerInfo();
    ServerType serverType = null;
    if (serverInfo != null) {
        serverType = serverInfo.getServerType();
    }
    if (serverType != ServerType.DATABASE && brokerChartPart == null) {
        loadBrokerChart(chartComp);
        chartComp.layout();
        composite.layout();
    }
    if (serverInfo != null) {
        String hostAddress = serverInfo.getHostAddress();
        int monPort = serverInfo.getHostMonPort();
        historyFileName = HistoryComposite.HOSTDASHBOARD_HISTORY_FILE_PREFIX + hostAddress + "_" + monPort + HistoryComposite.HISTORY_SUFFIX;
        IPath histPath = CubridManagerCorePlugin.getDefault().getStateLocation();
        historyPath = histPath.toOSString() + File.separator + historyFileName;
        historyFileHelp = new HistoryFileHelp();
        historyFileHelp.setHistoryPath(historyPath);
        isNewBrokerDiag = CompatibleUtil.isNewBrokerDiag(serverInfo);
    }
    List<String> typeLst = new ArrayList<String>();
    for (HostStatEnum hostEnum : HostStatEnum.values()) {
        typeLst.add(hostEnum.getName());
    }
    for (BrokerDiagEnum brokerEnum : BrokerDiagEnum.values()) {
        typeLst.add(brokerEnum.getName());
    }
    typeNames = typeLst.toArray(new String[typeLst.size()]);
    DataGeneratorPool pool = DataGeneratorPool.getInstance();
    String generatorName = hostNode.getUserName() + "@" + hostNode.getIp() + ":" + hostNode.getPort();
    generator = pool.getDataGenerator(generatorName, new DataProvider());
    generator.addDataUpdateListener(this);
}
Also used : DataProvider(com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataProvider) ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) HostStatEnum(com.cubrid.cubridmanager.core.monitoring.model.HostStatEnum) IPath(org.eclipse.core.runtime.IPath) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) DataGeneratorPool(com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataGeneratorPool) BrokerDiagEnum(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagEnum)

Aggregations

ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 BrokerDiagEnum (com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagEnum)2 ArrayList (java.util.ArrayList)2 IPath (org.eclipse.core.runtime.IPath)2 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)1 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)1 BrokerDiagData (com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData)1 HostStatEnum (com.cubrid.cubridmanager.core.monitoring.model.HostStatEnum)1 DataGeneratorPool (com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataGeneratorPool)1 DataProvider (com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataProvider)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 Calendar (java.util.Calendar)1 List (java.util.List)1 Map (java.util.Map)1 TreeMap (java.util.TreeMap)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1