Search in sources :

Example 21 with DatabaseNode

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

the class ConnectionManager method connectHostInJob.

/**
	 * 
	 * Connect Host
	 * 
	 * @param hostNode The HostNode
	 * @param isConnectChild The boolean
	 * @param isPing The boolean
	 */
public static void connectHostInJob(HostNode hostNode, boolean isConnectChild, boolean isPing) {
    if (hostNode.isConnected() || hostNode.isConnecting()) {
        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.jobConnectHost, serverInfo.getHostAddress()));
    hostNode.setConnecting(true);
    ConnectHostJobExecutor executor = new ConnectHostJobExecutor(hostNode, serverInfo, isPing);
    job.addTaskJobExecutor(executor);
    if (isConnectChild) {
        List<DatabaseNode> dbNodeList = hostNode.getDbNodeList();
        for (DatabaseNode dbNode : dbNodeList) {
            if (dbNode.isConnecting() || dbNode.isConnected()) {
                continue;
            }
            dbNode.setConnecting(true);
            ConnectDatabaseNodeJobExecutor dbJobExecutor = new ConnectDatabaseNodeJobExecutor(dbNode, serverInfo);
            job.addTaskJobExecutor(dbJobExecutor);
        }
    }
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverInfo.getServerName());
    jobFamily.setDbName(JobFamily.ALL_DB);
    job.setJobFamily(jobFamily);
    job.setPriority(Job.SHORT);
    job.setUser(false);
    job.schedule();
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) TaskJob(com.cubrid.common.ui.spi.progress.TaskJob)

Example 22 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode 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)

Example 23 with DatabaseNode

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

the class DataProvider method filterDatabaseDataProvider.

/**
	 * 
	 * Filter the database provider
	 * 
	 */
private void filterDatabaseDataProvider() {
    //delete the unused DatabaseDataProvider
    List<DatabaseDataProvider> providerList = new ArrayList<DatabaseDataProvider>();
    providerList.addAll(dbDataProviderList);
    for (DatabaseDataProvider dbDataProvider : providerList) {
        DatabaseNode node = dbDataProvider.getDatabaseNode();
        boolean isNodeExist = false;
        for (DatabaseNode dbNode : uniqueDbNodeList) {
            if (node.equals(dbNode)) {
                isNodeExist = true;
                break;
            }
        }
        if (!isNodeExist) {
            dbDataProviderList.remove(dbDataProvider);
        }
    }
    //add the DatabaseDataProvider
    for (DatabaseNode dbNode : uniqueDbNodeList) {
        boolean isHaveProvider = false;
        for (DatabaseDataProvider dbDataProvider : dbDataProviderList) {
            DatabaseNode databaseNode = dbDataProvider.getDatabaseNode();
            if (dbNode.equals(databaseNode)) {
                isHaveProvider = true;
                break;
            }
        }
        if (!isHaveProvider) {
            IDataProvider dbDataProvider = new DatabaseDataProvider(dbNode);
            dbDataProvider.setDataGenerator(generator);
            dbDataProviderList.add((DatabaseDataProvider) dbDataProvider);
        }
    }
}
Also used : DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) ArrayList(java.util.ArrayList)

Example 24 with DatabaseNode

use of com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode 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)

Example 25 with DatabaseNode

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

the class BrokerDBListMonitorPart method refreshVisuals.

/**
	 * Refreshes this EditPart's <i>visuals</i>. This method is called by
	 * {@link #refresh()}, and may also be called in response to notifications
	 * from the model.
	 */
protected void refreshVisuals() {
    BrokerDBListFigure figure = (BrokerDBListFigure) this.getFigure();
    BrokerDBListNode dn = (BrokerDBListNode) this.getModel();
    figure.setName(dn.getName());
    //Remove defined dabatases.
    List<String> dbList = new ArrayList<String>();
    dbList.addAll(dn.getDbList());
    Dashboard dashboard = (Dashboard) getParent().getModel();
    for (DatabaseNode dbNode : dashboard.getAllDatabaseNode()) {
        String dbName = dbNode.getDbName() + "@" + dbNode.getParent().getIp();
        if (dn.getDbList().contains(dbName)) {
            dbList.remove(dbName);
        }
    }
    figure.setDBList(dbList);
    BrokerNode broker = dn.getBrokerNode();
    figure.setHostConnected(broker.getParent().isConnected());
    super.refreshVisuals();
}
Also used : BrokerDBListFigure(com.cubrid.cubridmanager.ui.mondashboard.editor.figure.BrokerDBListFigure) BrokerNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode) DatabaseNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode) BrokerDBListNode(com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode) ArrayList(java.util.ArrayList) Dashboard(com.cubrid.cubridmanager.ui.mondashboard.editor.model.Dashboard)

Aggregations

DatabaseNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.DatabaseNode)36 HostNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.HostNode)20 BrokerNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerNode)14 DatabaseMonitorPart (com.cubrid.cubridmanager.ui.mondashboard.editor.parts.DatabaseMonitorPart)11 ArrayList (java.util.ArrayList)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)6 HADatabaseStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HADatabaseStatusInfo)5 HAHostStatusInfo (com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Point (org.eclipse.draw2d.geometry.Point)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 GridData (org.eclipse.swt.layout.GridData)4 RowLayout (org.eclipse.swt.layout.RowLayout)4 Button (org.eclipse.swt.widgets.Button)4 Composite (org.eclipse.swt.widgets.Composite)4 Label (org.eclipse.swt.widgets.Label)4 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)3 BrokerDBListNode (com.cubrid.cubridmanager.ui.mondashboard.editor.model.BrokerDBListNode)3