From 1278ad8c34154e7260a7dca6e5206cfe469c0a86 Mon Sep 17 00:00:00 2001 From: enesakar Date: Wed, 2 May 2012 11:04:47 +0300 Subject: [PATCH] enable/disable change mancenter url --- .../config/ConfigurationProperties.xml | 8 ++++++ .../com/hazelcast/impl/GroupProperties.java | 4 +++ .../ascii/rest/HttpPostCommandProcessor.java | 25 +++++++++++-------- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/hazelcast-documentation/src/main/docbook/manual/content/config/ConfigurationProperties.xml b/hazelcast-documentation/src/main/docbook/manual/content/config/ConfigurationProperties.xml index 6c20cc88fa38..73d7f52e424c 100755 --- a/hazelcast-documentation/src/main/docbook/manual/content/config/ConfigurationProperties.xml +++ b/hazelcast-documentation/src/main/docbook/manual/content/config/ConfigurationProperties.xml @@ -485,6 +485,14 @@ cfg.setProperty("hazelcast.property.foo", "value"); integer 100 + + + hazelcast.mc.url.change.enabled + + Management Center changing server url is enabled + boolean + true + hazelcast.elastic.memory.enabled diff --git a/hazelcast/src/main/java/com/hazelcast/impl/GroupProperties.java b/hazelcast/src/main/java/com/hazelcast/impl/GroupProperties.java index e4305d7aa06c..851338326aa8 100644 --- a/hazelcast/src/main/java/com/hazelcast/impl/GroupProperties.java +++ b/hazelcast/src/main/java/com/hazelcast/impl/GroupProperties.java @@ -72,6 +72,7 @@ public class GroupProperties { public static final String PROP_MC_SEMAPHORE_EXCLUDES = "hazelcast.mc.semaphore.excludes"; public static final String PROP_MC_TOPIC_EXCLUDES = "hazelcast.mc.topic.excludes"; public static final String PROP_MC_MAX_VISIBLE_INSTANCE_COUNT = "hazelcast.mc.max.visible.instance.count"; + public static final String PROP_MC_URL_CHANGE_ENABLED = "hazelcast.mc.url.change.enabled"; public static final String PROP_CONCURRENT_MAP_SIMPLE_RECORD = "hazelcast.map.simple.record"; public static final String PROP_CONNECTION_MONITOR_INTERVAL = "hazelcast.connection.monitor.interval"; public static final String PROP_CONNECTION_MONITOR_MAX_FAULTS = "hazelcast.connection.monitor.max.faults"; @@ -189,6 +190,8 @@ public class GroupProperties { public final GroupProperty MC_MAX_INSTANCE_COUNT; + public final GroupProperty MC_URL_CHANGE_ENABLED; + public final GroupProperty CONCURRENT_MAP_SIMPLE_RECORD; public final GroupProperty CONNECTION_MONITOR_INTERVAL; @@ -263,6 +266,7 @@ public GroupProperties(Config config) { MC_SEMAPHORE_EXCLUDES = new GroupProperty(config, PROP_MC_SEMAPHORE_EXCLUDES, null); MC_TOPIC_EXCLUDES = new GroupProperty(config, PROP_MC_TOPIC_EXCLUDES, null); MC_MAX_INSTANCE_COUNT = new GroupProperty(config, PROP_MC_MAX_VISIBLE_INSTANCE_COUNT, "100"); + MC_URL_CHANGE_ENABLED = new GroupProperty(config, PROP_MC_URL_CHANGE_ENABLED, "true"); CONCURRENT_MAP_SIMPLE_RECORD = new GroupProperty(config, PROP_CONCURRENT_MAP_SIMPLE_RECORD, "false"); CONNECTION_MONITOR_INTERVAL = new GroupProperty(config, PROP_CONNECTION_MONITOR_INTERVAL, "100"); CONNECTION_MONITOR_MAX_FAULTS = new GroupProperty(config, PROP_CONNECTION_MONITOR_MAX_FAULTS, "3"); diff --git a/hazelcast/src/main/java/com/hazelcast/impl/ascii/rest/HttpPostCommandProcessor.java b/hazelcast/src/main/java/com/hazelcast/impl/ascii/rest/HttpPostCommandProcessor.java index 2e8bfcd9797f..359149200eaf 100644 --- a/hazelcast/src/main/java/com/hazelcast/impl/ascii/rest/HttpPostCommandProcessor.java +++ b/hazelcast/src/main/java/com/hazelcast/impl/ascii/rest/HttpPostCommandProcessor.java @@ -40,18 +40,23 @@ public void handle(HttpPostCommand command) { textCommandService.put(mapName, key, new RestValue(data, command.getContentType()), 0); command.setResponse(HttpCommand.RES_204); } else if (uri.startsWith(URI_MANCENTER_CHANGE_URL)) { - byte[] res = null; - byte[] data = command.getData(); - String[] strList = new String(data).split("&"); - String cluster = URLDecoder.decode(strList[0], "UTF-8"); - String pass = URLDecoder.decode(strList[1], "UTF-8"); - String url = URLDecoder.decode(strList[2], "UTF-8"); + if (textCommandService.getNode().getGroupProperties().MC_URL_CHANGE_ENABLED.getBoolean()) { + byte[] res = null; + byte[] data = command.getData(); + String[] strList = new String(data).split("&"); + String cluster = URLDecoder.decode(strList[0], "UTF-8"); + String pass = URLDecoder.decode(strList[1], "UTF-8"); + String url = URLDecoder.decode(strList[2], "UTF-8"); - ManagementCenterService managementCenterService = textCommandService.getNode().getManagementCenterService(); - if (managementCenterService != null) { - res = managementCenterService.changeWebServerUrlOverCluster(cluster, pass, url); + ManagementCenterService managementCenterService = textCommandService.getNode().getManagementCenterService(); + if (managementCenterService != null) { + res = managementCenterService.changeWebServerUrlOverCluster(cluster, pass, url); + } + command.setResponse(res); + } + else { + command.setResponse(HttpCommand.RES_503); } - command.setResponse(res); } else if (uri.startsWith(URI_QUEUES)) { String queueName = null; String simpleValue = null;