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
commit 43b189a7db5333fba6f2a7e797ff482d9c9cf7de Author: Lei Xia <[email protected]> AuthorDate: Fri May 17 09:17:33 2019 -0700 Two minor improvements. 1) Avoid persisting null entry into CurrentStateOutput, 2) add addition info to CallbackProcess thread name to differeniate different threads. RB=1670214 G=helix-reviewers A=hulee Signed-off-by: Hunter Lee <[email protected]> --- .../controller/stages/CurrentStateComputationStage.java | 14 ++++++++++---- .../java/org/apache/helix/manager/zk/CallbackHandler.java | 3 ++- .../java/org/apache/helix/tools/TestHelixAdminCli.java | 1 + 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java b/helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java index 0bf4d28..6115465 100644 --- a/helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java +++ b/helix-core/src/main/java/org/apache/helix/controller/stages/CurrentStateComputationStage.java @@ -190,12 +190,18 @@ public class CurrentStateComputationStage extends AbstractBaseStage { if (partition != null) { currentStateOutput.setCurrentState(resourceName, partition, instanceName, currentState.getState(partitionName)); - currentStateOutput.setRequestedState(resourceName, partition, instanceName, - currentState.getRequestedState(partitionName)); - currentStateOutput - .setInfo(resourceName, partition, instanceName, currentState.getInfo(partitionName)); currentStateOutput.setEndTime(resourceName, partition, instanceName, currentState.getEndTime(partitionName)); + String info = currentState.getInfo(partitionName); + // This is to avoid null value entries in the map, and reduce memory usage by avoiding extra empty entries in the map. + if (info != null) { + currentStateOutput.setInfo(resourceName, partition, instanceName, info); + } + String requestState = currentState.getRequestedState(partitionName); + if (requestState != null) { + currentStateOutput + .setRequestedState(resourceName, partition, instanceName, requestState); + } } } } diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java index 713d214..969805e 100644 --- a/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java +++ b/helix-core/src/main/java/org/apache/helix/manager/zk/CallbackHandler.java @@ -160,7 +160,8 @@ public class CallbackHandler implements IZkChildListener, IZkDataListener { private CallbackHandler _handler; public CallbackProcessor(CallbackHandler handler) { - super(_manager.getClusterName(), "CallbackProcessor"); + super(_manager.getClusterName(), + "CallbackProcessor@" + Integer.toHexString(handler.hashCode())); _handler = handler; } diff --git a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java b/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java index d363b8d..420beba 100644 --- a/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java +++ b/helix-core/src/test/java/org/apache/helix/tools/TestHelixAdminCli.java @@ -282,6 +282,7 @@ public class TestHelixAdminCli extends ZkTestBase { Thread.sleep(200); leader = accessor.getProperty(accessor.keyBuilder().controllerLeader()); } + Assert.assertNotNull(leader); Assert.assertTrue(leader.getInstanceName().startsWith("controller_900")); boolean verifyResult = ClusterStateVerifier
