You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by hu...@apache.org on 2020/03/11 20:25:59 UTC
[helix] branch master updated: Standardize the logging message
format in ClusterAccessor and ConfigAccessor (#886)
This is an automated email from the ASF dual-hosted git repository.
hulee pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/helix.git
The following commit(s) were added to refs/heads/master by this push:
new 1651f9e Standardize the logging message format in ClusterAccessor and ConfigAccessor (#886)
1651f9e is described below
commit 1651f9edddb86118834c7a1f47f47ed9f5a300ee
Author: Molly Gao <31...@users.noreply.github.com>
AuthorDate: Wed Mar 11 13:25:50 2020 -0700
Standardize the logging message format in ClusterAccessor and ConfigAccessor (#886)
This PR takes advantage of parameterized message provided by slf4j to form logging messages in ClusterAccessor and ConfigAccessor. The parameterized message gives a clear syntax than simply concatenating the strings and variables.
---
.../main/java/org/apache/helix/ConfigAccessor.java | 54 +++--
.../server/resources/helix/ClusterAccessor.java | 242 +++++++++++----------
2 files changed, 150 insertions(+), 146 deletions(-)
diff --git a/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java b/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
index b5f06ef..1596ee3 100644
--- a/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
@@ -44,6 +44,7 @@ import org.apache.helix.zookeeper.impl.factory.SharedZkClientFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* Provides access to the persistent configuration of the cluster, the instances that live on it,
* and the logical resources assigned to it.
@@ -52,6 +53,7 @@ public class ConfigAccessor {
private static Logger LOG = LoggerFactory.getLogger(ConfigAccessor.class);
private static final StringTemplate template = new StringTemplate();
+
static {
// @formatter:off
template.addEntry(ConfigScopeProperty.CLUSTER, 1, "/{clusterName}/CONFIGS/CLUSTER");
@@ -94,9 +96,9 @@ public class ConfigAccessor {
* @param zkAddress
*/
public ConfigAccessor(String zkAddress) {
- _zkClient = SharedZkClientFactory.getInstance().buildZkClient(
- new HelixZkClient.ZkConnectionConfig(zkAddress),
- new HelixZkClient.ZkClientConfig().setZkSerializer(new ZNRecordSerializer()));
+ _zkClient = SharedZkClientFactory.getInstance()
+ .buildZkClient(new HelixZkClient.ZkConnectionConfig(zkAddress),
+ new HelixZkClient.ZkClientConfig().setZkSerializer(new ZNRecordSerializer()));
_usesExternalZkClient = false;
}
@@ -157,7 +159,6 @@ public class ConfigAccessor {
}
}
return map;
-
}
/**
@@ -184,13 +185,13 @@ public class ConfigAccessor {
*/
public Map<String, String> get(HelixConfigScope scope, List<String> keys) {
if (scope == null || scope.getType() == null || !scope.isFullKey()) {
- LOG.error("fail to get configs. invalid config scope. scope: " + scope + ", keys: " + keys);
+ LOG.error("fail to get configs. invalid config scope. scope: {}, keys: {}.", scope, keys);
return null;
}
ZNRecord record = getConfigZnRecord(scope);
if (record == null) {
- LOG.warn("No config found at " + scope.getZkPath());
+ LOG.warn("No config found at {}.", scope.getZkPath());
return null;
}
@@ -205,7 +206,7 @@ public class ConfigAccessor {
} else {
Map<String, String> configMap = record.getMapField(mapKey);
if (configMap == null) {
- LOG.warn("No map-field found in " + record + " using mapKey: " + mapKey);
+ LOG.warn("No map-field found in {} using mapKey: {}.", record, mapKey);
return null;
}
@@ -251,7 +252,7 @@ public class ConfigAccessor {
@Deprecated
public void set(ConfigScope scope, Map<String, String> keyValueMap) {
if (scope == null || scope.getScope() == null) {
- LOG.error("Scope can't be null");
+ LOG.error("Scope can't be null.");
return;
}
@@ -265,8 +266,8 @@ public class ConfigAccessor {
String instanceName = scopeStr.substring(scopeStr.lastIndexOf('/') + 1);
if (!ZKUtil.isInstanceSetup(_zkClient, scope.getClusterName(), instanceName,
InstanceType.PARTICIPANT)) {
- throw new HelixException("instance: " + instanceName + " is NOT setup in cluster: "
- + clusterName);
+ throw new HelixException(
+ "instance: " + instanceName + " is NOT setup in cluster: " + clusterName);
}
}
@@ -314,7 +315,7 @@ public class ConfigAccessor {
*/
public void set(HelixConfigScope scope, Map<String, String> keyValueMap) {
if (scope == null || scope.getType() == null || !scope.isFullKey()) {
- LOG.error("fail to set config. invalid config scope. scope: {}", scope);
+ LOG.error("fail to set config. invalid config scope. Scope: {}.", scope);
return;
}
@@ -364,7 +365,7 @@ public class ConfigAccessor {
@Deprecated
public void remove(ConfigScope scope, List<String> keys) {
if (scope == null || scope.getScope() == null) {
- LOG.error("Scope can't be null");
+ LOG.error("Scope can't be null.");
return;
}
@@ -414,7 +415,7 @@ public class ConfigAccessor {
*/
public void remove(HelixConfigScope scope, List<String> keys) {
if (scope == null || scope.getType() == null || !scope.isFullKey()) {
- LOG.error("fail to remove. invalid scope: " + scope + ", keys: " + keys);
+ LOG.error("fail to remove. invalid scope: {}, keys: {}", scope, keys);
return;
}
@@ -452,7 +453,7 @@ public class ConfigAccessor {
*/
public void remove(HelixConfigScope scope, ZNRecord recordToRemove) {
if (scope == null || scope.getType() == null || !scope.isFullKey()) {
- LOG.error("fail to remove. invalid scope: " + scope);
+ LOG.error("fail to remove. invalid scope: {}.", scope);
return;
}
@@ -476,13 +477,13 @@ public class ConfigAccessor {
@Deprecated
public List<String> getKeys(ConfigScopeProperty type, String clusterName, String... keys) {
if (type == null || clusterName == null) {
- LOG.error("clusterName|scope can't be null");
+ LOG.error("ClusterName|scope can't be null.");
return Collections.emptyList();
}
try {
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
- LOG.error("cluster " + clusterName + " is not setup yet");
+ LOG.error("cluster {} is not setup yet.", clusterName);
return Collections.emptyList();
}
@@ -499,7 +500,6 @@ public class ConfigAccessor {
if (splits[1].startsWith("SIMPLEKEYS")) {
retKeys = new ArrayList<String>(record.getSimpleFields().keySet());
-
} else if (splits[1].startsWith("MAPKEYS")) {
retKeys = new ArrayList<String>(record.getMapFields().keySet());
} else if (splits[1].startsWith("MAPMAPKEYS")) {
@@ -507,7 +507,7 @@ public class ConfigAccessor {
}
}
if (retKeys == null) {
- LOG.error("Invalid scope: " + type + " or keys: " + Arrays.toString(args));
+ LOG.error("Invalid scope: {} or keys: {}.", type, Arrays.toString(args));
return Collections.emptyList();
}
@@ -516,7 +516,6 @@ public class ConfigAccessor {
} catch (Exception e) {
return Collections.emptyList();
}
-
}
/**
@@ -526,12 +525,12 @@ public class ConfigAccessor {
*/
public List<String> getKeys(HelixConfigScope scope) {
if (scope == null || scope.getType() == null) {
- LOG.error("fail to getKeys. invalid config scope: " + scope);
+ LOG.error("Fail to getKeys. Invalid config scope: {}.", scope);
return null;
}
if (!ZKUtil.isClusterSetup(scope.getClusterName(), _zkClient)) {
- LOG.error("fail to getKeys. cluster " + scope.getClusterName() + " is not setup yet");
+ LOG.error("Fail to getKeys. Cluster {} is not setup yet.", scope.getClusterName());
return Collections.emptyList();
}
@@ -578,7 +577,7 @@ public class ConfigAccessor {
ZNRecord record = getConfigZnRecord(scope);
if (record == null) {
- LOG.warn("No config found at " + scope.getZkPath());
+ LOG.warn("No config found at {}.", scope.getZkPath());
return null;
}
@@ -598,7 +597,7 @@ public class ConfigAccessor {
ZNRecord record = getConfigZnRecord(scope);
if (record == null) {
- LOG.warn("No rest config found at " + scope.getZkPath());
+ LOG.warn("No rest config found at {}.", scope.getZkPath());
return null;
}
@@ -638,8 +637,8 @@ public class ConfigAccessor {
updateClusterConfig(clusterName, clusterConfig, false);
}
-
- private void updateClusterConfig(String clusterName, ClusterConfig clusterConfig, boolean overwrite) {
+ private void updateClusterConfig(String clusterName, ClusterConfig clusterConfig,
+ boolean overwrite) {
if (!ZKUtil.isClusterSetup(clusterName, _zkClient)) {
throw new HelixException("fail to update config. cluster: " + clusterName + " is NOT setup.");
}
@@ -670,7 +669,7 @@ public class ConfigAccessor {
ZNRecord record = getConfigZnRecord(scope);
if (record == null) {
- LOG.warn("No config found at " + scope.getZkPath());
+ LOG.warn("No config found at {}.", scope.getZkPath());
return null;
}
@@ -754,7 +753,7 @@ public class ConfigAccessor {
ZNRecord record = getConfigZnRecord(scope);
if (record == null) {
- LOG.warn("No config found at " + scope.getZkPath());
+ LOG.warn("No config found at {}.", scope.getZkPath());
return null;
}
@@ -775,7 +774,6 @@ public class ConfigAccessor {
public void setInstanceConfig(String clusterName, String instanceName,
InstanceConfig instanceConfig) {
updateInstanceConfig(clusterName, instanceName, instanceConfig, true);
-
}
/**
diff --git a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
index 1257cdb..1fab898 100644
--- a/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
+++ b/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/ClusterAccessor.java
@@ -63,9 +63,10 @@ import org.codehaus.jackson.type.TypeReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
@Path("/clusters")
public class ClusterAccessor extends AbstractHelixResource {
- private static Logger _logger = LoggerFactory.getLogger(ClusterAccessor.class.getName());
+ private static Logger LOG = LoggerFactory.getLogger(ClusterAccessor.class.getName());
public enum ClusterProperties {
controller,
@@ -113,7 +114,8 @@ public class ClusterAccessor extends AbstractHelixResource {
clusterInfo.put(ClusterProperties.controller.name(), "No Lead Controller!");
}
- boolean paused = dataAccessor.getBaseDataAccessor().exists(keyBuilder.pause().getPath(), AccessOption.PERSISTENT);
+ boolean paused = dataAccessor.getBaseDataAccessor()
+ .exists(keyBuilder.pause().getPath(), AccessOption.PERSISTENT);
clusterInfo.put(ClusterProperties.paused.name(), paused);
boolean maintenance = getHelixAdmin().isInMaintenanceMode(clusterId);
clusterInfo.put(ClusterProperties.maintenance.name(), maintenance);
@@ -128,7 +130,6 @@ public class ClusterAccessor extends AbstractHelixResource {
return JSONRepresentation(clusterInfo);
}
-
@PUT
@Path("{clusterId}")
public Response createCluster(@PathParam("clusterId") String clusterId,
@@ -139,7 +140,7 @@ public class ClusterAccessor extends AbstractHelixResource {
try {
clusterSetup.addCluster(clusterId, recreateIfExists);
} catch (Exception ex) {
- _logger.error("Failed to create cluster " + clusterId + ", exception: " + ex);
+ LOG.error("Failed to create cluster {}. Exception: {}.", clusterId, ex);
return serverError(ex);
}
@@ -154,11 +155,12 @@ public class ClusterAccessor extends AbstractHelixResource {
try {
clusterSetup.deleteCluster(clusterId);
} catch (HelixException ex) {
- _logger.info(
- "Failed to delete cluster " + clusterId + ", cluster is still in use. Exception: " + ex);
+ LOG
+ .info("Failed to delete cluster {}, cluster is still in use. Exception: {}.", clusterId,
+ ex);
return badRequest(ex.getMessage());
} catch (Exception ex) {
- _logger.error("Failed to delete cluster " + clusterId + ", exception: " + ex);
+ LOG.error("Failed to delete cluster {}. Exception: {}.", clusterId, ex);
return serverError(ex);
}
@@ -181,74 +183,75 @@ public class ClusterAccessor extends AbstractHelixResource {
HelixAdmin helixAdmin = getHelixAdmin();
switch (command) {
- case activate:
- if (superCluster == null) {
- return badRequest("Super Cluster name is missing!");
- }
- try {
- clusterSetup.activateCluster(clusterId, superCluster, true);
- } catch (Exception ex) {
- _logger.error("Failed to add cluster " + clusterId + " to super cluster " + superCluster);
- return serverError(ex);
- }
- break;
-
- case expand:
- try {
- clusterSetup.expandCluster(clusterId);
- } catch (Exception ex) {
- _logger.error("Failed to expand cluster " + clusterId);
- return serverError(ex);
- }
- break;
-
- case enable:
- try {
- helixAdmin.enableCluster(clusterId, true);
- } catch (Exception ex) {
- _logger.error("Failed to enable cluster " + clusterId);
- return serverError(ex);
- }
- break;
-
- case disable:
- try {
- helixAdmin.enableCluster(clusterId, false);
- } catch (Exception ex) {
- _logger.error("Failed to disable cluster " + clusterId);
- return serverError(ex);
- }
- break;
-
- case enableMaintenanceMode:
- case disableMaintenanceMode:
- // Try to parse the content string. If parseable, use it as a KV mapping. Otherwise, treat it
- // as a REASON String
- Map<String, String> customFieldsMap = null;
- try {
- // Try to parse content
- customFieldsMap =
- OBJECT_MAPPER.readValue(content, new TypeReference<HashMap<String, String>>() {
- });
- // content is given as a KV mapping. Nullify content
- content = null;
- } catch (Exception e) {
- // NOP
- }
- helixAdmin.manuallyEnableMaintenanceMode(clusterId, command == Command.enableMaintenanceMode,
- content, customFieldsMap);
- break;
- case enableWagedRebalanceForAllResources:
- // Enable WAGED rebalance for all resources in the cluster
- List<String> resources = helixAdmin.getResourcesInCluster(clusterId);
- try {
- helixAdmin.enableWagedRebalance(clusterId, resources);
- } catch (HelixException e) {
- return badRequest(e.getMessage());
- }
- break;
- default:
- return badRequest("Unsupported command " + command);
+ case activate:
+ if (superCluster == null) {
+ return badRequest("Super Cluster name is missing!");
+ }
+ try {
+ clusterSetup.activateCluster(clusterId, superCluster, true);
+ } catch (Exception ex) {
+ LOG.error("Failed to add cluster {} to super cluster {}.", clusterId, superCluster);
+ return serverError(ex);
+ }
+ break;
+
+ case expand:
+ try {
+ clusterSetup.expandCluster(clusterId);
+ } catch (Exception ex) {
+ LOG.error("Failed to expand cluster {}.", clusterId);
+ return serverError(ex);
+ }
+ break;
+
+ case enable:
+ try {
+ helixAdmin.enableCluster(clusterId, true);
+ } catch (Exception ex) {
+ LOG.error("Failed to enable cluster {}.", clusterId);
+ return serverError(ex);
+ }
+ break;
+
+ case disable:
+ try {
+ helixAdmin.enableCluster(clusterId, false);
+ } catch (Exception ex) {
+ LOG.error("Failed to disable cluster {}.", clusterId);
+ return serverError(ex);
+ }
+ break;
+
+ case enableMaintenanceMode:
+ case disableMaintenanceMode:
+ // Try to parse the content string. If parseable, use it as a KV mapping. Otherwise, treat it
+ // as a REASON String
+ Map<String, String> customFieldsMap = null;
+ try {
+ // Try to parse content
+ customFieldsMap =
+ OBJECT_MAPPER.readValue(content, new TypeReference<HashMap<String, String>>() {
+ });
+ // content is given as a KV mapping. Nullify content
+ content = null;
+ } catch (Exception e) {
+ // NOP
+ }
+ helixAdmin
+ .manuallyEnableMaintenanceMode(clusterId, command == Command.enableMaintenanceMode,
+ content, customFieldsMap);
+ break;
+ case enableWagedRebalanceForAllResources:
+ // Enable WAGED rebalance for all resources in the cluster
+ List<String> resources = helixAdmin.getResourcesInCluster(clusterId);
+ try {
+ helixAdmin.enableWagedRebalance(clusterId, resources);
+ } catch (HelixException e) {
+ return badRequest(e.getMessage());
+ }
+ break;
+ default:
+ return badRequest("Unsupported command {}." + command);
}
return OK();
@@ -263,10 +266,10 @@ public class ClusterAccessor extends AbstractHelixResource {
config = accessor.getClusterConfig(clusterId);
} catch (HelixException ex) {
// cluster not found.
- _logger.info("Failed to get cluster config for cluster " + clusterId
- + ", cluster not found, Exception: " + ex);
+ LOG.info("Failed to get cluster config for cluster {}, cluster not found. Exception: {}.",
+ clusterId, ex);
} catch (Exception ex) {
- _logger.error("Failed to get cluster config for cluster " + clusterId + " Exception: " + ex);
+ LOG.error("Failed to get cluster config for cluster {}. Exception: {}", clusterId, ex);
return serverError(ex);
}
if (config == null) {
@@ -279,7 +282,8 @@ public class ClusterAccessor extends AbstractHelixResource {
@Path("{clusterId}/topology")
public Response getClusterTopology(@PathParam("clusterId") String clusterId) throws IOException {
//TODO reduce the GC by dependency injection
- ClusterService clusterService = new ClusterServiceImpl(getDataAccssor(clusterId), getConfigAccessor());
+ ClusterService clusterService =
+ new ClusterServiceImpl(getDataAccssor(clusterId), getConfigAccessor());
ObjectMapper objectMapper = new ObjectMapper();
ClusterTopology clusterTopology = clusterService.getClusterTopology(clusterId);
@@ -288,9 +292,8 @@ public class ClusterAccessor extends AbstractHelixResource {
@POST
@Path("{clusterId}/configs")
- public Response updateClusterConfig(
- @PathParam("clusterId") String clusterId, @QueryParam("command") String commandStr,
- String content) {
+ public Response updateClusterConfig(@PathParam("clusterId") String clusterId,
+ @QueryParam("command") String commandStr, String content) {
Command command;
try {
command = getCommand(commandStr);
@@ -302,7 +305,7 @@ public class ClusterAccessor extends AbstractHelixResource {
try {
record = toZNRecord(content);
} catch (IOException e) {
- _logger.error("Failed to deserialize user's input " + content + ", Exception: " + e);
+ LOG.error("Failed to deserialize user's input {}. Exception: {}.", content, e);
return badRequest("Input is not a valid ZNRecord!");
}
@@ -314,26 +317,26 @@ public class ClusterAccessor extends AbstractHelixResource {
ConfigAccessor configAccessor = getConfigAccessor();
try {
switch (command) {
- case update:
- configAccessor.updateClusterConfig(clusterId, config);
- break;
- case delete: {
- HelixConfigScope clusterScope =
- new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.CLUSTER)
- .forCluster(clusterId).build();
- configAccessor.remove(clusterScope, config.getRecord());
+ case update:
+ configAccessor.updateClusterConfig(clusterId, config);
+ break;
+ case delete: {
+ HelixConfigScope clusterScope =
+ new HelixConfigScopeBuilder(HelixConfigScope.ConfigScopeProperty.CLUSTER)
+ .forCluster(clusterId).build();
+ configAccessor.remove(clusterScope, config.getRecord());
}
break;
- default:
- return badRequest("Unsupported command " + commandStr);
+ default:
+ return badRequest("Unsupported command " + commandStr);
}
} catch (HelixException ex) {
return notFound(ex.getMessage());
} catch (Exception ex) {
- _logger.error(
- "Failed to " + command + " cluster config, cluster " + clusterId + " new config: "
- + content + ", Exception: " + ex);
+ LOG
+ .error("Failed to {} cluster config, cluster {}, new config: {}. Exception: {}.", command,
+ clusterId, content, ex);
return serverError(ex);
}
return OK();
@@ -360,8 +363,8 @@ public class ClusterAccessor extends AbstractHelixResource {
@GET
@Path("{clusterId}/controller/history")
public Response getClusterControllerLeadershipHistory(@PathParam("clusterId") String clusterId) {
- return JSONRepresentation(getControllerHistory(clusterId,
- ControllerHistory.HistoryType.CONTROLLER_LEADERSHIP));
+ return JSONRepresentation(
+ getControllerHistory(clusterId, ControllerHistory.HistoryType.CONTROLLER_LEADERSHIP));
}
@GET
@@ -403,10 +406,11 @@ public class ClusterAccessor extends AbstractHelixResource {
@GET
@Path("{clusterId}/controller/messages/{messageId}")
- public Response getClusterControllerMessages(@PathParam("clusterId") String clusterId, @PathParam("messageId") String messageId) {
+ public Response getClusterControllerMessages(@PathParam("clusterId") String clusterId,
+ @PathParam("messageId") String messageId) {
HelixDataAccessor dataAccessor = getDataAccssor(clusterId);
- Message message = dataAccessor.getProperty(
- dataAccessor.keyBuilder().controllerMessage(messageId));
+ Message message =
+ dataAccessor.getProperty(dataAccessor.keyBuilder().controllerMessage(messageId));
return JSONRepresentation(message.getRecord());
}
@@ -429,7 +433,8 @@ public class ClusterAccessor extends AbstractHelixResource {
public Response getClusterStateModelDefinition(@PathParam("clusterId") String clusterId,
@PathParam("statemodel") String statemodel) {
HelixDataAccessor dataAccessor = getDataAccssor(clusterId);
- StateModelDefinition stateModelDef = dataAccessor.getProperty(dataAccessor.keyBuilder().stateModelDef(statemodel));
+ StateModelDefinition stateModelDef =
+ dataAccessor.getProperty(dataAccessor.keyBuilder().stateModelDef(statemodel));
if (stateModelDef == null) {
return badRequest("Statemodel not found!");
@@ -445,7 +450,7 @@ public class ClusterAccessor extends AbstractHelixResource {
try {
record = toZNRecord(content);
} catch (IOException e) {
- _logger.error("Failed to deserialize user's input " + content + ", Exception: " + e);
+ LOG.error("Failed to deserialize user's input {}. Exception: {}.", content, e);
return badRequest("Input is not a valid ZNRecord!");
}
HelixZkClient zkClient = getHelixZkClient();
@@ -453,7 +458,7 @@ public class ClusterAccessor extends AbstractHelixResource {
try {
ZKUtil.createChildren(zkClient, path, record);
} catch (Exception e) {
- _logger.error("Failed to create zk node with path " + path + ", Exception:" + e);
+ LOG.error("Failed to create zk node with path {}. Exception: {}", path, e);
return badRequest("Failed to create a Znode for stateModel! " + e);
}
@@ -468,7 +473,7 @@ public class ClusterAccessor extends AbstractHelixResource {
try {
record = toZNRecord(content);
} catch (IOException e) {
- _logger.error("Failed to deserialize user's input " + content + ", Exception: " + e);
+ LOG.error("Failed to deserialize user's input {}. Exception: {}.", content, e);
return badRequest("Input is not a valid ZNRecord!");
}
@@ -480,7 +485,7 @@ public class ClusterAccessor extends AbstractHelixResource {
try {
retcode = dataAccessor.setProperty(key, stateModelDefinition);
} catch (Exception e) {
- _logger.error("Failed to set StateModelDefinition key:" + key + ", Exception: " + e);
+ LOG.error("Failed to set StateModelDefinition key: {}. Exception: {}.", key, e);
return badRequest("Failed to set the content " + content);
}
@@ -502,7 +507,7 @@ public class ClusterAccessor extends AbstractHelixResource {
try {
retcode = dataAccessor.removeProperty(key);
} catch (Exception e) {
- _logger.error("Failed to remove StateModelDefinition key:" + key + ", Exception: " + e);
+ LOG.error("Failed to remove StateModelDefinition key: {}. Exception: {}.", key, e);
retcode = false;
}
if (!retcode) {
@@ -514,9 +519,10 @@ public class ClusterAccessor extends AbstractHelixResource {
@GET
@Path("{clusterId}/maintenance")
public Response getClusterMaintenanceMode(@PathParam("clusterId") String clusterId) {
- return JSONRepresentation(
- ImmutableMap.of(ClusterProperties.maintenance.name(), getHelixAdmin().isInMaintenanceMode(clusterId)));
+ return JSONRepresentation(ImmutableMap
+ .of(ClusterProperties.maintenance.name(), getHelixAdmin().isInMaintenanceMode(clusterId)));
}
+
private boolean doesClusterExist(String cluster) {
HelixZkClient zkClient = getHelixZkClient();
return ZKUtil.isClusterSetup(cluster, zkClient);
@@ -539,15 +545,15 @@ public class ClusterAccessor extends AbstractHelixResource {
dataAccessor.getProperty(dataAccessor.keyBuilder().controllerLeaderHistory());
switch (historyType) {
- case CONTROLLER_LEADERSHIP:
- history.put(Properties.history.name(),
- historyRecord != null ? historyRecord.getHistoryList() : Collections.emptyList());
- break;
- case MAINTENANCE:
- history.put(ClusterProperties.maintenanceHistory.name(),
- historyRecord != null ? historyRecord.getMaintenanceHistoryList()
- : Collections.emptyList());
- break;
+ case CONTROLLER_LEADERSHIP:
+ history.put(Properties.history.name(),
+ historyRecord != null ? historyRecord.getHistoryList() : Collections.emptyList());
+ break;
+ case MAINTENANCE:
+ history.put(ClusterProperties.maintenanceHistory.name(),
+ historyRecord != null ? historyRecord.getMaintenanceHistoryList()
+ : Collections.emptyList());
+ break;
}
return history;
}