Search in sources :

Example 6 with CubridBroker

use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.

the class CubridBrokerFolderLoader method checkBrokerExist.

/**
	 * 
	 * Check broker whether exist
	 * 
	 * @param parent the parent node
	 * @param monitor the IProgressMonitor
	 * @return <code>0</code> exist;<code>1</code> has error;<code>2</code>
	 *         canceled;<code>3</code> no exist;
	 */
private int checkBrokerExist(final ICubridNode parent, final IProgressMonitor monitor) {
    ServerInfo serverInfo = parent.getServer().getServerInfo();
    BrokerInfos brokerInfos = new BrokerInfos();
    final CommonQueryTask<BrokerInfos> getBrokersTask = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
    monitorCancel(monitor, new ITask[] { getBrokersTask });
    getBrokersTask.execute();
    final String msg = getBrokersTask.getErrorMsg();
    if (!monitor.isCanceled() && msg != null && msg.trim().length() > 0) {
        parent.removeAllChild();
        openErrorBox(msg);
        setLoaded(true);
        return 1;
    }
    if (monitor.isCanceled()) {
        setLoaded(true);
        return 2;
    }
    CubridBroker broker = (CubridBroker) parent;
    String brokerName = broker.getLabel();
    brokerInfos = getBrokersTask.getResultModel();
    boolean isExist = false;
    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);
        if (brokerInfo.getName().equalsIgnoreCase(brokerName)) {
            broker.setRunning(brokerInfo.getState() == null ? false : brokerInfo.getState().equalsIgnoreCase("ON"));
            isExist = true;
        }
    }
    return isExist ? 0 : 3;
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 7 with CubridBroker

use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker 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 8 with CubridBroker

use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.

the class NavigatorTreeLabelProvider method getText.

public String getText(Object element) {
    if (element instanceof ICubridNode) {
        if (element instanceof CubridDatabase) {
            CubridDatabase database = (CubridDatabase) element;
            StringBuffer sbLabel = new StringBuffer();
            sbLabel.append(((ICubridNode) element).getLabel());
            DatabaseEditorConfig editorConfig = QueryOptions.getEditorConfig(database, true);
            if (editorConfig != null && editorConfig.getDatabaseComment() != null && editorConfig.getDatabaseComment().length() > 0) {
                sbLabel.append("(").append(editorConfig.getDatabaseComment()).append(")");
                return sbLabel.toString();
            }
        } else if (element instanceof CubridBroker) {
            CubridBroker broker = (CubridBroker) element;
            BrokerInfo brokerInfo = broker.getBrokerInfo();
            if (brokerInfo == null || brokerInfo.getAccess_mode() == null) {
                return broker.getName();
            }
            return broker.getName() + " (" + brokerInfo.getPort() + "," + brokerInfo.getAccess_mode() + ")";
        } else if (element instanceof CubridServer) {
            CubridServer server = (CubridServer) element;
            return decorateServerText(server.getLabel(), server);
        }
        return ((ICubridNode) element).getLabel();
    } else if (element instanceof PendingUpdateAdapter) {
        return com.cubrid.common.ui.common.Messages.msgLoading;
    }
    return element == null ? "" : element.toString();
}
Also used : PendingUpdateAdapter(org.eclipse.ui.progress.PendingUpdateAdapter) CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) ICubridNode(com.cubrid.common.ui.spi.model.ICubridNode) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) DatabaseEditorConfig(com.cubrid.common.ui.spi.model.DatabaseEditorConfig) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 9 with CubridBroker

use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.

the class CubridHostNavigatorView method getToolTip.

/**
	 * Get tooltip string
	 *
	 * @param cubridNode ICubridNode
	 * @return String
	 */
protected String getToolTip(ICubridNode cubridNode) {
    StringBuffer toolTipText = new StringBuffer();
    if (cubridNode instanceof CubridServer) {
        CubridServer server = (CubridServer) cubridNode;
        String ip = server.getHostAddress();
        toolTipText.append(Messages.bind(Messages.tipIP, ip == null ? "" : ip)).append("\r\n");
        String port = server.getMonPort();
        toolTipText.append(Messages.bind(Messages.tipPort, port == null ? "" : port)).append("\r\n");
        String userName = server.getUserName();
        toolTipText.append(Messages.bind(Messages.tipUser, userName == null ? "" : userName)).append("\r\n");
        String jdbcVersion = server.getJdbcDriverVersion();
        toolTipText.append(Messages.bind(Messages.tipJDBC, jdbcVersion == null ? "" : jdbcVersion));
    } else if (cubridNode instanceof CubridBroker) {
        CubridBroker broker = (CubridBroker) cubridNode;
        BrokerInfo brokerInfo = broker.getBrokerInfo();
        String brokerMode = brokerInfo.getAccess_mode() == null ? Messages.tipBrokerAccessModeNotWorking : brokerInfo.getAccess_mode();
        toolTipText.append(Messages.bind(Messages.tipBrokerPort, brokerInfo.getPort())).append("\r\n");
        toolTipText.append(Messages.bind(Messages.tipBrokerAccessMode, brokerMode)).append("\r\n");
        if (OnOffType.ON.getText().equalsIgnoreCase(brokerInfo.getState())) {
            toolTipText.append(Messages.tipBrokerStatusON);
        } else {
            toolTipText.append(Messages.tipBrokerStatusOFF);
        }
    }
    return toolTipText.toString();
}
Also used : CubridBroker(com.cubrid.cubridmanager.ui.spi.model.CubridBroker) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 10 with CubridBroker

use of com.cubrid.cubridmanager.ui.spi.model.CubridBroker in project cubrid-manager by CUBRID.

the class ShowBrokerStatusAction method isSupported.

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

Aggregations

CubridBroker (com.cubrid.cubridmanager.ui.spi.model.CubridBroker)12 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)6 CubridBrokerFolder (com.cubrid.cubridmanager.ui.spi.model.CubridBrokerFolder)6 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)5 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)4 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)3 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)2 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)2 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)2 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)2 CubridShardFolder (com.cubrid.cubridmanager.ui.spi.model.CubridShardFolder)2 DecoratedImage (com.cubrid.common.ui.decorator.DecoratedImage)1 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)1 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)1 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)1 Shards (com.cubrid.cubridmanager.core.shard.model.Shards)1 GetShardConfTask (com.cubrid.cubridmanager.core.shard.task.GetShardConfTask)1 GetShardStatusTask (com.cubrid.cubridmanager.core.shard.task.GetShardStatusTask)1 StartBrokerAction (com.cubrid.cubridmanager.ui.broker.action.StartBrokerAction)1