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;
}
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;
}
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;
}
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;
}
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;
}
}
Aggregations