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 BrokerEnvStatusView method refresh.
/**
* Refreshes this view
*
* @param isUpdateTable whether update table
* @param isRefreshChanged whether refresh changed
*
*/
public void refresh(boolean isUpdateTable, boolean isRefreshChanged) {
ServerInfo site = cubridNode.getServer().getServerInfo();
BrokerInfos brokerInfos = new BrokerInfos();
final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(site, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
task.execute();
brokerInfos = task.getResultModel();
List<BrokerInfo> newBrokerInfoList = null;
if (null != brokerInfos) {
BrokerInfoList list = brokerInfos.getBorkerInfoList();
if (list != null && list.getBrokerInfoList() != null) {
newBrokerInfoList = list.getBrokerInfoList();
}
}
List<BrokerInfo> changedBrokerInfoList = new ArrayList<BrokerInfo>();
for (int i = 0; newBrokerInfoList != null && i < newBrokerInfoList.size(); i++) {
BrokerInfo newBrokerInfo = newBrokerInfoList.get(i);
BrokerInfo changedBrokerInfo = newBrokerInfo.clone();
for (int j = 0; oldBrokerInfoList != null && j < oldBrokerInfoList.size(); j++) {
BrokerInfo oldBrokerInfo = oldBrokerInfoList.get(j);
if (newBrokerInfo.getName().equalsIgnoreCase(oldBrokerInfo.getName())) {
// FIXME more simple
long newTran = StringUtil.intValue(newBrokerInfo.getTran());
long newQuery = StringUtil.intValue(newBrokerInfo.getQuery());
long newLongTran = StringUtil.longValue(newBrokerInfo.getLong_tran());
long newLongQuery = StringUtil.longValue(newBrokerInfo.getLong_query());
long newErrQuery = StringUtil.intValue(newBrokerInfo.getError_query());
long oldTran = StringUtil.intValue(oldBrokerInfo.getTran());
long oldQuery = StringUtil.intValue(oldBrokerInfo.getQuery());
long oldLongTran = StringUtil.longValue(oldBrokerInfo.getLong_tran());
long oldLongQuery = StringUtil.longValue(oldBrokerInfo.getLong_query());
long oldErrQuery = StringUtil.intValue(oldBrokerInfo.getError_query());
long changedTran = newTran - oldTran;
long changedQuery = newQuery - oldQuery;
long changedLongTran = newLongTran - oldLongTran;
long changedLongQuery = newLongQuery - oldLongQuery;
long changedErrQuery = newErrQuery - oldErrQuery;
changedBrokerInfo.setTran(String.valueOf(changedTran > 0 ? changedTran : 0));
changedBrokerInfo.setQuery(String.valueOf(changedQuery > 0 ? changedQuery : 0));
changedBrokerInfo.setLong_tran(String.valueOf(changedLongTran > 0 ? changedLongTran : 0));
changedBrokerInfo.setLong_query(String.valueOf(changedLongQuery > 0 ? changedLongQuery : 0));
changedBrokerInfo.setError_query(String.valueOf(changedErrQuery > 0 ? changedErrQuery : 0));
break;
}
}
changedBrokerInfoList.add(changedBrokerInfo);
}
oldBrokerInfoList = newBrokerInfoList;
if (isUpdateTable) {
if (isRefreshChanged) {
tableViewer.setInput(changedBrokerInfoList);
} else {
tableViewer.setInput(oldBrokerInfoList);
}
tableViewer.refresh();
}
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class LockInfoDialog method loadData.
/**
* load the init data from the server
*
* @param shell the shell
* @return <code>true</code> if load successfully;<code>false</code>
* otherwise
*/
public boolean loadData(Shell shell) {
CommonQueryTask<DatabaseLockInfo> task = new CommonQueryTask<DatabaseLockInfo>(database.getServer().getServerInfo(), CommonSendMsg.getCommonDatabaseSendMsg(), new DatabaseLockInfo());
task.setDbName(database.getName());
execTask(-1, new SocketTask[] { task }, true, shell);
if (task.getErrorMsg() != null) {
return false;
}
setDatabaseLockInfo(task.getResultModel());
return true;
}
use of com.cubrid.cubridmanager.core.common.task.CommonQueryTask in project cubrid-manager by CUBRID.
the class KillTransactionDialog method killTransaction.
/**
*
* Kill the transaction
*
* @param type the transaction type
* @param parameter the parameter
*/
private void killTransaction(KillTranType type, String parameter) {
CommonQueryTask<KillTransactionList> task = new CommonQueryTask<KillTransactionList>(database.getServer().getServerInfo(), CommonSendMsg.getKillTransactionMSGItems(), new KillTransactionList());
task.setDbName(database.getName());
task.setKillTranType(type);
task.setKillTranParameter(parameter);
executeKillTrans(-1, new SocketTask[] { task }, true, getShell());
if (task.getErrorMsg() != null) {
isSuccess = false;
return;
}
isSuccess = true;
CommonUITool.openInformationBox(parentComp.getShell(), Messages.titleSuccess, Messages.msgKillSuccess);
killTransactionList = task.getResultModel();
}
Aggregations