Search in sources :

Example 1 with DatabaseDashboardViewPart

use of com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart in project cubrid-manager by CUBRID.

the class DataProvider method setDefaultValue.

/**
	 * 
	 * Set the default value
	 * 
	 */
private void setDefaultValue() {
    boolean isOldExecuteHostStatTask = isExecuteHostStatTask;
    isExecuteHostStatTask = false;
    isExecuteHeartbeatTask = false;
    isExecuteBrokerStatTask = false;
    isExecuteDbModeTask = false;
    errorMsg = "";
    getHeartbeatNodeInfoTask = null;
    hostNodeList.clear();
    connectedHostNode = null;
    uniqueDbNodeList.clear();
    uniqueBrokerNodeList.clear();
    List<DataUpdateListener> listenerList = generator.getListeners();
    for (DataUpdateListener listener : listenerList) {
        addHaNode(listener.getModel());
    }
    if (connectedHostNode == null && !hostNodeList.isEmpty()) {
        connectedHostNode = hostNodeList.get(0);
    }
    if (connectedHostNode == null) {
        return;
    }
    filterDatabaseDataProvider();
    if (!uniqueBrokerNodeList.isEmpty()) {
        brokerDataProvider.setDataGenerator(generator);
        brokerDataProvider.setBrokerNodeList(uniqueBrokerNodeList);
    }
    //Connect host and set time out
    if (!connectedHostNode.isConnected() && !connectedHostNode.isConnecting()) {
        for (final HostNode hostNode : hostNodeList) {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    hostNode.setConnected(false);
                }
            });
        }
        ConnectionManager.connectHost(connectedHostNode, true, !isFirstConnected);
    }
    final boolean isCanConnected = connectedHostNode.isConnected();
    for (final HostNode hostNode : hostNodeList) {
        if (hostNode != connectedHostNode) {
            Display.getDefault().syncExec(new Runnable() {

                public void run() {
                    hostNode.setConnected(isCanConnected);
                    hostNode.setErrorMsg(connectedHostNode.getLastErrorMsg());
                }
            });
        }
    }
    if (isCanConnected) {
        isFirstConnected = true;
        serverInfo = connectedHostNode.getServerInfo();
        if (serverInfo != null) {
            MonitoringTask monitoringTask = serverInfo.getMonitoringTask();
            monitoringTask.setTimeout(DataProvider.TIME_OUT_MILL);
        }
    } else {
        isFirstConnected = false;
    }
    for (DataUpdateListener listener : listenerList) {
        if (listener instanceof HostMonitorPartHelper) {
            isExecuteHostStatTask = isCanConnected;
            isExecuteHeartbeatTask = isCanConnected;
        } else if (listener instanceof DatabaseMonitorPartHelper) {
            isExecuteHostStatTask = isCanConnected;
            isExecuteHeartbeatTask = isCanConnected;
            isExecuteDbModeTask = isCanConnected;
        } else if (listener instanceof HostDashboardViewPart) {
            isExecuteHostStatTask = isCanConnected;
            isExecuteBrokerStatTask = isCanConnected;
        } else if (listener instanceof DatabaseDashboardViewPart) {
            isExecuteHostStatTask = isCanConnected;
            isExecuteHeartbeatTask = isCanConnected;
            isExecuteDbModeTask = isCanConnected;
        }
    }
    ServerType serverType = serverInfo == null ? null : serverInfo.getServerType();
    isExecuteBrokerStatTask = isExecuteBrokerStatTask && (serverType == ServerType.BOTH || serverType == ServerType.BROKER);
    if (isOldExecuteHostStatTask != isExecuteHostStatTask) {
        hostStatRequestCount = 0;
    }
}
Also used : HostMonitorPartHelper(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.HostMonitorPartHelper) ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) DatabaseMonitorPartHelper(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.DatabaseMonitorPartHelper) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) HostDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.HostDashboardViewPart) DatabaseDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart)

Example 2 with DatabaseDashboardViewPart

use of com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart in project cubrid-manager by CUBRID.

the class DatabaseDataProvider method setDefaultValue.

/**
	 * 
	 * Set default value
	 * 
	 */
private void setDefaultValue() {
    boolean isOldExecuteStandbyStaTask = isExecuteStandbyStaTask;
    boolean isOldExecuteDbProcessTask = isExecuteDbProcessTask;
    isExecuteStandbyStaTask = false;
    isExecuteDbDumpTask = false;
    isExecuteDbProcessTask = false;
    errorMsg = "";
    DBStatusType statusType = dbStatusInfo == null ? DBStatusType.UNKNOWN : dbStatusInfo.getStatusType();
    boolean isDatabaseStarted = DBStatusType.isDbStarted(statusType);
    HostNode hostNode = dbNode.getParent();
    if (hostNode != null && hostNode.isConnected()) {
        List<DataUpdateListener> listenerList = generator.getListeners();
        for (DataUpdateListener listener : listenerList) {
            HANode node = listener.getModel();
            if (!dbNode.equals(node)) {
                continue;
            }
            if (listener instanceof DatabaseMonitorPartHelper || listener instanceof DatabaseDashboardViewPart) {
                isExecuteDbProcessTask = isDatabaseStarted;
                isExecuteStandbyStaTask = statusType == DBStatusType.STANDBY || statusType == DBStatusType.MAINTENANCE;
            }
            if (listener instanceof DatabaseDashboardViewPart) {
                isExecuteDbDumpTask = isDatabaseStarted;
            }
        }
    }
    if (isOldExecuteStandbyStaTask != isExecuteStandbyStaTask) {
        standyServerStatRequestCount = 0;
    }
    if (isOldExecuteDbProcessTask != isExecuteDbProcessTask) {
        dbProcRequestCount = 0;
    }
}
Also used : DatabaseMonitorPartHelper(com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.DatabaseMonitorPartHelper) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) DBStatusType(com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType) HANode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode) DatabaseDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart)

Example 3 with DatabaseDashboardViewPart

use of com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart in project cubrid-manager by CUBRID.

the class DatabaseMonitorPart method performRequest.

/**
	 * @see org.eclipse.gef.editparts.AbstractEditPart#performRequest(org.eclipse.gef.Request)
	 * @param req Request
	 */
public void performRequest(Request req) {
    if (req.getType() == RequestConstants.REQ_OPEN) {
        DatabaseNode databaseNode = (DatabaseNode) getModel();
        if (!databaseNode.isConnected()) {
            return;
        }
        IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
        if (window == null) {
            return;
        }
        IWorkbenchPage page = window.getActivePage();
        if (page == null) {
            return;
        }
        HostNode hn = databaseNode.getParent();
        String secondaryId = new StringBuffer(databaseNode.getDbName()).append("&").append(hn.getUserName()).append("&").append(hn.getIp()).append("&").append(hn.getPort()).toString();
        IViewReference viewReference = page.findViewReference(DatabaseDashboardViewPart.ID, secondaryId);
        if (viewReference == null) {
            try {
                IViewPart viewPart = page.showView(DatabaseDashboardViewPart.ID, secondaryId, IWorkbenchPage.VIEW_ACTIVATE);
                ((DatabaseDashboardViewPart) viewPart).init(databaseNode);
            } catch (PartInitException ex) {
                viewReference = null;
            }
        } else {
            IViewPart viewPart = viewReference.getView(false);
            window.getActivePage().bringToTop(viewPart);
            ((DatabaseDashboardViewPart) viewPart).init(databaseNode);
        }
    }
}
Also used : IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IViewPart(org.eclipse.ui.IViewPart) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) IViewReference(org.eclipse.ui.IViewReference) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) PartInitException(org.eclipse.ui.PartInitException) DatabaseDashboardViewPart(com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart)

Aggregations

DatabaseDashboardViewPart (com.cubrid.cubridmanager.ui.mondashboard.editor.DatabaseDashboardViewPart)3 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)3 DatabaseMonitorPartHelper (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.DatabaseMonitorPartHelper)2 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)1 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)1 DBStatusType (com.cubrid.cubridmanager.core.mondashboard.model.DBStatusType)1 HostDashboardViewPart (com.cubrid.cubridmanager.ui.mondashboard.editor.HostDashboardViewPart)1 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)1 HANode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HANode)1 HostMonitorPartHelper (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.helper.HostMonitorPartHelper)1 IViewPart (org.eclipse.ui.IViewPart)1 IViewReference (org.eclipse.ui.IViewReference)1 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)1 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)1 PartInitException (org.eclipse.ui.PartInitException)1