You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@helix.apache.org by ka...@apache.org on 2013/11/07 02:19:13 UTC
[05/53] [abbrv] [HELIX-238] Refactor, add update to accessors,
test update logic
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index 11e3608..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/ParticipantAccessor.java
+++ /dev/null
@@ -1,393 +0,0 @@
-package org.apache.helix.api;
-
-/*
- * 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.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.I0Itec.zkclient.DataUpdater;
-import org.apache.helix.AccessOption;
-import org.apache.helix.BaseDataAccessor;
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.HelixException;
-import org.apache.helix.PropertyKey;
-import org.apache.helix.ZNRecord;
-import org.apache.helix.model.CurrentState;
-import org.apache.helix.model.IdealState;
-import org.apache.helix.model.IdealState.RebalanceMode;
-import org.apache.helix.model.InstanceConfig;
-import org.apache.helix.model.InstanceConfig.InstanceConfigProperty;
-import org.apache.helix.model.LiveInstance;
-import org.apache.helix.model.Message;
-import org.apache.log4j.Logger;
-
-public class ParticipantAccessor {
- private static final Logger LOG = Logger.getLogger(ParticipantAccessor.class);
-
- private final HelixDataAccessor _accessor;
- private final PropertyKey.Builder _keyBuilder;
- private final ClusterId _clusterId;
-
- public ParticipantAccessor(ClusterId clusterId, HelixDataAccessor accessor) {
- _clusterId = clusterId;
- _accessor = accessor;
- _keyBuilder = accessor.keyBuilder();
- }
-
- /**
- * enable/disable a participant
- * @param participantId
- * @param isEnabled
- */
- void enableParticipant(ParticipantId participantId, boolean isEnabled) {
- String participantName = participantId.stringify();
- if (_accessor.getProperty(_keyBuilder.instanceConfig(participantName)) == null) {
- LOG.error("Config for participant: " + participantId + " does NOT exist in cluster: "
- + _clusterId);
- return;
- }
-
- InstanceConfig config = new InstanceConfig(participantName);
- config.setInstanceEnabled(isEnabled);
- _accessor.updateProperty(_keyBuilder.instanceConfig(participantName), config);
-
- }
-
- /**
- * disable participant
- * @param participantId
- */
- public void disableParticipant(ParticipantId participantId) {
- enableParticipant(participantId, false);
- }
-
- /**
- * enable participant
- * @param participantId
- */
- public void enableParticipant(ParticipantId participantId) {
- enableParticipant(participantId, true);
- }
-
- /**
- * create messages for participant
- * @param participantId
- * @param msgMap map of message-id to message
- */
- public void insertMessagesToParticipant(ParticipantId participantId,
- Map<MessageId, Message> msgMap) {
- List<PropertyKey> msgKeys = new ArrayList<PropertyKey>();
- List<Message> msgs = new ArrayList<Message>();
- for (MessageId msgId : msgMap.keySet()) {
- msgKeys.add(_keyBuilder.message(participantId.stringify(), msgId.stringify()));
- msgs.add(msgMap.get(msgId));
- }
-
- _accessor.createChildren(msgKeys, msgs);
- }
-
- /**
- * set messages of participant
- * @param participantId
- * @param msgMap map of message-id to message
- */
- public void updateMessageStatus(ParticipantId participantId, Map<MessageId, Message> msgMap) {
- String participantName = participantId.stringify();
- List<PropertyKey> msgKeys = new ArrayList<PropertyKey>();
- List<Message> msgs = new ArrayList<Message>();
- for (MessageId msgId : msgMap.keySet()) {
- msgKeys.add(_keyBuilder.message(participantName, msgId.stringify()));
- msgs.add(msgMap.get(msgId));
- }
- _accessor.setChildren(msgKeys, msgs);
- }
-
- /**
- * delete messages from participant
- * @param participantId
- * @param msgIdSet
- */
- public void deleteMessagesFromParticipant(ParticipantId participantId, Set<MessageId> msgIdSet) {
- String participantName = participantId.stringify();
- List<PropertyKey> msgKeys = new ArrayList<PropertyKey>();
- for (MessageId msgId : msgIdSet) {
- msgKeys.add(_keyBuilder.message(participantName, msgId.stringify()));
- }
-
- // TODO impl batch remove
- for (PropertyKey msgKey : msgKeys) {
- _accessor.removeProperty(msgKey);
- }
- }
-
- /**
- * enable/disable partitions on a participant
- * @param enabled
- * @param participantId
- * @param resourceId
- * @param partitionIdSet
- */
- void enablePartitionsForParticipant(final boolean enabled, final ParticipantId participantId,
- final ResourceId resourceId, final Set<PartitionId> partitionIdSet) {
- String participantName = participantId.stringify();
- String resourceName = resourceId.stringify();
-
- // check instanceConfig exists
- PropertyKey instanceConfigKey = _keyBuilder.instanceConfig(participantName);
- if (_accessor.getProperty(instanceConfigKey) == null) {
- LOG.error("Config for participant: " + participantId + " does NOT exist in cluster: "
- + _clusterId);
- return;
- }
-
- // check resource exist. warn if not
- IdealState idealState = _accessor.getProperty(_keyBuilder.idealState(resourceName));
- if (idealState == null) {
- LOG.warn("Disable partitions: " + partitionIdSet + " but Cluster: " + _clusterId
- + ", resource: " + resourceId
- + " does NOT exists. probably disable it during ERROR->DROPPED transtition");
-
- } else {
- // check partitions exist. warn if not
- for (PartitionId partitionId : partitionIdSet) {
- if ((idealState.getRebalanceMode() == RebalanceMode.SEMI_AUTO && idealState
- .getPreferenceList(partitionId) == null)
- || (idealState.getRebalanceMode() == RebalanceMode.CUSTOMIZED && idealState
- .getParticipantStateMap(partitionId) == null)) {
- LOG.warn("Cluster: " + _clusterId + ", resource: " + resourceId + ", partition: "
- + partitionId + ", partition does NOT exist in ideal state");
- }
- }
- }
-
- // TODO merge list logic should go to znrecord updater
- // update participantConfig
- // could not use ZNRecordUpdater since it doesn't do listField merge/subtract
- BaseDataAccessor<ZNRecord> baseAccessor = _accessor.getBaseDataAccessor();
- final List<String> partitionNames = new ArrayList<String>();
- for (PartitionId partitionId : partitionIdSet) {
- partitionNames.add(partitionId.stringify());
- }
-
- baseAccessor.update(instanceConfigKey.getPath(), new DataUpdater<ZNRecord>() {
- @Override
- public ZNRecord update(ZNRecord currentData) {
- if (currentData == null) {
- throw new HelixException("Cluster: " + _clusterId + ", instance: " + participantId
- + ", participant config is null");
- }
-
- // TODO: merge with InstanceConfig.setInstanceEnabledForPartition
- List<String> list =
- currentData.getListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.toString());
- Set<String> disabledPartitions = new HashSet<String>();
- if (list != null) {
- disabledPartitions.addAll(list);
- }
-
- if (enabled) {
- disabledPartitions.removeAll(partitionNames);
- } else {
- disabledPartitions.addAll(partitionNames);
- }
-
- list = new ArrayList<String>(disabledPartitions);
- Collections.sort(list);
- currentData.setListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.toString(), list);
- return currentData;
- }
- }, AccessOption.PERSISTENT);
- }
-
- /**
- * disable partitions on a participant
- * @param participantId
- * @param resourceId
- * @param disablePartitionIdSet
- */
- public void disablePartitionsForParticipant(ParticipantId participantId, ResourceId resourceId,
- Set<PartitionId> disablePartitionIdSet) {
- enablePartitionsForParticipant(false, participantId, resourceId, disablePartitionIdSet);
- }
-
- /**
- * enable partitions on a participant
- * @param participantId
- * @param resourceId
- * @param enablePartitionIdSet
- */
- public void enablePartitionsForParticipant(ParticipantId participantId, ResourceId resourceId,
- Set<PartitionId> enablePartitionIdSet) {
- enablePartitionsForParticipant(true, participantId, resourceId, enablePartitionIdSet);
- }
-
- /**
- * reset partitions on a participant
- * @param participantId
- * @param resourceId
- * @param resetPartitionIdSet
- */
- public void resetPartitionsForParticipant(ParticipantId participantId, ResourceId resourceId,
- Set<PartitionId> resetPartitionIdSet) {
- // TODO impl this
- }
-
- /**
- * Update a participant configuration
- * @param participantId the participant to update
- * @param participantDelta changes to the participant
- * @return ParticipantConfig, or null if participant is not persisted
- */
- public ParticipantConfig updateParticipant(ParticipantId participantId,
- ParticipantConfig.Delta participantDelta) {
- Participant participant = readParticipant(participantId);
- if (participant == null) {
- LOG.error("Participant " + participantId + " does not exist, cannot be updated");
- return null;
- }
- ParticipantConfig config = participantDelta.mergeInto(participant.getConfig());
- // TODO: persist this
- return config;
- }
-
- /**
- * create a participant based on physical model
- * @param participantId
- * @param instanceConfig
- * @param userConfig
- * @param liveInstance
- * @param instanceMsgMap map of message-id to message
- * @param instanceCurStateMap map of resource-id to current-state
- * @return participant
- */
- static Participant createParticipant(ParticipantId participantId, InstanceConfig instanceConfig,
- UserConfig userConfig, LiveInstance liveInstance, Map<String, Message> instanceMsgMap,
- Map<String, CurrentState> instanceCurStateMap) {
-
- String hostName = instanceConfig.getHostName();
-
- int port = -1;
- try {
- port = Integer.parseInt(instanceConfig.getPort());
- } catch (IllegalArgumentException e) {
- // keep as -1
- }
- if (port < 0 || port > 65535) {
- port = -1;
- }
- boolean isEnabled = instanceConfig.getInstanceEnabled();
-
- List<String> disabledPartitions = instanceConfig.getDisabledPartitions();
- Set<PartitionId> disabledPartitionIdSet = Collections.emptySet();
- if (disabledPartitions != null) {
- disabledPartitionIdSet = new HashSet<PartitionId>();
- for (String partitionId : disabledPartitions) {
- disabledPartitionIdSet.add(PartitionId.from(PartitionId.extractResourceId(partitionId),
- PartitionId.stripResourceId(partitionId)));
- }
- }
-
- Set<String> tags = new HashSet<String>(instanceConfig.getTags());
-
- RunningInstance runningInstance = null;
- if (liveInstance != null) {
- runningInstance =
- new RunningInstance(liveInstance.getSessionId(), liveInstance.getHelixVersion(),
- liveInstance.getProcessId());
- }
-
- Map<MessageId, Message> msgMap = new HashMap<MessageId, Message>();
- if (instanceMsgMap != null) {
- for (String msgId : instanceMsgMap.keySet()) {
- Message message = instanceMsgMap.get(msgId);
- msgMap.put(MessageId.from(msgId), message);
- }
- }
-
- Map<ResourceId, CurrentState> curStateMap = new HashMap<ResourceId, CurrentState>();
- if (instanceCurStateMap != null) {
-
- for (String resourceName : instanceCurStateMap.keySet()) {
- curStateMap.put(ResourceId.from(resourceName), instanceCurStateMap.get(resourceName));
- }
- }
-
- return new Participant(participantId, hostName, port, isEnabled, disabledPartitionIdSet, tags,
- runningInstance, curStateMap, msgMap, userConfig);
- }
-
- /**
- * read participant related data
- * @param participantId
- * @return participant
- */
- public Participant readParticipant(ParticipantId participantId) {
- // read physical model
- String participantName = participantId.stringify();
- InstanceConfig instanceConfig = _accessor.getProperty(_keyBuilder.instance(participantName));
- UserConfig userConfig = UserConfig.from(instanceConfig);
- LiveInstance liveInstance = _accessor.getProperty(_keyBuilder.liveInstance(participantName));
-
- Map<String, Message> instanceMsgMap = Collections.emptyMap();
- Map<String, CurrentState> instanceCurStateMap = Collections.emptyMap();
- if (liveInstance != null) {
- SessionId sessionId = liveInstance.getSessionId();
-
- instanceMsgMap = _accessor.getChildValuesMap(_keyBuilder.messages(participantName));
- instanceCurStateMap =
- _accessor.getChildValuesMap(_keyBuilder.currentStates(participantName,
- sessionId.stringify()));
- }
-
- return createParticipant(participantId, instanceConfig, userConfig, liveInstance,
- instanceMsgMap, instanceCurStateMap);
- }
-
- /**
- * update resource current state of a participant
- * @param resourceId resource id
- * @param participantId participant id
- * @param sessionId session id
- * @param curStateUpdate current state change delta
- */
- public void updateCurrentState(ResourceId resourceId, ParticipantId participantId,
- SessionId sessionId, CurrentState curStateUpdate) {
- _accessor.updateProperty(
- _keyBuilder.currentState(participantId.stringify(), sessionId.stringify(),
- resourceId.stringify()), curStateUpdate);
- }
-
- /**
- * drop resource current state of a participant
- * @param resourceId resource id
- * @param participantId participant id
- * @param sessionId session id
- */
- public void dropCurrentState(ResourceId resourceId, ParticipantId participantId,
- SessionId sessionId) {
- _accessor.removeProperty(_keyBuilder.currentState(participantId.stringify(),
- sessionId.stringify(), resourceId.stringify()));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index 5498ca3..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/ParticipantConfig.java
+++ /dev/null
@@ -1,371 +0,0 @@
-package org.apache.helix.api;
-
-import java.util.HashSet;
-import java.util.Set;
-
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Sets;
-
-/*
- * 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.
- */
-
-/**
- * Configuration properties of a Helix participant
- */
-public class ParticipantConfig {
- private final ParticipantId _id;
- private final String _hostName;
- private final int _port;
- private final boolean _isEnabled;
- private final Set<PartitionId> _disabledPartitions;
- private final Set<String> _tags;
- private final UserConfig _userConfig;
-
- /**
- * Initialize a participant configuration. Also see ParticipantConfig.Builder
- * @param id participant id
- * @param hostName host where participant can be reached
- * @param port port to use to contact participant
- * @param isEnabled true if enabled, false if disabled
- * @param disabledPartitions set of partitions, if any to disable on this participant
- * @param tags tags to set for the participant
- */
- public ParticipantConfig(ParticipantId id, String hostName, int port, boolean isEnabled,
- Set<PartitionId> disabledPartitions, Set<String> tags, UserConfig userConfig) {
- _id = id;
- _hostName = hostName;
- _port = port;
- _isEnabled = isEnabled;
- _disabledPartitions = ImmutableSet.copyOf(disabledPartitions);
- _tags = ImmutableSet.copyOf(tags);
- _userConfig = userConfig;
- }
-
- /**
- * Get the host name of the participant
- * @return host name, or null if not applicable
- */
- public String getHostName() {
- return _hostName;
- }
-
- /**
- * Get the port of the participant
- * @return port number, or -1 if not applicable
- */
- public int getPort() {
- return _port;
- }
-
- /**
- * Get if the participant is enabled
- * @return true if enabled or false otherwise
- */
- public boolean isEnabled() {
- return _isEnabled;
- }
-
- /**
- * Get disabled partition id's
- * @return set of disabled partition id's, or empty set if none
- */
- public Set<PartitionId> getDisabledPartitions() {
- return _disabledPartitions;
- }
-
- /**
- * Get tags
- * @return set of tags
- */
- public Set<String> getTags() {
- return _tags;
- }
-
- /**
- * Check if participant has a tag
- * @param tag tag to check
- * @return true if tagged, false otherwise
- */
- public boolean hasTag(String tag) {
- return _tags.contains(tag);
- }
-
- /**
- * Get user-specified configuration properties of this participant
- * @return UserConfig properties
- */
- public UserConfig getUserConfig() {
- return _userConfig;
- }
-
- /**
- * Get the participant id
- * @return ParticipantId
- */
- public ParticipantId getId() {
- return _id;
- }
-
- /**
- * Update context for a ParticipantConfig
- */
- public static class Delta {
- private enum Fields {
- HOST_NAME,
- PORT,
- ENABLED,
- USER_CONFIG
- }
-
- private Set<Fields> _updateFields;
- private Set<String> _removedTags;
- private Set<PartitionId> _removedDisabledPartitions;
- private Builder _builder;
-
- /**
- * Instantiate the delta for a participant config
- * @param participantId the participant to update
- */
- public Delta(ParticipantId participantId) {
- _updateFields = Sets.newHashSet();
- _removedTags = Sets.newHashSet();
- _removedDisabledPartitions = Sets.newHashSet();
- _builder = new Builder(participantId);
- }
-
- /**
- * Set the participant host name
- * @param hostName reachable host when live
- * @return Delta
- */
- public Delta setHostName(String hostName) {
- _builder.hostName(hostName);
- _updateFields.add(Fields.HOST_NAME);
- return this;
- }
-
- /**
- * Set the participant port
- * @param port port number
- * @return Delta
- */
- public Delta setPort(int port) {
- _builder.port(port);
- _updateFields.add(Fields.PORT);
- return this;
- }
-
- /**
- * Set whether or not the participant is enabled
- * @param isEnabled true if enabled, false otherwise
- * @return Delta
- */
- public Delta setEnabled(boolean isEnabled) {
- _builder.enabled(isEnabled);
- _updateFields.add(Fields.ENABLED);
- return this;
- }
-
- /**
- * Set the user configuration
- * @param userConfig user-specified properties
- * @return Delta
- */
- public Delta setUserConfig(UserConfig userConfig) {
- _builder.userConfig(userConfig);
- _updateFields.add(Fields.USER_CONFIG);
- return this;
- }
-
- /**
- * Add an new tag for this participant
- * @param tag the tag to add
- * @return Delta
- */
- public Delta addTag(String tag) {
- _builder.addTag(tag);
- return this;
- }
-
- /**
- * Remove a tag for this participant
- * @param tag the tag to remove
- * @return Delta
- */
- public Delta removeTag(String tag) {
- _removedTags.add(tag);
- return this;
- }
-
- /**
- * Add a partition to disable for this participant
- * @param partitionId the partition to disable
- * @return Delta
- */
- public Delta addDisabledPartition(PartitionId partitionId) {
- _builder.addDisabledPartition(partitionId);
- return this;
- }
-
- /**
- * Remove a partition from the disabled set for this participant
- * @param partitionId the partition to enable
- * @return Delta
- */
- public Delta removeDisabledPartition(PartitionId partitionId) {
- _removedDisabledPartitions.add(partitionId);
- return this;
- }
-
- /**
- * Create a ParticipantConfig that is the combination of an existing ParticipantConfig and this
- * delta
- * @param orig the original ParticipantConfig
- * @return updated ParticipantConfig
- */
- public ParticipantConfig mergeInto(ParticipantConfig orig) {
- ParticipantConfig deltaConfig = _builder.build();
- Builder builder =
- new Builder(orig.getId()).hostName(orig.getHostName()).port(orig.getPort())
- .userConfig(orig.getUserConfig());
- for (Fields field : _updateFields) {
- switch (field) {
- case HOST_NAME:
- builder.hostName(deltaConfig.getHostName());
- break;
- case PORT:
- builder.port(deltaConfig.getPort());
- break;
- case ENABLED:
- builder.enabled(deltaConfig.isEnabled());
- break;
- case USER_CONFIG:
- builder.userConfig(deltaConfig.getUserConfig());
- break;
- }
- }
- Set<String> tags = Sets.newHashSet(orig.getTags());
- tags.addAll(deltaConfig.getTags());
- tags.removeAll(_removedTags);
- for (String tag : tags) {
- builder.addTag(tag);
- }
- Set<PartitionId> disabledPartitions = Sets.newHashSet(orig.getDisabledPartitions());
- disabledPartitions.addAll(deltaConfig.getDisabledPartitions());
- for (PartitionId partitionId : disabledPartitions) {
- builder.addDisabledPartition(partitionId);
- }
- return builder.build();
- }
- }
-
- /**
- * Assemble a participant
- */
- public static class Builder {
- private final ParticipantId _id;
- private String _hostName;
- private int _port;
- private boolean _isEnabled;
- private final Set<PartitionId> _disabledPartitions;
- private final Set<String> _tags;
- private UserConfig _userConfig;
-
- /**
- * Build a participant with a given id
- * @param id participant id
- */
- public Builder(ParticipantId id) {
- _id = id;
- _disabledPartitions = new HashSet<PartitionId>();
- _tags = new HashSet<String>();
- _isEnabled = true;
- _userConfig = new UserConfig(Scope.participant(id));
- }
-
- /**
- * Set the participant host name
- * @param hostName reachable host when live
- * @return Builder
- */
- public Builder hostName(String hostName) {
- _hostName = hostName;
- return this;
- }
-
- /**
- * Set the participant port
- * @param port port number
- * @return Builder
- */
- public Builder port(int port) {
- _port = port;
- return this;
- }
-
- /**
- * Set whether or not the participant is enabled
- * @param isEnabled true if enabled, false otherwise
- * @return Builder
- */
- public Builder enabled(boolean isEnabled) {
- _isEnabled = isEnabled;
- return this;
- }
-
- /**
- * Add a partition to disable for this participant
- * @param partitionId the partition to disable
- * @return Builder
- */
- public Builder addDisabledPartition(PartitionId partitionId) {
- _disabledPartitions.add(partitionId);
- return this;
- }
-
- /**
- * Add an arbitrary tag for this participant
- * @param tag the tag to add
- * @return Builder
- */
- public Builder addTag(String tag) {
- _tags.add(tag);
- return this;
- }
-
- /**
- * Set the user configuration
- * @param userConfig user-specified properties
- * @return Builder
- */
- public Builder userConfig(UserConfig userConfig) {
- _userConfig = userConfig;
- return this;
- }
-
- /**
- * Assemble the participant
- * @return instantiated Participant
- */
- public ParticipantConfig build() {
- return new ParticipantConfig(_id, _hostName, _port, _isEnabled, _disabledPartitions, _tags,
- _userConfig);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index 59aa93b..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/ParticipantId.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.apache.helix.api;
-
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/*
- * 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.
- */
-
-public class ParticipantId extends Id {
- @JsonProperty("id")
- private final String _id;
-
- /**
- * Instantiate for a participant with a string name
- * @param id string participant id
- */
- @JsonCreator
- public ParticipantId(@JsonProperty("id") String id) {
- _id = id;
- }
-
- @Override
- 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/644ef67f/helix-core/src/main/java/org/apache/helix/api/Partition.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/Partition.java b/helix-core/src/main/java/org/apache/helix/api/Partition.java
index 3853f61..b295d72 100644
--- a/helix-core/src/main/java/org/apache/helix/api/Partition.java
+++ b/helix-core/src/main/java/org/apache/helix/api/Partition.java
@@ -1,5 +1,6 @@
package org.apache.helix.api;
+import org.apache.helix.api.id.PartitionId;
import org.codehaus.jackson.annotate.JsonCreator;
import org.codehaus.jackson.annotate.JsonProperty;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index 8f852c2..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/PartitionId.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package org.apache.helix.api;
-
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/*
- * 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.
- */
-
-public class PartitionId extends Id {
- @JsonProperty("resourceId")
- private final ResourceId _resourceId;
- @JsonProperty("partitionName")
- private final String _partitionName;
-
- /**
- * Instantiate for a resource and suffix
- * @param resourceId resource that the partition belongs to
- * @param partitionName name of the partition relative to the resource
- */
- @JsonCreator
- public PartitionId(@JsonProperty("resourceId") ResourceId resourceId,
- @JsonProperty("partitionName") String partitionName) {
- _resourceId = resourceId;
- _partitionName = partitionName;
- }
-
- /**
- * Get the id of the resource containing this partition
- * @return ResourceId
- */
- public ResourceId getResourceId() {
- return _resourceId;
- }
-
- @Override
- public String stringify() {
- // check in case the partition name is instantiated incorrectly
- if (_resourceId.stringify().equals(_partitionName)) {
- return _partitionName;
- }
- return String.format("%s_%s", _resourceId, _partitionName);
- }
-
- /**
- * @param partitionName
- * @return
- */
- public static String stripResourceId(String partitionName) {
- if (partitionName == null || !partitionName.contains("_")) {
- return partitionName;
- }
- return partitionName.substring(partitionName.lastIndexOf("_") + 1);
- }
-
- /**
- * @param partitionName
- * @return
- */
- public static ResourceId extractResourceId(String partitionName) {
- if (partitionName == null || !partitionName.contains("_")) {
- return ResourceId.from(partitionName);
- }
- 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));
- }
-
- /**
- * Same as {@link PartitionId#from(String)}.
- * @param partitionId string partition identifier
- * @return PartitionId
- */
- public static PartitionId valueOf(String partitionId) {
- return from(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/644ef67f/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
deleted file mode 100644
index 4668f57..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/ProcId.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.apache.helix.api;
-
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/*
- * 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.
- */
-
-public class ProcId extends Id {
- @JsonProperty("id")
- private final String _id;
-
- /**
- * Create a process id
- * @param id string representation of a process id
- */
- @JsonCreator
- public ProcId(@JsonProperty("id") String id) {
- _id = id;
- }
-
- @Override
- public String stringify() {
- 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/644ef67f/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 2c3b7ca..e9d07bd 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
@@ -24,7 +24,13 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import org.apache.helix.api.ResourceConfig.ResourceType;
+import org.apache.helix.api.config.ResourceConfig;
+import org.apache.helix.api.config.SchedulerTaskConfig;
+import org.apache.helix.api.config.UserConfig;
+import org.apache.helix.api.config.ResourceConfig.ResourceType;
+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.rebalancer.context.RebalancerConfig;
import org.apache.helix.controller.rebalancer.context.RebalancerContext;
import org.apache.helix.model.ExternalView;
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index 5adec4e..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/ResourceAccessor.java
+++ /dev/null
@@ -1,233 +0,0 @@
-package org.apache.helix.api;
-
-/*
- * 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 org.apache.helix.HelixConstants.StateModelToken;
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.PropertyKey;
-import org.apache.helix.api.ResourceConfig.ResourceType;
-import org.apache.helix.controller.rebalancer.context.CustomRebalancerContext;
-import org.apache.helix.controller.rebalancer.context.PartitionedRebalancerContext;
-import org.apache.helix.controller.rebalancer.context.RebalancerConfig;
-import org.apache.helix.controller.rebalancer.context.RebalancerContext;
-import org.apache.helix.controller.rebalancer.context.SemiAutoRebalancerContext;
-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;
-import org.apache.helix.model.ResourceConfiguration;
-import org.apache.log4j.Logger;
-
-public class ResourceAccessor {
- private static final Logger LOG = Logger.getLogger(ResourceAccessor.class);
- private final HelixDataAccessor _accessor;
- private final PropertyKey.Builder _keyBuilder;
-
- public ResourceAccessor(HelixDataAccessor accessor) {
- _accessor = accessor;
- _keyBuilder = accessor.keyBuilder();
- }
-
- /**
- * Read a single snapshot of a resource
- * @param resourceId the resource id to read
- * @return Resource
- */
- public Resource readResource(ResourceId resourceId) {
- ResourceConfiguration config =
- _accessor.getProperty(_keyBuilder.resourceConfig(resourceId.stringify()));
- IdealState idealState = _accessor.getProperty(_keyBuilder.idealState(resourceId.stringify()));
- ExternalView externalView =
- _accessor.getProperty(_keyBuilder.externalView(resourceId.stringify()));
- ResourceAssignment resourceAssignment =
- _accessor.getProperty(_keyBuilder.resourceAssignment(resourceId.stringify()));
- return createResource(resourceId, config, idealState, externalView, resourceAssignment);
- }
-
- /**
- * Update a resource configuration
- * @param resourceId the resource id to update
- * @param resourceDelta changes to the resource
- * @return ResourceConfig, or null if the resource is not persisted
- */
- public ResourceConfig updateResource(ResourceId resourceId, ResourceConfig.Delta resourceDelta) {
- Resource resource = readResource(resourceId);
- if (resource == null) {
- LOG.error("Resource " + resourceId + " does not exist, cannot be updated");
- return null;
- }
- ResourceConfig config = resourceDelta.mergeInto(resource.getConfig());
- // TODO: persist this
- return config;
- }
-
- /**
- * save resource assignment
- * @param resourceId
- * @param resourceAssignment
- */
- public void setResourceAssignment(ResourceId resourceId, ResourceAssignment resourceAssignment) {
- _accessor.setProperty(_keyBuilder.resourceAssignment(resourceId.stringify()),
- resourceAssignment);
- }
-
- /**
- * save resource assignment
- * @param resourceId
- * @return resource assignment or null
- */
- public ResourceAssignment getResourceAssignment(ResourceId resourceId) {
- return _accessor.getProperty(_keyBuilder.resourceAssignment(resourceId.stringify()));
- }
-
- /**
- * Set a resource configuration, which may include user-defined configuration, as well as
- * rebalancer configuration
- * @param resourceId
- * @param configuration
- */
- public void setConfiguration(ResourceId resourceId, ResourceConfiguration configuration) {
- _accessor.setProperty(_keyBuilder.resourceConfig(resourceId.stringify()), configuration);
- // also set an ideal state if the resource supports it
- RebalancerConfig rebalancerConfig = new RebalancerConfig(configuration);
- IdealState idealState =
- rebalancerConfigToIdealState(rebalancerConfig, configuration.getBucketSize(),
- configuration.getBatchMessageMode());
- if (idealState != null) {
- _accessor.setProperty(_keyBuilder.idealState(resourceId.stringify()), idealState);
- }
- }
-
- /**
- * Get a resource configuration, which may include user-defined configuration, as well as
- * rebalancer configuration
- * @param resourceId
- * @return configuration
- */
- public void getConfiguration(ResourceId resourceId) {
- _accessor.getProperty(_keyBuilder.resourceConfig(resourceId.stringify()));
- }
-
- /**
- * set external view of a resource
- * @param resourceId
- * @param extView
- */
- public void setExternalView(ResourceId resourceId, ExternalView extView) {
- _accessor.setProperty(_keyBuilder.externalView(resourceId.stringify()), extView);
- }
-
- /**
- * drop external view of a resource
- * @param resourceId
- */
- public void dropExternalView(ResourceId resourceId) {
- _accessor.removeProperty(_keyBuilder.externalView(resourceId.stringify()));
- }
-
- /**
- * Get an ideal state from a rebalancer config if the resource is partitioned
- * @param config RebalancerConfig instance
- * @param bucketSize bucket size to use
- * @param batchMessageMode true if batch messaging allowed, false otherwise
- * @return IdealState, or null
- */
- static IdealState rebalancerConfigToIdealState(RebalancerConfig config, int bucketSize,
- boolean batchMessageMode) {
- PartitionedRebalancerContext partitionedContext =
- config.getRebalancerContext(PartitionedRebalancerContext.class);
- if (partitionedContext != null) {
- IdealState idealState = new IdealState(partitionedContext.getResourceId());
- idealState.setRebalanceMode(partitionedContext.getRebalanceMode());
- idealState.setRebalancerRef(partitionedContext.getRebalancerRef());
- String replicas = null;
- if (partitionedContext.anyLiveParticipant()) {
- replicas = StateModelToken.ANY_LIVEINSTANCE.toString();
- } else {
- replicas = Integer.toString(partitionedContext.getReplicaCount());
- }
- idealState.setReplicas(replicas);
- idealState.setNumPartitions(partitionedContext.getPartitionSet().size());
- idealState.setInstanceGroupTag(partitionedContext.getParticipantGroupTag());
- idealState.setMaxPartitionsPerInstance(partitionedContext.getMaxPartitionsPerParticipant());
- idealState.setStateModelDefId(partitionedContext.getStateModelDefId());
- idealState.setStateModelFactoryId(partitionedContext.getStateModelFactoryId());
- idealState.setBucketSize(bucketSize);
- idealState.setBatchMessageMode(batchMessageMode);
- if (partitionedContext.getRebalanceMode() == RebalanceMode.SEMI_AUTO) {
- SemiAutoRebalancerContext semiAutoContext =
- config.getRebalancerContext(SemiAutoRebalancerContext.class);
- for (PartitionId partitionId : semiAutoContext.getPartitionSet()) {
- idealState.setPreferenceList(partitionId, semiAutoContext.getPreferenceList(partitionId));
- }
- } else if (partitionedContext.getRebalanceMode() == RebalanceMode.CUSTOMIZED) {
- CustomRebalancerContext customContext =
- config.getRebalancerContext(CustomRebalancerContext.class);
- for (PartitionId partitionId : customContext.getPartitionSet()) {
- idealState.setParticipantStateMap(partitionId,
- customContext.getPreferenceMap(partitionId));
- }
- }
- return idealState;
- }
- return null;
- }
-
- /**
- * Create a resource snapshot instance from the physical model
- * @param resourceId the resource id
- * @param resourceConfiguration physical resource configuration
- * @param idealState ideal state of the resource
- * @param externalView external view of the resource
- * @param resourceAssignment current resource assignment
- * @return Resource
- */
- static Resource createResource(ResourceId resourceId,
- ResourceConfiguration resourceConfiguration, IdealState idealState,
- ExternalView externalView, ResourceAssignment resourceAssignment) {
- UserConfig userConfig;
- ResourceType type = ResourceType.DATA;
- if (resourceConfiguration != null) {
- userConfig = UserConfig.from(resourceConfiguration);
- type = resourceConfiguration.getType();
- } else {
- userConfig = new UserConfig(Scope.resource(resourceId));
- }
- int bucketSize = 0;
- boolean batchMessageMode = false;
- RebalancerContext rebalancerContext;
- if (idealState != null) {
- rebalancerContext = PartitionedRebalancerContext.from(idealState);
- bucketSize = idealState.getBucketSize();
- batchMessageMode = idealState.getBatchMessageMode();
- } else {
- if (resourceConfiguration != null) {
- bucketSize = resourceConfiguration.getBucketSize();
- batchMessageMode = resourceConfiguration.getBatchMessageMode();
- RebalancerConfig rebalancerConfig = new RebalancerConfig(resourceConfiguration);
- rebalancerContext = rebalancerConfig.getRebalancerContext(RebalancerContext.class);
- } else {
- rebalancerContext = new PartitionedRebalancerContext(RebalanceMode.NONE);
- }
- }
- return new Resource(resourceId, type, idealState, resourceAssignment, externalView,
- rebalancerContext, userConfig, bucketSize, batchMessageMode);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index dc3dc1d..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/ResourceConfig.java
+++ /dev/null
@@ -1,369 +0,0 @@
-package org.apache.helix.api;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.helix.controller.rebalancer.context.RebalancerConfig;
-import org.apache.helix.controller.rebalancer.context.RebalancerContext;
-
-import com.google.common.collect.Sets;
-
-/*
- * 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.
- */
-
-/**
- * Full configuration of a Helix resource. Typically used to add or modify resources on a cluster
- */
-public class ResourceConfig {
- /**
- * Type of a resource. A resource is any entity that can be managed by Helix.
- */
- public enum ResourceType {
- /**
- * A resource that is persistent, and potentially partitioned and replicated.
- */
- DATA
- }
-
- private final ResourceId _id;
- private final RebalancerConfig _rebalancerConfig;
- private final SchedulerTaskConfig _schedulerTaskConfig;
- private final UserConfig _userConfig;
- private final int _bucketSize;
- private final boolean _batchMessageMode;
- private final ResourceType _resourceType;
-
- /**
- * Instantiate a configuration. Consider using ResourceConfig.Builder
- * @param id resource id
- * @param partitionMap map of partition identifiers to partition objects
- * @param schedulerTaskConfig configuration for scheduler tasks associated with the resource
- * @param rebalancerConfig configuration for rebalancing the resource
- * @param userConfig user-defined resource properties
- * @param bucketSize bucket size for this resource
- * @param batchMessageMode whether or not batch messaging is allowed
- */
- public ResourceConfig(ResourceId id, ResourceType resourceType,
- SchedulerTaskConfig schedulerTaskConfig, RebalancerConfig rebalancerConfig,
- UserConfig userConfig, int bucketSize, boolean batchMessageMode) {
- _id = id;
- _resourceType = resourceType;
- _schedulerTaskConfig = schedulerTaskConfig;
- _rebalancerConfig = rebalancerConfig;
- _userConfig = userConfig;
- _bucketSize = bucketSize;
- _batchMessageMode = batchMessageMode;
- }
-
- /**
- * Get the subunits of the resource
- * @return map of subunit id to subunit or empty map if none
- */
- public Map<? extends PartitionId, ? extends Partition> getSubUnitMap() {
- return _rebalancerConfig.getRebalancerContext(RebalancerContext.class).getSubUnitMap();
- }
-
- /**
- * Get a subunit that the resource contains
- * @param subUnitId the subunit id to look up
- * @return Partition or null if none is present with the given id
- */
- public Partition getSubUnit(PartitionId subUnitId) {
- return getSubUnitMap().get(subUnitId);
- }
-
- /**
- * Get the set of subunit ids that the resource contains
- * @return subunit id set, or empty if none
- */
- public Set<? extends PartitionId> getSubUnitSet() {
- return getSubUnitMap().keySet();
- }
-
- /**
- * Get the resource properties configuring rebalancing
- * @return RebalancerConfig properties
- */
- public RebalancerConfig getRebalancerConfig() {
- return _rebalancerConfig;
- }
-
- /**
- * Get the resource id
- * @return ResourceId
- */
- public ResourceId getId() {
- return _id;
- }
-
- /**
- * Get the resource type
- * @return ResourceType
- */
- public ResourceType getType() {
- return _resourceType;
- }
-
- /**
- * Get the properties configuring scheduler tasks
- * @return SchedulerTaskConfig properties
- */
- public SchedulerTaskConfig getSchedulerTaskConfig() {
- return _schedulerTaskConfig;
- }
-
- /**
- * Get user-specified configuration properties of this resource
- * @return UserConfig properties
- */
- public UserConfig getUserConfig() {
- return _userConfig;
- }
-
- /**
- * Get the bucket size for this resource
- * @return bucket size
- */
- public int getBucketSize() {
- return _bucketSize;
- }
-
- /**
- * Get the batch message mode
- * @return true if enabled, false if disabled
- */
- public boolean getBatchMessageMode() {
- return _batchMessageMode;
- }
-
- @Override
- public String toString() {
- return getSubUnitMap().toString();
- }
-
- /**
- * Update context for a ResourceConfig
- */
- public static class Delta {
- private enum Fields {
- TYPE,
- REBALANCER_CONTEXT,
- USER_CONFIG,
- BUCKET_SIZE,
- BATCH_MESSAGE_MODE
- }
-
- private Set<Fields> _updateFields;
- private Builder _builder;
-
- /**
- * Instantiate the delta for a resource config
- * @param resourceId the resource to update
- */
- public Delta(ResourceId resourceId) {
- _builder = new Builder(resourceId);
- _updateFields = Sets.newHashSet();
- }
-
- /**
- * Set the type of this resource
- * @param type ResourceType
- * @return Delta
- */
- public Delta setType(ResourceType type) {
- _builder.type(type);
- _updateFields.add(Fields.TYPE);
- return this;
- }
-
- /**
- * Set the rebalancer configuration
- * @param context properties of interest for rebalancing
- * @return Delta
- */
- public Delta setRebalancerContext(RebalancerContext context) {
- _builder.rebalancerContext(context);
- _updateFields.add(Fields.REBALANCER_CONTEXT);
- return this;
- }
-
- /**
- * Set the user configuration
- * @param userConfig user-specified properties
- * @return Delta
- */
- public Delta setUserConfig(UserConfig userConfig) {
- _builder.userConfig(userConfig);
- _updateFields.add(Fields.USER_CONFIG);
- return this;
- }
-
- /**
- * Set the bucket size
- * @param bucketSize the size to use
- * @return Delta
- */
- public Delta setBucketSize(int bucketSize) {
- _builder.bucketSize(bucketSize);
- _updateFields.add(Fields.BUCKET_SIZE);
- return this;
- }
-
- /**
- * Set the batch message mode
- * @param batchMessageMode true to enable, false to disable
- * @return Delta
- */
- public Delta setBatchMessageMode(boolean batchMessageMode) {
- _builder.batchMessageMode(batchMessageMode);
- _updateFields.add(Fields.BATCH_MESSAGE_MODE);
- return this;
- }
-
- /**
- * Create a ResourceConfig that is the combination of an existing ResourceConfig and this delta
- * @param orig the original ResourceConfig
- * @return updated ResourceConfig
- */
- public ResourceConfig mergeInto(ResourceConfig orig) {
- ResourceConfig deltaConfig = _builder.build();
- Builder builder =
- new Builder(orig.getId())
- .type(orig.getType())
- .rebalancerContext(
- orig.getRebalancerConfig().getRebalancerContext(RebalancerContext.class))
- .schedulerTaskConfig(orig.getSchedulerTaskConfig()).userConfig(orig.getUserConfig())
- .bucketSize(orig.getBucketSize()).batchMessageMode(orig.getBatchMessageMode());
- for (Fields field : _updateFields) {
- switch (field) {
- case TYPE:
- builder.type(deltaConfig.getType());
- break;
- case REBALANCER_CONTEXT:
- builder.rebalancerContext(deltaConfig.getRebalancerConfig().getRebalancerContext(
- RebalancerContext.class));
- break;
- case USER_CONFIG:
- builder.userConfig(deltaConfig.getUserConfig());
- break;
- case BUCKET_SIZE:
- builder.bucketSize(deltaConfig.getBucketSize());
- break;
- case BATCH_MESSAGE_MODE:
- builder.batchMessageMode(deltaConfig.getBatchMessageMode());
- break;
- }
- }
- return builder.build();
- }
- }
-
- /**
- * Assembles a ResourceConfig
- */
- public static class Builder {
- private final ResourceId _id;
- private ResourceType _type;
- private RebalancerConfig _rebalancerConfig;
- private SchedulerTaskConfig _schedulerTaskConfig;
- private UserConfig _userConfig;
- private int _bucketSize;
- private boolean _batchMessageMode;
-
- /**
- * Build a Resource with an id
- * @param id resource id
- */
- public Builder(ResourceId id) {
- _id = id;
- _type = ResourceType.DATA;
- _bucketSize = 0;
- _batchMessageMode = false;
- _userConfig = new UserConfig(Scope.resource(id));
- }
-
- /**
- * Set the type of this resource
- * @param type ResourceType
- * @return Builder
- */
- public Builder type(ResourceType type) {
- _type = type;
- return this;
- }
-
- /**
- * Set the rebalancer configuration
- * @param rebalancerContext properties of interest for rebalancing
- * @return Builder
- */
- public Builder rebalancerContext(RebalancerContext rebalancerContext) {
- _rebalancerConfig = new RebalancerConfig(rebalancerContext);
- return this;
- }
-
- /**
- * Set the user configuration
- * @param userConfig user-specified properties
- * @return Builder
- */
- public Builder userConfig(UserConfig userConfig) {
- _userConfig = userConfig;
- return this;
- }
-
- /**
- * @param schedulerTaskConfig
- * @return
- */
- public Builder schedulerTaskConfig(SchedulerTaskConfig schedulerTaskConfig) {
- _schedulerTaskConfig = schedulerTaskConfig;
- return this;
- }
-
- /**
- * Set the bucket size
- * @param bucketSize the size to use
- * @return Builder
- */
- public Builder bucketSize(int bucketSize) {
- _bucketSize = bucketSize;
- return this;
- }
-
- /**
- * Set the batch message mode
- * @param batchMessageMode true to enable, false to disable
- * @return Builder
- */
- public Builder batchMessageMode(boolean batchMessageMode) {
- _batchMessageMode = batchMessageMode;
- return this;
- }
-
- /**
- * Create a Resource object
- * @return instantiated Resource
- */
- public ResourceConfig build() {
- return new ResourceConfig(_id, _type, _schedulerTaskConfig, _rebalancerConfig, _userConfig,
- _bucketSize, _batchMessageMode);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index dfffe5e..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/ResourceId.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.helix.api;
-
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/*
- * 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.
- */
-
-/**
- * Identifies a resource
- */
-public class ResourceId extends Id {
- @JsonProperty("id")
- private final String _id;
-
- @Override
- public String stringify() {
- return _id;
- }
-
- /**
- * Create a resource id
- * @param id string representation of a resource id
- */
- @JsonCreator
- public ResourceId(@JsonProperty("id") 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/644ef67f/helix-core/src/main/java/org/apache/helix/api/RunningInstance.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/RunningInstance.java b/helix-core/src/main/java/org/apache/helix/api/RunningInstance.java
index 4effd24..4e5aedb 100644
--- a/helix-core/src/main/java/org/apache/helix/api/RunningInstance.java
+++ b/helix-core/src/main/java/org/apache/helix/api/RunningInstance.java
@@ -1,5 +1,8 @@
package org.apache.helix.api;
+import org.apache.helix.api.id.ProcId;
+import org.apache.helix.api.id.SessionId;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/helix-core/src/main/java/org/apache/helix/api/SchedulerTaskConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/SchedulerTaskConfig.java b/helix-core/src/main/java/org/apache/helix/api/SchedulerTaskConfig.java
deleted file mode 100644
index e7d0779..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/SchedulerTaskConfig.java
+++ /dev/null
@@ -1,68 +0,0 @@
-package org.apache.helix.api;
-
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.helix.model.Message;
-
-import com.google.common.collect.ImmutableMap;
-
-public class SchedulerTaskConfig {
- // TODO refactor using Transition logical model
- private final Map<String, Integer> _transitionTimeoutMap;
-
- private final Map<PartitionId, Message> _innerMessageMap;
-
- public SchedulerTaskConfig(Map<String, Integer> transitionTimeoutMap,
- Map<PartitionId, Message> innerMsgMap) {
- _transitionTimeoutMap = ImmutableMap.copyOf(transitionTimeoutMap);
- _innerMessageMap = ImmutableMap.copyOf(innerMsgMap);
- }
-
- /**
- * Get inner message for a partition
- * @param partitionId
- * @return inner message
- */
- public Message getInnerMessage(PartitionId partitionId) {
- return _innerMessageMap.get(partitionId);
- }
-
- /**
- * Get timeout for a transition
- * @param transition
- * @return timeout or -1 if not available
- */
- public int getTransitionTimeout(String transition) {
- Integer timeout = _transitionTimeoutMap.get(transition);
- if (timeout == null) {
- return -1;
- }
-
- return timeout;
- }
-
- /**
- * Get timeout for an inner message
- * @param transition
- * @param partitionId
- * @return timeout or -1 if not available
- */
- public int getTimeout(String transition, PartitionId partitionId) {
- Integer timeout = getTransitionTimeout(transition);
- if (timeout == null) {
- Message innerMessage = getInnerMessage(partitionId);
- timeout = innerMessage.getTimeout();
- }
-
- return timeout;
- }
-
- /**
- * Get partition-id set
- * @return partition-id set
- */
- public Set<PartitionId> getPartitionSet() {
- return _innerMessageMap.keySet();
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/helix-core/src/main/java/org/apache/helix/api/Scope.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/Scope.java b/helix-core/src/main/java/org/apache/helix/api/Scope.java
index 4bff194..4d4eead 100644
--- a/helix-core/src/main/java/org/apache/helix/api/Scope.java
+++ b/helix-core/src/main/java/org/apache/helix/api/Scope.java
@@ -1,5 +1,11 @@
package org.apache.helix.api;
+import org.apache.helix.api.id.ClusterId;
+import org.apache.helix.api.id.Id;
+import org.apache.helix.api.id.ParticipantId;
+import org.apache.helix.api.id.PartitionId;
+import org.apache.helix.api.id.ResourceId;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index df36193..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/SessionId.java
+++ /dev/null
@@ -1,54 +0,0 @@
-package org.apache.helix.api;
-
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/*
- * 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.
- */
-
-public class SessionId extends Id {
- @JsonProperty("id")
- private final String _id;
-
- /**
- * Create a session id
- * @param id string representing a session id
- */
- @JsonCreator
- public SessionId(@JsonProperty("id") String id) {
- _id = id;
- }
-
- @Override
- public String stringify() {
- 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/644ef67f/helix-core/src/main/java/org/apache/helix/api/Spectator.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/Spectator.java b/helix-core/src/main/java/org/apache/helix/api/Spectator.java
index e25601b..993de2f 100644
--- a/helix-core/src/main/java/org/apache/helix/api/Spectator.java
+++ b/helix-core/src/main/java/org/apache/helix/api/Spectator.java
@@ -1,5 +1,7 @@
package org.apache.helix.api;
+import org.apache.helix.api.id.SpectatorId;
+
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index 851eb0d..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/SpectatorId.java
+++ /dev/null
@@ -1,51 +0,0 @@
-package org.apache.helix.api;
-
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/*
- * 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.
- */
-
-public class SpectatorId extends Id {
- @JsonProperty("id")
- private final String _id;
-
- /**
- * Create a spectator id
- * @param id string representing a spectator id
- */
- @JsonCreator
- public SpectatorId(@JsonProperty("id") String id) {
- _id = id;
- }
-
- @Override
- public String stringify() {
- return _id;
- }
-
- /**
- * Create a spectator id from a string
- * @param spectatorId string representing a spectator id
- * @return SpectatorId
- */
- public static SpectatorId from(String spectatorId) {
- return new SpectatorId(spectatorId);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index 50ea020..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/StateModelDefId.java
+++ /dev/null
@@ -1,66 +0,0 @@
-package org.apache.helix.api;
-
-import org.apache.helix.manager.zk.DefaultSchedulerMessageHandlerFactory;
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/*
- * 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.
- */
-
-public class StateModelDefId extends Id {
- public static final StateModelDefId SchedulerTaskQueue = StateModelDefId
- .from(DefaultSchedulerMessageHandlerFactory.SCHEDULER_TASK_QUEUE);
- @JsonProperty("id")
- private final String _id;
-
- /**
- * Create a state model definition id
- * @param id string representing a state model definition id
- */
- @JsonCreator
- public StateModelDefId(@JsonProperty("id") String id) {
- _id = id;
- }
-
- @Override
- public String stringify() {
- return _id;
- }
-
- /**
- * Check if the underlying state model definition id is equal if case is ignored
- * @param that the StateModelDefId to compare
- * @return true if equal ignoring case, false otherwise
- */
- 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/644ef67f/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
deleted file mode 100644
index 60b6210..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/StateModelDefinitionAccessor.java
+++ /dev/null
@@ -1,69 +0,0 @@
-package org.apache.helix.api;
-
-/*
- * 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.HashMap;
-import java.util.Map;
-
-import org.apache.helix.HelixDataAccessor;
-import org.apache.helix.PropertyKey;
-import org.apache.helix.model.StateModelDefinition;
-
-import com.google.common.collect.ImmutableMap;
-
-public class StateModelDefinitionAccessor {
- private final HelixDataAccessor _accessor;
- private final PropertyKey.Builder _keyBuilder;
-
- /**
- * @param accessor
- */
- public StateModelDefinitionAccessor(HelixDataAccessor accessor) {
- _accessor = accessor;
- _keyBuilder = accessor.keyBuilder();
- }
-
- /**
- * Get all of the state model definitions available to the cluster
- * @return map of state model ids to state model definition objects
- */
- public Map<StateModelDefId, StateModelDefinition> readStateModelDefinitions() {
- Map<String, StateModelDefinition> stateModelDefs =
- _accessor.getChildValuesMap(_keyBuilder.stateModelDefs());
- Map<StateModelDefId, StateModelDefinition> stateModelDefMap =
- new HashMap<StateModelDefId, StateModelDefinition>();
-
- for (String stateModelDefName : stateModelDefs.keySet()) {
- stateModelDefMap.put(StateModelDefId.from(stateModelDefName),
- stateModelDefs.get(stateModelDefName));
- }
-
- return ImmutableMap.copyOf(stateModelDefMap);
- }
-
- /**
- * Set a state model definition. Adds the state model definition if it does not exist
- * @param stateModelDef fully initialized state model definition
- * @return true if the model is persisted, false otherwise
- */
- public boolean setStateModelDefinition(StateModelDefinition stateModelDef) {
- return _accessor.setProperty(_keyBuilder.stateModelDef(stateModelDef.getId()), stateModelDef);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-helix/blob/644ef67f/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
deleted file mode 100644
index 422b4e9..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/StateModelFactoryId.java
+++ /dev/null
@@ -1,57 +0,0 @@
-package org.apache.helix.api;
-
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonProperty;
-
-/*
- * 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.
- */
-
-/**
- * Id representing a state model factory
- */
-public class StateModelFactoryId extends Id {
- @JsonProperty("id")
- private final String _id;
-
- /**
- * Create a state model factory id
- * @param id string representing a state model factory
- */
- @JsonCreator
- public StateModelFactoryId(@JsonProperty("id") String id) {
- _id = id;
- }
-
- @Override
- public String stringify() {
- 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/644ef67f/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
deleted file mode 100644
index 181c071..0000000
--- a/helix-core/src/main/java/org/apache/helix/api/UserConfig.java
+++ /dev/null
@@ -1,52 +0,0 @@
-package org.apache.helix.api;
-
-import org.apache.helix.HelixProperty;
-
-/*
- * 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.
- */
-
-/**
- * Generic user-defined configuration of Helix components
- */
-public class UserConfig extends NamespacedConfig {
- /**
- * Instantiate a UserConfig. It is intended for use only by entities that can be identified
- * @param scope scope of the configuration, e.g. cluster, resource, partition, participant, etc
- */
- public UserConfig(Scope<?> scope) {
- super(scope, UserConfig.class.getSimpleName());
- }
-
- /**
- * Instantiate a UserConfig from an existing HelixProperty
- * @param property property wrapping a configuration
- */
- 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 extract from
- * @return UserConfig
- */
- public static UserConfig from(HelixProperty property) {
- return new UserConfig(property);
- }
-}