Search in sources :

Example 81 with DatabaseInfo

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;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 82 with DatabaseInfo

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;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 83 with DatabaseInfo

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;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 84 with DatabaseInfo

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;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) MonitorDashboardPreference(com.cubrid.cubridmanager.ui.mondashboard.preference.MonitorDashboardPreference) ITask(com.cubrid.common.core.task.ITask) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) MonitoringTask(com.cubrid.cubridmanager.core.common.task.MonitoringTask) CommonUpdateTask(com.cubrid.cubridmanager.core.common.task.CommonUpdateTask) Display(org.eclipse.swt.widgets.Display)

Example 85 with DatabaseInfo

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;
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo)

Aggregations

DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)188 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)79 ArrayList (java.util.ArrayList)45 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)35 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)31 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)30 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)30 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)25 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)24 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)24 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)23 ITask (com.cubrid.common.core.task.ITask)20 DefaultSchemaNode (com.cubrid.common.ui.spi.model.DefaultSchemaNode)18 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)18 Map (java.util.Map)15 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)14 HashMap (java.util.HashMap)14 Composite (org.eclipse.swt.widgets.Composite)14 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)13 GridLayout (org.eclipse.swt.layout.GridLayout)13