use of com.cubrid.cubridmanager.core.common.model.EnvInfo 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.model.EnvInfo in project cubrid-manager by CUBRID.
the class VolumeSizeValidator method initial.
private void initial() {
volumeTypeCombo.setItems(VOLUME_TYPES);
volumeTypeCombo.select(0);
EnvInfo envInfo = server.getServerInfo().getEnvInfo();
if (envInfo != null) {
databasePath = envInfo.getDatabaseDir();
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo != null) {
databasePath = FileUtil.changeSeparatorByOS(databasePath, serverInfo.getServerOsInfo());
}
}
volumeNameText.addModifyListener(this);
volumePathText.addModifyListener(this);
}
use of com.cubrid.cubridmanager.core.common.model.EnvInfo in project cubrid-manager by CUBRID.
the class RenameDatabaseDialog method initial.
/**
*
* Initial data
*
*/
private void initial() {
EnvInfo envInfo = database.getServer().getServerInfo().getEnvInfo();
if (envInfo != null) {
extVolumePath = envInfo.getDatabaseDir();
extVolumePath = FileUtil.changeSeparatorByOS(extVolumePath, database.getServer().getServerInfo().getServerOsInfo());
exVolumePathText.setText(extVolumePath);
}
String dir = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_EXTENDED_VOLUME_PATH + database.getId());
if (dir != null && dir.trim().length() > 0) {
extVolumePath = dir;
exVolumePathText.setText(extVolumePath);
}
if (spaceInfoList == null) {
spaceInfoList = new ArrayList<Map<String, String>>();
if (this.dbSpaceInfoList != null) {
List<DbSpaceInfo> list = this.dbSpaceInfoList.getSpaceinfo();
for (int i = 0; list != null && i < list.size(); i++) {
Map<String, String> map = new HashMap<String, String>();
DbSpaceInfo spaceInfo = list.get(i);
String type = spaceInfo.getType();
if (!VolumeType.GENERIC.getText().equals(type) && !VolumeType.DATA.getText().equals(type) && !VolumeType.INDEX.getText().equals(type) && !VolumeType.TEMP.getText().equals(type)) {
continue;
}
map.put("0", spaceInfo.getSpacename());
map.put("1", spaceInfo.getSpacename());
String location = spaceInfo.getLocation();
location = FileUtil.changeSeparatorByOS(location, database.getServer().getServerInfo().getServerOsInfo());
map.put("2", location);
map.put("3", location);
spaceInfoList.add(map);
}
}
}
volumeTableViewer.setInput(spaceInfoList);
for (int i = 0; i < volumeTable.getColumnCount(); i++) {
volumeTable.getColumn(i).pack();
}
databaseNameText.addModifyListener(this);
exVolumePathText.addModifyListener(this);
}
use of com.cubrid.cubridmanager.core.common.model.EnvInfo in project cubrid-manager by CUBRID.
the class GetHeartbeatNodeInfoTaskTest method testSend.
public void testSend() throws Exception {
if (StringUtil.isEqual(SystemParameter.getParameterValue("useMockTest"), "y"))
return;
String filepath = this.getFilePathInPlugin("/com/cubrid/cubridmanager/core/mondashboard/task/test.message/GetHeartbeatNodeInfoTask_send");
String msg = Tool.getFileContent(filepath);
//replace "token" field with the latest value
msg = msg.replaceFirst("token:.*\n", "token:" + token + "\n");
//composite message
GetHeartbeatNodeInfoTask task = new GetHeartbeatNodeInfoTask(serverInfo);
task.setAllDb(false);
List<String> dbList = new ArrayList<String>();
dbList.add("demodb");
dbList.add("tb1");
task.setDbList(dbList);
//compare
assertEquals(msg, task.getRequest());
//test special case1
ServerInfo server = new ServerInfo();
server.setConnected(true);
EnvInfo envInfo = new EnvInfo();
envInfo.setServerVersion("CUBRID 2008 R2.0(8.2.0.1150)");
envInfo.setOsInfo("NT");
server.setEnvInfo(envInfo);
task = new GetHeartbeatNodeInfoTask(server);
task.execute();
//test special case2
envInfo.setServerVersion("CUBRID 2008 R2.0(8.3.1.1150)");
task.execute();
}
use of com.cubrid.cubridmanager.core.common.model.EnvInfo in project cubrid-manager by CUBRID.
the class GeneralInfoPage method initial.
private void initial() {
String[] pageSizeItem = CompatibleUtil.getSupportedPageSize(server.getServerInfo());
pageSizeCombo.setItems(pageSizeItem);
pageSizeCombo.setText(CompatibleUtil.getDefaultPageSize(server.getServerInfo()));
if (logPageSizeCombo != null) {
logPageSizeCombo.setItems(pageSizeItem);
logPageSizeCombo.setText(CompatibleUtil.getDefaultPageSize(server.getServerInfo()));
}
/*if (charsetCombo != null) {
charsetCombo.setItems(charsetItem);
charsetCombo.setText(DEFAULT);
}*/
EnvInfo envInfo = server.getServerInfo().getEnvInfo();
if (envInfo != null) {
databasePath = envInfo.getDatabaseDir();
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo != null) {
databasePath = FileUtil.changeSeparatorByOS(databasePath, serverInfo.getServerOsInfo());
}
genericVolumePathText.setText(databasePath);
logVolumePathText.setText(databasePath);
}
genericVolumeSizeText.setText(ConfConstants.DEFAULT_DATA_VOLUME_SIZE);
defaultDatVolumeSize = ConfConstants.DEFAULT_DATA_VOLUME_SIZE;
/*If Configed Generic Volume Size is not null*/
String genericVolumeSize = CompatibleUtil.getConfigGenericVolumeSize(server.getServerInfo(), null);
if (!StringUtil.isEmpty(genericVolumeSize)) {
Long bytes = StringUtil.getByteNumber(genericVolumeSize);
if (bytes > -1) {
double value = StringUtil.convertToM(bytes);
String strValue = getIntSizeString(value, 20);
genericVolumeSizeText.setText(strValue);
defaultDatVolumeSize = strValue;
}
}
logVolumeSizeText.setText(ConfConstants.DEFAULT_DATA_VOLUME_SIZE);
/*If Config Log Volume Size is not null*/
String logValueSize = CompatibleUtil.getConfigLogVolumeSize(server.getServerInfo(), null);
if (!StringUtil.isEmpty(logValueSize)) {
Long bytes = StringUtil.getByteNumber(logValueSize);
if (bytes > -1) {
double value = StringUtil.convertToM(bytes);
logVolumeSizeText.setText(getIntSizeString(value, 20));
}
}
databaseNameText.addModifyListener(this);
genericVolumePathText.addModifyListener(this);
logVolumePathText.addModifyListener(this);
}
Aggregations