Search in sources :

Example 1 with BrokerIntervalSetting

use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting in project cubrid-manager by CUBRID.

the class BrokersParameterPropertyPage method isSettingChange.

/**
	 * Judge if there is change on interval setting
	 * 
	 * @return <code>true</code> if changed;<code>false</code> otherwise
	 */
private boolean isSettingChange() {
    if (oldIntervalSettingMap.size() != newIntervalSettingMap.size()) {
        return true;
    }
    for (Map.Entry<String, BrokerIntervalSetting> oldEntry : oldIntervalSettingMap.entrySet()) {
        String oldKey = oldEntry.getKey();
        BrokerIntervalSetting oldSetting = oldEntry.getValue();
        BrokerIntervalSetting newSetting = newIntervalSettingMap.get(oldKey);
        if (null == newSetting) {
            return true;
        } else {
            if (oldSetting.isOn() != newSetting.isOn()) {
                return true;
            }
            if (!oldSetting.getInterval().equals(newSetting.getInterval())) {
                return true;
            }
        }
    }
    return false;
}
Also used : Map(java.util.Map) HashMap(java.util.HashMap) BrokerIntervalSetting(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting)

Example 2 with BrokerIntervalSetting

use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting in project cubrid-manager by CUBRID.

the class BrokerParameterDialog method performOk.

/**
	 * Executes tasks
	 */
private void performOk() {
    TableItem[] items = paraTable.getItems();
    for (TableItem item : items) {
        String key = item.getText(0).trim();
        if (key.length() != 0) {
            if (key.equals(ConfConstants.LONG_QUERY_TIME) || key.equals(ConfConstants.LONG_TRANSACTION_TIME)) {
                String newVal = item.getText(2).trim();
                if (isQueryOrTransTimeUseMs) {
                    double dVal = Double.parseDouble(newVal) / 1000;
                    newVal = Double.toString(dVal);
                }
                brokerMap.put(key, newVal);
            } else {
                brokerMap.put(key, item.getText(2).trim());
            }
        }
    }
    brokerMap.put("0", nameTxt.getText().trim());
    brokerMap.put("1", brokerMap.get(ConfConstants.BROKER_PORT));
    String brokerName = nameTxt.getText().trim();
    boolean state = refreshBtn.getSelection();
    String interval = intervalTxt.getText().trim();
    if (null == brokerIntervalSetting) {
        brokerIntervalSetting = new BrokerIntervalSetting();
        brokerIntervalSetting.setBrokerName(brokerName);
    }
    brokerIntervalSetting.setInterval(interval);
    brokerIntervalSetting.setOn(state);
}
Also used : TableItem(org.eclipse.swt.widgets.TableItem) BrokerIntervalSetting(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting)

Example 3 with BrokerIntervalSetting

use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting in project cubrid-manager by CUBRID.

the class BrokerParameterPropertyPage method performOk.

/**
	 * Save the page content
	 * 
	 * @return <code>true</code> if it saved successfully;<code>false</code>
	 *         otherwise
	 */
public boolean performOk() {
    // execute set parameter task
    String[][] brokerParameters = ConfConstants.getBrokerParameters(serverInfo);
    if (isTableChange()) {
        Map<String, String> paraMap = confParaMap.get(node.getLabel());
        //compare the default value, if equal default value and delete it from map
        for (String[] brokerPara : brokerParameters) {
            if (brokerPara[0].equals(ConfConstants.APPL_SERVER_PORT)) {
                String serverPort = paraMap.get(ConfConstants.APPL_SERVER_PORT);
                if (null != serverPort) {
                    int serverPortValue = Integer.parseInt(paraMap.get(ConfConstants.BROKER_PORT)) + 1;
                    if (serverPort.equalsIgnoreCase(Integer.toString(serverPortValue))) {
                        paraMap.remove(ConfConstants.APPL_SERVER_PORT);
                    }
                }
            } else if (brokerPara[0].equals(ConfConstants.LONG_QUERY_TIME)) {
                if (isQueryOrTransTimeUseMs) {
                    int intValue = Integer.parseInt(brokerPara[2]) * 1000;
                    if (Integer.toString(intValue).equals(paraMap.get(ConfConstants.LONG_QUERY_TIME))) {
                        paraMap.remove(ConfConstants.LONG_QUERY_TIME);
                    } else {
                        String sVal = paraMap.get(ConfConstants.LONG_QUERY_TIME);
                        double dVal = Double.parseDouble(sVal) / 1000;
                        paraMap.put(ConfConstants.LONG_QUERY_TIME, String.valueOf(dVal));
                    }
                } else {
                    if (brokerPara[2].equals(paraMap.get(ConfConstants.LONG_QUERY_TIME))) {
                        paraMap.remove(ConfConstants.LONG_QUERY_TIME);
                    }
                }
            } else if (brokerPara[0].equals(ConfConstants.LONG_TRANSACTION_TIME)) {
                if (isQueryOrTransTimeUseMs) {
                    int intValue = Integer.parseInt(brokerPara[2]) * 1000;
                    if (Integer.toString(intValue).equals(paraMap.get(ConfConstants.LONG_TRANSACTION_TIME))) {
                        paraMap.remove(ConfConstants.LONG_TRANSACTION_TIME);
                    } else {
                        String sVal = paraMap.get(ConfConstants.LONG_TRANSACTION_TIME);
                        double dVal = Double.parseDouble(sVal) / 1000;
                        paraMap.put(ConfConstants.LONG_TRANSACTION_TIME, String.valueOf(dVal));
                    }
                } else {
                    if (brokerPara[2].equals(paraMap.get(ConfConstants.LONG_TRANSACTION_TIME))) {
                        paraMap.remove(ConfConstants.LONG_TRANSACTION_TIME);
                    }
                }
            } else if (brokerPara[2].equals(paraMap.get(brokerPara[0]))) {
                paraMap.remove(brokerPara[0]);
            }
        }
        SetBrokerConfParameterTask setBrokerConfParameterTask = new SetBrokerConfParameterTask(serverInfo);
        setBrokerConfParameterTask.setConfParameters(confParaMap);
        String taskName = Messages.bind(Messages.setBrokerConfParameterTaskName, this.node.getName());
        CommonTaskExec taskExec = new CommonTaskExec(taskName);
        taskExec.addTask(setBrokerConfParameterTask);
        new ExecTaskWithProgress(taskExec).exec();
        if (taskExec.isSuccess()) {
            CommonUITool.openInformationBox(com.cubrid.cubridmanager.ui.common.Messages.titleSuccess, Messages.restartBrokerMsg);
        } else {
            return true;
        }
    }
    // refresh tap
    if (isSettingChange()) {
        boolean isOn = refreshBtn.getSelection();
        String interval = intervalTxt.getText();
        String serverName = node.getServer().getLabel();
        String nodeName = node.getLabel();
        BrokerIntervalSetting newSetting = new BrokerIntervalSetting(serverName, nodeName, interval, isOn);
        BrokerIntervalSettingManager manager = BrokerIntervalSettingManager.getInstance();
        manager.removeBrokerIntervalSetting(serverName, brokerName);
        manager.setBrokerInterval(newSetting);
    }
    return true;
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) BrokerIntervalSettingManager(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) SetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask) BrokerIntervalSetting(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting)

Example 4 with BrokerIntervalSetting

use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting in project cubrid-manager by CUBRID.

the class BrokersParameterPropertyPage method initial.

/**
	 * Initializes the parameters of this dialog
	 */
private void initial() {
    oldConfParaMap = node.getServer().getServerInfo().getBrokerConfParaMap();
    Map<String, String> map = null;
    if (oldConfParaMap != null) {
        map = oldConfParaMap.get(ConfConstants.BROKER_SECTION_NAME);
    }
    if (map != null) {
        Iterator<Map.Entry<String, String>> it = map.entrySet().iterator();
        Map<String, String> defaultMap = new HashMap<String, String>();
        defaultValueMap.put(ConfConstants.BROKER_SECTION_NAME, defaultMap);
        while (it.hasNext()) {
            Map.Entry<String, String> entry = it.next();
            defaultMap.put(entry.getKey(), entry.getValue());
        }
        if (null == defaultMap.get(ConfConstants.MASTER_SHM_ID)) {
            masterShmIdTxt.setText("");
        } else {
            masterShmIdTxt.setText(defaultMap.get(ConfConstants.MASTER_SHM_ID));
        }
        if (null == defaultMap.get(ConfConstants.ADMIN_LOG_FILE)) {
            adminlogTxt.setText("");
        } else {
            adminlogTxt.setText(defaultMap.get(ConfConstants.ADMIN_LOG_FILE));
        }
        if (isSupportEnableAccessControl) {
            if (null == defaultMap.get(ConfConstants.ENABLE_ACCESS_CONTROL)) {
                enableAccessControlCombo.select(1);
            } else {
                enableAccessControlCombo.setText(defaultMap.get(ConfConstants.ENABLE_ACCESS_CONTROL));
            }
            if (null == defaultMap.get(ConfConstants.ACCESS_CONTROL_FILE)) {
                accessControlFileTxt.setText("");
            } else {
                accessControlFileTxt.setText(defaultMap.get(ConfConstants.ACCESS_CONTROL_FILE));
            }
        }
    }
    brokerList = new ArrayList<Map<String, String>>();
    if (oldConfParaMap == null) {
        return;
    }
    // set the broker list
    String[][] supportedBrokerParams = ConfConstants.getBrokerParameters(serverInfo);
    for (Map.Entry<String, Map<String, String>> brokerPara : oldConfParaMap.entrySet()) {
        if (brokerPara.getKey().equals(ConfConstants.BROKER_SECTION_NAME)) {
            continue;
        }
        String name = brokerPara.getKey();
        Map<String, String> pair = brokerPara.getValue();
        String port = pair.get(ConfConstants.BROKER_PORT);
        Map<String, String> dataMap = new HashMap<String, String>();
        dataMap.put("0", name);
        dataMap.put("1", port);
        for (int i = 0; i < supportedBrokerParams.length; i++) {
            String paramKey = supportedBrokerParams[i][0];
            String value = pair.get(paramKey);
            dataMap.put(paramKey, value);
        }
        brokerList.add(dataMap);
    }
    brokersTableViewer.setInput(brokerList);
    // initialize refresh
    BrokerIntervalSettingManager manager = BrokerIntervalSettingManager.getInstance();
    serverName = node.getServer().getLabel();
    brokerEnvName = node.getLabel();
    BrokerIntervalSetting setting = manager.getBrokerIntervalSetting(serverName, brokerEnvName);
    oldIntervalSettingMap = new HashMap<String, BrokerIntervalSetting>();
    newIntervalSettingMap = new HashMap<String, BrokerIntervalSetting>();
    if (null != setting) {
        boolean isOn = setting.isOn();
        refreshBtn.setSelection(isOn);
        intervalTxt.setText(setting.getInterval());
        intervalTxt.setEnabled(isOn);
        oldIntervalSettingMap.put(serverName + "_" + brokerEnvName, setting);
    }
    for (Map<String, String> dataMap : brokerList) {
        String brokername = dataMap.get("0");
        setting = manager.getBrokerIntervalSetting(serverName, brokername);
        if (null != setting) {
            oldIntervalSettingMap.put(serverName + "_" + brokername, setting);
        }
    }
    for (Map.Entry<String, BrokerIntervalSetting> entry : oldIntervalSettingMap.entrySet()) {
        String aSettingName = entry.getKey();
        BrokerIntervalSetting aSetting = new BrokerIntervalSetting();
        String aBrokerName = entry.getValue().getBrokerName();
        String aServerName = entry.getValue().getServerName();
        String aInterval = entry.getValue().getInterval();
        boolean aOn = entry.getValue().isOn();
        aSetting.setBrokerName(aBrokerName);
        aSetting.setServerName(aServerName);
        aSetting.setInterval(aInterval);
        aSetting.setOn(aOn);
        newIntervalSettingMap.put(aSettingName, aSetting);
    }
    // add Listener
    refreshBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            BrokerIntervalSetting brokerEnvSetting = newIntervalSettingMap.get(serverName + "_" + brokerEnvName);
            if (refreshBtn.getSelection()) {
                intervalTxt.setEnabled(true);
                brokerEnvSetting.setOn(true);
            } else {
                intervalTxt.setEnabled(false);
                brokerEnvSetting.setOn(false);
            }
        }
    });
    intervalTxt.addVerifyListener(new VerifyListener() {

        public void verifyText(VerifyEvent event) {
            if (!"".equals(event.text) && !ValidateUtil.isNumber(event.text)) {
                event.doit = false;
                return;
            }
        }
    });
    intervalTxt.addModifyListener(new ModifyListener() {

        public void modifyText(ModifyEvent event) {
            String newInterval = intervalTxt.getText().trim();
            BrokerIntervalSetting brokerEnvSetting = newIntervalSettingMap.get(serverName + "_" + brokerEnvName);
            brokerEnvSetting.setInterval(newInterval);
        }
    });
}
Also used : BrokerIntervalSettingManager(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager) VerifyListener(org.eclipse.swt.events.VerifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) HashMap(java.util.HashMap) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Point(org.eclipse.swt.graphics.Point) BrokerIntervalSetting(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting) ModifyEvent(org.eclipse.swt.events.ModifyEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Map(java.util.Map) HashMap(java.util.HashMap) VerifyEvent(org.eclipse.swt.events.VerifyEvent)

Example 5 with BrokerIntervalSetting

use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting in project cubrid-manager by CUBRID.

the class BrokersParameterPropertyPage method performOk.

/**
	 * Save the page content
	 * 
	 * @return <code>true</code> if it saved successfully;<code>false</code>
	 *         otherwise
	 */
public boolean performOk() {
    if (adminlogTxt == null || adminlogTxt.isDisposed()) {
        return true;
    }
    // execute delete broker task
    if (isTableChange()) {
        CommonTaskExec taskExec = new CommonTaskExec(Messages.setBrokerConfParametersTaskName);
        for (String bname : deletedBrokerLst) {
            DeleteBrokerTask task = new DeleteBrokerTask(serverInfo);
            task.setBrokerName(bname);
            taskExec.addTask(task);
        }
        //remove the default value
        String[][] brokerParameters = ConfConstants.getBrokerParameters(serverInfo);
        for (Map.Entry<String, Map<String, String>> entry : newConfParaMap.entrySet()) {
            Map<String, String> paraMap = entry.getValue();
            for (String[] brokerPara : brokerParameters) {
                if (brokerPara[0].equals(ConfConstants.APPL_SERVER_PORT)) {
                    String port = paraMap.get(ConfConstants.BROKER_PORT);
                    if (null != port) {
                        int serverPortValue = Integer.parseInt(paraMap.get(ConfConstants.BROKER_PORT)) + 1;
                        String serverPort = paraMap.get(ConfConstants.APPL_SERVER_PORT);
                        if (serverPort.equalsIgnoreCase(Integer.toString(serverPortValue))) {
                            paraMap.remove(ConfConstants.APPL_SERVER_PORT);
                        }
                    }
                } else if (ConfConstants.isDefaultBrokerParameter(brokerPara[0]) && brokerPara[2].equals(paraMap.get(brokerPara[0]))) {
                    paraMap.remove(brokerPara[0]);
                }
            }
        }
        // execute set parameter task
        SetBrokerConfParameterTask setBrokerConfParameterTask = new SetBrokerConfParameterTask(serverInfo);
        setBrokerConfParameterTask.setConfParameters(newConfParaMap);
        taskExec.addTask(setBrokerConfParameterTask);
        new ExecTaskWithProgress(taskExec).exec();
        if (taskExec.isSuccess()) {
            CommonUITool.openInformationBox(Messages.titleSuccess, RESTART_BROKER_MSG);
        }
    }
    // refresh tap
    if (isSettingChange()) {
        boolean isOn = refreshBtn.getSelection();
        String interval = intervalTxt.getText().trim();
        String serverName = node.getServer().getLabel();
        String nodeName = node.getLabel();
        BrokerIntervalSetting setting = new BrokerIntervalSetting(serverName, nodeName, interval, isOn);
        newIntervalSettingMap.put(serverName + "_" + brokerEnvName, setting);
        BrokerIntervalSettingManager manager = BrokerIntervalSettingManager.getInstance();
        for (Map.Entry<String, BrokerIntervalSetting> entry : oldIntervalSettingMap.entrySet()) {
            String brokerName = entry.getValue().getBrokerName();
            manager.removeBrokerIntervalSetting(serverName, brokerName);
        }
        for (Map.Entry<String, BrokerIntervalSetting> entry : newIntervalSettingMap.entrySet()) {
            BrokerIntervalSetting newSetting = entry.getValue();
            manager.setBrokerInterval(newSetting);
        }
    }
    return true;
}
Also used : CommonTaskExec(com.cubrid.common.ui.spi.progress.CommonTaskExec) BrokerIntervalSettingManager(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager) Point(org.eclipse.swt.graphics.Point) BrokerIntervalSetting(com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting) DeleteBrokerTask(com.cubrid.cubridmanager.core.broker.task.DeleteBrokerTask) ExecTaskWithProgress(com.cubrid.common.ui.spi.progress.ExecTaskWithProgress) Map(java.util.Map) HashMap(java.util.HashMap) SetBrokerConfParameterTask(com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask)

Aggregations

BrokerIntervalSetting (com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting)5 BrokerIntervalSettingManager (com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)2 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)2 SetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask)2 Point (org.eclipse.swt.graphics.Point)2 DeleteBrokerTask (com.cubrid.cubridmanager.core.broker.task.DeleteBrokerTask)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 VerifyEvent (org.eclipse.swt.events.VerifyEvent)1 VerifyListener (org.eclipse.swt.events.VerifyListener)1 TableItem (org.eclipse.swt.widgets.TableItem)1