Search in sources :

Example 6 with DbRunningType

use of com.cubrid.cubridmanager.core.common.model.DbRunningType in project cubrid-manager by CUBRID.

the class DbStatusDumpMonitorViewPart method createPartControl.

/**
	 * Creates the SWT controls for this workbench part.
	 * 
	 * @param parent the parent control
	 * @see IWorkbenchPart
	 */
public void createPartControl(Composite parent) {
    composite = new Composite(parent, SWT.RESIZE);
    composite.setLayout(new FillLayout());
    serverInfo = cubridNode.getServer().getServerInfo();
    List<String> databaseLst = new ArrayList<String>();
    List<DatabaseInfo> databaseInfoLst = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
    for (DatabaseInfo databaseInfo : databaseInfoLst) {
        DbRunningType dbRunningType = databaseInfo.getRunningType();
        if (dbRunningType == DbRunningType.CS) {
            databaseLst.add(databaseInfo.getDbName());
        }
    }
    DbStatDumpData dbStatDumpData = new DbStatDumpData();
    TreeMap<String, String> map = convertMapKey(dbStatDumpData.getDiagStatusResultMap());
    chartPart = new ChartCompositePart(composite, map);
    dbCombo = new DbComboContribution("database", this);
    dbCombo.setDatabaseLst(databaseLst);
    if (databaseLst.isEmpty()) {
        runflag = false;
    } else {
        dbCombo.setSelectedDb(databaseLst.get(0));
    }
    String hostAddress = serverInfo.getHostAddress();
    int monPort = serverInfo.getHostMonPort();
    String dbName = dbCombo.getSelectedDb();
    String historyFileName = HistoryComposite.DB_HISTORY_FILE_PREFIX + dbName + "@" + 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.DATABASE);
        }
        chartPart.setChartTitle(Messages.dbMonitorChartTtl);
        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();
    this.dbName = dbCombo.getSelectedDb();
    new DataGenerator().start();
}
Also used : DbComboContribution(com.cubrid.cubridmanager.ui.monitoring.editor.internal.DbComboContribution) Composite(org.eclipse.swt.widgets.Composite) HistoryComposite(com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite) IPath(org.eclipse.core.runtime.IPath) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) ArrayList(java.util.ArrayList) FillLayout(org.eclipse.swt.layout.FillLayout) ShowSetting(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ShowSetting) ChartCompositePart(com.cubrid.cubridmanager.ui.monitoring.editor.internal.ChartCompositePart) DbRunningType(com.cubrid.cubridmanager.core.common.model.DbRunningType) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 7 with DbRunningType

use of com.cubrid.cubridmanager.core.common.model.DbRunningType in project cubrid-manager by CUBRID.

the class GetAllClassesTaskExecutor method exec.

/**
	 * @see com.cubrid.common.ui.spi.progress.TaskExecutor#exec(org.eclipse.core.runtime.IProgressMonitor)
	 * @param monitor IProgressMonitor
	 * @return boolean
	 */
public boolean exec(final IProgressMonitor monitor) {
    if (monitor.isCanceled()) {
        return false;
    }
    boolean isConnected = false;
    OnOffType status = OnOffType.OFF;
    MonitorDashboardPreference monPref = new MonitorDashboardPreference();
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            MonitoringTask monitoringTask = (MonitoringTask) task;
            monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
            isConnected = true;
        } else if (task instanceof UpdateCMUserTask) {
            UpdateCMUserTask updateCMUserTask = (UpdateCMUserTask) task;
            ServerInfo serverInfo = updateCMUserTask.getServerInfo();
            if (serverInfo != null && serverInfo.isConnected()) {
                List<String> dbNameList = new ArrayList<String>();
                List<String> dbUserList = new ArrayList<String>();
                List<String> dbPasswordList = new ArrayList<String>();
                List<String> dbBrokerPortList = new ArrayList<String>();
                ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
                if (userInfo != null) {
                    List<DatabaseInfo> authDatabaseList = userInfo.getDatabaseInfoList();
                    if (authDatabaseList != null && !authDatabaseList.isEmpty()) {
                        int size = authDatabaseList.size();
                        for (int i = 0; i < size; i++) {
                            DatabaseInfo databaseInfo = authDatabaseList.get(i);
                            dbNameList.add(databaseInfo.getDbName());
                            dbBrokerPortList.add(QueryOptions.getBrokerIp(databaseInfo) + "," + databaseInfo.getBrokerPort());
                            String password = databaseInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
                            if (databaseInfo.getDbName().equalsIgnoreCase(dbName)) {
                                password = dbaPassword;
                                dbUserList.add("dba");
                            } else {
                                dbUserList.add(databaseInfo.getAuthLoginedDbUserInfo().getName());
                            }
                            dbPasswordList.add(password == null ? "" : password);
                        }
                    }
                }
                String[] dbNameArr = new String[dbNameList.size()];
                String[] dbUserArr = new String[dbUserList.size()];
                String[] dbPasswordArr = new String[dbPasswordList.size()];
                String[] dbBrokerPortArr = new String[dbBrokerPortList.size()];
                updateCMUserTask.setDbAuth(dbNameList.toArray(dbNameArr), dbUserList.toArray(dbUserArr), dbPasswordList.toArray(dbPasswordArr), dbBrokerPortList.toArray(dbBrokerPortArr));
                updateCMUserTask.execute();
            }
        } else if (task instanceof GetClassListTask) {
            GetClassListTask getClassListTask = (GetClassListTask) task;
            if (status != OnOffType.OFF) {
                getClassListTask.setDbStatus(status);
            }
            getClassListTask.execute();
            dbClasses = getClassListTask.getDbClassInfo();
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (monitor.isCanceled()) {
            if (isConnected) {
                disConnect();
            }
            return false;
        }
        if (openErrorBox(shell, msg, monitor)) {
            if (isConnected) {
                disConnect();
            }
            return false;
        }
        if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
                DatabaseInfo dbInfo = databaseInfoList.get(i);
                if (dbName.equalsIgnoreCase(dbInfo.getDbName())) {
                    DbRunningType type = dbInfo.getRunningType();
                    if (type == DbRunningType.CS) {
                        status = OnOffType.ON;
                    }
                }
            }
        } else if (task instanceof GetCMUserListTask) {
            ServerInfo serverInfo = ((GetCMUserListTask) task).getServerInfo();
            if (serverInfo != null && serverInfo.isConnected()) {
                GetCMUserListTask getUserInfoTask = (GetCMUserListTask) task;
                List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
                for (int i = 0; serverUserInfoList != null && i < serverUserInfoList.size(); i++) {
                    ServerUserInfo userInfo = serverUserInfoList.get(i);
                    if (userInfo != null && userInfo.getUserName().equals(serverInfo.getUserName())) {
                        serverInfo.setLoginedUserInfo(userInfo);
                        break;
                    }
                }
            }
        }
    }
    if (isConnected) {
        disConnect();
    }
    return true;
}
Also used : MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) OnOffType(com.cubrid.cubridmanager.core.common.model.OnOffType) GetClassListTask(com.cubrid.cubridmanager.core.cubrid.table.task.GetClassListTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ArrayList(java.util.ArrayList) List(java.util.List) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) DbRunningType(com.cubrid.cubridmanager.core.common.model.DbRunningType)

Aggregations

DbRunningType (com.cubrid.cubridmanager.core.common.model.DbRunningType)7 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)7 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)5 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)4 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)4 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)4 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)4 ArrayList (java.util.ArrayList)4 Map (java.util.Map)4 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)3 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)3 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)3 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)3 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)3 HistoryComposite (com.cubrid.cubridmanager.ui.monitoring.editor.internal.HistoryComposite)3 HashMap (java.util.HashMap)3 Composite (org.eclipse.swt.widgets.Composite)3 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2