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;
}
Aggregations