Search in sources :

Example 1 with BrokerInfoList

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

the class HaNodeTest method testHaNode.

public void testHaNode() {
    HaNode node = new HaNode(NodeType.MASTER);
    BrokerInfoList brokerInfoList = new BrokerInfoList();
    node.setBrokerInfoList(brokerInfoList);
    assertEquals(node.getBrokerInfoList(), brokerInfoList);
    assertNotNull(node.getBrokerInfo());
    List<HAHostStatusInfo> hostStatusInfoList = new ArrayList<HAHostStatusInfo>();
    node.setHostStatusInfoList(hostStatusInfoList);
    assertEquals(node.getHostStatusInfoList(), hostStatusInfoList);
    node.buildStatus("ON");
    assertNotNull(node.getStatus());
}
Also used : HAHostStatusInfo(com.cubrid.cubridmanager.core.mondashboard.model.HAHostStatusInfo) ArrayList(java.util.ArrayList) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)

Example 2 with BrokerInfoList

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

the class BrokerEnvStatusView method refresh.

/**
	 * Refreshes this view
	 *
	 * @param isUpdateTable whether update table
	 * @param isRefreshChanged whether refresh changed
	 *
	 */
public void refresh(boolean isUpdateTable, boolean isRefreshChanged) {
    ServerInfo site = cubridNode.getServer().getServerInfo();
    BrokerInfos brokerInfos = new BrokerInfos();
    final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(site, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
    task.execute();
    brokerInfos = task.getResultModel();
    List<BrokerInfo> newBrokerInfoList = null;
    if (null != brokerInfos) {
        BrokerInfoList list = brokerInfos.getBorkerInfoList();
        if (list != null && list.getBrokerInfoList() != null) {
            newBrokerInfoList = list.getBrokerInfoList();
        }
    }
    List<BrokerInfo> changedBrokerInfoList = new ArrayList<BrokerInfo>();
    for (int i = 0; newBrokerInfoList != null && i < newBrokerInfoList.size(); i++) {
        BrokerInfo newBrokerInfo = newBrokerInfoList.get(i);
        BrokerInfo changedBrokerInfo = newBrokerInfo.clone();
        for (int j = 0; oldBrokerInfoList != null && j < oldBrokerInfoList.size(); j++) {
            BrokerInfo oldBrokerInfo = oldBrokerInfoList.get(j);
            if (newBrokerInfo.getName().equalsIgnoreCase(oldBrokerInfo.getName())) {
                // FIXME more simple
                long newTran = StringUtil.intValue(newBrokerInfo.getTran());
                long newQuery = StringUtil.intValue(newBrokerInfo.getQuery());
                long newLongTran = StringUtil.longValue(newBrokerInfo.getLong_tran());
                long newLongQuery = StringUtil.longValue(newBrokerInfo.getLong_query());
                long newErrQuery = StringUtil.intValue(newBrokerInfo.getError_query());
                long oldTran = StringUtil.intValue(oldBrokerInfo.getTran());
                long oldQuery = StringUtil.intValue(oldBrokerInfo.getQuery());
                long oldLongTran = StringUtil.longValue(oldBrokerInfo.getLong_tran());
                long oldLongQuery = StringUtil.longValue(oldBrokerInfo.getLong_query());
                long oldErrQuery = StringUtil.intValue(oldBrokerInfo.getError_query());
                long changedTran = newTran - oldTran;
                long changedQuery = newQuery - oldQuery;
                long changedLongTran = newLongTran - oldLongTran;
                long changedLongQuery = newLongQuery - oldLongQuery;
                long changedErrQuery = newErrQuery - oldErrQuery;
                changedBrokerInfo.setTran(String.valueOf(changedTran > 0 ? changedTran : 0));
                changedBrokerInfo.setQuery(String.valueOf(changedQuery > 0 ? changedQuery : 0));
                changedBrokerInfo.setLong_tran(String.valueOf(changedLongTran > 0 ? changedLongTran : 0));
                changedBrokerInfo.setLong_query(String.valueOf(changedLongQuery > 0 ? changedLongQuery : 0));
                changedBrokerInfo.setError_query(String.valueOf(changedErrQuery > 0 ? changedErrQuery : 0));
                break;
            }
        }
        changedBrokerInfoList.add(changedBrokerInfo);
    }
    oldBrokerInfoList = newBrokerInfoList;
    if (isUpdateTable) {
        if (isRefreshChanged) {
            tableViewer.setInput(changedBrokerInfoList);
        } else {
            tableViewer.setInput(oldBrokerInfoList);
        }
        tableViewer.refresh();
    }
}
Also used : ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ArrayList(java.util.ArrayList) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 3 with BrokerInfoList

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

the class UserAuthDbInfoPage method initialBrokerPorts.

/**
	 * 
	 * Initial the broker ports
	 * 
	 * @param brokerIp String
	 * 
	 */
private void initialBrokerPorts(String brokerIp) {
    String ip = server.getHostAddress();
    if (!ip.equals(brokerIp)) {
        allBrokerPorts = null;
        return;
    }
    BrokerInfos brokerInfos = server.getServerInfo().getBrokerInfos();
    if (brokerInfos != null) {
        String brokerStauts = brokerInfos.getBrokerstatus();
        BrokerInfoList brokerInfo = brokerInfos.getBorkerInfoList();
        if (brokerInfo != null) {
            List<BrokerInfo> brokerInfoList = brokerInfo.getBrokerInfoList();
            if (brokerInfoList != null) {
                List<String> brokerPortList = new ArrayList<String>();
                for (int i = 0; i < brokerInfoList.size(); i++) {
                    BrokerInfo info = brokerInfoList.get(i);
                    if (info.getPort() == null || info.getPort().trim().length() == 0) {
                        continue;
                    }
                    String port = info.getPort();
                    String status = "";
                    if (brokerStauts == null || !brokerStauts.equalsIgnoreCase("ON")) {
                        status = "OFF";
                    } else {
                        status = info.getState() == null || info.getState().trim().equalsIgnoreCase("OFF") ? "OFF" : "ON";
                    }
                    brokerPortList.add(info.getName() + "[" + port + "/" + status + "]");
                }
                if (!brokerPortList.isEmpty()) {
                    allBrokerPorts = new String[brokerPortList.size()];
                    brokerPortList.toArray(allBrokerPorts);
                }
            }
        }
    }
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) ArrayList(java.util.ArrayList) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 4 with BrokerInfoList

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

the class DatabaseDashboardEditor method loadBrokerInfo.

/**
	 * load broker information
	 */
public void loadBrokerInfo() {
    // if database is stop, do not get data
    if (database.getRunningType() != DbRunningType.CS) {
        return;
    }
    // broker info tasks
    BrokerInfos brokerInfos = new BrokerInfos();
    final CommonQueryTask<BrokerInfos> brokerInfosTask = new CommonQueryTask<BrokerInfos>(database.getServer().getServerInfo(), CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
    new Thread(new Runnable() {

        public void run() {
            brokerInfosTask.execute();
            if (!brokerInfosTask.isSuccess()) {
                brokerInfosTask.finish();
                return;
            }
            Display.getDefault().asyncExec(new Runnable() {

                public void run() {
                    process();
                }
            });
        }

        private void process() {
            asinfoLst.clear();
            brokerInfoListData.clear();
            BrokerInfos brokerInfos = brokerInfosTask.getResultModel();
            if (null != brokerInfos) {
                BrokerInfoList list = brokerInfos.getBorkerInfoList();
                if (list != null && list.getBrokerInfoList() != null) {
                    // all broker
                    List<BrokerInfo> newBrokerInfoList = list.getBrokerInfoList();
                    for (BrokerInfo brokerInfo : newBrokerInfoList) {
                        BrokerStatusInfos brokerStatusInfos = new BrokerStatusInfos();
                        final GetBrokerStatusInfosTask<BrokerStatusInfos> statisTask = new GetBrokerStatusInfosTask<BrokerStatusInfos>(database.getServer().getServerInfo(), CommonSendMsg.getGetBrokerStatusItems(), brokerStatusInfos);
                        statisTask.setBrokerName(brokerInfo.getName());
                        statisTask.execute();
                        brokerStatusInfos = statisTask.getResultModel();
                        if (brokerStatusInfos != null) {
                            //one broker status
                            List<ApplyServerInfo> applyServerInfoList = brokerStatusInfos.getAsinfo();
                            for (ApplyServerInfo applyServerInfo : applyServerInfoList) {
                                if (database.getName().equalsIgnoreCase(applyServerInfo.getAs_dbname())) {
                                    HashMap<String, ApplyServerInfo> valueMap = new HashMap<String, ApplyServerInfo>();
                                    valueMap.put(brokerInfo.getName(), applyServerInfo);
                                    asinfoLst.add(valueMap);
                                }
                            }
                        }
                        statisTask.finish();
                    }
                }
            }
            //set task obejct to table view
            for (HashMap<String, ApplyServerInfo> brokerValueMap : asinfoLst) {
                for (Entry<String, ApplyServerInfo> entry : brokerValueMap.entrySet()) {
                    String brokerName = entry.getKey();
                    ApplyServerInfo applyServerInfo = entry.getValue();
                    Map<String, String> brokerInfoMap = new HashMap<String, String>();
                    brokerInfoMap.put("0", brokerName);
                    brokerInfoMap.put("1", applyServerInfo.getAs_id());
                    brokerInfoMap.put("2", applyServerInfo.getAs_pid());
                    brokerInfoMap.put("3", applyServerInfo.getAs_num_query());
                    brokerInfoMap.put("4", applyServerInfo.getAs_long_query());
                    brokerInfoMap.put("5", applyServerInfo.getAs_status());
                    brokerInfoMap.put("6", applyServerInfo.getAs_lct());
                    brokerInfoListData.add(brokerInfoMap);
                }
            }
            setBrokerInfoData();
            brokerInfosTask.finish();
        }
    }).start();
}
Also used : HashMap(java.util.HashMap) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) ApplyServerInfo(com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo) BrokerStatusInfos(com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos) GetBrokerStatusInfosTask(com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask)

Example 5 with BrokerInfoList

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

the class DBSpaceLabelProvider method loadBrokerData.

public void loadBrokerData() {
    BrokerInfos brokerInfos = new BrokerInfos();
    final CommonQueryTask<BrokerInfos> task = new CommonQueryTask<BrokerInfos>(serverInfo, CommonSendMsg.getCommonSimpleSendMsg(), brokerInfos);
    TaskJobExecutor taskJobExec = new CommonTaskJobExec(new ITaskExecutorInterceptor() {

        public void completeAll() {
            BrokerInfos brokerInfos = task.getResultModel();
            List<BrokerInfo> newBrokerInfoList = null;
            if (null != brokerInfos) {
                BrokerInfoList list = brokerInfos.getBorkerInfoList();
                if (list != null && list.getBrokerInfoList() != null) {
                    newBrokerInfoList = list.getBrokerInfoList();
                }
            }
            setBrokerData(newBrokerInfoList);
            finishedCount++;
            updateToolBar();
        }

        public IStatus postTaskFinished(ITask task) {
            return Status.OK_STATUS;
        }
    });
    taskJobExec.addTask(task);
    String serverName = serverInfo.getServerName();
    String jobName = Messages.taskGetBrokerInfo + serverName;
    JobFamily jobFamily = new JobFamily();
    jobFamily.setServerName(serverName);
    taskJobExec.schedule(jobName, jobFamily, false, Job.SHORT);
}
Also used : TaskJobExecutor(com.cubrid.common.ui.spi.progress.TaskJobExecutor) ITaskExecutorInterceptor(com.cubrid.common.ui.spi.progress.ITaskExecutorInterceptor) ITask(com.cubrid.common.core.task.ITask) IStatus(org.eclipse.core.runtime.IStatus) CommonTaskJobExec(com.cubrid.common.ui.spi.progress.CommonTaskJobExec) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CommonQueryTask(com.cubrid.cubridmanager.core.common.task.CommonQueryTask) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList) List(java.util.List) ArrayList(java.util.ArrayList) DbSpaceInfoList(com.cubrid.cubridmanager.core.cubrid.dbspace.model.DbSpaceInfoList) JobFamily(com.cubrid.common.ui.spi.progress.JobFamily) BrokerInfoList(com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)

Aggregations

BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)16 BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)13 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)11 ArrayList (java.util.ArrayList)7 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)5 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)4 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)4 ApplyServerInfo (com.cubrid.cubridmanager.core.broker.model.ApplyServerInfo)3 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)3 List (java.util.List)3 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 TaskExecutor (com.cubrid.common.ui.spi.progress.TaskExecutor)2 HashMap (java.util.HashMap)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Combo (org.eclipse.swt.widgets.Combo)2 Composite (org.eclipse.swt.widgets.Composite)2 Group (org.eclipse.swt.widgets.Group)2 Label (org.eclipse.swt.widgets.Label)2 Text (org.eclipse.swt.widgets.Text)2