Search in sources :

Example 41 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.

the class StartShardEnvAction method isSupportedNode.

/**
	 * Return whether this action support this object,if not support,this action
	 * will be disabled
	 * 
	 * @param obj
	 *            the object
	 * @return <code>true</code> if supported;<code>false</code>
	 */
public static boolean isSupportedNode(Object obj) {
    if (obj instanceof CubridShardFolder) {
        CubridShardFolder selection = ((CubridShardFolder) obj);
        if (!selection.isEnable()) {
            return false;
        }
        ServerUserInfo userInfo = selection.getServer().getServerInfo().getLoginedUserInfo();
        if (userInfo == null || CasAuthType.AUTH_ADMIN != userInfo.getCasAuth()) {
            return false;
        }
        return !selection.isRunning();
    }
    return false;
}
Also used : CubridShardFolder(com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 42 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.

the class StopShardAction method isSupportedNode.

/**
	 * Return whether this action support this object,if not support,this action
	 * will be disabled
	 * 
	 * @param obj
	 *            the object
	 * @return <code>true</code> if supported;<code>false</code>
	 */
public static boolean isSupportedNode(Object obj) {
    if (obj instanceof CubridShard) {
        CubridShard selection = ((CubridShard) obj);
        ServerUserInfo userInfo = selection.getServer().getServerInfo().getLoginedUserInfo();
        if (userInfo == null || CasAuthType.AUTH_ADMIN != userInfo.getCasAuth()) {
            return false;
        }
        return selection.isRunning();
    }
    return false;
}
Also used : CubridShard(com.cubrid.cubridmanager.ui.spi.model.CubridShard) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Example 43 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.

the class CubridBrokersFolderLoader 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();
        ServerUserInfo userInfo = serverInfo.getLoginedUserInfo();
        if (userInfo == null || CasAuthType.AUTH_NONE == userInfo.getCasAuth()) {
            parent.removeAllChild();
            CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
            return;
        }
        BrokerInfos brokerInfos = new BrokerInfos();
        final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
        monitorCancel(monitor, new ITask[] { task });
        task.execute();
        final String errorMsg = task.getErrorMsg();
        if (!monitor.isCanceled() && errorMsg != null && errorMsg.trim().length() > 0) {
            parent.removeAllChild();
            Display display = Display.getDefault();
            display.syncExec(new Runnable() {

                public void run() {
                    CommonUITool.openErrorBox(errorMsg);
                }
            });
            setLoaded(true);
            return;
        }
        if (monitor.isCanceled()) {
            setLoaded(true);
            return;
        }
        brokerInfos = task.getResultModel();
        List<ICubridNode> oldNodeList = parent.getChildren();
        parent.removeAllChild();
        List<BrokerInfo> brokerInfoList = (brokerInfos == null || brokerInfos.getBorkerInfoList() == null) ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
        for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
            BrokerInfo brokerInfo = brokerInfoList.get(i);
            String id = parent.getId() + NODE_SEPARATOR + brokerInfo.getName();
            ICubridNode brokerInfoNode = isContained(oldNodeList, id);
            if (brokerInfoNode == null) {
                brokerInfoNode = new CubridBroker(id, brokerInfo.getName(), "icons/navigator/broker.png");
                ((CubridBroker) brokerInfoNode).setStartedIconPath("icons/navigator/broker_started.png");
                brokerInfoNode.setType(CubridNodeType.BROKER);
                brokerInfoNode.setContainer(true);
                brokerInfoNode.setModelObj(brokerInfo);
                brokerInfoNode.setViewId(BrokerStatusView.ID);
                brokerInfoNode.setLoader(new CubridBrokerFolderLoader());
            } else {
                brokerInfoNode.setModelObj(brokerInfo);
                if (brokerInfoNode.getLoader() != null && brokerInfoNode.getLoader().isLoaded()) {
                    brokerInfoNode.getLoader().setLoaded(false);
                    brokerInfoNode.getChildren(monitor);
                }
            }
            parent.addChild(brokerInfoNode);
        }
        serverInfo.setBrokerInfos(brokerInfos);
        // For the Shard Broker Folder
        if (CompatibleUtil.isSupportShard(serverInfo)) {
            Shards shards = new Shards();
            GetShardConfTask<Shards> getShardConfTask = new GetShardConfTask<Shards>(serverInfo, shards);
            getShardConfTask.execute();
            // !"File(?) open error".equals(errorMsg.trim())) {
            if (getShardConfTask.isSuccess()) {
                GetShardStatusTask getShardStatusTask = new GetShardStatusTask(serverInfo, null);
                getShardStatusTask.execute();
                boolean runningShard = getShardStatusTask.isSuccess();
                serverInfo.setShards(shards);
                shards.setRunning(runningShard);
                String shardFolderId = parent.getId() + NODE_SEPARATOR + SHARD_FOLDER_ID;
                ICubridNode shardFolder = parent.getChild(shardFolderId);
                if (shardFolder == null) {
                    shardFolder = new CubridShardFolder(shardFolderId, SHARD_FOLDER_NAME);
                    ICubridNodeLoader loader = new CubridShardsFolderLoader((CubridShardFolder) shardFolder);
                    loader.setLevel(getLevel());
                    shardFolder.setLoader(loader);
                    parent.addChild(shardFolder);
                // shardFolder.getChildren(monitor);
                } else {
                    if (shardFolder.getLoader() != null && shardFolder.getLoader().isLoaded()) {
                        shardFolder.getLoader().setLoaded(false);
                        shardFolder.getChildren(monitor);
                    }
                }
            }
        }
        Collections.sort(parent.getChildren());
        setLoaded(true);
        CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent((ICubridNode) parent, CubridNodeChangedEventType.CONTAINER_NODE_REFRESH));
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) CubridShardFolder(com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) GetShardConfTask(com.cubrid.cubridmanager.core.shard.task.GetShardConfTask) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) ICubridNodeLoader(com.cubrid.common.ui.spi.model.ICubridNodeLoader) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) Shards(com.cubrid.cubridmanager.core.shard.model.Shards) GetShardStatusTask(com.cubrid.cubridmanager.core.shard.task.GetShardStatusTask) Display(org.eclipse.swt.widgets.Display)

Example 44 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo in project cubrid-manager by CUBRID.

the class CubridDatabaseLoader method loadReplication.

/**
	 * 
	 * Load replication function
	 * 
	 * @param parent the parent node
	 * @param monitor the monitor object
	 * @return <code>true</code> it can be loaded;<code>false</code> otherwise
	 */
private boolean loadReplication(final ICubridNode parent, final IProgressMonitor monitor) {
    CubridDatabase database = (CubridDatabase) parent;
    ServerInfo serverInfo = parent.getServer().getServerInfo();
    ServerUserInfo serverUserInfo = serverInfo.getLoginedUserInfo();
    if (serverUserInfo == null || !serverUserInfo.isAdmin()) {
        return true;
    }
    DbUserInfo dbUserInfo = database.getDatabaseInfo().getAuthLoginedDbUserInfo();
    if (dbUserInfo == null || dbUserInfo.getName() == null || !dbUserInfo.getName().trim().equalsIgnoreCase("DBA")) {
        return true;
    }
    String dbPassword = dbUserInfo.getNoEncryptPassword();
    //add for replication support,only can be supported after version 8.2.2 and in linux OS
    if (serverInfo.isSupportReplication() == 0) {
        final CheckDistributorDbTask checkDistributorDbTask = new CheckDistributorDbTask(serverInfo);
        checkDistributorDbTask.setDistDbName(database.getLabel());
        checkDistributorDbTask.setDbaPassword(dbPassword);
        checkDistributorDbTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
        final GetReplicationInfoTask getReplicationInfoTask = new GetReplicationInfoTask(serverInfo);
        getReplicationInfoTask.setDistDbName(database.getLabel());
        getReplicationInfoTask.setDbaPassword(dbPassword);
        getReplicationInfoTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
        final GetReplicatedTablesTask getReplicatedTablesTask = new GetReplicatedTablesTask(serverInfo);
        getReplicatedTablesTask.setDistdbName(database.getLabel());
        getReplicatedTablesTask.setDistdbPassword(dbPassword);
        getReplicatedTablesTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
        final GetReplicationParamTask getReplicationParamTask = new GetReplicationParamTask(serverInfo);
        getReplicationParamTask.setDistDbName(database.getLabel());
        getReplicationParamTask.setDistDbDbaPasswd(dbPassword);
        getReplicationParamTask.setRunningMode(database.getRunningType() == DbRunningType.CS);
        final GetReplAgentStatusTask getReplAgentStatusTask = new GetReplAgentStatusTask(serverInfo);
        getReplAgentStatusTask.setDbName(database.getLabel());
        monitorCancel(monitor, new ITask[] { checkDistributorDbTask, getReplicationInfoTask, getReplicatedTablesTask, getReplicationParamTask, getReplAgentStatusTask });
        checkDistributorDbTask.execute();
        if (!checkResult(checkDistributorDbTask, monitor)) {
            return false;
        }
        boolean isDistdb = checkDistributorDbTask.isDistributorDb();
        database.getDatabaseInfo().setDistributorDb(isDistdb);
        if (isDistdb) {
            getReplicationInfoTask.execute();
            if (!checkResult(getReplicationInfoTask, monitor)) {
                return false;
            }
            ReplicationInfo replInfo = getReplicationInfoTask.getReplicationInfo();
            database.getDatabaseInfo().setReplInfo(replInfo);
            if (replInfo != null && replInfo.getDistInfo() != null) {
                replInfo.getDistInfo().setDistDbPath(database.getDatabaseInfo().getDbDir());
            }
            if (replInfo != null && replInfo.getMasterList() != null && replInfo.getMasterList().size() > 0 && replInfo.getSlaveList() != null && replInfo.getSlaveList().size() > 0) {
                MasterInfo masterInfo = replInfo.getMasterList().get(0);
                SlaveInfo slaveInfo = replInfo.getSlaveList().get(0);
                getReplicatedTablesTask.setMasterdbName(masterInfo.getMasterDbName());
                getReplicatedTablesTask.setSlavedbName(slaveInfo.getSlaveDbName());
                getReplicatedTablesTask.execute();
                if (!checkResult(getReplicatedTablesTask, monitor)) {
                    return false;
                }
                String[] classNames = getReplicatedTablesTask.getReplicatedTables();
                boolean isReplAll = getReplicatedTablesTask.isReplicateAll();
                if (classNames != null && classNames.length > 0) {
                    masterInfo.setReplTableList(Arrays.asList(classNames));
                }
                masterInfo.setReplAllTable(isReplAll);
                getReplicationParamTask.setMasterDbName(masterInfo.getMasterDbName());
                getReplicationParamTask.setSlaveDbName(replInfo.getSlaveList().get(0).getSlaveDbName());
                getReplicationParamTask.execute();
                if (!checkResult(getReplicationParamTask, monitor)) {
                    return false;
                }
                ReplicationParamInfo paramInfo = getReplicationParamTask.getReplicationParams();
                slaveInfo.setParamInfo(paramInfo);
            }
            getReplAgentStatusTask.execute();
            if (!checkResult(getReplAgentStatusTask, monitor)) {
                return false;
            }
            boolean isActive = getReplAgentStatusTask.isActive();
            replInfo.getDistInfo().setAgentActive(isActive);
        }
    }
    return true;
}
Also used : GetReplicationInfoTask(com.cubrid.cubridmanager.core.replication.task.GetReplicationInfoTask) GetReplAgentStatusTask(com.cubrid.cubridmanager.core.replication.task.GetReplAgentStatusTask) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) GetReplicatedTablesTask(com.cubrid.cubridmanager.core.replication.task.GetReplicatedTablesTask) GetReplicationParamTask(com.cubrid.cubridmanager.core.replication.task.GetReplicationParamTask) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) MasterInfo(com.cubrid.cubridmanager.core.replication.model.MasterInfo) CheckDistributorDbTask(com.cubrid.cubridmanager.core.replication.task.CheckDistributorDbTask) ReplicationParamInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationParamInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) ReplicationInfo(com.cubrid.cubridmanager.core.replication.model.ReplicationInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) SlaveInfo(com.cubrid.cubridmanager.core.replication.model.SlaveInfo)

Example 45 with ServerUserInfo

use of com.cubrid.cubridmanager.core.common.model.ServerUserInfo 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));
    }
}
Also used : DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) ArrayList(java.util.ArrayList) GetCMUserListTask(com.cubrid.cubridmanager.core.common.task.GetCMUserListTask) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridNodeChangedEvent(com.cubrid.common.ui.spi.event.CubridNodeChangedEvent) GetDatabaseListTask(com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo)

Aggregations

ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)101 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)33 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)23 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)21 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)19 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)18 ArrayList (java.util.ArrayList)16 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)12 ServerType (com.cubrid.cubridmanager.core.common.model.ServerType)10 DbUserInfo (com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo)10 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)9 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)8 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)8 CubridBrokerFolder (com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)8 Map (java.util.Map)8 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)7 ITask (com.cubrid.common.core.task.ITask)6 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)6 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)6 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)6