use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager in project cubrid-manager by CUBRID.
the class BrokerParameterPropertyPage method initialize.
/**
* Initialize the value of all controls
*/
private void initialize() {
String serverName = node.getServer().getLabel();
// if need
brokerName = node.getLabel().toLowerCase();
// initialize table
confParaMap = node.getParent().getServer().getServerInfo().getBrokerConfParaMap();
brokerMap = confParaMap.get(brokerName);
List<Map<String, String>> parameterList = getParameterList();
paraTableViewer.setInput(parameterList);
for (int k = 0; k < paraTable.getItemCount(); k++) {
if (parameterList.get(k).get("bgColor").equalsIgnoreCase("grey")) {
paraTable.getItem(k).setBackground(ResourceManager.getColor(200, 200, 200));
}
}
for (int i = 0; i < paraTable.getColumnCount(); i++) {
paraTable.getColumn(i).pack();
}
if (userInfo.getCasAuth() == CasAuthType.AUTH_ADMIN) {
linkEditorForTable();
}
// initialize refresh
BrokerIntervalSettingManager manager = BrokerIntervalSettingManager.getInstance();
setting = manager.getBrokerIntervalSetting(serverName, brokerName);
boolean state = setting.isOn();
String interval = setting.getInterval();
if (state) {
refreshBtn.setSelection(true);
intervalTxt.setEnabled(true);
intervalTxt.setText(interval);
} else {
refreshBtn.setSelection(false);
intervalTxt.setEnabled(false);
}
}
use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager 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.ui.broker.editor.internal.BrokerIntervalSettingManager 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);
}
});
}
use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager in project cubrid-manager by CUBRID.
the class EditHostAction method doRun.
/**
* Perform do run
*
* @param obj
*/
public void doRun(CubridServer[] servers, boolean actionIsConnect) {
//multi edit
if (servers.length > 1) {
MultiHostEditDialog dialog = new MultiHostEditDialog(getShell(), Arrays.asList(servers));
if (dialog.open() != MultiHostEditDialog.SAVE_ID) {
return;
}
BrokerIntervalSettingManager brokerManager = BrokerIntervalSettingManager.getInstance();
//new server infolist
List<CubridServer> newServerInfoList = dialog.getNewServerList();
for (int i = 0; i < servers.length; i++) {
CubridServer newServer = newServerInfoList.get(i);
CubridServer server = servers[i];
if (server == null) {
continue;
}
// if the server is not changed, ignore it.
if (!checkServerChanges(newServer, server)) {
continue;
}
ServerInfo oldServerInfo = server.getServerInfo();
if (oldServerInfo == null) {
LOGGER.error("oldServerInfo is null.");
continue;
}
ServerInfo newServerInfo = newServer.getServerInfo();
if (newServerInfo == null) {
LOGGER.error("newServerInfo is null.");
continue;
}
if (!newServerInfo.getServerName().equals(server.getLabel())) {
QueryOptions.removePref(server.getServerInfo());
brokerManager.removeAllBrokerIntervalSettingInServer(server.getLabel());
}
if (oldServerInfo.isConnected()) {
HostUtils.processHostDisconnected(server);
}
server.setAutoSavePassword(newServer.isAutoSavePassword());
server.getServerInfo().setServerName(newServerInfo.getServerName());
server.getServerInfo().setHostAddress(newServerInfo.getHostAddress());
server.getServerInfo().setHostMonPort(newServerInfo.getHostMonPort());
server.getServerInfo().setJdbcDriverVersion(newServerInfo.getJdbcDriverVersion());
server.getServerInfo().setUserName(newServerInfo.getUserName());
if (newServer.isAutoSavePassword()) {
server.getServerInfo().setUserPassword(newServerInfo.getUserPassword());
} else {
server.getServerInfo().setUserPassword(null);
}
server.setId(newServerInfo.getServerName());
server.setLabel(newServerInfo.getServerName());
CMHostNodePersistManager.getInstance().addServer(newServerInfo.getHostAddress(), newServerInfo.getHostMonPort(), newServerInfo.getUserName(), newServerInfo);
CMGroupNodePersistManager.getInstance().saveAllGroupNode();
CMHostNodePersistManager.getInstance().saveServers();
if (server.getLoader() != null) {
server.getLoader().setLoaded(false);
}
CubridWorkbenchContrItem.closeAllEditorAndViewInServer(server, false);
CubridNavigatorView navigatorView = CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (navigatorView != null) {
navigatorView.getViewer().refresh(server, true);
}
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_DISCONNECTED));
}
return;
}
// single edit
HostDialog dialog = new HostDialog(getShell(), false, actionIsConnect);
CubridServer server = null;
try {
server = servers[0];
//read it from hostgroup preference first
if (server.getParent() == null) {
CMGroupNodePersistManager.getInstance();
}
} catch (ClassCastException cce) {
CubridGroupNode node = (CubridGroupNode) getSelectedObj()[0];
for (ICubridNode icNode : node.getChildren()) {
if (icNode instanceof CubridServer) {
if (!((CubridServer) icNode).isConnected())
server = (CubridServer) icNode;
}
}
}
ServerInfo oldServerInfo = server.getServerInfo();
if (oldServerInfo == null) {
LOGGER.error("oldServerInfo is null.");
return;
}
dialog.setServer(server);
int returnCode = dialog.open();
if (returnCode != HostDialog.SAVE_ID && returnCode != HostDialog.CONNECT_ID) {
return;
}
// Save the server info
ServerInfo serverInfo = dialog.getServerInfo();
if (serverInfo == null) {
LOGGER.error("serverInfo is null.");
return;
}
if (!serverInfo.getServerName().equals(server.getLabel())) {
QueryOptions.removePref(server.getServerInfo());
BrokerIntervalSettingManager.getInstance().removeAllBrokerIntervalSettingInServer(server.getLabel());
}
if (oldServerInfo.isConnected() && !oldServerInfo.equals(serverInfo)) {
HostUtils.processHostDisconnected(server);
}
server.setId(serverInfo.getServerName());
server.setLabel(serverInfo.getServerName());
server.setServerInfo(serverInfo);
server.setAutoSavePassword(dialog.isSavePassword());
CMHostNodePersistManager.getInstance().addServer(serverInfo.getHostAddress(), serverInfo.getHostMonPort(), serverInfo.getUserName(), serverInfo);
// Refresh the tree node
if (returnCode == HostDialog.CONNECT_ID) {
ISelectionProvider provider = getSelectionProvider();
if (provider instanceof TreeViewer) {
server.removeAllChild();
if (server.getLoader() != null) {
server.getLoader().setLoaded(false);
}
TreeViewer treeViewer = (TreeViewer) provider;
treeViewer.refresh(server, true);
treeViewer.expandToLevel(server, 1);
treeViewer.setSelection(null, true);
treeViewer.setSelection(new StructuredSelection(server), true);
setEnabled(false);
}
}
CMGroupNodePersistManager.getInstance().saveAllGroupNode();
CMHostNodePersistManager.getInstance().saveServers();
ActionManager.getInstance().fireSelectionChanged(getSelection());
LayoutManager.getInstance().fireSelectionChanged(getSelection());
CubridNodeManager.getInstance().fireCubridNodeChanged(new CubridNodeChangedEvent(server, CubridNodeChangedEventType.SERVER_CONNECTED));
}
use of com.cubrid.cubridmanager.ui.broker.editor.internal.BrokerIntervalSettingManager 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