Repository: helix Updated Branches: refs/heads/master 122ebf5d2 -> 8e58aa5ad
[HELIX-552] StateModelFactory#_stateModelMap should use both resourceName and partitionKey to map a state model, rb=28211 Project: http://git-wip-us.apache.org/repos/asf/helix/repo Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/8e58aa5a Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/8e58aa5a Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/8e58aa5a Branch: refs/heads/master Commit: 8e58aa5ad7133284876b9bcbb46f18e03855938e Parents: 122ebf5 Author: zzhang <[email protected]> Authored: Wed Nov 19 15:36:37 2014 -0800 Committer: zzhang <[email protected]> Committed: Wed Nov 19 15:36:37 2014 -0800 ---------------------------------------------------------------------- .../helix/agent/AgentStateModelFactory.java | 3 +- .../main/java/org/apache/helix/PropertyKey.java | 9 ++ .../api/StateTransitionHandlerFactory.java | 63 ++++++---- .../handling/HelixStateTransitionHandler.java | 2 +- .../GenericLeaderStandbyStateModelFactory.java | 4 +- .../participant/HelixStateMachineEngine.java | 51 ++++---- ...usterControllerTransitionHandlerFactory.java | 4 +- .../statemachine/ScheduledTaskStateModel.java | 9 +- .../ScheduledTaskStateModelFactory.java | 7 +- .../helix/task/TaskStateModelFactory.java | 3 +- .../org/apache/helix/TestHelixTaskExecutor.java | 2 +- .../org/apache/helix/TestHelixTaskHandler.java | 2 +- .../TestCorrectnessOnConnectivityLoss.java | 3 +- .../integration/TestEntropyFreeNodeBounce.java | 16 +++ .../helix/integration/TestHelixConnection.java | 2 +- .../helix/integration/TestMessageThrottle2.java | 3 +- .../TestPartitionLevelTransitionConstraint.java | 3 +- .../integration/TestPreferenceListAsQueue.java | 8 +- .../TestResourceWithSamePartitionKey.java | 125 +++++++++++++++++++ .../integration/TestStateTransitionTimeout.java | 12 +- .../helix/integration/TestZkReconnect.java | 2 +- .../integration/manager/TestStateModelLeak.java | 21 ++-- .../helix/mock/participant/DummyProcess.java | 7 +- .../participant/MockBootstrapModelFactory.java | 8 +- .../mock/participant/MockMSModelFactory.java | 12 +- .../participant/MockSchemataModelFactory.java | 4 +- ...MultiClusterControllerStateModelFactory.java | 3 +- .../apache/helix/examples/BootstrapHandler.java | 3 +- .../apache/helix/examples/DummyParticipant.java | 3 +- .../LeaderStandbyStateModelFactory.java | 3 +- .../helix/examples/LogicalModelExample.java | 2 +- .../examples/MasterSlaveStateModelFactory.java | 3 +- .../OnlineOfflineStateModelFactory.java | 3 +- .../helix/ipc/TestNettyHelixIPCService.java | 3 +- .../StatelessServiceStateModelFactory.java | 3 +- .../apache/helix/lockmanager/LockFactory.java | 3 +- .../ConsumerTransitionHandlerFactory.java | 3 +- .../filestore/FileStoreStateModelFactory.java | 3 +- .../taskexecution/TaskStateModelFactory.java | 3 +- .../userdefinedrebalancer/LockFactory.java | 3 +- 40 files changed, 324 insertions(+), 102 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java b/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java index 4e74405..3ace3b6 100644 --- a/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java +++ b/helix-agent/src/main/java/org/apache/helix/agent/AgentStateModelFactory.java @@ -21,11 +21,12 @@ package org.apache.helix.agent; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; public class AgentStateModelFactory extends StateTransitionHandlerFactory<AgentStateModel> { @Override - public AgentStateModel createStateTransitionHandler(PartitionId partitionKey) { + public AgentStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { AgentStateModel model = new AgentStateModel(); return model; } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/PropertyKey.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/PropertyKey.java b/helix-core/src/main/java/org/apache/helix/PropertyKey.java index cbb4e7b..08800a5 100644 --- a/helix-core/src/main/java/org/apache/helix/PropertyKey.java +++ b/helix-core/src/main/java/org/apache/helix/PropertyKey.java @@ -358,6 +358,15 @@ public class PropertyKey { } /** + * Get a property key associated with {@link Error} for an instance + * @param instanceName + * @return {@link PropertyKey} + */ + public PropertyKey errors(String instanceName) { + return new PropertyKey(ERRORS, Error.class, _clusterName, instanceName); + } + + /** * Get a property key associated with a specific {@link Message} on an instance * @param instanceName * @param messageId http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/api/StateTransitionHandlerFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/api/StateTransitionHandlerFactory.java b/helix-core/src/main/java/org/apache/helix/api/StateTransitionHandlerFactory.java index 1e2326d..5ce0704 100644 --- a/helix-core/src/main/java/org/apache/helix/api/StateTransitionHandlerFactory.java +++ b/helix-core/src/main/java/org/apache/helix/api/StateTransitionHandlerFactory.java @@ -19,6 +19,8 @@ package org.apache.helix.api; * under the License. */ +import java.util.Collections; +import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; @@ -29,62 +31,79 @@ import org.apache.helix.messaging.handling.BatchMessageWrapper; public abstract class StateTransitionHandlerFactory<T extends TransitionHandler> { /** - * map from partitionId to transition-handler + * map from ResourceId resourceId to map from partitionId to transition-handler */ - private final ConcurrentMap<PartitionId, T> _transitionHandlerMap = - new ConcurrentHashMap<PartitionId, T>(); + private final ConcurrentMap<ResourceId, ConcurrentMap<PartitionId, T>> _transitionHandlerMap = + new ConcurrentHashMap<ResourceId, ConcurrentMap<PartitionId, T>>(); /** - * map from resourceName to BatchMessageWrapper + * map from ResourceId to BatchMessageWrapper */ private final ConcurrentMap<ResourceId, BatchMessageWrapper> _batchMsgWrapperMap = new ConcurrentHashMap<ResourceId, BatchMessageWrapper>(); /** - * This method will be invoked only once per partition per session + * This method will be invoked only once per resource per partition per session + * @param resourceId * @param partitionId * @return */ - public abstract T createStateTransitionHandler(PartitionId partitionId); + public abstract T createStateTransitionHandler(ResourceId resourceId, PartitionId partitionId); /** - * Create a state model for a partition + * Create a state model for a partition of a resource + * @param resourceId * @param partitionId */ - public T createAndAddSTransitionHandler(PartitionId partitionId) { - T stateModel = createStateTransitionHandler(partitionId); - _transitionHandlerMap.put(partitionId, stateModel); + public T createAndAddSTransitionHandler(ResourceId resourceId, PartitionId partitionId) { + T stateModel = createStateTransitionHandler(resourceId, partitionId); + _transitionHandlerMap.putIfAbsent(resourceId, new ConcurrentHashMap<PartitionId, T>()); + _transitionHandlerMap.get(resourceId).put(partitionId, stateModel); return stateModel; } /** - * Get the state model for a partition + * Get the state model for a partition of a resource + * @param resourceId * @param partitionId * @return state model if exists, null otherwise */ - public T getTransitionHandler(PartitionId partitionId) { - return _transitionHandlerMap.get(partitionId); + public T getTransitionHandler(ResourceId resourceId, PartitionId partitionId) { + Map<PartitionId, T> map = _transitionHandlerMap.get(resourceId); + return map == null? null : map.get(partitionId); } /** - * remove state model for a partition + * Remove state model for a partition of a resource + * @param resourceId * @param partitionId * @return state model removed or null if not exist */ - public T removeTransitionHandler(PartitionId partitionId) { - return _transitionHandlerMap.remove(partitionId); + public T removeTransitionHandler(ResourceId resourceId, PartitionId partitionId) { + Map<PartitionId, T> map = _transitionHandlerMap.get(resourceId); + return map == null? null : map.remove(partitionId); } /** - * get partition set - * @return partitionId set + * Get resource set + * @return resourceId set */ - public Set<PartitionId> getPartitionSet() { + public Set<ResourceId> getResourceSet() { return _transitionHandlerMap.keySet(); } /** - * create a default batch-message-wrapper for a resource + * Get partition set of a resource + * @param resourceId + * @return partitionId set + */ + public Set<PartitionId> getPartitionSet(ResourceId resourceId) { + Map<PartitionId, T> map = _transitionHandlerMap.get(resourceId); + return map == null? Collections.<PartitionId>emptySet() : map.keySet(); + } + + /** + * Create a default batch-message-wrapper for a resource * @param resourceId * @return */ @@ -93,7 +112,7 @@ public abstract class StateTransitionHandlerFactory<T extends TransitionHandler> } /** - * create a batch-message-wrapper for a resource and put it into map + * Create a batch-message-wrapper for a resource and put it into map * @param resourceId * @return */ @@ -104,7 +123,7 @@ public abstract class StateTransitionHandlerFactory<T extends TransitionHandler> } /** - * get batch-message-wrapper for a resource + * Get batch-message-wrapper for a resource * @param resourceId * @return */ http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java index 4ede2a4..bc5fcd1 100644 --- a/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java +++ b/helix-core/src/main/java/org/apache/helix/messaging/handling/HelixStateTransitionHandler.java @@ -206,7 +206,7 @@ public class HelixStateTransitionHandler extends MessageHandler { List<ZNRecordDelta> deltaList = new ArrayList<ZNRecordDelta>(); deltaList.add(delta); _currentStateDelta.setDeltaList(deltaList); - _stateModelFactory.removeTransitionHandler(partitionId); + _stateModelFactory.removeTransitionHandler(resource, partitionId); } else { // if the partition is not to be dropped, update _stateModel to the TO_STATE _stateModel.updateState(toState.toString()); http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/participant/GenericLeaderStandbyStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/participant/GenericLeaderStandbyStateModelFactory.java b/helix-core/src/main/java/org/apache/helix/participant/GenericLeaderStandbyStateModelFactory.java index c5d7390..b6f8571 100644 --- a/helix-core/src/main/java/org/apache/helix/participant/GenericLeaderStandbyStateModelFactory.java +++ b/helix-core/src/main/java/org/apache/helix/participant/GenericLeaderStandbyStateModelFactory.java @@ -24,6 +24,7 @@ import java.util.List; import org.apache.helix.HelixConstants.ChangeType; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; public class GenericLeaderStandbyStateModelFactory extends StateTransitionHandlerFactory<GenericLeaderStandbyModel> { @@ -40,7 +41,8 @@ public class GenericLeaderStandbyStateModelFactory extends } @Override - public GenericLeaderStandbyModel createStateTransitionHandler(PartitionId partition) { + public GenericLeaderStandbyModel createStateTransitionHandler(ResourceId resourceId, + PartitionId partition) { return new GenericLeaderStandbyModel(_callback, _notificationTypes, partition); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/participant/HelixStateMachineEngine.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/participant/HelixStateMachineEngine.java b/helix-core/src/main/java/org/apache/helix/participant/HelixStateMachineEngine.java index 56769b5..d696606 100644 --- a/helix-core/src/main/java/org/apache/helix/participant/HelixStateMachineEngine.java +++ b/helix-core/src/main/java/org/apache/helix/participant/HelixStateMachineEngine.java @@ -71,12 +71,13 @@ public class HelixStateMachineEngine implements StateMachineEngine { _stateModelDefs = new ConcurrentHashMap<StateModelDefId, StateModelDefinition>(); } - public StateTransitionHandlerFactory<? extends TransitionHandler> getStateModelFactory(StateModelDefId stateModelName) { + public StateTransitionHandlerFactory<? extends TransitionHandler> getStateModelFactory( + StateModelDefId stateModelName) { return getStateModelFactory(stateModelName, HelixConstants.DEFAULT_STATE_MODEL_FACTORY); } - public StateTransitionHandlerFactory<? extends TransitionHandler> getStateModelFactory(StateModelDefId stateModelName, - String factoryName) { + public StateTransitionHandlerFactory<? extends TransitionHandler> getStateModelFactory( + StateModelDefId stateModelName, String factoryName) { if (!_stateModelFactoryMap.containsKey(stateModelName)) { return null; } @@ -116,14 +117,18 @@ public class HelixStateMachineEngine implements StateMachineEngine { public void reset() { for (Map<String, StateTransitionHandlerFactory<? extends TransitionHandler>> ftyMap : _stateModelFactoryMap .values()) { - for (StateTransitionHandlerFactory<? extends TransitionHandler> stateModelFactory : ftyMap.values()) { - for (PartitionId partition : stateModelFactory.getPartitionSet()) { - TransitionHandler stateModel = stateModelFactory.getTransitionHandler(partition); - stateModel.reset(); - String initialState = _stateModelParser.getInitialState(stateModel.getClass()); - stateModel.updateState(initialState); - // TODO probably should update the state on ZK. Shi confirm what needs - // to be done here. + for (StateTransitionHandlerFactory<? extends TransitionHandler> stateModelFactory : ftyMap + .values()) { + for (ResourceId resource : stateModelFactory.getResourceSet()) { + for (PartitionId partition : stateModelFactory.getPartitionSet(resource)) { + TransitionHandler stateModel = + stateModelFactory.getTransitionHandler(resource, partition); + stateModel.reset(); + String initialState = _stateModelParser.getInitialState(stateModel.getClass()); + stateModel.updateState(initialState); + // TODO probably should update the state on ZK. Shi confirm what needs + // to be done here. + } } } } @@ -179,9 +184,10 @@ public class HelixStateMachineEngine implements StateMachineEngine { if (message.getBatchMessageMode() == false) { // create currentStateDelta for this partition String initState = _stateModelDefs.get(message.getStateModelDefId()).getInitialState(); - TransitionHandler stateModel = stateModelFactory.getTransitionHandler(partitionKey); + TransitionHandler stateModel = + stateModelFactory.getTransitionHandler(resourceId, partitionKey); if (stateModel == null) { - stateModel = stateModelFactory.createAndAddSTransitionHandler(partitionKey); + stateModel = stateModelFactory.createAndAddSTransitionHandler(resourceId, partitionKey); stateModel.updateState(initState); } @@ -200,8 +206,7 @@ public class HelixStateMachineEngine implements StateMachineEngine { return new HelixStateTransitionHandler(stateModelFactory, stateModel, message, context, currentStateDelta); } else { - BatchMessageWrapper wrapper = - stateModelFactory.getBatchMessageWrapper(resourceId); + BatchMessageWrapper wrapper = stateModelFactory.getBatchMessageWrapper(resourceId); if (wrapper == null) { wrapper = stateModelFactory.createAndAddBatchMessageWrapper(resourceId); } @@ -241,8 +246,10 @@ public class HelixStateMachineEngine implements StateMachineEngine { + " using factory-name: " + factoryName + " with: " + factory); if (!_stateModelFactoryMap.containsKey(stateModelDefId)) { - _stateModelFactoryMap.put(stateModelDefId, - new ConcurrentHashMap<String, StateTransitionHandlerFactory<? extends TransitionHandler>>()); + _stateModelFactoryMap + .put( + stateModelDefId, + new ConcurrentHashMap<String, StateTransitionHandlerFactory<? extends TransitionHandler>>()); } if (_stateModelFactoryMap.get(stateModelDefId).containsKey(factoryName)) { @@ -290,10 +297,12 @@ public class HelixStateMachineEngine implements StateMachineEngine { _stateModelFactoryMap.remove(stateModelDefId); } - for (PartitionId partition : fty.getPartitionSet()) { - TransitionHandler stateModel = fty.getTransitionHandler(partition); - stateModel.reset(); - // TODO probably should remove the state from zookeeper + for (ResourceId resource : fty.getResourceSet()) { + for (PartitionId partition : fty.getPartitionSet(resource)) { + TransitionHandler stateModel = fty.getTransitionHandler(resource, partition); + stateModel.reset(); + // TODO probably should remove the state from zookeeper + } } return true; http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/participant/MultiClusterControllerTransitionHandlerFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/participant/MultiClusterControllerTransitionHandlerFactory.java b/helix-core/src/main/java/org/apache/helix/participant/MultiClusterControllerTransitionHandlerFactory.java index f368c7a..14a11f1 100644 --- a/helix-core/src/main/java/org/apache/helix/participant/MultiClusterControllerTransitionHandlerFactory.java +++ b/helix-core/src/main/java/org/apache/helix/participant/MultiClusterControllerTransitionHandlerFactory.java @@ -21,6 +21,7 @@ package org.apache.helix.participant; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; public class MultiClusterControllerTransitionHandlerFactory extends StateTransitionHandlerFactory<MultiClusterControllerTransitionHandler> { @@ -31,7 +32,8 @@ public class MultiClusterControllerTransitionHandlerFactory extends } @Override - public MultiClusterControllerTransitionHandler createStateTransitionHandler(PartitionId partition) { + public MultiClusterControllerTransitionHandler createStateTransitionHandler(ResourceId resource, + PartitionId partition) { return new MultiClusterControllerTransitionHandler(_zkAddr); } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModel.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModel.java b/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModel.java index 954fba8..f007f7c 100644 --- a/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModel.java +++ b/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModel.java @@ -26,6 +26,7 @@ import org.apache.helix.NotificationContext; import org.apache.helix.ZNRecord; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.messaging.handling.HelixTaskExecutor; import org.apache.helix.messaging.handling.MessageHandler; import org.apache.helix.model.Message; @@ -39,13 +40,15 @@ public class ScheduledTaskStateModel extends TransitionHandler { // StateModel with initial state other than OFFLINE should override this field protected String _currentState = DEFAULT_INITIAL_STATE; final ScheduledTaskStateModelFactory _factory; + final ResourceId _resource; final PartitionId _partition; final HelixTaskExecutor _executor; public ScheduledTaskStateModel(ScheduledTaskStateModelFactory factory, - HelixTaskExecutor executor, PartitionId partition) { + HelixTaskExecutor executor, ResourceId resource, PartitionId partition) { _factory = factory; + _resource = resource; _partition = partition; _executor = executor; } @@ -108,8 +111,8 @@ public class ScheduledTaskStateModel extends TransitionHandler { // We need this to prevent state model leak private void removeFromStatemodelFactory() { - if (_factory.getTransitionHandler(_partition) != null) { - _factory.removeTransitionHandler(_partition); + if (_factory.getTransitionHandler(_resource, _partition) != null) { + _factory.removeTransitionHandler(_resource, _partition); } else { logger.warn(_partition + " not found in ScheduledTaskStateModelFactory"); } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModelFactory.java b/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModelFactory.java index e2bc461..6112b80 100644 --- a/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModelFactory.java +++ b/helix-core/src/main/java/org/apache/helix/participant/statemachine/ScheduledTaskStateModelFactory.java @@ -21,6 +21,7 @@ package org.apache.helix.participant.statemachine; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.messaging.handling.HelixTaskExecutor; import org.apache.log4j.Logger; @@ -34,8 +35,8 @@ public class ScheduledTaskStateModelFactory extends StateTransitionHandlerFactor } @Override - public ScheduledTaskStateModel createStateTransitionHandler(PartitionId partition) { - logger.info("Create state model for ScheduledTask " + partition); - return new ScheduledTaskStateModel(this, _executor, partition); + public ScheduledTaskStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { + logger.info("Create state model for ScheduledTask " + resource + "_" + partition); + return new ScheduledTaskStateModel(this, _executor, resource, partition); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/main/java/org/apache/helix/task/TaskStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/main/java/org/apache/helix/task/TaskStateModelFactory.java b/helix-core/src/main/java/org/apache/helix/task/TaskStateModelFactory.java index 8fb5690..23d6160 100644 --- a/helix-core/src/main/java/org/apache/helix/task/TaskStateModelFactory.java +++ b/helix-core/src/main/java/org/apache/helix/task/TaskStateModelFactory.java @@ -24,6 +24,7 @@ import java.util.Map; import org.apache.helix.HelixManager; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; /** * Factory class for {@link TaskStateModel}. @@ -38,7 +39,7 @@ public class TaskStateModelFactory extends StateTransitionHandlerFactory<TaskSta } @Override - public TaskStateModel createStateTransitionHandler(PartitionId partitionId) { + public TaskStateModel createStateTransitionHandler(ResourceId resourceId, PartitionId partitionId) { return new TaskStateModel(_manager, _taskFactoryRegistry); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/TestHelixTaskExecutor.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/TestHelixTaskExecutor.java b/helix-core/src/test/java/org/apache/helix/TestHelixTaskExecutor.java index d16417e..69e008f 100644 --- a/helix-core/src/test/java/org/apache/helix/TestHelixTaskExecutor.java +++ b/helix-core/src/test/java/org/apache/helix/TestHelixTaskExecutor.java @@ -78,7 +78,7 @@ public class TestHelixTaskExecutor { StateTransitionHandlerFactory<MockStateModel> stateModelFactory = new StateTransitionHandlerFactory<MockStateModel>() { @Override - public MockStateModel createStateTransitionHandler(PartitionId partition) { + public MockStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { // TODO Auto-generated method stub return new MockStateModel(); } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/TestHelixTaskHandler.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/TestHelixTaskHandler.java b/helix-core/src/test/java/org/apache/helix/TestHelixTaskHandler.java index 21a3ae7..9882f31 100644 --- a/helix-core/src/test/java/org/apache/helix/TestHelixTaskHandler.java +++ b/helix-core/src/test/java/org/apache/helix/TestHelixTaskHandler.java @@ -119,7 +119,7 @@ public class TestHelixTaskHandler { new StateTransitionHandlerFactory<MockStateModelAnnotated>() { @Override - public MockStateModelAnnotated createStateTransitionHandler(PartitionId partitionName) { + public MockStateModelAnnotated createStateTransitionHandler(ResourceId resource, PartitionId partitionName) { // TODO Auto-generated method stub return new MockStateModelAnnotated(); } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestCorrectnessOnConnectivityLoss.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestCorrectnessOnConnectivityLoss.java b/helix-core/src/test/java/org/apache/helix/integration/TestCorrectnessOnConnectivityLoss.java index e4e844a..97aa357 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestCorrectnessOnConnectivityLoss.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestCorrectnessOnConnectivityLoss.java @@ -30,6 +30,7 @@ import org.apache.helix.TestHelper; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.manager.zk.MockController; import org.apache.helix.model.IdealState.RebalanceMode; @@ -198,7 +199,7 @@ public class TestCorrectnessOnConnectivityLoss { } @Override - public MyStateModel createStateTransitionHandler(PartitionId partitionId) { + public MyStateModel createStateTransitionHandler(ResourceId resource, PartitionId partitionId) { return new MyStateModel(_counts); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java b/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java index 09fe1e4..00522b8 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestEntropyFreeNodeBounce.java @@ -20,6 +20,7 @@ package org.apache.helix.integration; */ import java.util.Date; +import java.util.Map; import org.apache.helix.HelixAdmin; import org.apache.helix.HelixDataAccessor; @@ -38,10 +39,14 @@ import org.apache.helix.testutil.ZkTestBase; import org.apache.helix.tools.ClusterStateVerifier; import org.apache.helix.tools.ClusterStateVerifier.BestPossAndExtViewZkVerifier; import org.apache.helix.tools.ClusterStateVerifier.ZkVerifier; +import org.apache.log4j.Logger; import org.testng.Assert; import org.testng.annotations.Test; public class TestEntropyFreeNodeBounce extends ZkTestBase { + private static Logger LOG = Logger.getLogger(TestEntropyFreeNodeBounce.class); + + // TODO fix this test. it fails because of HELIX-543 RB-27808 @Test public void testBounceAll() throws Exception { // pick numbers that don't divide evenly @@ -110,6 +115,17 @@ public class TestEntropyFreeNodeBounce extends ZkTestBase { result = ClusterStateVerifier.verifyByZkCallback(new MatchingExternalViewVerifier( stableExternalView, clusterName)); + if (!result) { + ExternalView currentExternalView = + accessor.getProperty(keyBuilder.externalView(RESOURCE_NAME)); + for (String partition : stableExternalView.getPartitionSet()) { + Map<String, String> expect = stableExternalView.getStateMap(partition); + Map<String, String> actual = currentExternalView.getStateMap(partition); + if (!expect.equals(actual)) { + LOG.error(partition + " is moved. expect: " + expect + ", actual: " + actual); + } + } + } Assert.assertTrue(result); } } finally { http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java b/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java index 484ae8c..06f5f26 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestHelixConnection.java @@ -80,7 +80,7 @@ public class TestHelixConnection extends ZkTestBase { } @Override - public MockStateModel createStateTransitionHandler(PartitionId partitionId) { + public MockStateModel createStateTransitionHandler(ResourceId resource, PartitionId partitionId) { MockStateModel model = new MockStateModel(); return model; http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle2.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle2.java b/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle2.java index 95673d4..5576844 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle2.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestMessageThrottle2.java @@ -42,6 +42,7 @@ import org.apache.helix.ZNRecord; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.controller.HelixControllerMain; import org.apache.helix.manager.zk.MockParticipant; @@ -328,7 +329,7 @@ public class TestMessageThrottle2 extends ZkTestBase { } @Override - public MyStateModel createStateTransitionHandler(PartitionId partitionName) { + public MyStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { return new MyStateModel(helixManager); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestPartitionLevelTransitionConstraint.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestPartitionLevelTransitionConstraint.java b/helix-core/src/test/java/org/apache/helix/integration/TestPartitionLevelTransitionConstraint.java index 0962921..0d08a25 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestPartitionLevelTransitionConstraint.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestPartitionLevelTransitionConstraint.java @@ -31,6 +31,7 @@ import org.apache.helix.TestHelper; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.manager.zk.MockParticipant; import org.apache.helix.manager.zk.MockController; @@ -90,7 +91,7 @@ public class TestPartitionLevelTransitionConstraint extends ZkTestBase { public class BootstrapStateModelFactory extends StateTransitionHandlerFactory<BootstrapStateModel> { @Override - public BootstrapStateModel createStateTransitionHandler(PartitionId partition) { + public BootstrapStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { BootstrapStateModel model = new BootstrapStateModel(); return model; } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestPreferenceListAsQueue.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestPreferenceListAsQueue.java b/helix-core/src/test/java/org/apache/helix/integration/TestPreferenceListAsQueue.java index db6910a..3bc7c45 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestPreferenceListAsQueue.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestPreferenceListAsQueue.java @@ -39,6 +39,7 @@ import org.apache.helix.ZNRecord; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.model.ClusterConstraints.ConstraintAttribute; import org.apache.helix.model.ClusterConstraints.ConstraintType; @@ -161,8 +162,8 @@ public class TestPreferenceListAsQueue extends ZkTestBase { participants[i] = HelixManagerFactory.getZKHelixManager(_clusterName, instanceInfoArray[i], InstanceType.PARTICIPANT, _zkaddr); - participants[i].getStateMachineEngine().registerStateModelFactory(StateModelDefId.from(_stateModel), - new PrefListTaskOnlineOfflineStateModelFactory()); + participants[i].getStateMachineEngine().registerStateModelFactory( + StateModelDefId.from(_stateModel), new PrefListTaskOnlineOfflineStateModelFactory()); participants[i].connect(); } @@ -504,7 +505,8 @@ public class TestPreferenceListAsQueue extends ZkTestBase { public class PrefListTaskOnlineOfflineStateModelFactory extends StateTransitionHandlerFactory<PrefListTaskOnlineOfflineStateModel> { @Override - public PrefListTaskOnlineOfflineStateModel createStateTransitionHandler(PartitionId partitionName) { + public PrefListTaskOnlineOfflineStateModel createStateTransitionHandler(ResourceId resource, + PartitionId partition) { return new PrefListTaskOnlineOfflineStateModel(); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestResourceWithSamePartitionKey.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestResourceWithSamePartitionKey.java b/helix-core/src/test/java/org/apache/helix/integration/TestResourceWithSamePartitionKey.java new file mode 100644 index 0000000..60fd018 --- /dev/null +++ b/helix-core/src/test/java/org/apache/helix/integration/TestResourceWithSamePartitionKey.java @@ -0,0 +1,125 @@ +package org.apache.helix.integration; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import java.util.Date; +import java.util.List; + +import org.apache.helix.HelixDataAccessor; +import org.apache.helix.PropertyKey; +import org.apache.helix.TestHelper; +import org.apache.helix.ZNRecord; +import org.apache.helix.manager.zk.MockController; +import org.apache.helix.manager.zk.MockParticipant; +import org.apache.helix.manager.zk.ZKHelixDataAccessor; +import org.apache.helix.manager.zk.ZkBaseDataAccessor; +import org.apache.helix.model.IdealState; +import org.apache.helix.model.IdealState.RebalanceMode; +import org.apache.helix.testutil.ZkTestBase; +import org.apache.helix.tools.ClusterStateVerifier; +import org.testng.Assert; +import org.testng.annotations.Test; + +/** + * @see HELIX-552 + * StateModelFactory#_stateModelMap should use both resourceName and partitionKey to map a + * state model + */ +public class TestResourceWithSamePartitionKey extends ZkTestBase { + + @Test + public void test() throws Exception { + String className = TestHelper.getTestClassName(); + String methodName = TestHelper.getTestMethodName(); + String clusterName = className + "_" + methodName; + int n = 2; + + System.out.println("START " + clusterName + " at " + new Date(System.currentTimeMillis())); + + TestHelper.setupCluster(clusterName, _zkaddr, 12918, // participant port + "localhost", // participant name prefix + "TestDB", // resource name prefix + 1, // resources + 2, // partitions per resource + n, // number of nodes + 2, // replicas + "OnlineOffline", RebalanceMode.CUSTOMIZED, false); // do rebalance + + HelixDataAccessor accessor = + new ZKHelixDataAccessor(clusterName, new ZkBaseDataAccessor<ZNRecord>(_zkclient)); + PropertyKey.Builder keyBuilder = accessor.keyBuilder(); + IdealState idealState = accessor.getProperty(keyBuilder.idealStates("TestDB0")); + idealState.setReplicas("2"); + idealState.setPartitionState("0", "localhost_12918", "ONLINE"); + idealState.setPartitionState("0", "localhost_12919", "ONLINE"); + idealState.setPartitionState("1", "localhost_12918", "ONLINE"); + idealState.setPartitionState("1", "localhost_12919", "ONLINE"); + accessor.setProperty(keyBuilder.idealStates("TestDB0"), idealState); + + MockController controller = new MockController(_zkaddr, clusterName, "controller"); + controller.syncStart(); + + // start participants + MockParticipant[] participants = new MockParticipant[n]; + for (int i = 0; i < n; i++) { + String instanceName = "localhost_" + (12918 + i); + + participants[i] = new MockParticipant(_zkaddr, clusterName, instanceName); + participants[i].syncStart(); + } + + boolean result = + ClusterStateVerifier + .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr, + clusterName)); + Assert.assertTrue(result); + + // add a second resource with the same partition-key + IdealState newIdealState = new IdealState("TestDB1"); + newIdealState.getRecord().setSimpleFields(idealState.getRecord().getSimpleFields()); + newIdealState.setPartitionState("0", "localhost_12918", "ONLINE"); + newIdealState.setPartitionState("0", "localhost_12919", "ONLINE"); + newIdealState.setPartitionState("1", "localhost_12918", "ONLINE"); + newIdealState.setPartitionState("1", "localhost_12919", "ONLINE"); + accessor.setProperty(keyBuilder.idealStates("TestDB1"), newIdealState); + + result = + ClusterStateVerifier + .verifyByZkCallback(new ClusterStateVerifier.BestPossAndExtViewZkVerifier(_zkaddr, + clusterName)); + Assert.assertTrue(result); + + // assert no ERROR + for (int i = 0; i < n; i++) { + String instanceName = "localhost_" + (12918 + i); + List<String> errs = accessor.getChildNames(keyBuilder.errors(instanceName)); + Assert.assertTrue(errs.isEmpty()); + } + + // clean up + controller.syncStop(); + for (int i = 0; i < n; i++) { + participants[i].syncStop(); + } + + System.out.println("END " + clusterName + " at " + new Date(System.currentTimeMillis())); + } + +} http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java b/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java index b929d5e..298135e 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestStateTransitionTimeout.java @@ -33,6 +33,7 @@ import org.apache.helix.api.State; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.ParticipantId; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.manager.zk.MockParticipant; import org.apache.helix.manager.zk.MockController; @@ -147,7 +148,8 @@ public class TestStateTransitionTimeout extends ZkStandAloneCMTestBase { } } - public static class SleepStateModelFactory extends StateTransitionHandlerFactory<TimeOutStateModel> { + public static class SleepStateModelFactory extends + StateTransitionHandlerFactory<TimeOutStateModel> { Set<PartitionId> partitionsToSleep = new HashSet<PartitionId>(); int _sleepTime; @@ -164,7 +166,7 @@ public class TestStateTransitionTimeout extends ZkStandAloneCMTestBase { } @Override - public TimeOutStateModel createStateTransitionHandler(PartitionId partition) { + public TimeOutStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { return new TimeOutStateModel(new SleepTransition(_sleepTime), partitionsToSleep.contains(partition)); } @@ -187,7 +189,8 @@ public class TestStateTransitionTimeout extends ZkStandAloneCMTestBase { } _participants[i] = new MockParticipant(_zkaddr, CLUSTER_NAME, instanceName); - _participants[i].getStateMachineEngine().registerStateModelFactory(StateModelDefId.from("MasterSlave"), factory); + _participants[i].getStateMachineEngine().registerStateModelFactory( + StateModelDefId.from("MasterSlave"), factory); _participants[i].syncStart(); } String controllerName = "controller_0"; @@ -206,7 +209,8 @@ public class TestStateTransitionTimeout extends ZkStandAloneCMTestBase { ParticipantId idealMaster = idealState.getPreferenceList(p).get(0); Assert.assertTrue(ev.getStateMap(p).get(idealMaster).equals(State.from("ERROR"))); - TimeOutStateModel model = factories.get(idealMaster.stringify()).getTransitionHandler(p); + TimeOutStateModel model = + factories.get(idealMaster.stringify()).getTransitionHandler(ResourceId.from(TEST_DB), p); Assert.assertEquals(model._errorCallcount, 1); Assert.assertEquals(model._error.getCode(), ErrorCode.TIMEOUT); } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java b/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java index 08a2f18..60a504d 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java +++ b/helix-core/src/test/java/org/apache/helix/integration/TestZkReconnect.java @@ -90,7 +90,7 @@ public class TestZkReconnect { participant.getStateMachineEngine().registerStateModelFactory( StateModelDefId.OnlineOffline, "test", new StateTransitionHandlerFactory<TransitionHandler>() { @Override - public TransitionHandler createStateTransitionHandler(PartitionId stateUnitKey) { + public TransitionHandler createStateTransitionHandler(ResourceId resource, PartitionId stateUnitKey) { return new SimpleStateModel(latch); } }); http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/integration/manager/TestStateModelLeak.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/integration/manager/TestStateModelLeak.java b/helix-core/src/test/java/org/apache/helix/integration/manager/TestStateModelLeak.java index eaf74bb..8fd1f67 100644 --- a/helix-core/src/test/java/org/apache/helix/integration/manager/TestStateModelLeak.java +++ b/helix-core/src/test/java/org/apache/helix/integration/manager/TestStateModelLeak.java @@ -31,6 +31,7 @@ import org.apache.helix.TestHelper; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.manager.zk.MockParticipant; import org.apache.helix.manager.zk.MockController; @@ -112,8 +113,10 @@ public class TestStateModelLeak extends ZkTestBase { Assert.assertTrue(result); // check state models have been dropped also - Assert.assertTrue(fty.getPartitionSet().isEmpty(), - "All state-models should be dropped, but was " + fty.getPartitionSet()); + for (ResourceId resource : fty.getResourceSet()) { + Assert.assertTrue(fty.getPartitionSet(resource).isEmpty(), + "All state-models should be dropped, but was " + fty.getPartitionSet(resource)); + } // cleanup controller.syncStop(); @@ -197,9 +200,10 @@ public class TestStateModelLeak extends ZkTestBase { Assert.assertTrue(result); // check state models have been dropped also - Assert.assertTrue(fty.getPartitionSet().isEmpty(), - "All state-models should be dropped, but was " + fty.getPartitionSet()); - + for (ResourceId resource : fty.getResourceSet()) { + Assert.assertTrue(fty.getPartitionSet(resource).isEmpty(), + "All state-models should be dropped, but was " + fty.getPartitionSet(resource)); + } // cleanup controller.syncStop(); for (int i = 0; i < n; i++) { @@ -216,9 +220,10 @@ public class TestStateModelLeak extends ZkTestBase { */ static void checkStateModelMap(StateTransitionHandlerFactory<? extends TransitionHandler> fty, Map<PartitionId, String> expectStateModelMap) { - Assert.assertEquals(fty.getPartitionSet().size(), expectStateModelMap.size()); - for (PartitionId partition : fty.getPartitionSet()) { - TransitionHandler stateModel = fty.getTransitionHandler(partition); + ResourceId resource = ResourceId.from("TestDB0"); + Assert.assertEquals(fty.getPartitionSet(resource).size(), expectStateModelMap.size()); + for (PartitionId partition : fty.getPartitionSet(resource)) { + TransitionHandler stateModel = fty.getTransitionHandler(resource, partition); String actualState = stateModel.getCurrentState(); String expectState = expectStateModelMap.get(partition); LOG.debug(partition + " actual state: " + actualState + ", expect state: " + expectState); http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/mock/participant/DummyProcess.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/DummyProcess.java b/helix-core/src/test/java/org/apache/helix/mock/participant/DummyProcess.java index 4b55935..9674d67 100644 --- a/helix-core/src/test/java/org/apache/helix/mock/participant/DummyProcess.java +++ b/helix-core/src/test/java/org/apache/helix/mock/participant/DummyProcess.java @@ -35,6 +35,7 @@ import org.apache.helix.NotificationContext; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.model.Message; import org.apache.helix.participant.StateMachineEngine; @@ -112,7 +113,7 @@ public class DummyProcess { } @Override - public DummyStateModel createStateTransitionHandler(PartitionId partition) { + public DummyStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { DummyStateModel model = new DummyStateModel(); model.setDelay(_delay); return model; @@ -128,7 +129,7 @@ public class DummyProcess { } @Override - public DummyLeaderStandbyStateModel createStateTransitionHandler(PartitionId partition) { + public DummyLeaderStandbyStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { DummyLeaderStandbyStateModel model = new DummyLeaderStandbyStateModel(); model.setDelay(_delay); return model; @@ -144,7 +145,7 @@ public class DummyProcess { } @Override - public DummyOnlineOfflineStateModel createStateTransitionHandler(PartitionId partition) { + public DummyOnlineOfflineStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { DummyOnlineOfflineStateModel model = new DummyOnlineOfflineStateModel(); model.setDelay(_delay); return model; http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java index 0e01b60..6e08090 100644 --- a/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java +++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockBootstrapModelFactory.java @@ -2,6 +2,7 @@ package org.apache.helix.mock.participant; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -22,11 +23,12 @@ import org.apache.helix.api.id.PartitionId; * under the License. */ - // mock Bootstrap state model factory -public class MockBootstrapModelFactory extends StateTransitionHandlerFactory<MockBootstrapStateModel> { +public class MockBootstrapModelFactory extends + StateTransitionHandlerFactory<MockBootstrapStateModel> { @Override - public MockBootstrapStateModel createStateTransitionHandler(PartitionId partitionKey) { + public MockBootstrapStateModel createStateTransitionHandler(ResourceId resource, + PartitionId partition) { MockBootstrapStateModel model = new MockBootstrapStateModel(); return model; } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java index 853b157..2322576 100644 --- a/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java +++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockMSModelFactory.java @@ -2,6 +2,7 @@ package org.apache.helix.mock.participant; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; /* * Licensed to the Apache Software Foundation (ASF) under one @@ -22,7 +23,6 @@ import org.apache.helix.api.id.PartitionId; * under the License. */ - // mock master slave state model factory public class MockMSModelFactory extends StateTransitionHandlerFactory<MockMSStateModel> { private MockTransition _transition; @@ -39,14 +39,16 @@ public class MockMSModelFactory extends StateTransitionHandlerFactory<MockMSStat _transition = transition; // set existing transition - for (PartitionId partition : getPartitionSet()) { - MockMSStateModel stateModel = getTransitionHandler(partition); - stateModel.setTransition(transition); + for (ResourceId resource : getResourceSet()) { + for (PartitionId partition : getPartitionSet(resource)) { + MockMSStateModel stateModel = getTransitionHandler(resource, partition); + stateModel.setTransition(transition); + } } } @Override - public MockMSStateModel createStateTransitionHandler(PartitionId partitionKey) { + public MockMSStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { MockMSStateModel model = new MockMSStateModel(_transition); return model; http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java b/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java index 7cc43ef..e881910 100644 --- a/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java +++ b/helix-core/src/test/java/org/apache/helix/mock/participant/MockSchemataModelFactory.java @@ -21,13 +21,15 @@ package org.apache.helix.mock.participant; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; /** * Mock STORAGE_DEFAULT_SM_SCHEMATA state model factory */ public class MockSchemataModelFactory extends StateTransitionHandlerFactory<MockSchemataStateModel> { @Override - public MockSchemataStateModel createStateTransitionHandler(PartitionId partitionKey) { + public MockSchemataStateModel createStateTransitionHandler(ResourceId resource, + PartitionId partition) { MockSchemataStateModel model = new MockSchemataStateModel(); return model; } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-core/src/test/java/org/apache/helix/participant/TestMultiClusterControllerStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-core/src/test/java/org/apache/helix/participant/TestMultiClusterControllerStateModelFactory.java b/helix-core/src/test/java/org/apache/helix/participant/TestMultiClusterControllerStateModelFactory.java index 922a60d..991660d 100644 --- a/helix-core/src/test/java/org/apache/helix/participant/TestMultiClusterControllerStateModelFactory.java +++ b/helix-core/src/test/java/org/apache/helix/participant/TestMultiClusterControllerStateModelFactory.java @@ -20,6 +20,7 @@ package org.apache.helix.participant; */ import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.testng.annotations.Test; public class TestMultiClusterControllerStateModelFactory { @@ -29,7 +30,7 @@ public class TestMultiClusterControllerStateModelFactory { MultiClusterControllerTransitionHandlerFactory factory = new MultiClusterControllerTransitionHandlerFactory("localhost:2181"); MultiClusterControllerTransitionHandler stateModel = - factory.createStateTransitionHandler(PartitionId.from("key")); + factory.createStateTransitionHandler(ResourceId.from("name"), PartitionId.from("key")); stateModel.onBecomeStandbyFromOffline(null, null); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-examples/src/main/java/org/apache/helix/examples/BootstrapHandler.java ---------------------------------------------------------------------- diff --git a/helix-examples/src/main/java/org/apache/helix/examples/BootstrapHandler.java b/helix-examples/src/main/java/org/apache/helix/examples/BootstrapHandler.java index d4b2817..a7ac93f 100644 --- a/helix-examples/src/main/java/org/apache/helix/examples/BootstrapHandler.java +++ b/helix-examples/src/main/java/org/apache/helix/examples/BootstrapHandler.java @@ -30,6 +30,7 @@ import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.MessageId; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.model.Message; import org.apache.helix.model.Message.MessageState; import org.apache.helix.model.Message.MessageType; @@ -39,7 +40,7 @@ import org.apache.helix.participant.statemachine.Transition; public class BootstrapHandler extends StateTransitionHandlerFactory<TransitionHandler> { @Override - public TransitionHandler createStateTransitionHandler(PartitionId stateUnitKey) { + public TransitionHandler createStateTransitionHandler(ResourceId resource, PartitionId stateUnitKey) { return new BootstrapStateModel(stateUnitKey); } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-examples/src/main/java/org/apache/helix/examples/DummyParticipant.java ---------------------------------------------------------------------- diff --git a/helix-examples/src/main/java/org/apache/helix/examples/DummyParticipant.java b/helix-examples/src/main/java/org/apache/helix/examples/DummyParticipant.java index 7dcdd8a..387dd34 100644 --- a/helix-examples/src/main/java/org/apache/helix/examples/DummyParticipant.java +++ b/helix-examples/src/main/java/org/apache/helix/examples/DummyParticipant.java @@ -26,6 +26,7 @@ import org.apache.helix.NotificationContext; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.model.Message; import org.apache.helix.participant.StateMachineEngine; @@ -89,7 +90,7 @@ public class DummyParticipant { // dummy master slave state model factory public static class DummyMSModelFactory extends StateTransitionHandlerFactory<DummyMSStateModel> { @Override - public DummyMSStateModel createStateTransitionHandler(PartitionId partitionName) { + public DummyMSStateModel createStateTransitionHandler(ResourceId resource, PartitionId partitionName) { DummyMSStateModel model = new DummyMSStateModel(); return model; } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-examples/src/main/java/org/apache/helix/examples/LeaderStandbyStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-examples/src/main/java/org/apache/helix/examples/LeaderStandbyStateModelFactory.java b/helix-examples/src/main/java/org/apache/helix/examples/LeaderStandbyStateModelFactory.java index 74027d4..85801f3 100644 --- a/helix-examples/src/main/java/org/apache/helix/examples/LeaderStandbyStateModelFactory.java +++ b/helix-examples/src/main/java/org/apache/helix/examples/LeaderStandbyStateModelFactory.java @@ -23,6 +23,7 @@ import org.apache.helix.NotificationContext; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.model.Message; public class LeaderStandbyStateModelFactory extends StateTransitionHandlerFactory<TransitionHandler> { @@ -33,7 +34,7 @@ public class LeaderStandbyStateModelFactory extends StateTransitionHandlerFactor } @Override - public TransitionHandler createStateTransitionHandler(PartitionId stateUnitKey) { + public TransitionHandler createStateTransitionHandler(ResourceId resource, PartitionId stateUnitKey) { LeaderStandbyStateModel stateModel = new LeaderStandbyStateModel(); stateModel.setDelay(_delay); return stateModel; http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-examples/src/main/java/org/apache/helix/examples/LogicalModelExample.java ---------------------------------------------------------------------- diff --git a/helix-examples/src/main/java/org/apache/helix/examples/LogicalModelExample.java b/helix-examples/src/main/java/org/apache/helix/examples/LogicalModelExample.java index 2ac5d37..e60f824 100644 --- a/helix-examples/src/main/java/org/apache/helix/examples/LogicalModelExample.java +++ b/helix-examples/src/main/java/org/apache/helix/examples/LogicalModelExample.java @@ -274,7 +274,7 @@ public class LogicalModelExample { */ public static class LockUnlockFactory extends StateTransitionHandlerFactory<LockUnlockStateModel> { @Override - public LockUnlockStateModel createStateTransitionHandler(PartitionId partitionId) { + public LockUnlockStateModel createStateTransitionHandler(ResourceId resource, PartitionId partitionId) { return new LockUnlockStateModel(partitionId); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-examples/src/main/java/org/apache/helix/examples/MasterSlaveStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-examples/src/main/java/org/apache/helix/examples/MasterSlaveStateModelFactory.java b/helix-examples/src/main/java/org/apache/helix/examples/MasterSlaveStateModelFactory.java index 2befd61..9af6672 100644 --- a/helix-examples/src/main/java/org/apache/helix/examples/MasterSlaveStateModelFactory.java +++ b/helix-examples/src/main/java/org/apache/helix/examples/MasterSlaveStateModelFactory.java @@ -23,6 +23,7 @@ import org.apache.helix.NotificationContext; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.model.Message; public class MasterSlaveStateModelFactory extends StateTransitionHandlerFactory<TransitionHandler> { @@ -44,7 +45,7 @@ public class MasterSlaveStateModelFactory extends StateTransitionHandlerFactory< } @Override - public TransitionHandler createStateTransitionHandler(PartitionId partitionName) { + public TransitionHandler createStateTransitionHandler(ResourceId resource, PartitionId partitionName) { MasterSlaveStateModel stateModel = new MasterSlaveStateModel(); stateModel.setInstanceName(_instanceName); stateModel.setDelay(_delay); http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-examples/src/main/java/org/apache/helix/examples/OnlineOfflineStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-examples/src/main/java/org/apache/helix/examples/OnlineOfflineStateModelFactory.java b/helix-examples/src/main/java/org/apache/helix/examples/OnlineOfflineStateModelFactory.java index f6fb2fa..7b7bece 100644 --- a/helix-examples/src/main/java/org/apache/helix/examples/OnlineOfflineStateModelFactory.java +++ b/helix-examples/src/main/java/org/apache/helix/examples/OnlineOfflineStateModelFactory.java @@ -23,6 +23,7 @@ import org.apache.helix.NotificationContext; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.model.Message; public class OnlineOfflineStateModelFactory extends StateTransitionHandlerFactory<TransitionHandler> { @@ -33,7 +34,7 @@ public class OnlineOfflineStateModelFactory extends StateTransitionHandlerFactor } @Override - public TransitionHandler createStateTransitionHandler(PartitionId stateUnitKey) { + public TransitionHandler createStateTransitionHandler(ResourceId resource, PartitionId stateUnitKey) { OnlineOfflineStateModel stateModel = new OnlineOfflineStateModel(); stateModel.setDelay(_delay); return stateModel; http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java ---------------------------------------------------------------------- diff --git a/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java b/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java index b399377..25833d7 100644 --- a/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java +++ b/helix-ipc/src/test/java/org/apache/helix/ipc/TestNettyHelixIPCService.java @@ -40,6 +40,7 @@ import org.apache.helix.TestHelper; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.TransitionHandler; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; import org.apache.helix.api.id.StateModelDefId; import org.apache.helix.controller.HelixControllerMain; import org.apache.helix.ipc.netty.NettyHelixIPCService; @@ -333,7 +334,7 @@ public class TestNettyHelixIPCService extends ZkTestBase { public static class DummyStateModelFactory extends StateTransitionHandlerFactory<TransitionHandler> { @Override - public TransitionHandler createStateTransitionHandler(PartitionId partitionId) { + public TransitionHandler createStateTransitionHandler(ResourceId resourceId, PartitionId partitionId) { return new DummyStateModel(); } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/helix-provisioning/src/main/java/org/apache/helix/provisioning/participant/StatelessServiceStateModelFactory.java ---------------------------------------------------------------------- diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/participant/StatelessServiceStateModelFactory.java b/helix-provisioning/src/main/java/org/apache/helix/provisioning/participant/StatelessServiceStateModelFactory.java index 21f32ce..90985f9 100644 --- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/participant/StatelessServiceStateModelFactory.java +++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/participant/StatelessServiceStateModelFactory.java @@ -21,6 +21,7 @@ package org.apache.helix.provisioning.participant; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; public class StatelessServiceStateModelFactory extends StateTransitionHandlerFactory<StatelessServiceStateModel> { @@ -32,7 +33,7 @@ public class StatelessServiceStateModelFactory extends } @Override - public StatelessServiceStateModel createStateTransitionHandler(PartitionId partitionId) { + public StatelessServiceStateModel createStateTransitionHandler(ResourceId resourceId, PartitionId partitionId) { return new StatelessServiceStateModel(partitionId, _service); } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java ---------------------------------------------------------------------- diff --git a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java b/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java index 27df916..487ec2a 100644 --- a/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java +++ b/recipes/distributed-lock-manager/src/main/java/org/apache/helix/lockmanager/LockFactory.java @@ -21,10 +21,11 @@ package org.apache.helix.lockmanager; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; public class LockFactory extends StateTransitionHandlerFactory<Lock> { @Override - public Lock createStateTransitionHandler(PartitionId lockName) { + public Lock createStateTransitionHandler(ResourceId resource, PartitionId lockName) { return new Lock(lockName.toString()); } } http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerTransitionHandlerFactory.java ---------------------------------------------------------------------- diff --git a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerTransitionHandlerFactory.java b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerTransitionHandlerFactory.java index a040a9c..6f3f3b2 100644 --- a/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerTransitionHandlerFactory.java +++ b/recipes/rabbitmq-consumer-group/src/main/java/org/apache/helix/recipes/rabbitmq/ConsumerTransitionHandlerFactory.java @@ -22,6 +22,7 @@ package org.apache.helix.recipes.rabbitmq; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.ParticipantId; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; public class ConsumerTransitionHandlerFactory extends StateTransitionHandlerFactory<ConsumerTransitionHandler> { private final ParticipantId _consumerId; @@ -33,7 +34,7 @@ public class ConsumerTransitionHandlerFactory extends StateTransitionHandlerFact } @Override - public ConsumerTransitionHandler createStateTransitionHandler(PartitionId partition) { + public ConsumerTransitionHandler createStateTransitionHandler(ResourceId resource, PartitionId partition) { ConsumerTransitionHandler model = new ConsumerTransitionHandler(_consumerId, partition, _mqServer); return model; http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java ---------------------------------------------------------------------- diff --git a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java b/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java index b1b3e44..f4317dd 100644 --- a/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java +++ b/recipes/rsync-replicated-file-system/src/main/java/org/apache/helix/filestore/FileStoreStateModelFactory.java @@ -22,6 +22,7 @@ package org.apache.helix.filestore; import org.apache.helix.HelixManager; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; public class FileStoreStateModelFactory extends StateTransitionHandlerFactory<FileStoreStateModel> { private final HelixManager manager; @@ -31,7 +32,7 @@ public class FileStoreStateModelFactory extends StateTransitionHandlerFactory<Fi } @Override - public FileStoreStateModel createStateTransitionHandler(PartitionId partition) { + public FileStoreStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { FileStoreStateModel model; model = new FileStoreStateModel(manager, partition.toString().split("_")[0], partition.toString()); http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java ---------------------------------------------------------------------- diff --git a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java b/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java index 9d6b978..5d9633f 100644 --- a/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java +++ b/recipes/task-execution/src/main/java/org/apache/helix/taskexecution/TaskStateModelFactory.java @@ -21,6 +21,7 @@ package org.apache.helix.taskexecution; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; public class TaskStateModelFactory extends StateTransitionHandlerFactory<TaskStateModel> { private final String _workerId; @@ -35,7 +36,7 @@ public class TaskStateModelFactory extends StateTransitionHandlerFactory<TaskSta } @Override - public TaskStateModel createStateTransitionHandler(PartitionId partition) { + public TaskStateModel createStateTransitionHandler(ResourceId resource, PartitionId partition) { TaskStateModel model = new TaskStateModel(_workerId, partition.toString(), _taskFactory, _taskResultStore); return model; http://git-wip-us.apache.org/repos/asf/helix/blob/8e58aa5a/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java ---------------------------------------------------------------------- diff --git a/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java b/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java index de0d5aa..0d51b45 100644 --- a/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java +++ b/recipes/user-defined-rebalancer/src/main/java/org/apache/helix/userdefinedrebalancer/LockFactory.java @@ -21,6 +21,7 @@ package org.apache.helix.userdefinedrebalancer; import org.apache.helix.api.StateTransitionHandlerFactory; import org.apache.helix.api.id.PartitionId; +import org.apache.helix.api.id.ResourceId; /** * This factory allows a participant to get the appropriate state model callbacks for the lock @@ -29,7 +30,7 @@ import org.apache.helix.api.id.PartitionId; */ public class LockFactory extends StateTransitionHandlerFactory<Lock> { @Override - public Lock createStateTransitionHandler(PartitionId partitionId) { + public Lock createStateTransitionHandler(ResourceId resource, PartitionId partitionId) { // TODO Auto-generated method stub return new Lock(partitionId.stringify()); }
