Search in sources :

Example 21 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class CubridTitleLineContrItem method getTitleForNavigator.

/**
	 * 
	 * Get title of CUBRID manager application for navigator
	 * 
	 * @param cubridNode the ICubridNode object
	 * @return the title
	 */
protected String getTitleForNavigator(ICubridNode cubridNode) {
    if (cubridNode == null) {
        return "";
    }
    String title = cubridNode.getLabel();
    CubridServer server = cubridNode.getServer();
    String serverTitle = server == null ? null : server.getLabel();
    if (server != null && server.isConnected()) {
        ServerInfo serverInfo = server.getServerInfo();
        ServerUserInfo userInfo = serverInfo == null ? null : serverInfo.getLoginedUserInfo();
        if (userInfo != null && userInfo.getUserName() != null && userInfo.getUserName().trim().length() > 0) {
            serverTitle = userInfo.getUserName() + "@" + serverTitle;
        }
        String monPort = server.getMonPort();
        if (monPort != null && monPort.trim().length() > 0) {
            serverTitle = serverTitle + ":" + monPort;
        }
    }
    StringBuffer dbTitleBuffer = new StringBuffer("");
    CubridDatabase database = cubridNode instanceof ISchemaNode ? ((ISchemaNode) cubridNode).getDatabase() : null;
    if (database != null && database.getDatabaseInfo() != null) {
        DatabaseInfo dbInfo = database.getDatabaseInfo();
        DbUserInfo dbUserInfo = dbInfo.getAuthLoginedDbUserInfo();
        String userName = dbUserInfo == null ? null : dbUserInfo.getName();
        dbTitleBuffer = (userName != null && userName.trim().length() > 0) ? dbTitleBuffer.append(userName).append("@").append(dbInfo.getDbName()) : dbTitleBuffer;
        String brokerPort = QueryOptions.getBrokerPort(dbInfo);
        BrokerInfos brokerInfos = database.getServer().getServerInfo().getBrokerInfos();
        List<BrokerInfo> brokerInfoList = brokerInfos == null || brokerInfos.getBorkerInfoList() == null ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
        boolean isExist = false;
        for (int i = 0; brokerInfoList != null && i < brokerInfoList.size(); i++) {
            BrokerInfo brokerInfo = brokerInfoList.get(i);
            if (brokerPort != null && brokerPort.equals(brokerInfo.getPort())) {
                isExist = true;
                String status = brokerInfo.getState() == null || brokerInfo.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
                String text = brokerInfo.getName() + "[" + brokerInfo.getPort() + "/" + status + "]";
                dbTitleBuffer.append(":").append(text);
                break;
            }
        }
        if (!isExist && brokerPort != null && brokerPort.trim().length() > 0) {
            dbTitleBuffer.append(":").append(brokerPort);
        }
        String charset = database.getDatabaseInfo().getCharSet();
        if (charset != null && charset.trim().length() > 0) {
            dbTitleBuffer.append(":charset=").append(charset);
        }
    }
    if (serverTitle != null && serverTitle.trim().length() > 0) {
        title = serverTitle;
    }
    if (dbTitleBuffer != null && dbTitleBuffer.toString().trim().length() > 0) {
        title = serverTitle + " / " + dbTitleBuffer.toString();
    }
    return title;
}
Also used : ISchemaNode(com.cubrid.common.ui.spi.model.ISchemaNode) DatabaseInfo(com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) DbUserInfo(com.cubrid.cubridmanager.core.cubrid.user.model.DbUserInfo) ServerUserInfo(com.cubrid.cubridmanager.core.common.model.ServerUserInfo) CubridDatabase(com.cubrid.common.ui.spi.model.CubridDatabase)

Example 22 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class BrokerNode method genBrokerInfo.

public void genBrokerInfo() {
    StringBuilder sb = new StringBuilder();
    if (brokerInfoList != null) {
        int count = 0;
        for (BrokerInfo brokerInfo : brokerInfoList.getBrokerInfoList()) {
            if (brokerInfo != null) {
                //sb.append(brokerInfo.getName()).append("[");
                sb.append(brokerInfo.getPort()).append("(");
                sb.append(brokerInfo.getAccess_mode()).append(")");
                sb.append(":");
                sb.append(brokerInfo.getState()).append(", ");
                count++;
            }
        }
        if (count > 0) {
            sb.delete(sb.length() - 2, sb.length());
        }
    }
    super.setBrokerInfo(sb.toString());
    super.setStatus(sb.toString());
}
Also used : BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 23 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class BrokersStatusLabelProvider method getColumnText.

/**
	 * @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object,
	 *      int)
	 *
	 * @param element the object representing the entire row, or
	 *        <code>null</code> indicating that no input object is set in the
	 *        viewer
	 * @param columnIndex the zero-based index of the column in which the label
	 *        appears
	 * @return String or or <code>null</code> if there is no text for the given
	 *         object at columnIndex
	 */
public String getColumnText(Object element, int columnIndex) {
    BrokerInfo brokerInfo = (BrokerInfo) element;
    boolean isQueryOrTransTimeUseMs = false;
    if (serverInfo != null) {
        isQueryOrTransTimeUseMs = CompatibleUtil.isQueryOrTransTimeUseMs(serverInfo);
    }
    switch(columnIndex) {
        case 0:
            return brokerInfo.getName();
        case 1:
            return brokerInfo.getState();
        case 2:
            return brokerInfo.getPid();
        case 3:
            return brokerInfo.getPort();
        case 4:
            return brokerInfo.getAs();
        case 5:
            return brokerInfo.getJq();
        case 6:
            return brokerInfo.getReq();
        case 7:
            return brokerInfo.getTran();
        case 8:
            return brokerInfo.getQuery();
        case 9:
            String longTran = brokerInfo.getLong_tran();
            String longTranTime = brokerInfo.getLong_query_time();
            if (isQueryOrTransTimeUseMs) {
                double dVal = Double.parseDouble(longTranTime) * 1000;
                longTranTime = String.valueOf((int) (dVal + 0.5));
            }
            return longTran + "/" + longTranTime;
        case 10:
            String longQuery = brokerInfo.getLong_query();
            String longQueryTime = brokerInfo.getLong_query_time();
            if (isQueryOrTransTimeUseMs) {
                double dVal = Double.parseDouble(longQueryTime) * 1000;
                longQueryTime = String.valueOf((int) (dVal + 0.5));
            }
            return longQuery + "/" + longQueryTime;
        case 11:
            return brokerInfo.getError_query();
        default:
            return "";
    }
}
Also used : BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 24 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class HaShardDemo method getBrokerNodeInfo.

protected NodeInfo getBrokerNodeInfo(ServerInfo serverInfo) {
    BrokerNode nodeInfo = new BrokerNode();
    BrokerInfos brokerInfos = new BrokerInfos();
    GetBrokerStatusInfosTask<BrokerInfos> getBrokerStatusInfosTask = new GetBrokerStatusInfosTask<BrokerInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerInfos);
    getBrokerStatusInfosTask.execute();
    if (!getBrokerStatusInfosTask.isSuccess()) {
        return null;
    }
    brokerInfos = getBrokerStatusInfosTask.getResultModel();
    BrokerInfoList brokerInfoList = brokerInfos.getBorkerInfoList();
    if (!(brokerInfoList != null && brokerInfoList.getBrokerInfoList() != null && brokerInfoList.getBrokerInfoList().size() > 0)) {
        return null;
    }
    nodeInfo.setBrokerInfoList(brokerInfoList);
    //Set<String> dbHosts = new HashSet<String>();
    for (BrokerInfo brokerInfo : brokerInfoList.getBrokerInfoList()) {
        if (brokerInfo == null) {
            continue;
        }
        String brokerName = brokerInfo.getName();
        String brokerPort = brokerInfo.getPort();
        BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
        GetBrokerStatusInfosTask<BrokerStatusInfos> statisTask = new GetBrokerStatusInfosTask<BrokerStatusInfos>(serverInfo, CommonSendMsg.getGetBrokerStatusItems(), brokerStatusInfos);
        statisTask.setBrokerName(brokerName);
        statisTask.execute();
        if (!statisTask.isSuccess()) {
            continue;
        }
        brokerStatusInfos = statisTask.getResultModel();
        nodeInfo.addBrokerStatus(brokerPort, brokerStatusInfos);
    }
    return nodeInfo;
}
Also used : BrokerNode(com.cubrid.cubridmanager.core.cubrid.service.model.BrokerNode) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)

Example 25 with BrokerInfo

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfo in project cubrid-manager by CUBRID.

the class SelectBrokerPage method pageChanged.

/**
	 * @see org.eclipse.jface.dialogs.IPageChangedListener#pageChanged(org.eclipse.jface.dialogs.PageChangedEvent)
	 * @param event PageChangedEvent
	 */
/**
	 * @see org.eclipse.jface.dialogs.IPageChangedListener#pageChanged(org.eclipse.jface.dialogs.PageChangedEvent)
	 * @param event PageChangedEvent
	 */
public void pageChanged(PageChangedEvent event) {
    IWizardPage page = (IWizardPage) event.getSelectedPage();
    if (page.getName().equals(PAGENAME)) {
        AddHostAndDbWizard wizard = ((AddHostAndDbWizard) getWizard());
        SetHostInfoPage setHostInfoPage = (SetHostInfoPage) getWizard().getPage(SetHostInfoPage.PAGENAME);
        if (setHostInfoPage == null) {
            hostNode = wizard.getSelectedHostNode();
        } else {
            hostNode = setHostInfoPage.getHostNode();
        }
        serverInfo = CMHostNodePersistManager.getInstance().getServerInfo(hostNode.getIp(), Integer.parseInt(hostNode.getPort()), hostNode.getUserName());
        BrokerInfos brokerInfos = serverInfo.getBrokerInfos();
        brokerInfoList = (brokerInfos == null || brokerInfos.getBorkerInfoList() == null) ? null : brokerInfos.getBorkerInfoList().getBrokerInfoList();
        BrokerInfo brokerInfo = null;
        brokerNameCombo.removeAll();
        for (int i = 0; brokerInfos != null && i < brokerInfoList.size(); i++) {
            if (i == 0) {
                brokerInfo = brokerInfoList.get(i);
            }
            brokerNameCombo.add(brokerInfoList.get(i).getName());
        }
        if (brokerNameCombo.getItemCount() > 0) {
            brokerNameCombo.select(0);
            brokerStatusText.setText(brokerInfo.getState());
            nickNameText.setText(brokerInfo.getName());
            addButton.setEnabled(true);
        } else {
            addButton.setEnabled(false);
        }
        brokerNameCombo.setFocus();
    }
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) IWizardPage(org.eclipse.jface.wizard.IWizardPage) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Aggregations

BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)35 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)16 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)11 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)6 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 ArrayList (java.util.ArrayList)5 CubridServer (com.cubrid.common.ui.spi.model.CubridServer)4 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)4 CubridBroker (com.cubrid.cubridmanager.ui.spi.model.CubridBroker)4 CubridNodeChangedEvent (com.cubrid.common.ui.spi.event.CubridNodeChangedEvent)3 CubridDatabase (com.cubrid.common.ui.spi.model.CubridDatabase)3 ICubridNode (com.cubrid.common.ui.spi.model.ICubridNode)3 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)3 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)3 Combo (org.eclipse.swt.widgets.Combo)3 DatabaseEditorConfig (com.cubrid.common.ui.spi.model.DatabaseEditorConfig)2 ICubridNodeLoader (com.cubrid.common.ui.spi.model.ICubridNodeLoader)2 ISchemaNode (com.cubrid.common.ui.spi.model.ISchemaNode)2 ApplyServerInfo (com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)2 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)2