Search in sources :

Example 6 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos 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 7 with BrokerInfos

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

the class ExecuteSqlLogAction method run.

/**
	 * Open dialog
	 */
public void run() {
    Object[] obj = this.getSelectedObj();
    DefaultCubridNode node = null;
    LogInfo logInfo = null;
    node = (DefaultCubridNode) obj[0];
    String targetBroker = node.getParent().getParent().getLabel();
    logInfo = (LogInfo) node.getAdapter(LogInfo.class);
    List<String> allDatabaseList = node.getServer().getServerInfo().getAllDatabaseList();
    BrokerInfos brokerInfos = node.getServer().getServerInfo().getBrokerInfos();
    CasRunnerConfigDialog casRunnerConfigDialog = new CasRunnerConfigDialog(getShell());
    casRunnerConfigDialog.setBrokerInfos(brokerInfos);
    casRunnerConfigDialog.setAllDatabaseList(allDatabaseList);
    casRunnerConfigDialog.setLogInfo(logInfo);
    casRunnerConfigDialog.setTargetBroker(targetBroker);
    casRunnerConfigDialog.setExecwithFile(true);
    casRunnerConfigDialog.create();
    if (casRunnerConfigDialog.open() == Dialog.OK) {
        final GetExecuteCasRunnerResultTask task = new GetExecuteCasRunnerResultTask(((DefaultCubridNode) obj[0]).getServer().getServerInfo());
        task.setBrokerName(CasRunnerConfigDialog.getBrokerName());
        task.setUserName(CasRunnerConfigDialog.getUserName());
        task.setPasswd(CasRunnerConfigDialog.getPassword());
        task.setNumThread(CasRunnerConfigDialog.getNumThread());
        task.setRepeatCount(casRunnerConfigDialog.getNumRepeatCount());
        String isShowqueryresult = "";
        if (casRunnerConfigDialog.isShowqueryresult()) {
            isShowqueryresult = "yes";
        } else {
            isShowqueryresult = "no";
        }
        task.setShowQueryResult(isShowqueryresult);
        String isShowqueryplan = "";
        if (casRunnerConfigDialog.isShowqueryplan()) {
            isShowqueryplan = "yes";
        } else {
            isShowqueryplan = "no";
        }
        task.setShowQueryResult(isShowqueryplan);
        task.setDbName(CasRunnerConfigDialog.getDbname());
        task.setExecuteLogFile("yes");
        task.setLogFile(logInfo.getPath());
        TaskExecutor taskExcutor = new CommonTaskExec(Messages.loadSqlLogExecResultTaskName);
        taskExcutor.addTask(task);
        new ExecTaskWithProgress(taskExcutor).exec();
        if (!taskExcutor.isSuccess()) {
            return;
        }
        GetExecuteCasRunnerResultInfo getExecuteCasRunnerResultInfo = (GetExecuteCasRunnerResultInfo) task.getContent();
        StringBuffer result = new StringBuffer("");
        if (getExecuteCasRunnerResultInfo.getResult() != null) {
            for (int i = 0, n = getExecuteCasRunnerResultInfo.getResult().size(); i < n; i++) {
                result.append(getExecuteCasRunnerResultInfo.getResult().get(i) + "\n");
            }
        }
        CasRunnerResultDialog casRunnerResultDialog = new CasRunnerResultDialog(getShell());
        casRunnerResultDialog.setResult(result);
        casRunnerResultDialog.open();
    }
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) DefaultCubridNode(com.cubrid.common.ui.spi.model.DefaultCubridNode) LogInfo(com.cubrid.cubridmanager.core.logs.model.LogInfo) GetExecuteCasRunnerResultInfo(com.cubrid.cubridmanager.core.logs.model.GetExecuteCasRunnerResultInfo) BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) CasRunnerConfigDialog(com.cubrid.cubridmanager.ui.logs.dialog.CasRunnerConfigDialog) CasRunnerResultDialog(com.cubrid.cubridmanager.ui.logs.dialog.CasRunnerResultDialog) TaskExecutor(com.cubrid.common.ui.spi.progress.TaskExecutor) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) GetExecuteCasRunnerResultTask(com.cubrid.cubridmanager.core.logs.task.GetExecuteCasRunnerResultTask)

Example 8 with BrokerInfos

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

the class LoginQueryEditDialog method fillBrokerPortCombo.

/**
	 * 
	 * Fill in the broker port combo
	 * 
	 * @param serverName the server name
	 */
private void fillBrokerPortCombo(String serverName) {
    CubridServer cubridServer = serverMap.get(serverName);
    BrokerInfos brokerInfos = cubridServer.getServerInfo().getBrokerInfos();
    if (brokerInfos != null && brokerInfos.getBorkerInfoList() != null && brokerInfos.getBorkerInfoList().getBrokerInfoList() != null) {
        List<BrokerInfo> brokerList = brokerInfos.getBorkerInfoList().getBrokerInfoList();
        Combo brokerPortCombo = connectionComp.getBrokerPortCombo();
        brokerPortCombo.removeAll();
        for (int i = 0; i < brokerList.size(); i++) {
            brokerPortCombo.add(brokerList.get(i).getPort());
        }
        if (!brokerList.isEmpty()) {
            brokerPortCombo.select(0);
        }
    }
}
Also used : BrokerInfos(com.cubrid.cubridmanager.core.broker.model.BrokerInfos) Combo(org.eclipse.swt.widgets.Combo) CubridServer(com.cubrid.common.ui.spi.model.CubridServer) BrokerInfo(com.cubrid.cubridmanager.core.broker.model.BrokerInfo)

Example 9 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos 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 10 with BrokerInfos

use of com.cubrid.cubridmanager.core.broker.model.BrokerInfos 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)

Aggregations

BrokerInfos (com.cubrid.cubridmanager.core.broker.model.BrokerInfos)30 BrokerInfo (com.cubrid.cubridmanager.core.broker.model.BrokerInfo)16 BrokerInfoList (com.cubrid.cubridmanager.core.broker.model.BrokerInfoList)13 CommonQueryTask (com.cubrid.cubridmanager.core.common.task.CommonQueryTask)12 ArrayList (java.util.ArrayList)9 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 List (java.util.List)7 ServerUserInfo (com.cubrid.cubridmanager.core.common.model.ServerUserInfo)6 ITask (com.cubrid.common.core.task.ITask)5 BrokerStatusInfos (com.cubrid.cubridmanager.core.broker.model.BrokerStatusInfos)5 GetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerConfParameterTask)5 GetBrokerStatusInfosTask (com.cubrid.cubridmanager.core.broker.task.GetBrokerStatusInfosTask)5 GetCMConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCMConfParameterTask)5 GetCMUserListTask (com.cubrid.cubridmanager.core.common.task.GetCMUserListTask)5 GetCubridConfParameterTask (com.cubrid.cubridmanager.core.common.task.GetCubridConfParameterTask)5 GetEnvInfoTask (com.cubrid.cubridmanager.core.common.task.GetEnvInfoTask)5 MonitoringTask (com.cubrid.cubridmanager.core.common.task.MonitoringTask)5 UpdateCMUserTask (com.cubrid.cubridmanager.core.common.task.UpdateCMUserTask)5 DatabaseInfo (com.cubrid.cubridmanager.core.cubrid.database.model.DatabaseInfo)5 GetDatabaseListTask (com.cubrid.cubridmanager.core.cubrid.database.task.GetDatabaseListTask)5