You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by zz...@apache.org on 2013/09/17 02:54:28 UTC
[6/6] git commit: [HELIX-234]
Convert-all-Id.x-to-x.from-and-assorted-code-cleanup
[HELIX-234] Convert-all-Id.x-to-x.from-and-assorted-code-cleanup
Project: http://git-wip-us.apache.org/repos/asf/incubator-helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-helix/commit/ac37a5e4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-helix/tree/ac37a5e4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-helix/diff/ac37a5e4
Branch: refs/heads/helix-logical-model
Commit: ac37a5e45336fc2f94a684b8b1f0ade24072d4c2
Parents: fdb48ec
Author: zzhang <zz...@apache.org>
Authored: Mon Sep 16 17:54:06 2013 -0700
Committer: zzhang <zz...@apache.org>
Committed: Mon Sep 16 17:54:06 2013 -0700
----------------------------------------------------------------------
.../helix/webapp/resources/ConfigResource.java | 3 -
.../resources/SchedulerTasksResource.java | 7 +-
.../helix/webapp/resources/ZkPathResource.java | 2 -
.../helix/agent/ProcessMonitorThread.java | 1 -
.../org/apache/helix/agent/TestHelixAgent.java | 2 -
.../java/org/apache/helix/ConfigAccessor.java | 4 +-
.../main/java/org/apache/helix/HelixAdmin.java | 9 +-
.../org/apache/helix/PropertyPathConfig.java | 2 +-
.../org/apache/helix/alerts/AlertProcessor.java | 3 -
.../org/apache/helix/alerts/AlertsHolder.java | 3 -
.../apache/helix/alerts/DecayAggregator.java | 2 -
.../apache/helix/alerts/ExpressionParser.java | 2 -
.../org/apache/helix/alerts/StatsHolder.java | 4 -
.../java/org/apache/helix/alerts/Tuple.java | 3 -
.../apache/helix/alerts/WindowAggregator.java | 2 -
.../org/apache/helix/api/ClusterAccessor.java | 29 ++---
.../org/apache/helix/api/ClusterConfig.java | 2 +-
.../java/org/apache/helix/api/ClusterId.java | 15 ++-
.../java/org/apache/helix/api/ControllerId.java | 14 ++-
.../src/main/java/org/apache/helix/api/Id.java | 118 -------------------
.../java/org/apache/helix/api/MessageId.java | 14 ++-
.../org/apache/helix/api/NamespacedConfig.java | 15 +--
.../apache/helix/api/ParticipantAccessor.java | 6 +-
.../org/apache/helix/api/ParticipantConfig.java | 2 +-
.../org/apache/helix/api/ParticipantId.java | 14 ++-
.../java/org/apache/helix/api/PartitionId.java | 28 ++++-
.../main/java/org/apache/helix/api/ProcId.java | 13 +-
.../org/apache/helix/api/RebalancerConfig.java | 67 ++++-------
.../org/apache/helix/api/RebalancerRef.java | 2 +-
.../java/org/apache/helix/api/Resource.java | 6 +-
.../org/apache/helix/api/ResourceAccessor.java | 1 -
.../org/apache/helix/api/ResourceConfig.java | 2 +-
.../java/org/apache/helix/api/ResourceId.java | 20 +++-
.../java/org/apache/helix/api/SessionId.java | 13 +-
.../java/org/apache/helix/api/SpectatorId.java | 2 +-
.../org/apache/helix/api/StateModelDefId.java | 18 ++-
.../helix/api/StateModelDefinitionAccessor.java | 2 +-
.../apache/helix/api/StateModelFactoryId.java | 13 +-
.../java/org/apache/helix/api/UserConfig.java | 10 +-
.../helix/controller/ExternalViewGenerator.java | 2 +-
.../controller/GenericHelixController.java | 2 +-
.../controller/rebalancer/AutoRebalancer.java | 7 +-
.../controller/rebalancer/CustomRebalancer.java | 7 +-
.../rebalancer/NewAutoRebalancer.java | 3 +-
.../rebalancer/SemiAutoRebalancer.java | 7 +-
.../restlet/ZKPropertyTransferServer.java | 1 -
.../restlet/ZNRecordUpdateResource.java | 1 -
.../stages/BestPossibleStateCalcStage.java | 4 +-
.../stages/ExternalViewComputeStage.java | 1 -
.../controller/stages/HealthDataCache.java | 2 -
.../stages/MessageGenerationPhase.java | 17 +--
.../controller/stages/MessageThrottleStage.java | 8 +-
.../stages/NewExternalViewComputeStage.java | 16 +--
.../stages/NewMessageGenerationStage.java | 9 +-
.../stages/NewReadClusterDataStage.java | 3 +-
.../stages/NewResourceComputationStage.java | 14 +--
.../stages/NewTaskAssignmentStage.java | 3 +-
.../stages/StatsAggregationStage.java | 2 +-
.../strategy/AutoRebalanceStrategy.java | 2 +-
.../helix/controller/strategy/RUSHrHash.java | 6 +-
.../helix/healthcheck/DecayAggregationType.java | 2 +-
.../DefaultHealthReportProvider.java | 1 -
.../ParticipantHealthReportCollectorImpl.java | 2 +-
.../PerformanceHealthReportProvider.java | 2 +-
.../java/org/apache/helix/healthcheck/Stat.java | 4 +-
.../healthcheck/StatHealthReportProvider.java | 4 +-
.../helix/josql/ClusterJosqlQueryProcessor.java | 2 +-
.../helix/manager/zk/AbstractManager.java | 6 +-
.../java/org/apache/helix/manager/zk/Cache.java | 1 -
.../helix/manager/zk/CallbackHandler.java | 2 -
.../helix/manager/zk/ControllerManager.java | 3 +-
.../manager/zk/ControllerManagerHelper.java | 1 -
.../manager/zk/CurStateCarryOverUpdater.java | 4 +-
.../DefaultSchedulerMessageHandlerFactory.java | 14 +--
.../helix/manager/zk/HelixGroupCommit.java | 1 -
.../helix/manager/zk/ParticipantManager.java | 2 -
.../helix/manager/zk/WriteThroughCache.java | 1 -
.../apache/helix/manager/zk/ZKHelixAdmin.java | 9 +-
.../apache/helix/manager/zk/ZKHelixManager.java | 8 +-
.../helix/manager/zk/ZkBaseDataAccessor.java | 3 -
.../manager/zk/ZkCacheBaseDataAccessor.java | 4 -
.../helix/manager/zk/ZkCallbackCache.java | 1 -
.../org/apache/helix/manager/zk/ZkClient.java | 1 -
.../zk/serializer/JacksonPayloadSerializer.java | 1 -
.../messaging/DefaultMessagingService.java | 17 +--
.../handling/AsyncCallbackService.java | 9 --
.../messaging/handling/BatchMessageHandler.java | 5 +-
.../handling/HelixStateTransitionHandler.java | 3 +-
.../messaging/handling/HelixTaskExecutor.java | 5 +-
.../messaging/handling/MessageHandler.java | 2 -
.../helix/model/ClusterConfiguration.java | 3 +-
.../org/apache/helix/model/CurrentState.java | 11 +-
.../org/apache/helix/model/ExternalView.java | 8 +-
.../java/org/apache/helix/model/IdealState.java | 20 ++--
.../org/apache/helix/model/InstanceConfig.java | 3 +-
.../org/apache/helix/model/LiveInstance.java | 7 +-
.../java/org/apache/helix/model/Message.java | 21 ++--
.../helix/model/PartitionConfiguration.java | 3 +-
.../apache/helix/model/ResourceAssignment.java | 12 +-
.../helix/model/ResourceConfiguration.java | 7 +-
.../helix/model/StateModelDefinition.java | 3 +-
.../helix/model/builder/AutoModeISBuilder.java | 4 +-
.../builder/AutoRebalanceModeISBuilder.java | 4 +-
.../model/builder/ConstraintItemBuilder.java | 2 +-
.../model/builder/CustomModeISBuilder.java | 4 +-
.../helix/monitoring/ZKPathDataDumpTask.java | 2 +-
.../monitoring/mbeans/ClusterMBeanObserver.java | 7 --
.../monitoring/mbeans/ResourceMonitor.java | 2 -
.../mbeans/StateTransitionStatMonitor.java | 1 -
.../participant/GenericLeaderStandbyModel.java | 2 +-
.../participant/HelixCustomCodeRunner.java | 4 +-
.../participant/HelixStateMachineEngine.java | 5 +-
.../statemachine/StateModelFactory.java | 1 -
.../apache/helix/tools/CLMLogFileAppender.java | 5 -
.../helix/tools/ClusterStateVerifier.java | 33 ++----
.../org/apache/helix/tools/MessagePoster.java | 13 +-
.../org/apache/helix/util/StatusUpdateUtil.java | 21 ++--
.../org/apache/helix/util/ZKClientPool.java | 1 -
.../src/test/java/org/apache/helix/Mocks.java | 1 -
.../org/apache/helix/TestConfigAccessor.java | 1 -
.../java/org/apache/helix/TestGroupCommit.java | 4 -
.../apache/helix/TestHelixConfigAccessor.java | 2 +-
.../org/apache/helix/TestHelixTaskExecutor.java | 17 +--
.../org/apache/helix/TestHelixTaskHandler.java | 34 +++---
.../test/java/org/apache/helix/TestHelper.java | 14 ++-
.../apache/helix/TestHierarchicalDataStore.java | 7 +-
.../TestPerformanceHealthReportProvider.java | 2 -
.../java/org/apache/helix/TestZKCallback.java | 30 ++---
.../apache/helix/TestZKRoutingInfoProvider.java | 3 +-
.../java/org/apache/helix/TestZNRecord.java | 1 -
.../apache/helix/TestZNRecordBucketizer.java | 1 -
.../test/java/org/apache/helix/TestZkBasis.java | 17 ++-
.../org/apache/helix/TestZkClientWrapper.java | 1 -
.../java/org/apache/helix/TestZnodeModify.java | 5 +-
.../java/org/apache/helix/ZkTestHelper.java | 16 +--
.../org/apache/helix/alerts/TestAddAlerts.java | 4 +-
.../helix/alerts/TestAddPersistentStats.java | 3 +-
.../helix/alerts/TestAlertValidation.java | 3 -
.../alerts/TestArrivingParticipantStats.java | 4 +-
.../helix/alerts/TestBaseStatsValidation.java | 4 -
.../apache/helix/alerts/TestEvaluateAlerts.java | 5 -
.../org/apache/helix/alerts/TestOperators.java | 4 -
.../org/apache/helix/alerts/TestStatsMatch.java | 4 -
.../test/java/org/apache/helix/api/TestId.java | 42 +++----
.../apache/helix/api/TestNamespacedConfig.java | 16 +--
.../org/apache/helix/api/TestNewStages.java | 10 +-
.../helix/controller/stages/BaseStageTest.java | 15 +--
.../TestBestPossibleCalcStageCompatibility.java | 18 +--
.../stages/TestBestPossibleStateCalcStage.java | 8 +-
.../TestCurrentStateComputationStage.java | 37 +++---
.../stages/TestMessageThrottleStage.java | 43 ++++---
.../stages/TestMsgSelectionStage.java | 68 ++++++-----
.../stages/TestParseInfoFromAlert.java | 1 -
.../stages/TestRebalancePipeline.java | 29 +++--
.../stages/TestResourceComputationStage.java | 26 ++--
.../strategy/TestAutoRebalanceStrategy.java | 4 +-
.../strategy/TestNewAutoRebalanceStrategy.java | 14 ++-
.../helix/healthcheck/TestAddDropAlert.java | 7 +-
.../healthcheck/TestAlertActionTriggering.java | 6 +-
.../helix/healthcheck/TestAlertFireHistory.java | 8 +-
.../helix/healthcheck/TestDummyAlerts.java | 2 +-
.../helix/healthcheck/TestExpandAlert.java | 7 +-
.../helix/healthcheck/TestSimpleAlert.java | 6 +-
.../healthcheck/TestSimpleWildcardAlert.java | 6 +-
.../helix/healthcheck/TestStalenessAlert.java | 6 +-
.../helix/healthcheck/TestWildcardAlert.java | 6 +-
.../helix/integration/TestAddClusterV2.java | 2 -
.../TestAddNodeAfterControllerStart.java | 2 -
.../TestAddStateModelFactoryAfterConnect.java | 7 +-
.../TestAutoRebalancePartitionLimit.java | 4 +-
.../helix/integration/TestBatchMessage.java | 8 +-
.../integration/TestBucketizedResource.java | 2 +-
.../apache/helix/integration/TestDisable.java | 2 +-
.../integration/TestDistributedCMMain.java | 2 +-
.../TestDistributedClusterController.java | 2 +-
.../org/apache/helix/integration/TestDrop.java | 10 +-
.../TestEnablePartitionDuringDisable.java | 3 +-
.../helix/integration/TestErrorPartition.java | 2 +-
.../integration/TestExternalViewUpdates.java | 2 +-
.../helix/integration/TestFailOverPerf1kp.java | 1 -
.../integration/TestHelixCustomCodeRunner.java | 4 +-
.../integration/TestInvalidAutoIdealState.java | 4 +-
.../TestMessagePartitionStateMismatch.java | 27 +++--
.../helix/integration/TestMessageThrottle.java | 8 +-
.../helix/integration/TestMessagingService.java | 30 ++---
.../integration/TestNonOfflineInitState.java | 2 +-
.../TestParticipantErrorMessage.java | 19 +--
.../helix/integration/TestResetInstance.java | 2 +-
.../helix/integration/TestResetResource.java | 2 +-
.../helix/integration/TestSchedulerMessage.java | 59 ++++------
.../integration/TestSchedulerMsgContraints.java | 11 +-
.../integration/TestSchedulerMsgUsingQueue.java | 12 +-
.../TestStandAloneCMSessionExpiry.java | 2 +-
.../helix/integration/TestSwapInstance.java | 2 +-
.../integration/TestZkCallbackHandlerLeak.java | 10 +-
.../helix/integration/TestZkReconnect.java | 8 +-
.../integration/ZkIntegrationTestBase.java | 6 +-
.../manager/TestConsecutiveZkSessionExpiry.java | 1 -
.../apache/helix/josql/TestJosqlProcessor.java | 1 -
.../TestDefaultControllerMsgHandlerFactory.java | 10 +-
.../helix/manager/zk/TestHandleNewSession.java | 1 -
.../manager/zk/TestLiveInstanceBounce.java | 4 +-
.../zk/TestWtCacheAsyncOpMultiThread.java | 2 -
.../zk/TestWtCacheAsyncOpSingleThread.java | 2 -
.../zk/TestWtCacheSyncOpSingleThread.java | 2 -
.../manager/zk/TestZKLiveInstanceData.java | 2 -
.../zk/TestZKPropertyTransferServer.java | 1 -
.../helix/manager/zk/TestZNRecordSizeLimit.java | 8 +-
.../manager/zk/TestZkBaseDataAccessor.java | 3 -
.../zk/TestZkCacheAsyncOpSingleThread.java | 4 -
.../zk/TestZkCacheSyncOpSingleThread.java | 5 -
.../helix/manager/zk/TestZkHelixAdmin.java | 13 +-
.../manager/zk/TestZkStateChangeListener.java | 8 +-
.../helix/messaging/TestAsyncCallback.java | 11 +-
.../helix/messaging/TestAsyncCallbackSvc.java | 20 ++--
.../messaging/TestDefaultMessagingService.java | 4 +-
.../handling/TestConfigThreadpoolSize.java | 4 +-
.../handling/TestHelixTaskExecutor.java | 76 ++++++------
.../handling/TestResourceThreadpoolSize.java | 4 +-
.../mock/controller/ClusterController.java | 2 -
.../helix/mock/controller/MockController.java | 7 +-
.../mock/controller/MockControllerProcess.java | 10 +-
.../mock/participant/MockMSModelFactory.java | 2 -
.../helix/mock/participant/MockParticipant.java | 16 ---
.../org/apache/helix/model/TestConstraint.java | 10 +-
.../org/apache/helix/model/TestIdealState.java | 9 +-
.../monitoring/TestParticipantMonitor.java | 3 -
.../helix/monitoring/TestStatCollector.java | 4 +-
.../TestClusterAlertItemMBeanCollection.java | 4 -
.../monitoring/mbeans/TestResourceMonitor.java | 3 +-
.../participant/TestDistControllerElection.java | 3 +-
.../TestDistControllerStateModel.java | 23 ++--
.../TestDistControllerStateModelFactory.java | 3 -
.../apache/helix/store/TestJsonComparator.java | 1 -
.../store/zk/TestZkHelixPropertyStore.java | 1 -
.../apache/helix/tools/TestClusterSetup.java | 7 +-
.../org/apache/helix/util/TestZKClientPool.java | 1 -
.../apache/helix/examples/BootstrapHandler.java | 4 +-
.../apache/helix/examples/BootstrapProcess.java | 24 +---
.../apache/helix/examples/ExampleProcess.java | 1 -
.../helix/examples/IdealStateExample.java | 5 +-
.../examples/MasterSlaveStateModelFactory.java | 1 -
.../apache/helix/examples/NewModelExample.java | 84 ++++++++++---
.../org/apache/helix/examples/Quickstart.java | 6 +-
.../helix/filestore/ChangeLogGenerator.java | 2 -
.../helix/filestore/ChangeLogProcessor.java | 6 -
.../apache/helix/filestore/ChangeLogReader.java | 2 -
.../org/apache/helix/filestore/FileStore.java | 5 -
.../java/org/apache/helix/filestore/Test.java | 3 -
.../servicediscovery/ServiceDiscovery.java | 1 -
250 files changed, 997 insertions(+), 1192 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
index c19ae9d..3856878 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ConfigResource.java
@@ -20,7 +20,6 @@ package org.apache.helix.webapp.resources;
*/
import java.util.Arrays;
-import java.util.HashSet;
import java.util.List;
import java.util.Map;
@@ -28,10 +27,8 @@ import org.apache.helix.HelixAdmin;
import org.apache.helix.HelixException;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZkClient;
-import org.apache.helix.model.ConfigScope;
import org.apache.helix.model.HelixConfigScope;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
-import org.apache.helix.model.builder.ConfigScopeBuilder;
import org.apache.helix.model.builder.HelixConfigScopeBuilder;
import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.webapp.RestAdminApplication;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
index 93f5b3f..2d3966c 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/SchedulerTasksResource.java
@@ -31,7 +31,8 @@ import org.apache.helix.HelixException;
import org.apache.helix.InstanceType;
import org.apache.helix.PropertyPathConfig;
import org.apache.helix.PropertyType;
-import org.apache.helix.api.Id;
+import org.apache.helix.api.MessageId;
+import org.apache.helix.api.SessionId;
import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory;
import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.model.LiveInstance;
@@ -153,12 +154,12 @@ public class SchedulerTasksResource extends Resource {
}
Message schedulerMessage =
- new Message(MessageType.SCHEDULER_MSG, Id.message(UUID.randomUUID().toString()));
+ new Message(MessageType.SCHEDULER_MSG, MessageId.from(UUID.randomUUID().toString()));
schedulerMessage.getRecord().getSimpleFields().put(CRITERIA, criteriaString);
schedulerMessage.getRecord().getMapFields().put(MESSAGETEMPLATE, messageTemplate);
- schedulerMessage.setTgtSessionId(Id.session(leader.getSessionId().stringify()));
+ schedulerMessage.setTgtSessionId(SessionId.from(leader.getSessionId().stringify()));
schedulerMessage.setTgtName("CONTROLLER");
schedulerMessage.setSrcInstanceType(InstanceType.CONTROLLER);
String taskQueueName =
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ZkPathResource.java
----------------------------------------------------------------------
diff --git a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ZkPathResource.java b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ZkPathResource.java
index 8f03e12..64f0e58 100644
--- a/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ZkPathResource.java
+++ b/helix-admin-webapp/src/main/java/org/apache/helix/webapp/resources/ZkPathResource.java
@@ -24,9 +24,7 @@ import java.util.List;
import org.apache.helix.HelixException;
import org.apache.helix.ZNRecord;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
import org.apache.helix.manager.zk.ZkClient;
-import org.apache.helix.tools.ClusterSetup;
import org.apache.helix.webapp.RestAdminApplication;
import org.apache.log4j.Logger;
import org.apache.zookeeper.data.Stat;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java b/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java
index e1a3d72..09a89df 100644
--- a/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java
+++ b/helix-agent/src/main/java/org/apache/helix/agent/ProcessMonitorThread.java
@@ -1,6 +1,5 @@
package org.apache.helix.agent;
-import java.io.File;
import java.util.Random;
import java.util.concurrent.TimeUnit;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java
----------------------------------------------------------------------
diff --git a/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java b/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java
index e723296..083cbd4 100644
--- a/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java
+++ b/helix-agent/src/test/java/org/apache/helix/agent/TestHelixAgent.java
@@ -20,9 +20,7 @@ package org.apache.helix.agent;
*/
import java.io.File;
-import java.io.IOException;
import java.util.Date;
-import java.util.concurrent.TimeUnit;
import org.apache.helix.ConfigAccessor;
import org.apache.helix.ExternalCommand;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
----------------------------------------------------------------------
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 34aef49..f46e537 100644
--- a/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/ConfigAccessor.java
@@ -27,11 +27,11 @@ import java.util.List;
import java.util.Map;
import java.util.TreeMap;
+import org.apache.helix.manager.zk.ZKUtil;
+import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.model.ConfigScope;
import org.apache.helix.model.HelixConfigScope;
import org.apache.helix.model.HelixConfigScope.ConfigScopeProperty;
-import org.apache.helix.manager.zk.ZKUtil;
-import org.apache.helix.manager.zk.ZkClient;
import org.apache.helix.util.StringTemplate;
import org.apache.log4j.Logger;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
index d5c62fa..892bada 100644
--- a/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
+++ b/helix-core/src/main/java/org/apache/helix/HelixAdmin.java
@@ -22,8 +22,15 @@ package org.apache.helix;
import java.io.IOException;
import java.util.List;
import java.util.Map;
-import org.apache.helix.model.*;
+
+import org.apache.helix.model.ClusterConstraints;
import org.apache.helix.model.ClusterConstraints.ConstraintType;
+import org.apache.helix.model.ConstraintItem;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.HelixConfigScope;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.InstanceConfig;
+import org.apache.helix.model.StateModelDefinition;
/*
* Helix cluster management
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java b/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
index 96497e0..7fa4404 100644
--- a/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/PropertyPathConfig.java
@@ -84,6 +84,7 @@ public class PropertyPathConfig {
addEntry(PropertyType.CONFIGS, 1, "/{clusterName}/CONFIGS");
addEntry(PropertyType.CONFIGS, 2, "/{clusterName}/CONFIGS/{scope}");
addEntry(PropertyType.CONFIGS, 3, "/{clusterName}/CONFIGS/{scope}/{scopeKey}");
+ addEntry(PropertyType.CONFIGS, 4, "/{clusterName}/CONFIGS/{scope}/{scopeKey}/{subScopeKey}");
// addEntry(PropertyType.CONFIGS,2,"/{clusterName}/CONFIGS/{instanceName}");
addEntry(PropertyType.LIVEINSTANCES, 1, "/{clusterName}/LIVEINSTANCES");
addEntry(PropertyType.LIVEINSTANCES, 2, "/{clusterName}/LIVEINSTANCES/{instanceName}");
@@ -173,7 +174,6 @@ public class PropertyPathConfig {
String template = null;
if (templateMap.containsKey(type)) {
// keys.length+1 since we add clusterName
- Map<Integer, String> fullTemplate = templateMap.get(type);
template = templateMap.get(type).get(keys.length + 1);
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java b/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java
index 2bb1976..26cabdf 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/AlertProcessor.java
@@ -22,14 +22,11 @@ package org.apache.helix.alerts;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import java.util.Set;
import org.apache.helix.HelixException;
-import org.apache.helix.healthcheck.StatHealthReportProvider;
import org.apache.log4j.Logger;
public class AlertProcessor {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java b/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java
index 8bfaae6..80f8561 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/AlertsHolder.java
@@ -28,10 +28,7 @@ import java.util.Map;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixException;
import org.apache.helix.HelixManager;
-import org.apache.helix.HelixProperty;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyType;
-import org.apache.helix.ZNRecord;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.controller.stages.HealthDataCache;
import org.apache.helix.model.AlertStatus;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java b/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java
index be17ca9..fd9f2a6 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/DecayAggregator.java
@@ -19,8 +19,6 @@ package org.apache.helix.alerts;
* under the License.
*/
-import java.util.Iterator;
-
import org.apache.helix.HelixException;
public class DecayAggregator extends Aggregator {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java b/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java
index ca64be5..2fd95e9 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/ExpressionParser.java
@@ -21,9 +21,7 @@ package org.apache.helix.alerts;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.HashSet;
import java.util.Map;
-import java.util.Set;
import java.util.StringTokenizer;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java b/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java
index 97ae463..1538eb8 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/StatsHolder.java
@@ -24,15 +24,11 @@ import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
-import java.util.Set;
-import java.util.regex.Pattern;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixException;
import org.apache.helix.HelixManager;
import org.apache.helix.PropertyKey;
-import org.apache.helix.PropertyType;
-import org.apache.helix.ZNRecord;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.controller.stages.HealthDataCache;
import org.apache.helix.model.PersistentStats;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java b/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java
index 9a876a4..e57f088 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/Tuple.java
@@ -21,10 +21,7 @@ package org.apache.helix.alerts;
import java.util.ArrayList;
import java.util.Iterator;
-import java.util.LinkedList;
import java.util.List;
-import java.util.StringTokenizer;
-import java.util.Vector;
public class Tuple<T> {
List<T> elements;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java b/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java
index ff4340c..6ef4cfe 100644
--- a/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java
+++ b/helix-core/src/main/java/org/apache/helix/alerts/WindowAggregator.java
@@ -21,8 +21,6 @@ package org.apache.helix.alerts;
import java.util.Iterator;
-import org.apache.helix.HelixException;
-
public class WindowAggregator extends Aggregator {
int _windowSize;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ClusterAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ClusterAccessor.java b/helix-core/src/main/java/org/apache/helix/api/ClusterAccessor.java
index 4bfe780..a46edad 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ClusterAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ClusterAccessor.java
@@ -69,6 +69,13 @@ public class ClusterAccessor {
LOG.warn("Cluster already created. Aborting.");
// return false;
}
+
+ StateModelDefinitionAccessor stateModelDefAccessor =
+ new StateModelDefinitionAccessor(_accessor);
+ Map<StateModelDefId, StateModelDefinition> stateModelDefs = cluster.getStateModelMap();
+ for (StateModelDefinition stateModelDef : stateModelDefs.values()) {
+ stateModelDefAccessor.addStateModelDefinition(stateModelDef);
+ }
Map<ResourceId, ResourceConfig> resources = cluster.getResourceMap();
for (ResourceConfig resource : resources.values()) {
addResourceToCluster(resource);
@@ -87,12 +94,6 @@ public class ClusterAccessor {
if (cluster.isPaused()) {
pauseCluster();
}
- StateModelDefinitionAccessor stateModelDefAccessor =
- new StateModelDefinitionAccessor(_accessor);
- Map<StateModelDefId, StateModelDefinition> stateModelDefs = cluster.getStateModelMap();
- for (StateModelDefinition stateModelDef : stateModelDefs.values()) {
- stateModelDefAccessor.addStateModelDefinition(stateModelDef);
- }
return true;
}
@@ -190,12 +191,12 @@ public class ClusterAccessor {
for (String resourceName : idealStateMap.keySet()) {
IdealState idealState = idealStateMap.get(resourceName);
// TODO pass resource assignment
- ResourceId resourceId = Id.resource(resourceName);
+ ResourceId resourceId = ResourceId.from(resourceName);
UserConfig userConfig;
if (resourceConfigMap != null && resourceConfigMap.containsKey(resourceName)) {
- userConfig = new UserConfig(resourceConfigMap.get(resourceName));
+ userConfig = UserConfig.from(resourceConfigMap.get(resourceName));
} else {
- userConfig = new UserConfig(resourceId);
+ userConfig = new UserConfig(Scope.resource(resourceId));
}
Map<String, PartitionConfiguration> partitionConfigMap =
@@ -203,7 +204,7 @@ public class ClusterAccessor {
if (partitionConfigMap != null) {
Map<PartitionId, UserConfig> partitionUserConfigs = new HashMap<PartitionId, UserConfig>();
for (String partitionName : partitionConfigMap.keySet()) {
- partitionUserConfigs.put(Id.partition(partitionName),
+ partitionUserConfigs.put(PartitionId.from(partitionName),
UserConfig.from(partitionConfigMap.get(partitionName)));
}
resourceMap.put(resourceId,
@@ -219,7 +220,7 @@ public class ClusterAccessor {
LiveInstance liveInstance = liveInstanceMap.get(participantName);
Map<String, Message> instanceMsgMap = messageMap.get(participantName);
- ParticipantId participantId = Id.participant(participantName);
+ ParticipantId participantId = ParticipantId.from(participantName);
participantMap.put(participantId, ParticipantAccessor.createParticipant(participantId,
instanceConfig, userConfig, liveInstance, instanceMsgMap,
@@ -229,7 +230,7 @@ public class ClusterAccessor {
Map<ControllerId, Controller> controllerMap = new HashMap<ControllerId, Controller>();
ControllerId leaderId = null;
if (leader != null) {
- leaderId = new ControllerId(leader.getId());
+ leaderId = ControllerId.from(leader.getId());
controllerMap.put(leaderId, new Controller(leaderId, leader, true));
}
@@ -246,9 +247,9 @@ public class ClusterAccessor {
ClusterConfiguration clusterUserConfig = _accessor.getProperty(_keyBuilder.clusterConfig());
UserConfig userConfig;
if (clusterUserConfig != null) {
- userConfig = new UserConfig(clusterUserConfig);
+ userConfig = UserConfig.from(clusterUserConfig);
} else {
- userConfig = new UserConfig(_clusterId);
+ userConfig = new UserConfig(Scope.cluster(_clusterId));
}
StateModelDefinitionAccessor stateModelDefAccessor =
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ClusterConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ClusterConfig.java b/helix-core/src/main/java/org/apache/helix/api/ClusterConfig.java
index dd19096..27da37d 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ClusterConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ClusterConfig.java
@@ -144,7 +144,7 @@ public class ClusterConfig {
_constraintMap = new HashMap<ConstraintType, ClusterConstraints>();
_stateModelMap = new HashMap<StateModelDefId, StateModelDefinition>();
_isPaused = false;
- _userConfig = new UserConfig(id);
+ _userConfig = new UserConfig(Scope.cluster(id));
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ClusterId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ClusterId.java b/helix-core/src/main/java/org/apache/helix/api/ClusterId.java
index 4f04c41..3375614 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ClusterId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ClusterId.java
@@ -20,7 +20,7 @@ package org.apache.helix.api;
*/
/**
- *
+ * Identifies a cluster
*/
public class ClusterId extends Id {
final private String _id;
@@ -28,7 +28,7 @@ public class ClusterId extends Id {
/**
* @param id
*/
- public ClusterId(String id) {
+ private ClusterId(String id) {
_id = id;
}
@@ -37,4 +37,15 @@ public class ClusterId extends Id {
return _id;
}
+ /**
+ * Get a concrete cluster id for a string name
+ * @param clusterId string cluster identifier
+ * @return ClusterId
+ */
+ public static ClusterId from(String clusterId) {
+ if (clusterId == null) {
+ return null;
+ }
+ return new ClusterId(clusterId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ControllerId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ControllerId.java b/helix-core/src/main/java/org/apache/helix/api/ControllerId.java
index 894c342..8a8c31f 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ControllerId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ControllerId.java
@@ -19,10 +19,13 @@ package org.apache.helix.api;
* under the License.
*/
+/**
+ * Identifies Helix nodes that take on the CONTROLLER role
+ */
public class ControllerId extends Id {
private final String _id;
- public ControllerId(String id) {
+ private ControllerId(String id) {
_id = id;
}
@@ -30,4 +33,13 @@ public class ControllerId extends Id {
public String stringify() {
return _id;
}
+
+ /**
+ * Get a ControllerId from a string
+ * @param controllerId string representing the id
+ * @return ControllerId
+ */
+ public static ControllerId from(String controllerId) {
+ return new ControllerId(controllerId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/Id.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/Id.java b/helix-core/src/main/java/org/apache/helix/api/Id.java
index 6c9556a..312bb26 100644
--- a/helix-core/src/main/java/org/apache/helix/api/Id.java
+++ b/helix-core/src/main/java/org/apache/helix/api/Id.java
@@ -52,122 +52,4 @@ public abstract class Id implements Comparable<Id> {
}
return -1;
}
-
- /**
- * Get a concrete cluster id for a string name
- * @param clusterId string cluter identifier
- * @return ClusterId
- */
- public static ClusterId cluster(String clusterId) {
- if (clusterId == null) {
- return null;
- }
- return new ClusterId(clusterId);
- }
-
- /**
- * Get a concrete resource id for a string name
- * @param resourceId string resource identifier
- * @return ResourceId
- */
- public static ResourceId resource(String resourceId) {
- if (resourceId == null) {
- return null;
- }
- return new ResourceId(resourceId);
- }
-
- /**
- * Get a concrete partition id
- * @param partitionId string partition identifier
- * @return PartitionId
- */
- public static PartitionId partition(String partitionId) {
- if (partitionId == null) {
- return null;
- }
- return new PartitionId(PartitionId.extractResourceId(partitionId),
- PartitionId.stripResourceId(partitionId));
- }
-
- /**
- * Get a concrete partition id
- * @param resourceId resource identifier
- * @param partitionSuffix partition identifier relative to a resource
- * @return PartitionId
- */
- public static PartitionId partition(ResourceId resourceId, String partitionSuffix) {
- return new PartitionId(resourceId, partitionSuffix);
- }
-
- /**
- * Get a concrete participant id
- * @param participantId string participant identifier
- * @return ParticipantId
- */
- public static ParticipantId participant(String participantId) {
- if (participantId == null) {
- return null;
- }
- return new ParticipantId(participantId);
- }
-
- /**
- * Get a concrete session id
- * @param sessionId string session identifier
- * @return SessionId
- */
- public static SessionId session(String sessionId) {
- if (sessionId == null) {
- return null;
- }
- return new SessionId(sessionId);
- }
-
- /**
- * Get a concrete process id
- * @param procId string process identifier (e.g. pid@host)
- * @return ProcId
- */
- public static ProcId process(String processId) {
- if (processId == null) {
- return null;
- }
- return new ProcId(processId);
- }
-
- /**
- * Get a concrete state model definition id
- * @param stateModelDefId string state model identifier
- * @return StateModelDefId
- */
- public static StateModelDefId stateModelDef(String stateModelDefId) {
- if (stateModelDefId == null) {
- return null;
- }
- return new StateModelDefId(stateModelDefId);
- }
-
- /**
- * @param stateModelFactoryId
- * @return
- */
- public static StateModelFactoryId stateModelFactory(String stateModelFactoryId) {
- if (stateModelFactoryId == null) {
- return null;
- }
- return new StateModelFactoryId(stateModelFactoryId);
- }
-
- /**
- * Get a concrete message id
- * @param messageId string message identifier
- * @return MsgId
- */
- public static MessageId message(String messageId) {
- if (messageId == null) {
- return null;
- }
- return new MessageId(messageId);
- }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/MessageId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/MessageId.java b/helix-core/src/main/java/org/apache/helix/api/MessageId.java
index 5d271c8..c84aae3 100644
--- a/helix-core/src/main/java/org/apache/helix/api/MessageId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/MessageId.java
@@ -23,7 +23,7 @@ public class MessageId extends Id {
private final String _id;
- public MessageId(String id) {
+ private MessageId(String id) {
_id = id;
}
@@ -31,4 +31,16 @@ public class MessageId extends Id {
public String stringify() {
return _id;
}
+
+ /**
+ * Get a concrete message id
+ * @param messageId string message identifier
+ * @return MsgId
+ */
+ public static MessageId from(String messageId) {
+ if (messageId == null) {
+ return null;
+ }
+ return new MessageId(messageId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/NamespacedConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/NamespacedConfig.java b/helix-core/src/main/java/org/apache/helix/api/NamespacedConfig.java
index f7656d7..5c7fbc3 100644
--- a/helix-core/src/main/java/org/apache/helix/api/NamespacedConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/NamespacedConfig.java
@@ -34,15 +34,16 @@ import com.google.common.collect.Maps;
* Generic configuration of Helix components prefixed with a namespace
*/
public abstract class NamespacedConfig extends ZNRecord {
+ private static final char PREFIX_CHAR = '!';
private final String _prefix;
/**
* Instantiate a NamespacedConfig. It is intended for use only by entities that can be identified
- * @param id id object
+ * @param scope scope object
*/
- public NamespacedConfig(Id id, String prefix) {
- super(id.stringify());
- _prefix = prefix + '_';
+ public NamespacedConfig(Scope<?> scope, String prefix) {
+ super(scope.getScopedId().stringify());
+ _prefix = prefix + PREFIX_CHAR;
}
/**
@@ -51,7 +52,7 @@ public abstract class NamespacedConfig extends ZNRecord {
*/
public NamespacedConfig(HelixProperty property, String prefix) {
super(property.getRecord());
- _prefix = prefix + '_';
+ _prefix = prefix + PREFIX_CHAR;
filterNonPrefixedFields();
}
@@ -61,7 +62,7 @@ public abstract class NamespacedConfig extends ZNRecord {
*/
public NamespacedConfig(NamespacedConfig config) {
super(config.getId());
- _prefix = config.getPrefix() + '_';
+ _prefix = config.getPrefix() + PREFIX_CHAR;
if (config.getRawPayload() != null && config.getRawPayload().length > 0) {
setRawPayload(config.getRawPayload());
setPayloadSerializer(config.getPayloadSerializer());
@@ -151,7 +152,7 @@ public abstract class NamespacedConfig extends ZNRecord {
* @return string prefix, not including the underscore
*/
public String getPrefix() {
- return _prefix.substring(0, _prefix.indexOf('_'));
+ return _prefix.substring(0, _prefix.indexOf(PREFIX_CHAR));
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ParticipantAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ParticipantAccessor.java b/helix-core/src/main/java/org/apache/helix/api/ParticipantAccessor.java
index bce5b2f..6c1be9e 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ParticipantAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ParticipantAccessor.java
@@ -293,7 +293,7 @@ public class ParticipantAccessor {
if (disabledPartitions != null) {
disabledPartitionIdSet = new HashSet<PartitionId>();
for (String partitionId : disabledPartitions) {
- disabledPartitionIdSet.add(Id.partition(PartitionId.extractResourceId(partitionId),
+ disabledPartitionIdSet.add(PartitionId.from(PartitionId.extractResourceId(partitionId),
PartitionId.stripResourceId(partitionId)));
}
}
@@ -311,7 +311,7 @@ public class ParticipantAccessor {
if (instanceMsgMap != null) {
for (String msgId : instanceMsgMap.keySet()) {
Message message = instanceMsgMap.get(msgId);
- msgMap.put(new MessageId(msgId), message);
+ msgMap.put(MessageId.from(msgId), message);
}
}
@@ -319,7 +319,7 @@ public class ParticipantAccessor {
if (instanceCurStateMap != null) {
for (String resourceName : instanceCurStateMap.keySet()) {
- curStateMap.put(new ResourceId(resourceName), instanceCurStateMap.get(resourceName));
+ curStateMap.put(ResourceId.from(resourceName), instanceCurStateMap.get(resourceName));
}
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ParticipantConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ParticipantConfig.java b/helix-core/src/main/java/org/apache/helix/api/ParticipantConfig.java
index 7164882..f41056c 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ParticipantConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ParticipantConfig.java
@@ -142,7 +142,7 @@ public class ParticipantConfig {
_disabledPartitions = new HashSet<PartitionId>();
_tags = new HashSet<String>();
_isEnabled = true;
- _userConfig = new UserConfig(id);
+ _userConfig = new UserConfig(Scope.participant(id));
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ParticipantId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ParticipantId.java b/helix-core/src/main/java/org/apache/helix/api/ParticipantId.java
index cf8a88d..7390d5d 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ParticipantId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ParticipantId.java
@@ -22,7 +22,7 @@ package org.apache.helix.api;
public class ParticipantId extends Id {
private final String _id;
- public ParticipantId(String id) {
+ private ParticipantId(String id) {
_id = id;
}
@@ -30,4 +30,16 @@ public class ParticipantId extends Id {
public String stringify() {
return _id;
}
+
+ /**
+ * Get a concrete participant id
+ * @param participantId string participant identifier
+ * @return ParticipantId
+ */
+ public static ParticipantId from(String participantId) {
+ if (participantId == null) {
+ return null;
+ }
+ return new ParticipantId(participantId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/PartitionId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/PartitionId.java b/helix-core/src/main/java/org/apache/helix/api/PartitionId.java
index 9257eee..e72f1b3 100644
--- a/helix-core/src/main/java/org/apache/helix/api/PartitionId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/PartitionId.java
@@ -23,7 +23,7 @@ public class PartitionId extends Id {
private final ResourceId _resourceId;
private final String _partitionName;
- public PartitionId(ResourceId resourceId, String partitionName) {
+ private PartitionId(ResourceId resourceId, String partitionName) {
_resourceId = resourceId;
_partitionName = partitionName;
}
@@ -54,8 +54,30 @@ public class PartitionId extends Id {
*/
public static ResourceId extractResourceId(String partitionName) {
if (partitionName == null || !partitionName.contains("_")) {
- return new ResourceId(partitionName);
+ return ResourceId.from(partitionName);
}
- return new ResourceId(partitionName.substring(0, partitionName.lastIndexOf("_")));
+ return ResourceId.from(partitionName.substring(0, partitionName.lastIndexOf("_")));
+ }
+
+ /**
+ * Get a concrete partition id
+ * @param partitionId string partition identifier
+ * @return PartitionId
+ */
+ public static PartitionId from(String partitionId) {
+ if (partitionId == null) {
+ return null;
+ }
+ return new PartitionId(extractResourceId(partitionId), stripResourceId(partitionId));
+ }
+
+ /**
+ * Get a concrete partition id
+ * @param resourceId resource identifier
+ * @param partitionSuffix partition identifier relative to a resource
+ * @return PartitionId
+ */
+ public static PartitionId from(ResourceId resourceId, String partitionSuffix) {
+ return new PartitionId(resourceId, partitionSuffix);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ProcId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ProcId.java b/helix-core/src/main/java/org/apache/helix/api/ProcId.java
index 106e5d6..b97512a 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ProcId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ProcId.java
@@ -23,7 +23,7 @@ public class ProcId extends Id {
private final String _id;
- public ProcId(String id) {
+ private ProcId(String id) {
_id = id;
}
@@ -32,4 +32,15 @@ public class ProcId extends Id {
return _id;
}
+ /**
+ * Get a concrete process id
+ * @param processId string process identifier (e.g. pid@host)
+ * @return ProcId
+ */
+ public static ProcId from(String processId) {
+ if (processId == null) {
+ return null;
+ }
+ return new ProcId(processId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/RebalancerConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/RebalancerConfig.java b/helix-core/src/main/java/org/apache/helix/api/RebalancerConfig.java
index be4a11f..2f531e0 100644
--- a/helix-core/src/main/java/org/apache/helix/api/RebalancerConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/RebalancerConfig.java
@@ -26,6 +26,7 @@ import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeMap;
import org.apache.helix.model.IdealState.RebalanceMode;
import org.apache.helix.model.ResourceConfiguration;
@@ -70,7 +71,7 @@ public class RebalancerConfig extends NamespacedConfig {
public RebalancerConfig(ResourceId resourceId, RebalanceMode rebalancerMode,
StateModelDefId stateModelDefId, StateModelFactoryId stateModelFactoryId,
Map<PartitionId, Partition> partitionMap) {
- super(resourceId, RebalancerConfig.class.getSimpleName());
+ super(Scope.resource(resourceId), RebalancerConfig.class.getSimpleName());
_resourceId = resourceId;
_fieldsSet =
ImmutableSet.copyOf(Lists.transform(Arrays.asList(Fields.values()),
@@ -90,7 +91,7 @@ public class RebalancerConfig extends NamespacedConfig {
*/
public RebalancerConfig(ResourceId resourceId, RebalanceMode rebalancerMode,
StateModelDefId stateModelDefId, Map<PartitionId, Partition> partitionMap) {
- super(resourceId, RebalancerConfig.class.getSimpleName());
+ super(Scope.resource(resourceId), RebalancerConfig.class.getSimpleName());
_resourceId = resourceId;
_fieldsSet =
ImmutableSet.copyOf(Lists.transform(Arrays.asList(Fields.values()),
@@ -120,7 +121,7 @@ public class RebalancerConfig extends NamespacedConfig {
* @param config populated RebalancerConfig
*/
protected RebalancerConfig(RebalancerConfig config) {
- super(config.getResourceId(), RebalancerConfig.class.getSimpleName());
+ super(Scope.resource(config.getResourceId()), RebalancerConfig.class.getSimpleName());
_resourceId = config.getResourceId();
_partitionMap = config.getPartitionMap();
_fieldsSet =
@@ -183,7 +184,7 @@ public class RebalancerConfig extends NamespacedConfig {
* @return state model definition
*/
public StateModelDefId getStateModelDefId() {
- return Id.stateModelDef(getStringField(Fields.STATE_MODEL_DEFINITION.toString(), null));
+ return StateModelDefId.from(getStringField(Fields.STATE_MODEL_DEFINITION.toString(), null));
}
/**
@@ -240,7 +241,7 @@ public class RebalancerConfig extends NamespacedConfig {
* @return state model factory id
*/
public StateModelFactoryId getStateModelFactoryId() {
- return Id.stateModelFactory(getStringField(Fields.STATE_MODEL_FACTORY.toString(), null));
+ return StateModelFactoryId.from(getStringField(Fields.STATE_MODEL_FACTORY.toString(), null));
}
/**
@@ -371,7 +372,7 @@ public class RebalancerConfig extends NamespacedConfig {
_anyLiveParticipant = false;
_replicaCount = 0;
_maxPartitionsPerParticipant = Integer.MAX_VALUE;
- _partitionMap = new HashMap<PartitionId, Partition>();
+ _partitionMap = new TreeMap<PartitionId, Partition>();
}
/**
@@ -465,13 +466,14 @@ public class RebalancerConfig extends NamespacedConfig {
*/
public T addPartitions(int partitionCount) {
for (int i = 0; i < partitionCount; i++) {
- addPartition(new Partition(Id.partition(_resourceId, Integer.toString(i)), null));
+ addPartition(new Partition(PartitionId.from(_resourceId, Integer.toString(i)), null));
}
return self();
}
/**
* Update a RebalancerConfig with built fields
+ * @param rebalancerConfig the config to update
*/
protected void update(RebalancerConfig rebalancerConfig) {
rebalancerConfig.setReplicaCount(_replicaCount);
@@ -499,59 +501,32 @@ public class RebalancerConfig extends NamespacedConfig {
}
/**
- * Simple non-mode builder for rebalancer config
+ * Simple none-mode builder for rebalancer config
*/
- public static class SimpleBuilder {
- private final ResourceId _resourceId;
- private StateModelDefId _stateModelDefId;
- private StateModelFactoryId _stateModelFactoryId;
- private final Map<PartitionId, Partition> _partitionMap;
-
+ public static class SimpleBuilder extends Builder<SimpleBuilder> {
/**
* Construct with a resource-id
* @param resourceId
*/
public SimpleBuilder(ResourceId resourceId) {
- _resourceId = resourceId;
- _partitionMap = new HashMap<PartitionId, Partition>();
+ super(resourceId);
}
/**
- * Set state model definition id
- * @param stateModelDefId
+ * Build a rebalancer config
* @return
*/
- public SimpleBuilder stateModelDefId(StateModelDefId stateModelDefId) {
- _stateModelDefId = stateModelDefId;
- return this;
- }
-
- /**
- * Add a partition that the resource serves
- * @param partition fully-qualified partition
- * @return Builder
- */
- public SimpleBuilder addPartition(Partition partition) {
- _partitionMap.put(partition.getId(), partition);
- return this;
+ @Override
+ public RebalancerConfig build() {
+ RebalancerConfig config =
+ new RebalancerConfig(_resourceId, RebalanceMode.NONE, _stateModelDefId, _partitionMap);
+ update(config);
+ return config;
}
- /**
- * Set state model factory
- * @param stateModelFactoryId
- * @return Builder
- */
- public SimpleBuilder stateModelFactoryId(StateModelFactoryId stateModelFactoryId) {
- _stateModelFactoryId = stateModelFactoryId;
+ @Override
+ protected SimpleBuilder self() {
return this;
}
-
- /**
- * Build a rebalancer config
- * @return
- */
- public RebalancerConfig build() {
- return new RebalancerConfig(_resourceId, RebalanceMode.NONE, _stateModelDefId, _partitionMap);
- }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/RebalancerRef.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/RebalancerRef.java b/helix-core/src/main/java/org/apache/helix/api/RebalancerRef.java
index f610585..8628795 100644
--- a/helix-core/src/main/java/org/apache/helix/api/RebalancerRef.java
+++ b/helix-core/src/main/java/org/apache/helix/api/RebalancerRef.java
@@ -55,7 +55,7 @@ public class RebalancerRef {
if (that instanceof RebalancerRef) {
return this.toString().equals(((RebalancerRef) that).toString());
} else if (that instanceof String) {
- return this.toString().equals((String) that);
+ return this.toString().equals(that);
}
return false;
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/Resource.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/Resource.java b/helix-core/src/main/java/org/apache/helix/api/Resource.java
index 6fb54e6..eade077 100644
--- a/helix-core/src/main/java/org/apache/helix/api/Resource.java
+++ b/helix-core/src/main/java/org/apache/helix/api/Resource.java
@@ -49,19 +49,19 @@ public class Resource {
ExternalView externalView, UserConfig userConfig,
Map<PartitionId, UserConfig> partitionUserConfigs) {
Map<PartitionId, Partition> partitionMap = new HashMap<PartitionId, Partition>();
- new HashMap<PartitionId, Map<String, String>>();
+ new HashMap<PartitionId, Map<String, String>>();
Set<PartitionId> partitionSet = idealState.getPartitionSet();
if (partitionSet.isEmpty() && idealState.getNumPartitions() > 0) {
partitionSet = new HashSet<PartitionId>();
for (int i = 0; i < idealState.getNumPartitions(); i++) {
- partitionSet.add(Id.partition(id, Integer.toString(i)));
+ partitionSet.add(PartitionId.from(id, Integer.toString(i)));
}
}
for (PartitionId partitionId : partitionSet) {
UserConfig partitionUserConfig = partitionUserConfigs.get(partitionId);
if (partitionUserConfig == null) {
- partitionUserConfig = new UserConfig(partitionId);
+ partitionUserConfig = new UserConfig(Scope.partition(partitionId));
}
partitionMap.put(partitionId, new Partition(partitionId, partitionUserConfig));
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ResourceAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ResourceAccessor.java b/helix-core/src/main/java/org/apache/helix/api/ResourceAccessor.java
index c3bcb37..fa36247 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ResourceAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ResourceAccessor.java
@@ -23,7 +23,6 @@ import org.apache.helix.HelixDataAccessor;
import org.apache.helix.PropertyKey;
import org.apache.helix.model.ExternalView;
import org.apache.helix.model.IdealState;
-import org.apache.helix.model.IdealState.RebalanceMode;
import org.apache.helix.model.ResourceAssignment;
public class ResourceAccessor {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ResourceConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ResourceConfig.java b/helix-core/src/main/java/org/apache/helix/api/ResourceConfig.java
index 4be28b0..dd93d79 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ResourceConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ResourceConfig.java
@@ -151,7 +151,7 @@ public class ResourceConfig {
_id = id;
_bucketSize = 0;
_batchMessageMode = false;
- _userConfig = new UserConfig(id);
+ _userConfig = new UserConfig(Scope.resource(id));
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/ResourceId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/ResourceId.java b/helix-core/src/main/java/org/apache/helix/api/ResourceId.java
index 0b10290..3df2ef0 100644
--- a/helix-core/src/main/java/org/apache/helix/api/ResourceId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/ResourceId.java
@@ -19,6 +19,9 @@ package org.apache.helix.api;
* under the License.
*/
+/**
+ * Identifies a resource
+ */
public class ResourceId extends Id {
private final String _id;
@@ -27,7 +30,22 @@ public class ResourceId extends Id {
return _id;
}
- public ResourceId(String id) {
+ /**
+ * @param id
+ */
+ private ResourceId(String id) {
_id = id;
}
+
+ /**
+ * Get a concrete resource id for a string name
+ * @param resourceId string resource identifier
+ * @return ResourceId
+ */
+ public static ResourceId from(String resourceId) {
+ if (resourceId == null) {
+ return null;
+ }
+ return new ResourceId(resourceId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/SessionId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/SessionId.java b/helix-core/src/main/java/org/apache/helix/api/SessionId.java
index 1bc1c32..777c506 100644
--- a/helix-core/src/main/java/org/apache/helix/api/SessionId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/SessionId.java
@@ -22,7 +22,7 @@ package org.apache.helix.api;
public class SessionId extends Id {
private final String _id;
- public SessionId(String id) {
+ private SessionId(String id) {
_id = id;
}
@@ -31,4 +31,15 @@ public class SessionId extends Id {
return _id;
}
+ /**
+ * Get a concrete session id
+ * @param sessionId string session identifier
+ * @return SessionId
+ */
+ public static SessionId from(String sessionId) {
+ if (sessionId == null) {
+ return null;
+ }
+ return new SessionId(sessionId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/SpectatorId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/SpectatorId.java b/helix-core/src/main/java/org/apache/helix/api/SpectatorId.java
index 689cad6..ebfa845 100644
--- a/helix-core/src/main/java/org/apache/helix/api/SpectatorId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/SpectatorId.java
@@ -22,7 +22,7 @@ package org.apache.helix.api;
public class SpectatorId extends Id {
private final String _id;
- public SpectatorId(String id) {
+ private SpectatorId(String id) {
_id = id;
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/StateModelDefId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/StateModelDefId.java b/helix-core/src/main/java/org/apache/helix/api/StateModelDefId.java
index f77cec8..e4e05ba 100644
--- a/helix-core/src/main/java/org/apache/helix/api/StateModelDefId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/StateModelDefId.java
@@ -22,11 +22,11 @@ import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory;
*/
public class StateModelDefId extends Id {
- public static final StateModelDefId SchedulerTaskQueue = Id
- .stateModelDef(DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE);
+ public static final StateModelDefId SchedulerTaskQueue = StateModelDefId
+ .from(DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE);
private final String _id;
- public StateModelDefId(String id) {
+ private StateModelDefId(String id) {
_id = id;
}
@@ -38,4 +38,16 @@ public class StateModelDefId extends Id {
public boolean equalsIgnoreCase(StateModelDefId that) {
return _id.equalsIgnoreCase(that._id);
}
+
+ /**
+ * Get a concrete state model definition id
+ * @param stateModelDefId string state model identifier
+ * @return StateModelDefId
+ */
+ public static StateModelDefId from(String stateModelDefId) {
+ if (stateModelDefId == null) {
+ return null;
+ }
+ return new StateModelDefId(stateModelDefId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/StateModelDefinitionAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/StateModelDefinitionAccessor.java b/helix-core/src/main/java/org/apache/helix/api/StateModelDefinitionAccessor.java
index 3f399c3..f2bbf6d 100644
--- a/helix-core/src/main/java/org/apache/helix/api/StateModelDefinitionAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/api/StateModelDefinitionAccessor.java
@@ -54,7 +54,7 @@ public class StateModelDefinitionAccessor {
new HashMap<StateModelDefId, StateModelDefinition>();
for (String stateModelDefName : stateModelDefs.keySet()) {
- stateModelDefMap.put(new StateModelDefId(stateModelDefName),
+ stateModelDefMap.put(StateModelDefId.from(stateModelDefName),
stateModelDefs.get(stateModelDefName));
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/StateModelFactoryId.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/StateModelFactoryId.java b/helix-core/src/main/java/org/apache/helix/api/StateModelFactoryId.java
index 37be836..fcd9f0d 100644
--- a/helix-core/src/main/java/org/apache/helix/api/StateModelFactoryId.java
+++ b/helix-core/src/main/java/org/apache/helix/api/StateModelFactoryId.java
@@ -22,7 +22,7 @@ package org.apache.helix.api;
public class StateModelFactoryId extends Id {
private final String _id;
- public StateModelFactoryId(String id) {
+ private StateModelFactoryId(String id) {
_id = id;
}
@@ -31,4 +31,15 @@ public class StateModelFactoryId extends Id {
return _id;
}
+ /**
+ * Get a concrete state model factory id
+ * @param stateModelFactoryId the string version of the id
+ * @return StateModelFactoryId
+ */
+ public static StateModelFactoryId from(String stateModelFactoryId) {
+ if (stateModelFactoryId == null) {
+ return null;
+ }
+ return new StateModelFactoryId(stateModelFactoryId);
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/api/UserConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/UserConfig.java b/helix-core/src/main/java/org/apache/helix/api/UserConfig.java
index 6bef146..181c071 100644
--- a/helix-core/src/main/java/org/apache/helix/api/UserConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/UserConfig.java
@@ -27,23 +27,23 @@ import org.apache.helix.HelixProperty;
public class UserConfig extends NamespacedConfig {
/**
* Instantiate a UserConfig. It is intended for use only by entities that can be identified
- * @param id id object
+ * @param scope scope of the configuration, e.g. cluster, resource, partition, participant, etc
*/
- public UserConfig(Id id) {
- super(id, UserConfig.class.getSimpleName());
+ public UserConfig(Scope<?> scope) {
+ super(scope, UserConfig.class.getSimpleName());
}
/**
* Instantiate a UserConfig from an existing HelixProperty
* @param property property wrapping a configuration
*/
- public UserConfig(HelixProperty property) {
+ private UserConfig(HelixProperty property) {
super(property, UserConfig.class.getSimpleName());
}
/**
* Get a UserConfig that filters out the user-specific configurations in a property
- * @param property the property to check
+ * @param property the property to extract from
* @return UserConfig
*/
public static UserConfig from(HelixProperty property) {
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java b/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java
index 3d811bc..c3287ce 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/ExternalViewGenerator.java
@@ -28,8 +28,8 @@ import java.util.TreeMap;
import java.util.TreeSet;
import org.apache.helix.ZNRecord;
-import org.apache.helix.model.Message;
import org.apache.helix.model.CurrentState.CurrentStateProperty;
+import org.apache.helix.model.Message;
import org.apache.log4j.Logger;
/*
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
index 4df2201..ab1f824 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/GenericHelixController.java
@@ -39,9 +39,9 @@ import org.apache.helix.IdealStateChangeListener;
import org.apache.helix.LiveInstanceChangeListener;
import org.apache.helix.MessageListener;
import org.apache.helix.NotificationContext;
-import org.apache.helix.ZNRecord;
import org.apache.helix.NotificationContext.Type;
import org.apache.helix.PropertyKey.Builder;
+import org.apache.helix.ZNRecord;
import org.apache.helix.controller.pipeline.Pipeline;
import org.apache.helix.controller.pipeline.PipelineRegistry;
import org.apache.helix.controller.stages.ClusterEvent;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/rebalancer/AutoRebalancer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/AutoRebalancer.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/AutoRebalancer.java
index b796b72..32b4e92 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/AutoRebalancer.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/AutoRebalancer.java
@@ -29,7 +29,8 @@ import java.util.Set;
import org.apache.helix.HelixManager;
import org.apache.helix.ZNRecord;
-import org.apache.helix.api.Id;
+import org.apache.helix.api.PartitionId;
+import org.apache.helix.api.ResourceId;
import org.apache.helix.controller.rebalancer.util.ConstraintBasedAssignment;
import org.apache.helix.controller.stages.ClusterDataCache;
import org.apache.helix.controller.stages.CurrentStateOutput;
@@ -136,7 +137,7 @@ public class AutoRebalancer implements Rebalancer {
LOG.debug("Processing resource:" + resource.getResourceName());
}
ResourceAssignment partitionMapping =
- new ResourceAssignment(Id.resource(resource.getResourceName()));
+ new ResourceAssignment(ResourceId.from(resource.getResourceName()));
for (String partitionName : partitions) {
Partition partition = new Partition(partitionName);
Map<String, String> currentStateMap =
@@ -149,7 +150,7 @@ public class AutoRebalancer implements Rebalancer {
Map<String, String> bestStateForPartition =
ConstraintBasedAssignment.computeAutoBestStateForPartition(clusterData, stateModelDef,
preferenceList, currentStateMap, disabledInstancesForPartition);
- partitionMapping.addReplicaMap(Id.partition(partitionName),
+ partitionMapping.addReplicaMap(PartitionId.from(partitionName),
ResourceAssignment.replicaMapFromStringMap(bestStateForPartition));
}
return partitionMapping;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/rebalancer/CustomRebalancer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/CustomRebalancer.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/CustomRebalancer.java
index b22562e..689561b 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/CustomRebalancer.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/CustomRebalancer.java
@@ -25,7 +25,8 @@ import java.util.Set;
import org.apache.helix.HelixDefinedState;
import org.apache.helix.HelixManager;
-import org.apache.helix.api.Id;
+import org.apache.helix.api.PartitionId;
+import org.apache.helix.api.ResourceId;
import org.apache.helix.controller.stages.ClusterDataCache;
import org.apache.helix.controller.stages.CurrentStateOutput;
import org.apache.helix.model.IdealState;
@@ -62,7 +63,7 @@ public class CustomRebalancer implements Rebalancer {
LOG.debug("Processing resource:" + resource.getResourceName());
}
ResourceAssignment partitionMapping =
- new ResourceAssignment(Id.resource(resource.getResourceName()));
+ new ResourceAssignment(ResourceId.from(resource.getResourceName()));
for (Partition partition : resource.getPartitions()) {
Map<String, String> currentStateMap =
currentStateOutput.getCurrentStateMap(resource.getResourceName(), partition);
@@ -73,7 +74,7 @@ public class CustomRebalancer implements Rebalancer {
Map<String, String> bestStateForPartition =
computeCustomizedBestStateForPartition(clusterData, stateModelDef, idealStateMap,
currentStateMap, disabledInstancesForPartition);
- partitionMapping.addReplicaMap(Id.partition(partition.getPartitionName()),
+ partitionMapping.addReplicaMap(PartitionId.from(partition.getPartitionName()),
ResourceAssignment.replicaMapFromStringMap(bestStateForPartition));
}
return partitionMapping;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/rebalancer/NewAutoRebalancer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/NewAutoRebalancer.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/NewAutoRebalancer.java
index 798e883..8212b7f 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/NewAutoRebalancer.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/NewAutoRebalancer.java
@@ -31,7 +31,6 @@ import java.util.Set;
import org.apache.helix.ZNRecord;
import org.apache.helix.api.Cluster;
import org.apache.helix.api.FullAutoRebalancerConfig;
-import org.apache.helix.api.Id;
import org.apache.helix.api.Participant;
import org.apache.helix.api.ParticipantId;
import org.apache.helix.api.PartitionId;
@@ -148,7 +147,7 @@ public class NewAutoRebalancer implements NewRebalancer<FullAutoRebalancerConfig
Lists.transform(rawPreferenceList, new Function<String, ParticipantId>() {
@Override
public ParticipantId apply(String participantName) {
- return Id.participant(participantName);
+ return ParticipantId.from(participantName);
}
});
preferenceList =
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/rebalancer/SemiAutoRebalancer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/SemiAutoRebalancer.java b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/SemiAutoRebalancer.java
index a488548..d525ea3 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/rebalancer/SemiAutoRebalancer.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/rebalancer/SemiAutoRebalancer.java
@@ -24,7 +24,8 @@ import java.util.Map;
import java.util.Set;
import org.apache.helix.HelixManager;
-import org.apache.helix.api.Id;
+import org.apache.helix.api.PartitionId;
+import org.apache.helix.api.ResourceId;
import org.apache.helix.controller.rebalancer.util.ConstraintBasedAssignment;
import org.apache.helix.controller.stages.ClusterDataCache;
import org.apache.helix.controller.stages.CurrentStateOutput;
@@ -61,7 +62,7 @@ public class SemiAutoRebalancer implements Rebalancer {
LOG.debug("Processing resource:" + resource.getResourceName());
}
ResourceAssignment partitionMapping =
- new ResourceAssignment(Id.resource(resource.getResourceName()));
+ new ResourceAssignment(ResourceId.from(resource.getResourceName()));
for (Partition partition : resource.getPartitions()) {
Map<String, String> currentStateMap =
currentStateOutput.getCurrentStateMap(resource.getResourceName(), partition);
@@ -73,7 +74,7 @@ public class SemiAutoRebalancer implements Rebalancer {
Map<String, String> bestStateForPartition =
ConstraintBasedAssignment.computeAutoBestStateForPartition(clusterData, stateModelDef,
preferenceList, currentStateMap, disabledInstancesForPartition);
- partitionMapping.addReplicaMap(Id.partition(partition.getPartitionName()),
+ partitionMapping.addReplicaMap(PartitionId.from(partition.getPartitionName()),
ResourceAssignment.replicaMapFromStringMap(bestStateForPartition));
}
return partitionMapping;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
index 96277cf..b210571 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZKPropertyTransferServer.java
@@ -29,7 +29,6 @@ import java.util.concurrent.atomic.AtomicReference;
import org.I0Itec.zkclient.DataUpdater;
import org.apache.helix.AccessOption;
-import org.apache.helix.BaseDataAccessor;
import org.apache.helix.ZNRecord;
import org.apache.helix.manager.zk.ZNRecordSerializer;
import org.apache.helix.manager.zk.ZkBaseDataAccessor;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
index f704f54..d489378 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/restlet/ZNRecordUpdateResource.java
@@ -27,7 +27,6 @@ import org.apache.log4j.Logger;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.type.TypeReference;
import org.restlet.data.Form;
-import org.restlet.data.MediaType;
import org.restlet.data.Status;
import org.restlet.resource.Representation;
import org.restlet.resource.Resource;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java b/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java
index a2749e6..c7473ff 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/BestPossibleStateCalcStage.java
@@ -22,8 +22,8 @@ package org.apache.helix.controller.stages;
import java.util.Map;
import org.apache.helix.HelixManager;
-import org.apache.helix.api.Id;
import org.apache.helix.api.ParticipantId;
+import org.apache.helix.api.PartitionId;
import org.apache.helix.api.State;
import org.apache.helix.controller.pipeline.AbstractBaseStage;
import org.apache.helix.controller.pipeline.StageException;
@@ -124,7 +124,7 @@ public class BestPossibleStateCalcStage extends AbstractBaseStage {
rebalancer.computeResourceMapping(resource, idealState, currentStateOutput, cache);
for (Partition partition : resource.getPartitions()) {
Map<ParticipantId, State> newStateMap =
- partitionStateAssignment.getReplicaMap(Id.partition(partition.getPartitionName()));
+ partitionStateAssignment.getReplicaMap(PartitionId.from(partition.getPartitionName()));
output.setParticipantStateMap(resourceName, partition, newStateMap);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/stages/ExternalViewComputeStage.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/ExternalViewComputeStage.java b/helix-core/src/main/java/org/apache/helix/controller/stages/ExternalViewComputeStage.java
index 8101b61..9e16568 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/ExternalViewComputeStage.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/ExternalViewComputeStage.java
@@ -29,7 +29,6 @@ import java.util.TreeMap;
import org.apache.helix.HelixDataAccessor;
import org.apache.helix.HelixDefinedState;
import org.apache.helix.HelixManager;
-import org.apache.helix.NotificationContext;
import org.apache.helix.PropertyKey;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.ZNRecord;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/stages/HealthDataCache.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/HealthDataCache.java b/helix-core/src/main/java/org/apache/helix/controller/stages/HealthDataCache.java
index 3ab8336..6b29e2d 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/HealthDataCache.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/HealthDataCache.java
@@ -24,8 +24,6 @@ import java.util.HashMap;
import java.util.Map;
import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixProperty;
-import org.apache.helix.PropertyType;
import org.apache.helix.PropertyKey.Builder;
import org.apache.helix.model.AlertStatus;
import org.apache.helix.model.Alerts;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/ac37a5e4/helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java b/helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
index d50ddb2..e2c8854 100644
--- a/helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
+++ b/helix-core/src/main/java/org/apache/helix/controller/stages/MessageGenerationPhase.java
@@ -26,9 +26,12 @@ import java.util.Map;
import java.util.UUID;
import org.apache.helix.HelixManager;
-import org.apache.helix.api.Id;
import org.apache.helix.api.MessageId;
+import org.apache.helix.api.PartitionId;
+import org.apache.helix.api.ResourceId;
+import org.apache.helix.api.SessionId;
import org.apache.helix.api.State;
+import org.apache.helix.api.StateModelDefId;
import org.apache.helix.controller.pipeline.AbstractBaseStage;
import org.apache.helix.controller.pipeline.StageException;
import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory;
@@ -191,18 +194,18 @@ public class MessageGenerationPhase extends AbstractBaseStage {
private Message createMessage(HelixManager manager, String resourceName, String partitionName,
String instanceName, String currentState, String nextState, String sessionId,
String stateModelDefName, String stateModelFactoryName, int bucketSize) {
- MessageId uuid = Id.message(UUID.randomUUID().toString());
+ MessageId uuid = MessageId.from(UUID.randomUUID().toString());
Message message = new Message(MessageType.STATE_TRANSITION, uuid);
message.setSrcName(manager.getInstanceName());
message.setTgtName(instanceName);
message.setMsgState(MessageState.NEW);
- message.setPartitionId(Id.partition(partitionName));
- message.setResourceId(Id.resource(resourceName));
+ message.setPartitionId(PartitionId.from(partitionName));
+ message.setResourceId(ResourceId.from(resourceName));
message.setFromState(State.from(currentState));
message.setToState(State.from(nextState));
- message.setTgtSessionId(Id.session(sessionId));
- message.setSrcSessionId(Id.session(manager.getSessionId()));
- message.setStateModelDef(Id.stateModelDef(stateModelDefName));
+ message.setTgtSessionId(SessionId.from(sessionId));
+ message.setSrcSessionId(SessionId.from(manager.getSessionId()));
+ message.setStateModelDef(StateModelDefId.from(stateModelDefName));
message.setStateModelFactoryName(stateModelFactoryName);
message.setBucketSize(bucketSize);