use of com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask 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;
}
use of com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask in project cubrid-manager by CUBRID.
the class UnifyHostConfigUtil method saveBrokerConf.
/**
* save cubrid broker conf
* @param monitor
* @param brokerConfMap
* @param editorInput
* @return failed server
*/
public List<String> saveBrokerConf(IProgressMonitor monitor, LinkedHashMap<String, BrokerConfig> brokerConfMap, CubridServer[] cubridServers) {
List<String> failedServer = new ArrayList<String>();
BrokerConfPersistUtil cubridBrokerConfUtil = new BrokerConfPersistUtil();
for (Entry<String, BrokerConfig> entry : brokerConfMap.entrySet()) {
BrokerConfig cubridBrokerConfig = entry.getValue();
String serverName = entry.getKey();
String contents = cubridBrokerConfUtil.readBrokerConfig(cubridBrokerConfig);
CubridServer cubridServer = getCubridServer(serverName, cubridServers);
if (cubridServer != null) {
monitor.subTask(Messages.bind(Messages.unifyHostConfigEditorSavingDataMsg2, "broker.conf", serverName));
String[] lines = contents.split(System.getProperty("line.separator"));
SetBrokerConfParameterTask task = new SetBrokerConfParameterTask(cubridServer.getServerInfo());
task.setConfContents(Arrays.asList(lines));
task.execute();
if (!task.isSuccess()) {
failedServer.add(cubridServer.getName());
}
task.finish();
monitor.worked(1);
}
}
return failedServer;
}
use of com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask in project cubrid-manager by CUBRID.
the class ConfigParaHelp method performImportBrokerConf.
/**
* Perform the import task for cubrid_broker.conf
*
* @param serverInfo the CubridserverInfo
* @param confParamList the List<String>
*/
public static void performImportBrokerConf(ServerInfo serverInfo, List<String> confParamList) {
CommonTaskExec taskExcutor = new CommonTaskExec(Messages.setBrokerConfParametersTaskName);
SetBrokerConfParameterTask task = new SetBrokerConfParameterTask(serverInfo);
task.setConfContents(confParamList);
taskExcutor.addTask(task);
new ExecTaskWithProgress(taskExcutor).busyCursorWhile();
if (taskExcutor.isSuccess()) {
CommonUITool.openInformationBox(Messages.titleSuccess, Messages.restartBrokerMsg);
task.finish();
}
}
use of com.cubrid.cubridmanager.core.broker.task.SetBrokerConfParameterTask 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