use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class StopSlaveDbAction method isSupportedNode.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public static boolean isSupportedNode(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined()) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
if (!database.isDistributorDb()) {
return false;
}
ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
boolean isSupported = false;
if (replInfo != null && replInfo.getSlaveList() != null) {
for (int i = 0; i < replInfo.getSlaveList().size(); i++) {
DatabaseInfo dbInfo = serverUserInfo.getDatabaseInfo(replInfo.getSlaveList().get(i).getSlaveDbName());
if (dbInfo == null || dbInfo.getRunningType() == DbRunningType.STANDALONE) {
isSupported = false;
break;
} else {
isSupported = true;
}
}
}
return isSupported;
}
return false;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class StartReplicationAgentAction method isSupportedNode.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public static boolean isSupportedNode(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined() || database.getRunningType() == DbRunningType.STANDALONE) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
if (!database.isDistributorDb()) {
return false;
}
ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
for (int i = 0; replInfo != null && replInfo.getSlaveList() != null && i < replInfo.getSlaveList().size(); i++) {
DatabaseInfo dbInfo = serverUserInfo.getDatabaseInfo(replInfo.getSlaveList().get(i).getSlaveDbName());
if (dbInfo == null || dbInfo.getRunningType() == DbRunningType.STANDALONE) {
return false;
}
}
if (replInfo != null && replInfo.getDistInfo() != null) {
return !replInfo.getDistInfo().isAgentActive();
}
return false;
}
return false;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class StartSlaveDbAction method isSupportedNode.
/**
* @see com.cubrid.common.ui.spi.action.ISelectionAction#isSupported(java
* .lang.Object)
* @param obj Object
* @return boolean(whether to support)
*/
public static boolean isSupportedNode(Object obj) {
if (obj instanceof CubridDatabase) {
CubridDatabase database = (CubridDatabase) obj;
if (!database.isLogined()) {
return false;
}
ServerUserInfo serverUserInfo = database.getServer().getServerInfo().getLoginedUserInfo();
if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
return false;
}
if (!database.isDistributorDb()) {
return false;
}
ReplicationInfo replInfo = (ReplicationInfo) database.getAdapter(ReplicationInfo.class);
boolean isSupported = false;
if (replInfo != null && replInfo.getSlaveList() != null) {
for (int i = 0; i < replInfo.getSlaveList().size(); i++) {
DatabaseInfo dbInfo = serverUserInfo.getDatabaseInfo(replInfo.getSlaveList().get(i).getSlaveDbName());
if (dbInfo == null || dbInfo.getRunningType() == DbRunningType.CS) {
isSupported = false;
break;
} else {
isSupported = true;
}
}
}
return isSupported;
}
return false;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class CreateReplicationJobExecutor method createDistributor.
/**
* create distributor database
*
* @param dbName String
* @param monitor IProgressMonitor
* @param taskList List<ITask>
* @return status
*/
private IStatus createDistributor(String dbName, final IProgressMonitor monitor, List<ITask> taskList) {
monitor.subTask(Messages.bind(Messages.createDistJobName, dbName));
Display display = Display.getDefault();
MonitoringTask monitoringTask = null;
boolean isExecuteStopDbTask = true;
MonitorDashboardPreference monPref = new MonitorDashboardPreference();
for (ITask task : taskList) {
if (task instanceof MonitoringTask) {
monitoringTask = (MonitoringTask) task;
ServerInfo serverInfo = monitoringTask.getServerInfo();
CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
monitoringTask.connectServer(Version.releaseVersion, monPref.getHAHeartBeatTimeout());
} else if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.STOP_DB_TASK_NAME)) {
if (isDeleteDb && isExecuteStopDbTask) {
task.execute();
} else {
continue;
}
} else if (task instanceof CommonUpdateTask && task.getTaskname().equals(CommonTaskName.DELETE_DATABASE_TASK_NAME)) {
if (isDeleteDb) {
task.execute();
} else {
continue;
}
} else {
task.execute();
}
if (monitor.isCanceled()) {
disConnect(monitoringTask);
return Status.CANCEL_STATUS;
}
final String msg = task.getErrorMsg();
if (msg != null && msg.length() > 0 && !monitor.isCanceled()) {
disConnect(monitoringTask);
return new Status(IStatus.ERROR, CubridManagerUIPlugin.PLUGIN_ID, msg);
}
if (task instanceof GetDatabaseListTask) {
GetDatabaseListTask getDatabaseListTask = (GetDatabaseListTask) task;
final String distdbName = (String) getDatabaseListTask.getData("dbName");
List<DatabaseInfo> dbInfoList = getDatabaseListTask.loadDatabaseInfo();
boolean isDbExist = false;
for (int i = 0; i < dbInfoList.size(); i++) {
DatabaseInfo dbInfo = dbInfoList.get(i);
if (dbName.equalsIgnoreCase(dbInfo.getDbName())) {
isDbExist = true;
display.syncExec(new Runnable() {
public void run() {
isDeleteDb = CommonUITool.openConfirmBox(Messages.bind(Messages.msgConfirmDeleteDb, distdbName));
}
});
if (dbInfo.getRunningType() == DbRunningType.CS) {
isExecuteStopDbTask = true;
}
break;
}
}
if (isDbExist && !isDeleteDb) {
disConnect(monitoringTask);
return Status.CANCEL_STATUS;
}
}
}
disConnect(monitoringTask);
isDeleteDb = false;
return Status.OK_STATUS;
}
use of com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo in project cubrid-manager by CUBRID.
the class SlaveDbInfoPage method validInput.
/**
* input content of to be verified.
*
* @return error message
*/
private String validInput() {
String hostIp = masterDbHostText.getText();
String masterDbHostPort = masterDbHostPortText.getText();
//verify master database server port
if (masterDbHostPort == null || "".equals(masterDbHostPort) || !ValidateUtil.isNumber(masterDbHostPort) || (Integer.parseInt(masterDbHostPort) < 1024 || Integer.parseInt(masterDbHostPort) > 65535)) {
return Messages.chsldb0errInvalidMasterDbPort;
}
ServerInfo serverInfo = ServerManager.getInstance().getServer(hostIp, Integer.parseInt(masterDbHostPort), masterDbHostUserText.getText());
//verify whether a user that it is not admin already logined
if (serverInfo != null && !serverInfo.getLoginedUserInfo().isAdmin()) {
return Messages.bind(Messages.errInvalidUser, hostIp);
}
//verify whether a user that it is not dba already logined
String dbaPassword = "";
boolean isDbaLogined = false;
if (serverInfo != null && serverInfo.isConnected()) {
DatabaseInfo dbInfo = serverInfo.getLoginedUserInfo().getDatabaseInfo(masterDbNameText.getText());
if (dbInfo != null && dbInfo.isLogined() && !"dba".equalsIgnoreCase(dbInfo.getAuthLoginedDbUserInfo().getName())) {
return Messages.bind(Messages.errInvalidDbUser, masterDbNameText.getText());
}
if (dbInfo != null && dbInfo.isLogined() && "dba".equalsIgnoreCase(dbInfo.getAuthLoginedDbUserInfo().getName())) {
dbaPassword = dbInfo.getAuthLoginedDbUserInfo().getNoEncryptPassword();
dbaPassword = dbaPassword == null ? "" : dbaPassword;
isDbaLogined = true;
}
}
//verify the master database server password
String hostPassword = masterHostPasswordText.getText();
boolean isValidPassword = hostPassword.trim().length() >= 4 && hostPassword.indexOf(" ") < 0;
if (isValidPassword && serverInfo != null && serverInfo.getLoginedUserInfo() != null) {
isValidPassword = hostPassword.equals(serverInfo.getLoginedUserInfo().getPassword());
}
if (!isValidPassword) {
return Messages.chsldb0errInvalidMasterHostPasswd;
}
//verify master database password
String masterDbPassword = masterDbDbaPasswordText.getText();
boolean isValidMasterDbaPassword = masterDbPassword.length() >= 4 && masterDbPassword.indexOf(" ") < 0;
if (!isValidMasterDbaPassword) {
return Messages.chsldb0errInvalidMasterDbaPasswd;
}
if (isDbaLogined && !masterDbPassword.equals(dbaPassword)) {
return Messages.chsldb0errInvalidMasterDbaPasswd;
}
//verify slave database name
if (slaveDbNameText.getText() == null || "".equals(slaveDbNameText.getText().trim()) || !ValidateUtil.isValidDBName(slaveDbNameText.getText())) {
return Messages.chsldb0errInvalidSlaveDbName;
}
DatabaseInfo databaseInfo = database.getServer().getServerInfo().getLoginedUserInfo().getDatabaseInfo(slaveDbNameText.getText());
boolean isDatabaseNameAlrExist = databaseInfo != null;
if (isDatabaseNameAlrExist) {
return Messages.errDbExist;
}
if (slaveDbUserText.getText() == null || "".equals(slaveDbUserText.getText().trim()) || "dba".equals(slaveDbUserText.getText().trim()) || slaveDbUserText.getText().indexOf(" ") >= 0 || slaveDbUserText.getText().trim().length() > ValidateUtil.MAX_NAME_LENGTH) {
return Messages.errDbUser;
}
if (slaveDbaPasswordText.getText() == null || "".equals(slaveDbaPasswordText.getText()) || slaveDbaPasswordText.getText().length() < 4 || slaveDbaPasswordText.getText().indexOf(" ") >= 0) {
return Messages.errDbPassword;
}
if (confirmSlaveDbaPasswordText.getText() == null || "".equals(confirmSlaveDbaPasswordText.getText()) || confirmSlaveDbaPasswordText.getText().length() < 4 || confirmSlaveDbaPasswordText.getText().indexOf(" ") >= 0) {
return Messages.errConfirmedDbPassword;
}
if (!(slaveDbaPasswordText.getText().equals(confirmSlaveDbaPasswordText.getText()))) {
return Messages.errPasswordNotEqual;
}
if (slaveDbPathText.getText() == null || "".equals(slaveDbPathText.getText().trim()) || !ValidateUtil.isValidPathName(slaveDbPathText.getText())) {
return Messages.chsldb0errInvalidSlaveDbPath;
}
return null;
}
Aggregations