Search in sources :

Example 26 with HostNode

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

the class ConnectionManager method connectDatabaseInJob.

/**
	 * 
	 * Connect database
	 * 
	 * @param dbNode The DatabaseNode
	 */
public static void connectDatabaseInJob(DatabaseNode dbNode) {
    HostNode hostNode = dbNode.getParent();
    if (hostNode.isConnecting() || dbNode.isConnecting() || dbNode.isConnected()) {
        return;
    }
    ServerInfo serverInfo = hostNode.getServerInfo();
    if (serverInfo == null) {
        serverInfo = new ServerInfo();
        serverInfo.setServerName(hostNode.getIp());
        serverInfo.setHostAddress(hostNode.getIp());
        serverInfo.setHostMonPort(Integer.parseInt(hostNode.getPort()));
        serverInfo.setHostJSPort(Integer.parseInt(hostNode.getPort()) + 1);
        serverInfo.setUserName(hostNode.getUserName());
        serverInfo.setUserPassword(hostNode.getPassword());
        serverInfo.setJdbcDriverVersion(ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION);
    }
    TaskJob job = new TaskJob(Messages.bind(Messages.jobConnectDatabase, dbNode.getDbName()));
    if (!hostNode.isConnected()) {
        hostNode.setConnecting(true);
        ConnectHostJobExecutor connectHostJobExecutor = new ConnectHostJobExecutor(hostNode, serverInfo, false);
        job.addTaskJobExecutor(connectHostJobExecutor);
    }
    dbNode.setConnecting(true);
    ConnectDatabaseNodeJobExecutor dbJobExecutor = new ConnectDatabaseNodeJobExecutor(dbNode, serverInfo);
    job.addTaskJobExecutor(dbJobExecutor);
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverInfo.getServerName());
    jobFamily.setDbName(dbNode.getDbName());
    job.setJobFamily(jobFamily);
    job.setPriority(Job.SHORT);
    job.setUser(false);
    job.schedule();
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) TaskJob(com.cubrid.common.ui.spi.progress.TaskJob)

Example 27 with HostNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode 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 28 with HostNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode 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 29 with HostNode

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

the class DeleteBrokerMonitorCommand method execute.

/**
	 * remove current broker node from dashboard
	 */
public void execute() {
    if (null == nodeToDelete || null == nodeToDelete.getParent()) {
        return;
    }
    boolean isDelete = CommonUITool.openConfirmBox(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), Messages.bind(Messages.msgConfirmDeleteBroker, nodeToDelete.getBrokerName()));
    if (!isDelete) {
        return;
    }
    HostNode parent = nodeToDelete.getParent();
    parent.removeBrokerNode(nodeToDelete);
    dashboard.refresh();
}
Also used : HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)

Example 30 with HostNode

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

the class DataGenerator method removeDataUpdateListener.

/**
	 * 
	 * remove a instance of DataUpdateListener to make it can be update
	 * 
	 * @param listener an instance of DataUpdateListener
	 */
public void removeDataUpdateListener(DataUpdateListener listener) {
    synchronized (listeners) {
        listeners.remove(listener);
        if (listeners.isEmpty()) {
            setRunflag(false);
            HostNode hostNode = null;
            if (listener.getModel() instanceof HostNode) {
                hostNode = (HostNode) listener.getModel();
            } else if (listener.getModel() instanceof DatabaseNode) {
                hostNode = ((DatabaseNode) listener.getModel()).getParent();
            } else if (listener.getModel() instanceof BrokerNode) {
                hostNode = ((BrokerNode) listener.getModel()).getParent();
            }
            if (hostNode != null) {
                hostNode.setConnecting(false);
            }
            getThreadPoolManager().disposeAll();
            DataGeneratorPool pool = DataGeneratorPool.getInstance();
            pool.removeDataGenerator(getName());
        }
    }
}
Also used : BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) HostNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)

Aggregations

HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)57 DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)20 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)12 HostMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.HostMonitorPart)10 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)9 Dashboard (com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 ArrayList (java.util.ArrayList)6 Point (org.eclipse.draw2d.geometry.Point)6 CMWizardDialog (com.cubrid.common.ui.spi.dialog.CMWizardDialog)4 AddHostAndDbWizard (com.cubrid.cubridmanager.ui.mondashboard.dialog.wizard.AddHostAndDbWizard)4 DataProvider (com.cubrid.cubridmanager.ui.mondashboard.editor.dispatcher.DataProvider)4 IViewPart (org.eclipse.ui.IViewPart)4 IViewReference (org.eclipse.ui.IViewReference)4 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 PartInitException (org.eclipse.ui.PartInitException)4 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)3 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)3 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)3