use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.
the class SetHostInfoDialog method connect.
/**
* connect the host
*
* @param buttonId int
*/
private void connect(final int buttonId) {
final String ip = ipText.getText();
final String port = portText.getText();
final String userName = userNameText.getText();
final String password = passwordText.getText();
boolean isConnected = ServerManager.getInstance().isConnected(ip, Integer.parseInt(port), userName);
if (isConnected && hostInfo != null) {
ServerInfo serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(ip, Integer.parseInt(port), userName);
if (!serverInfo.getLoginedUserInfo().isAdmin()) {
CommonUITool.openErrorBox(Messages.bind(Messages.errInvalidUser, ip));
return;
}
hostInfo.setIp(ip);
hostInfo.setPort(port);
hostInfo.setUserName(userName);
hostInfo.setPassword(password);
hostInfo.setName(ip + ":" + port);
List<DatabaseInfo> databaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
hostInfo.setDatabaseInfoList(databaseInfoList);
hostInfo.setDbPath(serverInfo.getEnvInfo().getDatabaseDir());
hostInfo.setOsInfoType(serverInfo.getServerOsInfo());
setReturnCode(buttonId);
close();
return;
}
if (!isConnected) {
final ServerInfo serverInfo = new ServerInfo();
serverInfo.setHostAddress(ip);
serverInfo.setHostMonPort(Integer.parseInt(port));
serverInfo.setHostJSPort(Integer.parseInt(port) + 1);
serverInfo.setUserName(userName);
serverInfo.setUserPassword(password);
TaskExecutor taskExcutor = new ConnectHostTaskExecutor(serverInfo, buttonId);
MonitoringTask monitoringTask = new MonitoringTask(serverInfo);
taskExcutor.addTask(monitoringTask);
GetEnvInfoTask getEnvInfoTask = new GetEnvInfoTask(serverInfo);
taskExcutor.addTask(getEnvInfoTask);
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo);
taskExcutor.addTask(getCMConfParameterTask);
GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
taskExcutor.addTask(getDatabaseListTask);
new ExecTaskWithProgress(taskExcutor).exec(true, true);
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.
the class CubridDatabasesFolderLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
ServerInfo serverInfo = parent.getServer().getServerInfo();
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
final GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo);
monitorCancel(monitor, new ITask[] { getUserInfoTask, getDatabaseListTask });
getUserInfoTask.execute();
final String msg1 = getUserInfoTask.getErrorMsg();
if (!monitor.isCanceled() && msg1 != null && msg1.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(msg1);
setLoaded(true);
return;
}
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
List<ServerUserInfo> serverUserInfoList = getUserInfoTask.getServerUserInfoList();
List<DatabaseInfo> oldDatabaseInfoList = null;
if (serverInfo.getLoginedUserInfo() != null) {
oldDatabaseInfoList = serverInfo.getLoginedUserInfo().getDatabaseInfoList();
}
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;
}
}
getDatabaseListTask.execute();
if (monitor.isCanceled()) {
setLoaded(true);
return;
}
final String msg2 = getDatabaseListTask.getErrorMsg();
if (!monitor.isCanceled() && msg2 != null && msg2.trim().length() > 0) {
parent.removeAllChild();
openErrorBox(msg2);
setLoaded(true);
return;
}
List<DatabaseInfo> newDatabaseInfoList = getDatabaseListTask.loadDatabaseInfo();
List<ICubridNode> oldNodeList = new ArrayList<ICubridNode>();
oldNodeList.addAll(parent.getChildren());
parent.removeAllChild();
//Construct the database folder children
buildDatabasesFolder(parent, monitor, serverInfo, oldDatabaseInfoList, newDatabaseInfoList, oldNodeList);
Collections.sort(parent.getChildren());
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.
the class SetupEnvTestCase method setupDatabaseInfo831.
/**
* * Setup database 8.3.1
*
*/
private void setupDatabaseInfo831() {
/*Setting Cubrid 8.3.1*/
serverInfo831 = new ServerInfo();
serverInfo831.setHostAddress(host831);
serverInfo831.setHostMonPort(monport831);
serverInfo831.setHostJSPort(jpport831);
serverInfo831.setUserName(userName831);
serverInfo831.setUserPassword(passwd831);
serverInfo831.setJdbcDriverVersion(serverVersion831);
ServerManager.getInstance().addServer(host831, monport831, userName831, serverInfo831);
MonitoringTask monTask = new MonitoringTask(serverInfo831);
serverInfo831 = monTask.connectServer(serverVersion831, 1000);
// get the latest token
token831 = serverInfo831.getHostToken();
//get evnInfo
if (envInfo831 == null) {
GetEnvInfoTask envTask = new GetEnvInfoTask(serverInfo831);
envTask.loadEnvInfo();
envTask.execute();
envInfo831 = envTask.loadEnvInfo();
serverInfo831.setEnvInfo(envInfo831);
}
assertNotNull(envInfo831);
serverPath831 = envInfo831.getRootDir();
dbRootDir831 = envInfo831.getDatabaseDir();
//get server type
GetCMConfParameterTask getCMConfParameterTask = new GetCMConfParameterTask(serverInfo831);
getCMConfParameterTask.execute();
assertEquals(null, getCMConfParameterTask.getErrorMsg());
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 (serverInfo831 != null) {
serverInfo831.setServerType(serverType);
}
//Get database list task
if (serverType == ServerType.DATABASE || serverType == ServerType.BOTH) {
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo831);
getDatabaseListTask.execute();
assertEquals(null, getDatabaseListTask.getErrorMsg());
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
for (DatabaseInfo dbInfo : databaseInfoList) {
if (dbInfo.getDbName().equals(testDbName831)) {
databaseInfo831 = dbInfo;
break;
}
}
if (databaseInfo831 == null) {
return;
}
}
//get CubridManager user list task
GetCMUserListTask getUserInfoTask = new GetCMUserListTask(serverInfo831);
getUserInfoTask.execute();
assertEquals(null, getUserInfoTask.getErrorMsg());
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(serverInfo831.getUserName())) {
serverInfo831.setLoginedUserInfo(userInfo);
break;
}
}
List<DatabaseInfo> databaseInfoList = serverInfo831.getLoginedUserInfo().getDatabaseInfoList();
String dbDir = databaseInfo831.getDbDir();
DbRunningType type = databaseInfo831.getRunningType();
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
if (testDbName831.equalsIgnoreCase(databaseInfoList.get(i).getDbName())) {
databaseInfo831 = databaseInfoList.get(i);
databaseInfo831.setDbDir(dbDir);
databaseInfo831.setBrokerIP(host831);
databaseInfo831.setBrokerPort(port831);
databaseInfo831.setCharSet(charset831);
databaseInfo831.setRunningType(type);
break;
}
}
//get CUBRID conf parameter
GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo831);
getCubridConfParameterTask.execute();
assertEquals(null, getCubridConfParameterTask.getErrorMsg());
Map<String, Map<String, String>> confParas = getCubridConfParameterTask.getConfParameters();
if (serverInfo831 != null) {
serverInfo831.setCubridConfParaMap(confParas);
}
//get broker Info
GetBrokerConfParameterTask getBrokerConfParameterTask = new GetBrokerConfParameterTask(serverInfo831);
getBrokerConfParameterTask.execute();
assertEquals(null, getBrokerConfParameterTask.getErrorMsg());
confParas = getBrokerConfParameterTask.getConfParameters();
if (serverInfo831 != null) {
serverInfo831.setBrokerConfParaMap(confParas);
}
//Set JDBC driver
String filePath = this.getFilePathInPlugin("/lib/JDBC-8.3.0.1004-cubrid.jar");
if (filePath != null) {
String version = JdbcClassLoaderFactory.validateJdbcFile(filePath);
if (version != null) {
JdbcClassLoaderFactory.registerClassLoader(filePath);
serverInfo831.setJdbcDriverVersion(version);
}
}
filePath = this.getFilePathInPlugin("/lib/JDBC-8.3.1.0173-cubrid.jar");
if (filePath != null) {
String version = JdbcClassLoaderFactory.validateJdbcFile(filePath);
if (version != null) {
JdbcClassLoaderFactory.registerClassLoader(filePath);
serverInfo831.setJdbcDriverVersion(version);
}
}
}
use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.
the class DBSpaceLabelProvider method loadDbData.
public void loadDbData() {
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
final GetCubridConfParameterTask getCubridConfParameterTask = new GetCubridConfParameterTask(serverInfo);
TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {
public void completeAll() {
databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
List<String> orignAutoStartDBList = getCubridConfParameterTask.getAutoStartDb(false);
setDatabaseData(databaseInfoList, orignAutoStartDBList);
finishedCount++;
updateToolBar();
//after get database data ,load volumn data
loadVolumeData();
}
public IStatus postTaskFinished(ITask task) {
return Status.OK_STATUS;
}
});
taskJobExec.addTask(getDatabaseListTask);
taskJobExec.addTask(getCubridConfParameterTask);
String serverName = serverInfo.getServerName();
String jobName = Messages.taskGetDBInfo + serverName;
JobFamily jobFamily = new JobFamily();
jobFamily.setServerName(serverName);
taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
use of com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask in project cubrid-manager by CUBRID.
the class CubridDatabaseLoader method load.
/**
*
* Load children object for parent
*
* @param parent the parent node
* @param monitor the IProgressMonitor object
*/
public void load(final ICubridNode parent, final IProgressMonitor monitor) {
synchronized (this) {
if (isLoaded()) {
return;
}
CubridDatabase database = (CubridDatabase) parent;
database.getDatabaseInfo().clear();
if (!database.isLogined()) {
parent.removeAllChild();
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
return;
}
//when refresh,firstly check whether this database exist
ServerInfo serverInfo = parent.getServer().getServerInfo();
final GetDatabaseListTask getDatabaseListTask = new GetDatabaseListTask(serverInfo);
ParamDumpTask paramDumpTask = null;
if (CompatibleUtil.isSupportGetParamDump(serverInfo)) {
paramDumpTask = new ParamDumpTask(serverInfo);
paramDumpTask.setDbName(database.getLabel());
paramDumpTask.setBoth(YesNoType.N);
}
monitorCancel(monitor, new ITask[] { getDatabaseListTask, paramDumpTask });
getDatabaseListTask.execute();
if (!checkResult(getDatabaseListTask, monitor)) {
parent.removeAllChild();
return;
}
List<DatabaseInfo> databaseInfoList = getDatabaseListTask.loadDatabaseInfo();
ParamDumpInfo paraDumpInfo = null;
if (paramDumpTask != null) {
paramDumpTask.execute();
if (!checkResult(paramDumpTask, monitor)) {
parent.removeAllChild();
return;
}
paraDumpInfo = paramDumpTask.getContent();
}
String databaseName = database.getLabel();
boolean isExist = false;
for (int i = 0; databaseInfoList != null && i < databaseInfoList.size(); i++) {
DatabaseInfo dbInfo = databaseInfoList.get(i);
if (dbInfo.getDbName().equalsIgnoreCase(databaseName)) {
database.setRunningType(dbInfo.getRunningType());
isExist = true;
}
}
if (!isExist) {
Display display = Display.getDefault();
display.syncExec(new Runnable() {
public void run() {
CommonUITool.openErrorBox(Messages.errDatabaseNoExist);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
TreeViewer treeViewer = navigatorView == null ? null : navigatorView.getViewer();
if (treeViewer != null) {
CommonUITool.refreshNavigatorTree(treeViewer, parent.getParent());
}
}
});
setLoaded(true);
return;
}
if (!loadReplication(parent, monitor)) {
setLoaded(true);
return;
}
// add tables folder
addTableFolder(monitor, database);
// add views folder
addViewFolder(monitor, database);
// add serials folder
addSerialFolder(monitor, database);
// add user folder
addUserFolder(monitor, database);
// add triggers folder
addTriggerFolder(monitor, database);
// add stored procedure folder
addProcedureFolder(monitor, database);
// add job automation folder
addJobAutoFolder(monitor, database);
// add database space folder
addSpaceFolder(monitor, database);
// set parameter dump information
database.getDatabaseInfo().setParaDumpInfo(paraDumpInfo);
// set charset info
setDbCollation(database);
setLoaded(true);
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
}
}
Aggregations