Search in sources :

Example 26 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class ConnectHostJobExecutor method exec.

/**
	 * Execute to connect host
	 * 
	 * @param monitor the IProgressMonitor
	 * @return <code>true</code> if successful;<code>false</code>otherwise;
	 */
@SuppressWarnings("unchecked")
public IStatus exec(final IProgressMonitor monitor) {
    monitor.subTask(Messages.bind(com.cubrid.cubridmanager.ui.mondashboard.Messages.jobConnectHost, serverInfo.getHostAddress()));
    isContinue = true;
    boolean isRunUpdateCmUserTask = false;
    BrokerInfos brokerInfos = null;
    errorMsg = null;
    for (ITask task : taskList) {
        if (task instanceof MonitoringTask) {
            IStatus status = connectHost((MonitoringTask) task);
            if (Status.OK_STATUS != status) {
                return status;
            }
        } else if ((task instanceof UpdateCMUserTask)) {
            updateCMUserAuthInfo(task, isRunUpdateCmUserTask);
        } else if ((task instanceof GetHeartbeatNodeInfoTask) && !CompatibleUtil.isSupportHA(serverInfo)) {
            continue;
        } else {
            task.execute();
        }
        final String msg = task.getErrorMsg();
        if (monitor.isCanceled()) {
            disConnect();
            return Status.CANCEL_STATUS;
        }
        if (!hostNode.isConnecting()) {
            return Status.CANCEL_STATUS;
        }
        if (msg != null && msg.length() > 0) {
            disConnect();
            if (isPing) {
                errorMsg = msg;
                return Status.CANCEL_STATUS;
            }
            return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
        }
        if (task instanceof GetEnvInfoTask) {
            GetEnvInfoTask getEnvInfoTask = (GetEnvInfoTask) task;
            EnvInfo envInfo = getEnvInfoTask.loadEnvInfo();
            serverInfo.setEnvInfo(envInfo);
            String clientVersion = Version.buildVersionId.substring(0, Version.buildVersionId.lastIndexOf("."));
            if (!CompatibleUtil.isSupportCMServer(serverInfo, clientVersion)) {
                disConnect();
                errorMsg = Messages.bind(Messages.errNoSupportServerVersion, clientVersion);
                if (isPing) {
                    return Status.CANCEL_STATUS;
                }
                return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
            }
            if (!serverInfo.validateJdbcVersion(serverInfo.getJdbcDriverVersion())) {
                disConnect();
                if (ServerJdbcVersionMapping.JDBC_SELF_ADAPTING_VERSION.equals(serverInfo.getJdbcDriverVersion())) {
                    errorMsg = Messages.errNoSupportDriver;
                } else {
                    errorMsg = Messages.errSelectSupportDriver;
                }
                if (isPing) {
                    return Status.CANCEL_STATUS;
                }
                return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, errorMsg);
            }
        } else if (task instanceof GetDatabaseListTask) {
            GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
            List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
            if (databaseInfoList != null) {
                allDatabaseInfoList.addAll(databaseInfoList);
            }
        } else if (task instanceof GetCMConfParameterTask) {
            GetCMConfParameterTask getCMConfParameterTask = (GetCMConfParameterTask) task;
            Map<String, String> confParameters = getCMConfParameterTask.getConfParameters();
            ServerType serverType = ServerType.BOTH;
            if (confParameters != null) {
                String target = confParameters.get(ConfConstants.CM_TARGET);
                if (target != null) {
                    if (target.indexOf("broker") >= 0 && target.indexOf("server") >= 0) {
                        serverType = ServerType.BOTH;
                    } else if (target.indexOf("broker") >= 0) {
                        serverType = ServerType.BROKER;
                    } else if (target.indexOf("server") >= 0) {
                        serverType = ServerType.DATABASE;
                    }
                }
            }
            if (serverInfo != null) {
                serverInfo.setServerType(serverType);
            }
        } else if (task instanceof CommonQueryTask) {
            CommonQueryTask<BrokerInfos> getBrokerTask = (CommonQueryTask<BrokerInfos>) task;
            brokerInfos = getBrokerTask.getResultModel();
            if (serverInfo != null) {
                serverInfo.setBrokerInfos(brokerInfos);
            }
        } else if (task instanceof GetCMUserListTask) {
            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;
                    }
                }
                List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
                if (databaseInfoList != null) {
                    authDatabaseList.addAll(databaseInfoList);
                }
                isRunUpdateCmUserTask = CubridDatabasesFolderLoader.filterDatabaseList(serverInfo, allDatabaseInfoList, authDatabaseList);
                if (isRunUpdateCmUserTask) {
                    serverInfo.getLoginedUserInfo().setDatabaseInfoList(authDatabaseList);
                }
            }
        } else if (task instanceof GetCubridConfParameterTask) {
            GetCubridConfParameterTask getCubridConfParameterTask = (GetCubridConfParameterTask) task;
            Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
            if (serverInfo != null) {
                serverInfo.setCubridConfParaMap(confParas);
            }
        } else if (task instanceof GetBrokerConfParameterTask) {
            GetBrokerConfParameterTask getBrokerConfParameterTask = (GetBrokerConfParameterTask) task;
            Map<String, Map<String, String>> confParas = getBrokerConfParameterTask.getConfParameters();
            if (serverInfo != null) {
                serverInfo.setBrokerConfParaMap(confParas);
            }
        } else if (task instanceof GetHeartbeatNodeInfoTask) {
            GetHeartbeatNodeInfoTask getHeartbeatNodeInfoTask = (GetHeartbeatNodeInfoTask) task;
            haHostStatusInfo = getHeartbeatNodeInfoTask.getHostStatusInfo(serverInfo.getHostAddress());
        }
        if (monitor.isCanceled() || !isContinue) {
            disConnect();
            return Status.CANCEL_STATUS;
        }
    }
    return Status.OK_STATUS;
}
Also used : ServerType(com.cubrid.cubridmanager.core.common.model.ServerType) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetHeartbeatNodeInfoTask(com.cubrid.cubridmanager.core.mondashboard.task.GetHeartbeatNodeInfoTask) GetCMConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask) UpdateCMUserTask(com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) ArrayList(java.util.ArrayList) List(java.util.List) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) GetCubridConfParameterTask(com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask) GetEnvInfoTask(com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) GetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask) Map(java.util.Map) EnvInfo(com.cubrid.cubridmanager.core.common.model.EnvInfo)

Example 27 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class DatabaseLogListDialog method postTaskFinished.

/**
	 * After a task has been executed, do some thing such as refresh.
	 * 
	 * @param task the task
	 * @return IStatus if complete refresh false if run into error
	 * 
	 */
@SuppressWarnings("unchecked")
public IStatus postTaskFinished(ITask task) {
    if (task instanceof CommonQueryTask) {
        CommonQueryTask<DbLogInfos> getLogListTask = (CommonQueryTask<DbLogInfos>) task;
        DbLogInfos dbLogInfos = getLogListTask.getResultModel();
        DbLogInfoList dbLogInfoList = dbLogInfos == null ? null : dbLogInfos.getDbLogInfoList();
        List<LogInfo> logInfoList = dbLogInfoList == null ? null : dbLogInfoList.getDbLogInfoList();
        for (int i = 0; logInfoList != null && i < logInfoList.size(); i++) {
            Map<String, Object> map = new HashMap<String, Object>();
            LogInfo logInfo = logInfoList.get(i);
            map.put("0", logInfo.getName());
            map.put("1", logInfo);
            dbLogList.add(map);
        }
        if (dbLogTable != null && !dbLogTable.isDisposed()) {
            dbLogTableViewer.refresh();
            for (int i = 0; i < dbLogTable.getColumnCount(); i++) {
                dbLogTable.getColumn(i).pack();
            }
        }
    }
    return Status.OK_STATUS;
}
Also used : DbLogInfos(com.cubrid.cubridmanager.core.logs.model.DbLogInfos) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) DbLogInfoList(com.cubrid.cubridmanager.core.logs.model.DbLogInfoList) HashMap(java.util.HashMap) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 28 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class BrokerStatusMonitorViewPart method getUpdateValue.

/**
	 * Get update value
	 *
	 * @param startRun int
	 * @return Map<String, String>
	 */
private TreeMap<String, String> getUpdateValue(int startRun) {
    ServerInfo site = cubridNode.getServer().getServerInfo();
    final CommonQueryTask<BrokerDiagData> task = new CommonQueryTask<BrokerDiagData>(site, CommonSendMsg.getGetBrokerStatusItems(), diagStatusResult);
    task.execute();
    TreeMap<String, String> resultMap = null;
    float inter = 0.0f;
    if (startRun == 0) {
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptReq) {
                return convertMapKey(diagStatusResult.getDiagStatusResultMap());
            } else {
                showErrorMsg(diagStatusResult);
            }
        }
        return convertMapKey(diagStatusResult.getDiagStatusResultMap());
    } else if (startRun == 1) {
        lastSec = Calendar.getInstance();
        diagOldOneStatusResult.copyFrom(diagStatusResult);
        BrokerDiagData brokerDiagDataDelta = new BrokerDiagData();
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptReq) {
                return convertMapKey(diagStatusResult.getDiagStatusResultMap());
            } else {
                showErrorMsg(diagStatusResult);
            }
        }
        brokerDiagDataDelta.getDelta(diagStatusResult, diagOldOneStatusResult);
        return convertMapKey(brokerDiagDataDelta.getDiagStatusResultMap());
    } else {
        nowSec = Calendar.getInstance();
        double interval = (double) (nowSec.getTimeInMillis() - lastSec.getTimeInMillis()) / 1000;
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(3);
        inter = Float.parseFloat(nf.format(interval));
        lastSec = nowSec;
        diagOldTwoStatusResult.copyFrom(diagOldOneStatusResult);
        diagOldOneStatusResult.copyFrom(diagStatusResult);
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptReq) {
                return convertMapKey(diagStatusResult.getDiagStatusResultMap());
            } else {
                showErrorMsg(diagStatusResult);
            }
        }
        BrokerDiagData diagStatusResultDelta = new BrokerDiagData();
        diagStatusResultDelta.getDelta(diagStatusResult, diagOldOneStatusResult, diagOldTwoStatusResult, inter);
        resultMap = convertMapKey(diagStatusResultDelta.getDiagStatusResultMap());
    }
    return resultMap;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) BrokerDiagData(com.cubrid.cubridmanager.core.monitoring.model.BrokerDiagData) NumberFormat(java.text.NumberFormat)

Example 29 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class DbStatusDumpMonitorViewPart method getUpdateValue.

/**
	 * Get update value
	 * 
	 * @param startRun int
	 * @return Map<String, String>
	 */
private TreeMap<String, String> getUpdateValue(int startRun) {
    ServerInfo serverInfo = cubridNode.getServer().getServerInfo();
    String dbName = dbCombo.getSelectedDb();
    final CommonQueryTask<DbStatDumpData> task = new CommonQueryTask<DbStatDumpData>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), diagStatusResult);
    task.setDbName(dbName);
    task.execute();
    TreeMap<String, String> resultMap = null;
    float inter = 0.0f;
    if (startRun == 0) {
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptSameDbReq) {
                if (this.dbName == null || this.dbName.equals(dbName)) {
                    return convertMapKey(diagStatusResult.getDiagStatusResultMap());
                } else {
                    interruptSameDbReq = false;
                }
            } else {
                showErrorMsg(diagStatusResult, dbName);
            }
        }
        return convertMapKey(diagStatusResult.getDiagStatusResultMap());
    } else if (startRun == 1) {
        lastSec = Calendar.getInstance();
        diagOldOneStatusResult.copy_from(diagStatusResult);
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptSameDbReq) {
                if (this.dbName == null || this.dbName.equals(dbName)) {
                    return convertMapKey(diagStatusResult.getDiagStatusResultMap());
                } else {
                    interruptSameDbReq = false;
                }
            } else {
                showErrorMsg(diagStatusResult, dbName);
            }
        }
        DbStatDumpData brokerDiagDataDelta = new DbStatDumpData();
        brokerDiagDataDelta.getDelta(diagStatusResult, diagOldOneStatusResult);
        return convertMapKey(brokerDiagDataDelta.getDiagStatusResultMap());
    } else {
        nowSec = Calendar.getInstance();
        double interval = (double) (nowSec.getTimeInMillis() - lastSec.getTimeInMillis()) / 1000;
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(3);
        inter = Float.parseFloat(nf.format(interval));
        lastSec = nowSec;
        diagOldTwoStatusResult.copy_from(diagOldOneStatusResult);
        diagOldOneStatusResult.copy_from(diagStatusResult);
        diagStatusResult = task.getResultModel();
        if (!diagStatusResult.getStatus()) {
            if (interruptSameDbReq) {
                if (this.dbName == null || this.dbName.equals(dbName)) {
                    return convertMapKey(diagStatusResult.getDiagStatusResultMap());
                } else {
                    interruptSameDbReq = false;
                }
            } else {
                showErrorMsg(diagStatusResult, dbName);
            }
        }
        DbStatDumpData diagStatusResultDelta = new DbStatDumpData();
        diagStatusResultDelta.getDelta(diagStatusResult, diagOldOneStatusResult, diagOldTwoStatusResult, inter);
        resultMap = convertMapKey(diagStatusResultDelta.getDiagStatusResultMap());
    }
    return resultMap;
}
Also used : DbStatDumpData(com.cubrid.cubridmanager.core.monitoring.model.DbStatDumpData) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) NumberFormat(java.text.NumberFormat)

Example 30 with CommonQueryTask

use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.

the class EditSingleHostStatisticItemDialog method refreshDbVolData.

//refresh data of itemsVolName and dbVolName
private void refreshDbVolData(String dbName) {
    DbSpaceInfoList dbSpaceInfo = new DbSpaceInfoList();
    CommonQueryTask<DbSpaceInfoList> dbSpaceInfoTask = new CommonQueryTask<DbSpaceInfoList>(serverInfo, CommonSendMsg.getCommonDatabaseSendMsg(), dbSpaceInfo);
    dbSpaceInfoTask.setDbName(dbName);
    dbSpaceInfoTask.execute();
    if (dbSpaceInfoTask.isSuccess()) {
        dbSpaceInfo = dbSpaceInfoTask.getResultModel();
        if (dbSpaceInfo.getSpaceinfo() != null && dbSpaceInfo.getSpaceinfo().size() > 0) {
            List<DbSpaceInfo> spaceInfoList = dbSpaceInfo.getSpaceinfo();
            itemsVolName = new String[spaceInfoList.size()];
            for (int i = 0; i < spaceInfoList.size(); i++) {
                itemsVolName[i] = spaceInfoList.get(i).getSpacename();
            }
            dbVolNameValue = itemsVolName[0];
        } else {
            itemsVolName = ITEMS_EMPTY;
            dbVolNameValue = VALUE_DEFAULT;
        }
    } else {
        itemsVolName = ITEMS_EMPTY;
        dbVolNameValue = VALUE_DEFAULT;
    }
}
Also used : DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) DbSpaceInfo(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfo) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Aggregations

CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)60 DbSpaceInfoList (com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList)19 ITask (com.cubrid.common.core.task.ITask)14 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)12 IStatus (org.eclipse.core.runtime.IStatus)12 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)11 TaskJobExecutor (com.cubrid.common.ui.spi.progress.TaskJobExecutor)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)11 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)8 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)7 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)7 CommonTaskJobExec (com.cubrid.common.ui.spi.progress.CommonTaskJobExec)7 ArrayList (java.util.ArrayList)7 DefaultCubridNode (com.cubrid.common.ui.spi.model.DefaultCubridNode)6 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)6 ITaskExecutorInterceptor (com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor)6 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)6 LogInfo (com.cubrid.cubridmanager.core.logs.model.LogInfo)6 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5