Search in sources :

Example 1 with DeleteBrokerTask

use of com.cubrid.cubridmanager.core.broker.task.DeleteBrokerTask 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

CommonTaskExec (com.cubrid.common.ui.spi.progress.CommonTaskExec)1 ExecTaskWithProgress (com.cubrid.common.ui.spi.progress.ExecTaskWithProgress)1 DeleteBrokerTask (com.cubrid.cubridmanager.core.broker.task.DeleteBrokerTask)1 SetBrokerConfParameterTask (com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask)1 BrokerIntervalSetting (com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSetting)1 BrokerIntervalSettingManager (com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Point (org.eclipse.swt.graphics.Point)1