helix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ka...@apache.org
Subject git commit: [HELIX-373] Simplify ClusterAccessor and logical updates
Date Tue, 29 Jul 2014 21:41:30 GMT
Repository: helix
Updated Branches:
  refs/heads/master 9984a5ad2 -> 961b93090


[HELIX-373] Simplify ClusterAccessor and logical updates


Project: http://git-wip-us.apache.org/repos/asf/helix/repo
Commit: http://git-wip-us.apache.org/repos/asf/helix/commit/961b9309
Tree: http://git-wip-us.apache.org/repos/asf/helix/tree/961b9309
Diff: http://git-wip-us.apache.org/repos/asf/helix/diff/961b9309

Branch: refs/heads/master
Commit: 961b9309059dcaa0ee8dd10eff0adf7f201b05fe
Parents: 9984a5a
Author: Kanak Biscuitwala <kanak@apache.org>
Authored: Tue Jul 29 14:20:18 2014 -0700
Committer: Kanak Biscuitwala <kanak@apache.org>
Committed: Tue Jul 29 14:20:18 2014 -0700

----------------------------------------------------------------------
 .../java/org/apache/helix/api/Participant.java  |   9 +
 .../api/accessor/AtomicClusterAccessor.java     |  54 +----
 .../helix/api/accessor/ClusterAccessor.java     | 210 ++++---------------
 .../apache/helix/api/config/ClusterConfig.java  | 117 ++++++-----
 .../helix/api/config/ParticipantConfig.java     | 138 ++++++------
 .../apache/helix/api/config/ResourceConfig.java |  86 ++++----
 .../helix/manager/zk/ZkHelixParticipant.java    |   2 +-
 .../helix/model/ClusterConfiguration.java       |  16 +-
 .../org/apache/helix/model/InstanceConfig.java  |   5 +-
 .../helix/model/ResourceConfiguration.java      |   5 +-
 .../org/apache/helix/api/TestNewStages.java     |   5 +-
 .../org/apache/helix/api/TestUpdateConfig.java  | 143 -------------
 .../api/accessor/TestAccessorRecreate.java      |   2 +-
 .../helix/api/accessor/TestAtomicAccessors.java |   4 +-
 .../helix/integration/TestHelixConnection.java  |   4 +-
 .../integration/TestLocalContainerProvider.java |   2 +-
 .../helix/examples/LogicalModelExample.java     |   2 +-
 .../provisioning/yarn/AppMasterLauncher.java    |   3 +-
 18 files changed, 256 insertions(+), 551 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/api/Participant.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/Participant.java b/helix-core/src/main/java/org/apache/helix/api/Participant.java
index ad6811b..1f0d0f7 100644
--- a/helix-core/src/main/java/org/apache/helix/api/Participant.java
+++ b/helix-core/src/main/java/org/apache/helix/api/Participant.java
@@ -30,6 +30,7 @@ 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.model.CurrentState;
+import org.apache.helix.model.InstanceConfig;
 import org.apache.helix.model.LiveInstance;
 import org.apache.helix.model.Message;
 
@@ -181,4 +182,12 @@ public class Participant {
   public ContainerConfig getContainerConfig() {
     return _containerConfig;
   }
+
+  /**
+   * Get the physical InstanceConfig that this participant is configured with
+   * @return InstanceConfig instance
+   */
+  public InstanceConfig getInstanceConfig() {
+    return _config.getInstanceConfig();
+  }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/api/accessor/AtomicClusterAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/accessor/AtomicClusterAccessor.java b/helix-core/src/main/java/org/apache/helix/api/accessor/AtomicClusterAccessor.java
index 83fde95..3e3bb62 100644
--- a/helix-core/src/main/java/org/apache/helix/api/accessor/AtomicClusterAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/api/accessor/AtomicClusterAccessor.java
@@ -113,7 +113,7 @@ public class AtomicClusterAccessor extends ClusterAccessor {
   }
 
   @Override
-  public boolean addParticipantToCluster(ParticipantConfig participant) {
+  public boolean addParticipant(ParticipantConfig participant) {
     if (participant == null) {
       LOG.error("Participant config cannot be null");
       return false;
@@ -123,7 +123,7 @@ public class AtomicClusterAccessor extends ClusterAccessor {
     boolean locked = lock.lock();
     if (locked) {
       try {
-        return _clusterAccessor.addParticipantToCluster(participant);
+        return _clusterAccessor.addParticipant(participant);
       } finally {
         lock.unlock();
       }
@@ -132,13 +132,13 @@ public class AtomicClusterAccessor extends ClusterAccessor {
   }
 
   @Override
-  public boolean dropParticipantFromCluster(ParticipantId participantId) {
+  public boolean dropParticipant(ParticipantId participantId) {
     ClusterId clusterId = clusterId();
     HelixLock lock = _lockProvider.getLock(clusterId, Scope.participant(participantId));
     boolean locked = lock.lock();
     if (locked) {
       try {
-        return _clusterAccessor.dropParticipantFromCluster(participantId);
+        return _clusterAccessor.dropParticipant(participantId);
       } finally {
         lock.unlock();
       }
@@ -147,7 +147,7 @@ public class AtomicClusterAccessor extends ClusterAccessor {
   }
 
   @Override
-  public boolean addResourceToCluster(ResourceConfig resource) {
+  public boolean addResource(ResourceConfig resource) {
     if (resource == null) {
       LOG.error("Resource config cannot be null");
       return false;
@@ -157,7 +157,7 @@ public class AtomicClusterAccessor extends ClusterAccessor {
     boolean locked = lock.lock();
     if (locked) {
       try {
-        return _clusterAccessor.addResourceToCluster(resource);
+        return _clusterAccessor.addResource(resource);
       } finally {
         lock.unlock();
       }
@@ -166,13 +166,13 @@ public class AtomicClusterAccessor extends ClusterAccessor {
   }
 
   @Override
-  public boolean dropResourceFromCluster(ResourceId resourceId) {
+  public boolean dropResource(ResourceId resourceId) {
     ClusterId clusterId = clusterId();
     HelixLock lock = _lockProvider.getLock(clusterId, Scope.resource(resourceId));
     boolean locked = lock.lock();
     if (locked) {
       try {
-        return _clusterAccessor.dropResourceFromCluster(resourceId);
+        return _clusterAccessor.dropResource(resourceId);
       } finally {
         lock.unlock();
       }
@@ -211,25 +211,6 @@ public class AtomicClusterAccessor extends ClusterAccessor {
   }
 
   @Override
-  public boolean setParticipant(ParticipantConfig participantConfig) {
-    if (participantConfig == null) {
-      LOG.error("participant config cannot be null");
-      return false;
-    }
-    ClusterId clusterId = clusterId();
-    HelixLock lock = _lockProvider.getLock(clusterId, Scope.participant(participantConfig.getId()));
-    boolean locked = lock.lock();
-    if (locked) {
-      try {
-        return _clusterAccessor.setParticipant(participantConfig);
-      } finally {
-        lock.unlock();
-      }
-    }
-    return false;
-  }
-
-  @Override
   public ParticipantConfig updateParticipant(ParticipantId participantId,
       ParticipantConfig.Delta participantDelta) {
     ClusterId clusterId = clusterId();
@@ -274,23 +255,4 @@ public class AtomicClusterAccessor extends ClusterAccessor {
     }
     return null;
   }
-
-  @Override
-  public boolean setResource(ResourceConfig resourceConfig) {
-    if (resourceConfig == null) {
-      LOG.error("resource config cannot be null");
-      return false;
-    }
-    ClusterId clusterId = clusterId();
-    HelixLock lock = _lockProvider.getLock(clusterId, Scope.resource(resourceConfig.getId()));
-    boolean locked = lock.lock();
-    if (locked) {
-      try {
-        return _clusterAccessor.setResource(resourceConfig);
-      } finally {
-        lock.unlock();
-      }
-    }
-    return false;
-  }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java b/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java
index 70e600b..6b92275 100644
--- a/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java
+++ b/helix-core/src/main/java/org/apache/helix/api/accessor/ClusterAccessor.java
@@ -44,7 +44,6 @@ import org.apache.helix.api.id.ContextId;
 import org.apache.helix.api.id.ControllerId;
 import org.apache.helix.api.id.MessageId;
 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.SessionId;
 import org.apache.helix.api.id.StateModelDefId;
@@ -123,26 +122,27 @@ public class ClusterAccessor {
     initClusterStructure();
     Map<StateModelDefId, StateModelDefinition> stateModelDefs = cluster.getStateModelMap();
     for (StateModelDefinition stateModelDef : stateModelDefs.values()) {
-      addStateModelDefinitionToCluster(stateModelDef);
+      addStateModelDefinition(stateModelDef);
     }
     Map<ResourceId, ResourceConfig> resources = cluster.getResourceMap();
     for (ResourceConfig resource : resources.values()) {
-      addResourceToCluster(resource);
+      addResource(resource);
     }
     Map<ParticipantId, ParticipantConfig> participants = cluster.getParticipantMap();
     for (ParticipantConfig participant : participants.values()) {
-      addParticipantToCluster(participant);
+      addParticipant(participant);
     }
     _accessor.createProperty(_keyBuilder.constraints(), null);
     for (ClusterConstraints constraints : cluster.getConstraintMap().values()) {
       _accessor.setProperty(_keyBuilder.constraint(constraints.getType().toString()), constraints);
     }
-    ClusterConfiguration clusterConfig = ClusterConfiguration.from(cluster.getUserConfig());
+    ClusterConfiguration clusterConfig =
+        ClusterConfiguration.from(_clusterId, cluster.getUserConfig());
     if (cluster.autoJoinAllowed()) {
       clusterConfig.setAutoJoinAllowed(cluster.autoJoinAllowed());
     }
     if (cluster.isPaused()) {
-      pauseCluster();
+      _accessor.createProperty(_keyBuilder.pause(), new PauseSignal("pause"));
     }
     _accessor.setProperty(_keyBuilder.clusterConfig(), clusterConfig);
 
@@ -155,34 +155,9 @@ public class ClusterAccessor {
    * @return updated ClusterConfig, or null if there was an error
    */
   public ClusterConfig updateCluster(ClusterConfig.Delta clusterDelta) {
+    clusterDelta.merge(_accessor);
     Cluster cluster = readCluster();
-    if (cluster == null) {
-      LOG.error("Cluster does not exist, cannot be updated");
-      return null;
-    }
-    ClusterConfig config = clusterDelta.mergeInto(cluster.getConfig());
-    boolean status = setBasicClusterConfig(config);
-    return status ? config : null;
-  }
-
-  /**
-   * Set a cluster config minus state model, participants, and resources
-   * @param config ClusterConfig
-   * @return true if correctly set, false otherwise
-   */
-  private boolean setBasicClusterConfig(ClusterConfig config) {
-    if (config == null) {
-      return false;
-    }
-    ClusterConfiguration configuration = ClusterConfiguration.from(config.getUserConfig());
-    configuration.setAutoJoinAllowed(config.autoJoinAllowed());
-    _accessor.setProperty(_keyBuilder.clusterConfig(), configuration);
-    Map<ConstraintType, ClusterConstraints> constraints = config.getConstraintMap();
-    for (ConstraintType type : constraints.keySet()) {
-      ClusterConstraints constraint = constraints.get(type);
-      _accessor.setProperty(_keyBuilder.constraint(type.toString()), constraint);
-    }
-    return true;
+    return (cluster != null) ? cluster.getConfig() : null;
   }
 
   /**
@@ -459,27 +434,11 @@ public class ClusterAccessor {
   }
 
   /**
-   * pause controller of cluster
-   * @return true if cluster was paused, false if pause failed or already paused
-   */
-  public boolean pauseCluster() {
-    return _accessor.createProperty(_keyBuilder.pause(), new PauseSignal("pause"));
-  }
-
-  /**
-   * resume controller of cluster
-   * @return true if resume succeeded, false otherwise
-   */
-  public boolean resumeCluster() {
-    return _accessor.removeProperty(_keyBuilder.pause());
-  }
-
-  /**
    * add a resource to cluster
    * @param resource
    * @return true if resource added, false if there was an error
    */
-  public boolean addResourceToCluster(ResourceConfig resource) {
+  public boolean addResource(ResourceConfig resource) {
     if (resource == null || resource.getRebalancerConfig() == null) {
       LOG.error("Resource not fully defined with a rebalancer config");
       return false;
@@ -517,22 +476,27 @@ public class ClusterAccessor {
     }
 
     // Add resource user config
+    boolean persistConfig = false;
+    ResourceConfiguration configuration = new ResourceConfiguration(resourceId);
     if (resource.getUserConfig() != null) {
-      ResourceConfiguration configuration = new ResourceConfiguration(resourceId);
       configuration.addNamespacedConfig(resource.getUserConfig());
-      PartitionedRebalancerConfig partitionedConfig = PartitionedRebalancerConfig.from(config);
-      if (idealState == null
-          && (partitionedConfig == null || partitionedConfig.getRebalanceMode() == RebalanceMode.USER_DEFINED)) {
-        // only persist if this is not easily convertible to an ideal state
-        configuration
-            .addNamespacedConfig(new RebalancerConfigHolder(resource.getRebalancerConfig())
-                .toNamespacedConfig());
-      }
-      ProvisionerConfig provisionerConfig = resource.getProvisionerConfig();
-      if (provisionerConfig != null) {
-        configuration.addNamespacedConfig(new ProvisionerConfigHolder(provisionerConfig)
-            .toNamespacedConfig());
-      }
+      persistConfig = true;
+    }
+    PartitionedRebalancerConfig partitionedConfig = PartitionedRebalancerConfig.from(config);
+    if (idealState == null
+        && (partitionedConfig == null || partitionedConfig.getRebalanceMode() == RebalanceMode.USER_DEFINED)) {
+      // only persist if this is not easily convertible to an ideal state
+      configuration.addNamespacedConfig(new RebalancerConfigHolder(resource.getRebalancerConfig())
+          .toNamespacedConfig());
+      persistConfig = true;
+    }
+    ProvisionerConfig provisionerConfig = resource.getProvisionerConfig();
+    if (provisionerConfig != null) {
+      configuration.addNamespacedConfig(new ProvisionerConfigHolder(provisionerConfig)
+          .toNamespacedConfig());
+      persistConfig = true;
+    }
+    if (persistConfig) {
       _accessor.setProperty(_keyBuilder.resourceConfig(resourceId.stringify()), configuration);
     }
     return true;
@@ -543,7 +507,7 @@ public class ClusterAccessor {
    * @param resourceId
    * @return true if removal succeeded, false otherwise
    */
-  public boolean dropResourceFromCluster(ResourceId resourceId) {
+  public boolean dropResource(ResourceId resourceId) {
     if (_accessor.getProperty(_keyBuilder.idealStates(resourceId.stringify())) == null) {
       LOG.error("Skip removing resource: " + resourceId
           + ", because resource ideal state already removed from cluster: " + _clusterId);
@@ -603,7 +567,7 @@ public class ClusterAccessor {
    * @param participant
    * @return true if participant added, false otherwise
    */
-  public boolean addParticipantToCluster(ParticipantConfig participant) {
+  public boolean addParticipant(ParticipantConfig participant) {
     if (participant == null) {
       LOG.error("Participant not initialized");
       return false;
@@ -637,7 +601,7 @@ public class ClusterAccessor {
    * @param participantId
    * @return true if participant dropped, false if there was an error
    */
-  public boolean dropParticipantFromCluster(ParticipantId participantId) {
+  public boolean dropParticipant(ParticipantId participantId) {
     if (_accessor.getProperty(_keyBuilder.instanceConfig(participantId.stringify())) == null) {
       LOG.error("Config for participant: " + participantId + " does NOT exist in cluster");
     }
@@ -659,7 +623,7 @@ public class ClusterAccessor {
    * @param stateModelDef fully initialized state model definition
    * @return true if the model is persisted, false otherwise
    */
-  public boolean addStateModelDefinitionToCluster(StateModelDefinition stateModelDef) {
+  public boolean addStateModelDefinition(StateModelDefinition stateModelDef) {
     if (!isClusterStructureValid()) {
       LOG.error("Cluster: " + _clusterId + " structure is not valid");
       return false;
@@ -674,7 +638,7 @@ public class ClusterAccessor {
    * @param stateModelDefId state model definition id
    * @return true if removed, false if it did not exist
    */
-  public boolean dropStateModelDefinitionFromCluster(StateModelDefId stateModelDefId) {
+  public boolean dropStateModelDefinition(StateModelDefId stateModelDefId) {
     return _accessor.removeProperty(_keyBuilder.stateModelDef(stateModelDefId.stringify()));
   }
 
@@ -699,40 +663,9 @@ public class ClusterAccessor {
    */
   public ParticipantConfig updateParticipant(ParticipantId participantId,
       ParticipantConfig.Delta participantDelta) {
+    participantDelta.merge(_accessor);
     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());
-    setParticipant(config);
-    return config;
-  }
-
-  /**
-   * Set the configuration of an existing participant
-   * @param participantConfig participant configuration
-   * @return true if config was set, false if there was an error
-   */
-  public boolean setParticipant(ParticipantConfig participantConfig) {
-    if (participantConfig == null) {
-      LOG.error("Participant config not initialized");
-      return false;
-    }
-    InstanceConfig instanceConfig = new InstanceConfig(participantConfig.getId());
-    instanceConfig.setHostName(participantConfig.getHostName());
-    instanceConfig.setPort(Integer.toString(participantConfig.getPort()));
-    for (String tag : participantConfig.getTags()) {
-      instanceConfig.addTag(tag);
-    }
-    for (PartitionId partitionId : participantConfig.getDisabledPartitions()) {
-      instanceConfig.setParticipantEnabledForPartition(partitionId, false);
-    }
-    instanceConfig.setInstanceEnabled(participantConfig.isEnabled());
-    instanceConfig.addNamespacedConfig(participantConfig.getUserConfig());
-    _accessor.setProperty(_keyBuilder.instanceConfig(participantConfig.getId().stringify()),
-        instanceConfig);
-    return true;
+    return (participant != null) ? participant.getConfig() : null;
   }
 
   /**
@@ -841,78 +774,9 @@ public class ClusterAccessor {
    * @return ResourceConfig, or null if the resource is not persisted
    */
   public ResourceConfig updateResource(ResourceId resourceId, ResourceConfig.Delta resourceDelta) {
+    resourceDelta.merge(_accessor);
     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());
-    setResource(config);
-    return config;
-  }
-
-  /**
-   * Set a physical resource configuration, which may include user-defined configuration, as well as
-   * rebalancer configuration
-   * @param resourceId
-   * @param configuration
-   * @return true if set, false otherwise
-   */
-  private boolean setResourceConfiguration(ResourceId resourceId,
-      ResourceConfiguration configuration, RebalancerConfig rebalancerConfig) {
-    boolean status = true;
-    if (configuration != null) {
-      status =
-          _accessor.setProperty(_keyBuilder.resourceConfig(resourceId.stringify()), configuration);
-    }
-    // set an ideal state if the resource supports it
-    IdealState idealState =
-        PartitionedRebalancerConfig.rebalancerConfigToIdealState(rebalancerConfig,
-            configuration.getBucketSize(), configuration.getBatchMessageMode());
-    if (idealState != null) {
-      status =
-          status
-              && _accessor.setProperty(_keyBuilder.idealStates(resourceId.stringify()), idealState);
-    }
-    return status;
-  }
-
-  /**
-   * Persist an existing resource's logical configuration
-   * @param resourceConfig logical resource configuration
-   * @return true if resource is set, false otherwise
-   */
-  public boolean setResource(ResourceConfig resourceConfig) {
-    if (resourceConfig == null || resourceConfig.getRebalancerConfig() == null) {
-      LOG.error("Resource not fully defined with a rebalancer context");
-      return false;
-    }
-    ResourceId resourceId = resourceConfig.getId();
-    ResourceConfiguration config = new ResourceConfiguration(resourceId);
-    UserConfig userConfig = resourceConfig.getUserConfig();
-    if (userConfig != null
-        && (!userConfig.getSimpleFields().isEmpty() || !userConfig.getListFields().isEmpty() || !userConfig
-            .getMapFields().isEmpty())) {
-      config.addNamespacedConfig(userConfig);
-    } else {
-      userConfig = null;
-    }
-    PartitionedRebalancerConfig partitionedConfig =
-        PartitionedRebalancerConfig.from(resourceConfig.getRebalancerConfig());
-    if (partitionedConfig == null
-        || partitionedConfig.getRebalanceMode() == RebalanceMode.USER_DEFINED) {
-      // only persist if this is not easily convertible to an ideal state
-      config.addNamespacedConfig(new RebalancerConfigHolder(resourceConfig.getRebalancerConfig())
-          .toNamespacedConfig());
-    } else if (userConfig == null) {
-      config = null;
-    }
-    if (resourceConfig.getProvisionerConfig() != null) {
-      config.addNamespacedConfig(new ProvisionerConfigHolder(resourceConfig.getProvisionerConfig())
-          .toNamespacedConfig());
-    }
-    setResourceConfiguration(resourceId, config, resourceConfig.getRebalancerConfig());
-    return true;
+    return (resource != null) ? resource.getConfig() : null;
   }
 
   /**

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/api/config/ClusterConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/config/ClusterConfig.java b/helix-core/src/main/java/org/apache/helix/api/config/ClusterConfig.java
index f39482c..ed32093 100644
--- a/helix-core/src/main/java/org/apache/helix/api/config/ClusterConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/config/ClusterConfig.java
@@ -5,17 +5,23 @@ import java.util.HashMap;
 import java.util.Map;
 import java.util.Set;
 
+import org.I0Itec.zkclient.DataUpdater;
+import org.apache.helix.AccessOption;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.ZNRecord;
 import org.apache.helix.api.Scope;
 import org.apache.helix.api.id.ClusterId;
 import org.apache.helix.api.id.ConstraintId;
 import org.apache.helix.api.id.ParticipantId;
 import org.apache.helix.api.id.ResourceId;
 import org.apache.helix.api.id.StateModelDefId;
+import org.apache.helix.model.ClusterConfiguration;
 import org.apache.helix.model.ClusterConstraints;
 import org.apache.helix.model.ClusterConstraints.ConstraintAttribute;
 import org.apache.helix.model.ClusterConstraints.ConstraintType;
 import org.apache.helix.model.ConstraintItem;
 import org.apache.helix.model.Message.MessageType;
+import org.apache.helix.model.PauseSignal;
 import org.apache.helix.model.StateModelDefinition;
 import org.apache.helix.model.Transition;
 import org.apache.helix.model.builder.ConstraintItemBuilder;
@@ -204,12 +210,7 @@ public class ClusterConfig {
    * Update context for a ClusterConfig
    */
   public static class Delta {
-    private enum Fields {
-      USER_CONFIG,
-      AUTO_JOIN
-    }
-
-    private Set<Fields> _updateFields;
+    private Boolean _paused;
     private Map<ConstraintType, Set<ConstraintId>> _removedConstraints;
     private Builder _builder;
 
@@ -218,7 +219,6 @@ public class ClusterConfig {
      * @param clusterId the cluster to update
      */
     public Delta(ClusterId clusterId) {
-      _updateFields = Sets.newHashSet();
       _removedConstraints = Maps.newHashMap();
       for (ConstraintType type : ConstraintType.values()) {
         Set<ConstraintId> constraints = Sets.newHashSet();
@@ -284,9 +284,8 @@ public class ClusterConfig {
      * @param userConfig user-specified properties
      * @return Delta
      */
-    public Delta setUserConfig(UserConfig userConfig) {
+    public Delta addUserConfig(UserConfig userConfig) {
       _builder.userConfig(userConfig);
-      _updateFields.add(Fields.USER_CONFIG);
       return this;
     }
 
@@ -297,59 +296,72 @@ public class ClusterConfig {
      */
     public Delta setAutoJoin(boolean autoJoin) {
       _builder.autoJoin(autoJoin);
-      _updateFields.add(Fields.AUTO_JOIN);
       return this;
     }
 
     /**
-     * Create a ClusterConfig that is the combination of an existing ClusterConfig and this delta
-     * @param orig the original ClusterConfig
-     * @return updated ClusterConfig
+     * Change the paused status of the cluster controller
+     * @param isPaused true to pause, false to unpause
+     * @return Delta
      */
-    public ClusterConfig mergeInto(ClusterConfig orig) {
-      // copy in original and updated fields
-      ClusterConfig deltaConfig = _builder.build();
-      Builder builder =
-          new Builder(orig.getId()).addResources(orig.getResourceMap().values())
-              .addParticipants(orig.getParticipantMap().values())
-              .addStateModelDefinitions(orig.getStateModelMap().values())
-              .userConfig(orig.getUserConfig()).pausedStatus(orig.isPaused())
-              .autoJoin(orig.autoJoinAllowed());
-      for (Fields field : _updateFields) {
-        switch (field) {
-        case USER_CONFIG:
-          builder.userConfig(deltaConfig.getUserConfig());
-          break;
-        case AUTO_JOIN:
-          builder.autoJoin(deltaConfig.autoJoinAllowed());
-          break;
-        }
+    public Delta setPaused(boolean isPaused) {
+      _paused = isPaused;
+      return this;
+    }
+
+    /**
+     * Merge in this delta with a physical accessor
+     * @param accessor the physical cluster accessor
+     */
+    public void merge(HelixDataAccessor accessor) {
+      // Update the main config
+      final ClusterConfig deltaConfig = _builder.build();
+      ClusterConfiguration config = new ClusterConfiguration(deltaConfig.getId());
+      config.setAutoJoinAllowed(deltaConfig.autoJoinAllowed());
+      if (deltaConfig.getUserConfig() != null) {
+        config.addNamespacedConfig(deltaConfig.getUserConfig());
       }
-      // add constraint deltas
-      for (ConstraintType type : ConstraintType.values()) {
-        ClusterConstraints constraints;
-        if (orig.getConstraintMap().containsKey(type)) {
-          constraints = orig.getConstraintMap().get(type);
+      accessor.updateProperty(accessor.keyBuilder().clusterConfig(), config);
+
+      // Update paused status
+      if (_paused != null) {
+        if (_paused) {
+          accessor.createProperty(accessor.keyBuilder().pause(), new PauseSignal("pause"));
         } else {
-          constraints = new ClusterConstraints(type);
-        }
-        // add new constraints
-        if (deltaConfig.getConstraintMap().containsKey(type)) {
-          ClusterConstraints deltaConstraints = deltaConfig.getConstraintMap().get(type);
-          for (ConstraintId constraintId : deltaConstraints.getConstraintItems().keySet()) {
-            ConstraintItem constraintItem = deltaConstraints.getConstraintItem(constraintId);
-            constraints.addConstraintItem(constraintId, constraintItem);
-          }
-        }
-        // remove constraints
-        for (ConstraintId constraintId : _removedConstraints.get(type)) {
-          constraints.removeConstraintItem(constraintId);
+          accessor.removeProperty(accessor.keyBuilder().pause());
         }
-        builder.addConstraint(constraints);
       }
 
-      // get the result
-      return builder.build();
+      // Update all constraints
+      Set<ConstraintType> allTypesToModify =
+          Sets.newHashSet(deltaConfig.getConstraintMap().keySet());
+      allTypesToModify.addAll(_removedConstraints.keySet());
+      for (final ConstraintType constraintType : allTypesToModify) {
+        String path = accessor.keyBuilder().constraint(constraintType.toString()).getPath();
+        accessor.getBaseDataAccessor().update(path, new DataUpdater<ZNRecord>() {
+          @Override
+          public ZNRecord update(ZNRecord currentData) {
+            ClusterConstraints constraints =
+                currentData == null ? new ClusterConstraints(constraintType)
+                    : new ClusterConstraints(currentData);
+
+            if (deltaConfig.getConstraintMap().containsKey(constraintType)) {
+              ClusterConstraints existing = deltaConfig.getConstraintMap().get(constraintType);
+              for (Map.Entry<ConstraintId, ConstraintItem> e : existing.getConstraintItems()
+                  .entrySet()) {
+                constraints.addConstraintItem(e.getKey(), e.getValue());
+              }
+            }
+            if (_removedConstraints.containsKey(constraintType)) {
+              Set<ConstraintId> toRemove = _removedConstraints.get(constraintType);
+              for (ConstraintId constraintId : toRemove) {
+                constraints.removeConstraintItem(constraintId);
+              }
+            }
+            return constraints.getRecord();
+          }
+        }, AccessOption.PERSISTENT);
+      }
     }
   }
 
@@ -378,7 +390,6 @@ public class ClusterConfig {
       _stateModelMap = new HashMap<StateModelDefId, StateModelDefinition>();
       _isPaused = false;
       _autoJoin = false;
-      _userConfig = new UserConfig(Scope.cluster(id));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/api/config/ParticipantConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/config/ParticipantConfig.java b/helix-core/src/main/java/org/apache/helix/api/config/ParticipantConfig.java
index 4fd42b9..0818897 100644
--- a/helix-core/src/main/java/org/apache/helix/api/config/ParticipantConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/config/ParticipantConfig.java
@@ -1,14 +1,5 @@
 package org.apache.helix.api.config;
 
-import java.util.Set;
-
-import org.apache.helix.api.id.ParticipantId;
-import org.apache.helix.api.id.PartitionId;
-import org.apache.helix.model.InstanceConfig;
-import org.apache.helix.model.InstanceConfig.InstanceConfigProperty;
-
-import com.google.common.collect.Sets;
-
 /*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
@@ -28,6 +19,22 @@ import com.google.common.collect.Sets;
  * under the License.
  */
 
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+import org.I0Itec.zkclient.DataUpdater;
+import org.apache.helix.AccessOption;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.ZNRecord;
+import org.apache.helix.api.id.ParticipantId;
+import org.apache.helix.api.id.PartitionId;
+import org.apache.helix.model.InstanceConfig;
+import org.apache.helix.model.InstanceConfig.InstanceConfigProperty;
+
+import com.google.common.collect.Lists;
+import com.google.common.collect.Sets;
+
 /**
  * Configuration properties of a Helix participant
  */
@@ -134,27 +141,18 @@ public class ParticipantConfig {
    * 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;
+    private final InstanceConfig _updatedConfig;
+    private final Set<String> _removedTags;
+    private final Set<String> _removedDisabledPartitions;
 
     /**
      * Instantiate the delta for a participant config
      * @param participantId the participant to update
      */
     public Delta(ParticipantId participantId) {
-      _updateFields = Sets.newHashSet();
+      _updatedConfig = new InstanceConfig(participantId);
       _removedTags = Sets.newHashSet();
       _removedDisabledPartitions = Sets.newHashSet();
-      _builder = new Builder(participantId);
     }
 
     /**
@@ -163,8 +161,7 @@ public class ParticipantConfig {
      * @return Delta
      */
     public Delta setHostName(String hostName) {
-      _builder.hostName(hostName);
-      _updateFields.add(Fields.HOST_NAME);
+      _updatedConfig.setHostName(hostName);
       return this;
     }
 
@@ -174,8 +171,7 @@ public class ParticipantConfig {
      * @return Delta
      */
     public Delta setPort(int port) {
-      _builder.port(port);
-      _updateFields.add(Fields.PORT);
+      _updatedConfig.setPort(String.valueOf(port));
       return this;
     }
 
@@ -185,8 +181,7 @@ public class ParticipantConfig {
      * @return Delta
      */
     public Delta setEnabled(boolean isEnabled) {
-      _builder.enabled(isEnabled);
-      _updateFields.add(Fields.ENABLED);
+      _updatedConfig.setInstanceEnabled(isEnabled);
       return this;
     }
 
@@ -195,9 +190,8 @@ public class ParticipantConfig {
      * @param userConfig user-specified properties
      * @return Delta
      */
-    public Delta setUserConfig(UserConfig userConfig) {
-      _builder.userConfig(userConfig);
-      _updateFields.add(Fields.USER_CONFIG);
+    public Delta addUserConfig(UserConfig userConfig) {
+      _updatedConfig.addNamespacedConfig(userConfig);
       return this;
     }
 
@@ -207,7 +201,8 @@ public class ParticipantConfig {
      * @return Delta
      */
     public Delta addTag(String tag) {
-      _builder.addTag(tag);
+      _updatedConfig.addTag(tag);
+      _removedTags.remove(tag);
       return this;
     }
 
@@ -218,6 +213,7 @@ public class ParticipantConfig {
      */
     public Delta removeTag(String tag) {
       _removedTags.add(tag);
+      _updatedConfig.removeTag(tag);
       return this;
     }
 
@@ -227,7 +223,7 @@ public class ParticipantConfig {
      * @return Delta
      */
     public Delta addDisabledPartition(PartitionId partitionId) {
-      _builder.addDisabledPartition(partitionId);
+      _updatedConfig.setParticipantEnabledForPartition(partitionId, false);
       return this;
     }
 
@@ -237,50 +233,50 @@ public class ParticipantConfig {
      * @return Delta
      */
     public Delta removeDisabledPartition(PartitionId partitionId) {
-      _removedDisabledPartitions.add(partitionId);
+      _removedDisabledPartitions.add(partitionId.stringify());
       return this;
     }
 
     /**
-     * Create a ParticipantConfig that is the combination of an existing ParticipantConfig and this
-     * delta
-     * @param orig the original ParticipantConfig
-     * @return updated ParticipantConfig
+     * Merge the participant delta in using a physical accessor
+     * @param accessor the physical accessor
      */
-    public ParticipantConfig mergeInto(ParticipantConfig orig) {
-      ParticipantConfig deltaConfig = _builder.build();
-      Builder builder =
-          new Builder(orig.getId()).hostName(orig.getHostName()).port(orig.getPort())
-              .enabled(orig.isEnabled()).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;
+    public void merge(HelixDataAccessor accessor) {
+      // Update the InstanceConfig but in place so that tags and disabled partitions can be
+      // added/removed
+      DataUpdater<ZNRecord> updater = new DataUpdater<ZNRecord>() {
+        @Override
+        public ZNRecord update(ZNRecord currentData) {
+          currentData.getSimpleFields().putAll(_updatedConfig.getRecord().getSimpleFields());
+          if (!_updatedConfig.getTags().isEmpty() || _removedTags.isEmpty()) {
+            List<String> tags =
+                currentData.getListField(InstanceConfigProperty.TAG_LIST.toString());
+            if (tags != null) {
+              tags.addAll(_updatedConfig.getTags());
+              tags.removeAll(_removedTags);
+              currentData.setListField(InstanceConfigProperty.TAG_LIST.toString(), tags);
+            }
+          }
+          if (!_updatedConfig.getDisabledPartitions().isEmpty()
+              || _removedDisabledPartitions.isEmpty()) {
+            List<String> disabledPartitions =
+                currentData
+                    .getListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.toString());
+            if (disabledPartitions != null) {
+              disabledPartitions.addAll(_updatedConfig.getDisabledPartitions());
+              disabledPartitions.removeAll(_removedDisabledPartitions);
+              currentData.setListField(InstanceConfigProperty.HELIX_DISABLED_PARTITION.toString(),
+                  disabledPartitions);
+            }
+          }
+          return currentData;
         }
-      }
-      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());
-      disabledPartitions.removeAll(_removedDisabledPartitions);
-      for (PartitionId partitionId : disabledPartitions) {
-        builder.addDisabledPartition(partitionId);
-      }
-      return builder.build();
+      };
+      List<String> paths =
+          Arrays.asList(accessor.keyBuilder().instanceConfig(_updatedConfig.getId()).getPath());
+      List<DataUpdater<ZNRecord>> updaters = Lists.newArrayList();
+      updaters.add(updater);
+      accessor.updateChildren(paths, updaters, AccessOption.PERSISTENT);
     }
   }
 

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/api/config/ResourceConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/api/config/ResourceConfig.java b/helix-core/src/main/java/org/apache/helix/api/config/ResourceConfig.java
index fd9f20f..b940d11 100644
--- a/helix-core/src/main/java/org/apache/helix/api/config/ResourceConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/api/config/ResourceConfig.java
@@ -21,14 +21,15 @@ package org.apache.helix.api.config;
 
 import java.util.Set;
 
-import org.apache.helix.api.Scope;
+import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.api.id.PartitionId;
 import org.apache.helix.api.id.ResourceId;
 import org.apache.helix.controller.provisioner.ProvisionerConfig;
 import org.apache.helix.controller.rebalancer.config.RebalancerConfig;
+import org.apache.helix.controller.rebalancer.config.RebalancerConfigHolder;
 import org.apache.helix.model.IdealState;
-
-import com.google.common.collect.Sets;
+import org.apache.helix.model.ProvisionerConfigHolder;
+import org.apache.helix.model.ResourceConfiguration;
 
 /**
  * Full configuration of a Helix resource. Typically used to add or modify resources on a cluster
@@ -127,14 +128,6 @@ public class ResourceConfig {
    * Update context for a ResourceConfig
    */
   public static class Delta {
-    private enum Fields {
-      IDEAL_STATE,
-      REBALANCER_CONFIG,
-      PROVISIONER_CONFIG,
-      USER_CONFIG,
-    }
-
-    private Set<Fields> _updateFields;
     private Builder _builder;
 
     /**
@@ -143,7 +136,6 @@ public class ResourceConfig {
      */
     public Delta(ResourceId resourceId) {
       _builder = new Builder(resourceId);
-      _updateFields = Sets.newHashSet();
     }
 
     /**
@@ -153,7 +145,6 @@ public class ResourceConfig {
      */
     public Delta setIdealState(IdealState idealState) {
       _builder.idealState(idealState);
-      _updateFields.add(Fields.IDEAL_STATE);
       return this;
     }
 
@@ -164,7 +155,6 @@ public class ResourceConfig {
      */
     public Delta setRebalancerConfig(RebalancerConfig config) {
       _builder.rebalancerConfig(config);
-      _updateFields.add(Fields.REBALANCER_CONFIG);
       return this;
     }
 
@@ -175,50 +165,59 @@ public class ResourceConfig {
      */
     public Delta setProvisionerConfig(ProvisionerConfig config) {
       _builder.provisionerConfig(config);
-      _updateFields.add(Fields.PROVISIONER_CONFIG);
       return this;
     }
 
     /**
-     * Set the user configuration
+     * Add the user configuration
      * @param userConfig user-specified properties
      * @return Delta
      */
-    public Delta setUserConfig(UserConfig userConfig) {
+    public Delta addUserConfig(UserConfig userConfig) {
       _builder.userConfig(userConfig);
-      _updateFields.add(Fields.USER_CONFIG);
       return this;
     }
 
     /**
-     * Create a ResourceConfig that is the combination of an existing ResourceConfig and this delta
-     * @param orig the original ResourceConfig
-     * @return updated ResourceConfig
+     * Given a physical accessor, merge in the updated logical properties
+     * @param accessor the physical accessor
      */
-    public ResourceConfig mergeInto(ResourceConfig orig) {
+    public void merge(HelixDataAccessor accessor) {
+      // Construct the logical delta
       ResourceConfig deltaConfig = _builder.build();
-      Builder builder =
-          new Builder(orig.getId()).idealState(orig.getIdealState())
-              .rebalancerConfig(orig.getRebalancerConfig())
-              .provisionerConfig(orig.getProvisionerConfig())
-              .schedulerTaskConfig(orig.getSchedulerTaskConfig()).userConfig(orig.getUserConfig());
-      for (Fields field : _updateFields) {
-        switch (field) {
-        case IDEAL_STATE:
-          builder.idealState(deltaConfig.getIdealState());
-          break;
-        case REBALANCER_CONFIG:
-          builder.rebalancerConfig(deltaConfig.getRebalancerConfig());
-          break;
-        case PROVISIONER_CONFIG:
-          builder.provisionerConfig(deltaConfig.getProvisionerConfig());
-          break;
-        case USER_CONFIG:
-          builder.userConfig(deltaConfig.getUserConfig());
-          break;
-        }
+      ResourceId resourceId = deltaConfig.getId();
+
+      // Update the ideal state if set
+      IdealState updatedIdealState = deltaConfig.getIdealState();
+      if (updatedIdealState != null) {
+        accessor.updateProperty(accessor.keyBuilder().idealStates(resourceId.toString()),
+            updatedIdealState);
+      }
+
+      // Update the resource config if any of its inner configs is set
+      boolean addedAnything = false;
+      ResourceConfiguration updatedResourceConfig = new ResourceConfiguration(resourceId);
+      ProvisionerConfig provisionerConfig = deltaConfig.getProvisionerConfig();
+      if (provisionerConfig != null) {
+        updatedResourceConfig.addNamespacedConfig(new ProvisionerConfigHolder(provisionerConfig)
+            .toNamespacedConfig());
+        addedAnything = true;
+      }
+      RebalancerConfig rebalancerConfig = deltaConfig.getRebalancerConfig();
+      if (rebalancerConfig != null) {
+        updatedResourceConfig.addNamespacedConfig(new RebalancerConfigHolder(rebalancerConfig)
+            .toNamespacedConfig());
+        addedAnything = true;
+      }
+      UserConfig userConfig = deltaConfig.getUserConfig();
+      if (userConfig != null) {
+        updatedResourceConfig.addNamespacedConfig(userConfig);
+        addedAnything = true;
+      }
+      if (addedAnything) {
+        accessor.updateProperty(accessor.keyBuilder().resourceConfig(resourceId.toString()),
+            updatedResourceConfig);
       }
-      return builder.build();
     }
   }
 
@@ -239,7 +238,6 @@ public class ResourceConfig {
      */
     public Builder(ResourceId id) {
       _id = id;
-      _userConfig = new UserConfig(Scope.resource(id));
     }
 
     /**

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixParticipant.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixParticipant.java b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixParticipant.java
index 674140e..d3ee8d1 100644
--- a/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixParticipant.java
+++ b/helix-core/src/main/java/org/apache/helix/manager/zk/ZkHelixParticipant.java
@@ -329,7 +329,7 @@ public class ZkHelixParticipant implements HelixParticipant {
         ParticipantConfig.Builder builder =
             new ParticipantConfig.Builder(_participantId).hostName(hostName).port(port)
                 .enabled(true);
-        _clusterAccessor.addParticipantToCluster(builder.build());
+        _clusterAccessor.addParticipant(builder.build());
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/model/ClusterConfiguration.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/ClusterConfiguration.java b/helix-core/src/main/java/org/apache/helix/model/ClusterConfiguration.java
index a7a7088..973fe5e 100644
--- a/helix-core/src/main/java/org/apache/helix/model/ClusterConfiguration.java
+++ b/helix-core/src/main/java/org/apache/helix/model/ClusterConfiguration.java
@@ -29,6 +29,8 @@ import org.apache.helix.api.id.ClusterId;
 import org.apache.helix.manager.zk.ZKHelixManager;
 import org.apache.log4j.Logger;
 
+import com.google.common.base.Enums;
+import com.google.common.base.Optional;
 import com.google.common.collect.Maps;
 
 /**
@@ -86,8 +88,11 @@ public class ClusterConfiguration extends HelixProperty {
     UserConfig userConfig = UserConfig.from(this);
     try {
       for (String simpleField : _record.getSimpleFields().keySet()) {
+        Optional<HelixPropertyAttribute> superEnumField =
+            Enums.getIfPresent(HelixPropertyAttribute.class, simpleField);
         if (!simpleField.contains(NamespacedConfig.PREFIX_CHAR + "")
-            && !simpleField.equals(ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN)) {
+            && !simpleField.equals(ZKHelixManager.ALLOW_PARTICIPANT_AUTO_JOIN)
+            && !superEnumField.isPresent()) {
           userConfig.setSimpleField(simpleField, _record.getSimpleField(simpleField));
         }
       }
@@ -134,10 +139,11 @@ public class ClusterConfiguration extends HelixProperty {
    * @param userConfig user-defined configuration properties
    * @return ClusterConfiguration
    */
-  public static ClusterConfiguration from(UserConfig userConfig) {
-    ClusterConfiguration clusterConfiguration =
-        new ClusterConfiguration(ClusterId.from(userConfig.getId()));
-    clusterConfiguration.addNamespacedConfig(userConfig);
+  public static ClusterConfiguration from(ClusterId clusterId, UserConfig userConfig) {
+    ClusterConfiguration clusterConfiguration = new ClusterConfiguration(clusterId);
+    if (userConfig != null) {
+      clusterConfiguration.addNamespacedConfig(userConfig);
+    }
     return clusterConfiguration;
   }
 }

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java b/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java
index c386035..f3edb62 100644
--- a/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java
+++ b/helix-core/src/main/java/org/apache/helix/model/InstanceConfig.java
@@ -291,7 +291,10 @@ public class InstanceConfig extends HelixProperty {
       for (String simpleField : _record.getSimpleFields().keySet()) {
         Optional<InstanceConfigProperty> enumField =
             Enums.getIfPresent(InstanceConfigProperty.class, simpleField);
-        if (!simpleField.contains(NamespacedConfig.PREFIX_CHAR + "") && !enumField.isPresent()) {
+        Optional<HelixPropertyAttribute> superEnumField =
+            Enums.getIfPresent(HelixPropertyAttribute.class, simpleField);
+        if (!simpleField.contains(NamespacedConfig.PREFIX_CHAR + "") && !enumField.isPresent()
+            && !superEnumField.isPresent()) {
           userConfig.setSimpleField(simpleField, _record.getSimpleField(simpleField));
         }
       }

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/main/java/org/apache/helix/model/ResourceConfiguration.java
----------------------------------------------------------------------
diff --git a/helix-core/src/main/java/org/apache/helix/model/ResourceConfiguration.java b/helix-core/src/main/java/org/apache/helix/model/ResourceConfiguration.java
index 001b792..14cf8a7 100644
--- a/helix-core/src/main/java/org/apache/helix/model/ResourceConfiguration.java
+++ b/helix-core/src/main/java/org/apache/helix/model/ResourceConfiguration.java
@@ -74,7 +74,10 @@ public class ResourceConfiguration extends HelixProperty {
     try {
       for (String simpleField : _record.getSimpleFields().keySet()) {
         Optional<Fields> enumField = Enums.getIfPresent(Fields.class, simpleField);
-        if (!simpleField.contains(NamespacedConfig.PREFIX_CHAR + "") && !enumField.isPresent()) {
+        Optional<HelixPropertyAttribute> superEnumField =
+            Enums.getIfPresent(HelixPropertyAttribute.class, simpleField);
+        if (!simpleField.contains(NamespacedConfig.PREFIX_CHAR + "") && !enumField.isPresent()
+            && !superEnumField.isPresent()) {
           userConfig.setSimpleField(simpleField, _record.getSimpleField(simpleField));
         }
       }

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/test/java/org/apache/helix/api/TestNewStages.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/api/TestNewStages.java b/helix-core/src/test/java/org/apache/helix/api/TestNewStages.java
index a35a47b..b5d218d 100644
--- a/helix-core/src/test/java/org/apache/helix/api/TestNewStages.java
+++ b/helix-core/src/test/java/org/apache/helix/api/TestNewStages.java
@@ -25,7 +25,6 @@ import java.util.Map;
 
 import org.apache.helix.HelixDataAccessor;
 import org.apache.helix.TestHelper;
-import org.apache.helix.ZNRecord;
 import org.apache.helix.api.accessor.ClusterAccessor;
 import org.apache.helix.api.config.ResourceConfig;
 import org.apache.helix.api.id.ClusterId;
@@ -42,7 +41,6 @@ import org.apache.helix.controller.stages.ResourceCurrentState;
 import org.apache.helix.integration.manager.ClusterControllerManager;
 import org.apache.helix.integration.manager.MockParticipantManager;
 import org.apache.helix.manager.zk.ZKHelixDataAccessor;
-import org.apache.helix.manager.zk.ZkBaseDataAccessor;
 import org.apache.helix.model.CurrentState;
 import org.apache.helix.model.ResourceAssignment;
 import org.apache.helix.testutil.ZkTestBase;
@@ -239,8 +237,7 @@ public class TestNewStages extends ZkTestBase {
             clusterName));
     Assert.assertTrue(result);
 
-    _dataAccessor =
-        new ZKHelixDataAccessor(clusterName, _baseAccessor);
+    _dataAccessor = new ZKHelixDataAccessor(clusterName, _baseAccessor);
   }
 
   @AfterClass

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/test/java/org/apache/helix/api/TestUpdateConfig.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/api/TestUpdateConfig.java b/helix-core/src/test/java/org/apache/helix/api/TestUpdateConfig.java
deleted file mode 100644
index feed534..0000000
--- a/helix-core/src/test/java/org/apache/helix/api/TestUpdateConfig.java
+++ /dev/null
@@ -1,143 +0,0 @@
-package org.apache.helix.api;
-
-import org.apache.helix.api.config.ClusterConfig;
-import org.apache.helix.api.config.ParticipantConfig;
-import org.apache.helix.api.config.ResourceConfig;
-import org.apache.helix.api.config.UserConfig;
-import org.apache.helix.api.id.ClusterId;
-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.controller.rebalancer.config.BasicRebalancerConfig;
-import org.apache.helix.controller.rebalancer.config.FullAutoRebalancerConfig;
-import org.apache.helix.controller.rebalancer.config.PartitionedRebalancerConfig;
-import org.apache.helix.controller.rebalancer.config.SemiAutoRebalancerConfig;
-import org.testng.Assert;
-import org.testng.annotations.Test;
-
-/*
- * 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.
- */
-
-/**
- * Testing the deltas of the various config classes. They should be able to update corresponding
- * configs correctly
- */
-public class TestUpdateConfig {
-  @Test
-  public void testParticipantConfigUpdate() {
-    final String ORIG_HOSTNAME = "host1";
-    final String NEW_HOSTNAME = "host2";
-    final int PORT = 1234;
-    final String TAG1 = "tag1";
-    final String TAG2 = "tag2";
-    final String TAG3 = "tag3";
-    final PartitionId partition1 = PartitionId.from("resource_1");
-    final PartitionId partition2 = PartitionId.from("resource_2");
-    final PartitionId partition3 = PartitionId.from("resource_3");
-    final ParticipantId participantId = ParticipantId.from("participant");
-
-    // start: add a user config, set host & port, add 2 tags and 2 disabled partition, start
-    // disabled
-    UserConfig userConfig = new UserConfig(Scope.participant(participantId));
-    userConfig.setSimpleField("key1", "value1");
-    ParticipantConfig config =
-        new ParticipantConfig.Builder(participantId).hostName(ORIG_HOSTNAME).port(PORT)
-            .enabled(false).addTag(TAG1).addTag(TAG2).addDisabledPartition(partition1)
-            .addDisabledPartition(partition2).userConfig(userConfig).build();
-    UserConfig newUserConfig = new UserConfig(Scope.participant(participantId));
-    newUserConfig.setSimpleField("key2", "value2");
-
-    // update: change host, remove a tag, add a tag, remove a disabled partition, add a disabled
-    // partition, change user config
-    ParticipantConfig updated =
-        new ParticipantConfig.Delta(participantId).setHostName(NEW_HOSTNAME).removeTag(TAG1)
-            .addTag(TAG3).removeDisabledPartition(partition1).addDisabledPartition(partition3)
-            .setUserConfig(newUserConfig).mergeInto(config);
-    Assert.assertEquals(updated.getHostName(), NEW_HOSTNAME);
-    Assert.assertEquals(updated.getPort(), PORT);
-    Assert.assertFalse(updated.hasTag(TAG1));
-    Assert.assertTrue(updated.hasTag(TAG2));
-    Assert.assertTrue(updated.hasTag(TAG3));
-    Assert.assertFalse(updated.getDisabledPartitions().contains(partition1));
-    Assert.assertTrue(updated.getDisabledPartitions().contains(partition2));
-    Assert.assertTrue(updated.getDisabledPartitions().contains(partition3));
-    Assert.assertEquals(updated.getUserConfig().getSimpleField("key2"), "value2");
-    Assert.assertEquals(updated.getUserConfig().getSimpleField("key1"), "value1");
-    Assert.assertFalse(updated.isEnabled());
-  }
-
-  @Test
-  public void testResourceConfigUpdate() {
-    final ResourceId resourceId = ResourceId.from("resource");
-
-    // start: add a user config, a semi auto rebalancer context
-    UserConfig userConfig = new UserConfig(Scope.resource(resourceId));
-    userConfig.setSimpleField("key1", "value1");
-    SemiAutoRebalancerConfig rebalancerContext =
-        new SemiAutoRebalancerConfig.Builder(resourceId).stateModelDefId(
-            StateModelDefId.from("MasterSlave")).build();
-    ResourceConfig config =
-        new ResourceConfig.Builder(resourceId)
-            .userConfig(userConfig)
-            .rebalancerConfig(rebalancerContext)
-            .idealState(
-                PartitionedRebalancerConfig
-                    .rebalancerConfigToIdealState(rebalancerContext, 0, true)).build();
-
-    // update: overwrite user config, change to full auto rebalancer context
-    UserConfig newUserConfig = new UserConfig(Scope.resource(resourceId));
-    newUserConfig.setSimpleField("key2", "value2");
-    FullAutoRebalancerConfig newRebalancerContext =
-        new FullAutoRebalancerConfig.Builder(resourceId).stateModelDefId(
-            StateModelDefId.from("MasterSlave")).build();
-    ResourceConfig updated =
-        new ResourceConfig.Delta(resourceId)
-            .setUserConfig(newUserConfig)
-            .setIdealState(
-                PartitionedRebalancerConfig.rebalancerConfigToIdealState(newRebalancerContext, 0,
-                    true)).setRebalancerConfig(newRebalancerContext).mergeInto(config);
-    Assert.assertNull(BasicRebalancerConfig.convert(updated.getRebalancerConfig(),
-        SemiAutoRebalancerConfig.class));
-    Assert.assertNotNull(BasicRebalancerConfig.convert(updated.getRebalancerConfig(),
-        FullAutoRebalancerConfig.class));
-    Assert.assertNull(updated.getUserConfig().getSimpleField("key1"));
-    Assert.assertEquals(updated.getUserConfig().getSimpleField("key2"), "value2");
-  }
-
-  @Test
-  public void testClusterConfigUpdate() {
-    final ClusterId clusterId = ClusterId.from("cluster");
-    // start: add a user config
-    UserConfig userConfig = new UserConfig(Scope.cluster(clusterId));
-    userConfig.setSimpleField("key1", "value1");
-    ClusterConfig config =
-        new ClusterConfig.Builder(clusterId).userConfig(userConfig).autoJoin(true).build();
-
-    // update: overwrite user config, change auto join
-    UserConfig newUserConfig = new UserConfig(Scope.cluster(clusterId));
-    newUserConfig.setSimpleField("key2", "value2");
-    ClusterConfig updated =
-        new ClusterConfig.Delta(clusterId).setUserConfig(newUserConfig).setAutoJoin(false)
-            .mergeInto(config);
-    Assert.assertNull(updated.getUserConfig().getSimpleField("key1"));
-    Assert.assertEquals(updated.getUserConfig().getSimpleField("key2"), "value2");
-    Assert.assertFalse(updated.autoJoinAllowed());
-  }
-}

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/test/java/org/apache/helix/api/accessor/TestAccessorRecreate.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/api/accessor/TestAccessorRecreate.java b/helix-core/src/test/java/org/apache/helix/api/accessor/TestAccessorRecreate.java
index c068132..a9bdcbd 100644
--- a/helix-core/src/test/java/org/apache/helix/api/accessor/TestAccessorRecreate.java
+++ b/helix-core/src/test/java/org/apache/helix/api/accessor/TestAccessorRecreate.java
@@ -155,7 +155,7 @@ public class TestAccessorRecreate extends ZkTestBase {
     ParticipantConfig participant =
         new ParticipantConfig.Builder(participantId).hostName("host").port(0)
             .userConfig(userConfig).build();
-    return accessor.addParticipantToCluster(participant);
+    return accessor.addParticipant(participant);
   }
   // private HelixLockable lockProvider() {
   // return new HelixLockable() {

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/test/java/org/apache/helix/api/accessor/TestAtomicAccessors.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/api/accessor/TestAtomicAccessors.java b/helix-core/src/test/java/org/apache/helix/api/accessor/TestAtomicAccessors.java
index fd5bc76..6fd4b40 100644
--- a/helix-core/src/test/java/org/apache/helix/api/accessor/TestAtomicAccessors.java
+++ b/helix-core/src/test/java/org/apache/helix/api/accessor/TestAtomicAccessors.java
@@ -63,7 +63,7 @@ public class TestAtomicAccessors extends ZkTestBase {
       public void run() {
         UserConfig userConfig = new UserConfig(Scope.cluster(clusterId));
         userConfig.setBooleanField(key1, true);
-        ClusterConfig.Delta delta = new ClusterConfig.Delta(clusterId).setUserConfig(userConfig);
+        ClusterConfig.Delta delta = new ClusterConfig.Delta(clusterId).addUserConfig(userConfig);
         ClusterAccessor accessor =
             new AtomicClusterAccessor(clusterId, helixAccessor, lockProvider);
         accessor.updateCluster(delta);
@@ -76,7 +76,7 @@ public class TestAtomicAccessors extends ZkTestBase {
       public void run() {
         UserConfig userConfig = new UserConfig(Scope.cluster(clusterId));
         userConfig.setBooleanField(key2, true);
-        ClusterConfig.Delta delta = new ClusterConfig.Delta(clusterId).setUserConfig(userConfig);
+        ClusterConfig.Delta delta = new ClusterConfig.Delta(clusterId).addUserConfig(userConfig);
         ClusterAccessor accessor =
             new AtomicClusterAccessor(clusterId, helixAccessor, lockProvider);
         accessor.updateCluster(delta);

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/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 1315574..3bb17a2 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
@@ -128,12 +128,12 @@ public class TestHelixConnection extends ZkTestBase {
             .preferenceList(PartitionId.from("testDB_0"), Arrays.asList(participantId)).build();
     clusterAccessor.createCluster(new ClusterConfig.Builder(clusterId).addStateModelDefinition(
         stateModelDef).build());
-    clusterAccessor.addResourceToCluster(new ResourceConfig.Builder(resourceId)
+    clusterAccessor.addResource(new ResourceConfig.Builder(resourceId)
         .rebalancerConfig(rebalancerCtx)
         .idealState(
             PartitionedRebalancerConfig.rebalancerConfigToIdealState(rebalancerCtx, 0, false))
         .build());
-    clusterAccessor.addParticipantToCluster(new ParticipantConfig.Builder(participantId).build());
+    clusterAccessor.addParticipant(new ParticipantConfig.Builder(participantId).build());
 
     // start controller
     HelixController controller = connection.createController(clusterId, controllerId);

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
----------------------------------------------------------------------
diff --git a/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java b/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
index c5b055b..5ab5f22 100644
--- a/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
+++ b/helix-core/src/test/java/org/apache/helix/integration/TestLocalContainerProvider.java
@@ -118,7 +118,7 @@ public class TestLocalContainerProvider extends ZkTestBase {
     RebalancerConfig rebalancerConfig =
         new FullAutoRebalancerConfig.Builder(resourceId).addPartitions(NUM_PARTITIONS)
             .replicaCount(NUM_REPLICAS).stateModelDefId(masterSlave.getStateModelDefId()).build();
-    clusterAccessor.addResourceToCluster(new ResourceConfig.Builder(ResourceId.from(resourceName))
+    clusterAccessor.addResource(new ResourceConfig.Builder(ResourceId.from(resourceName))
         .provisionerConfig(provisionerConfig)
         .rebalancerConfig(rebalancerConfig)
         .idealState(

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/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 9e897a0..e6a8fc4 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
@@ -179,7 +179,7 @@ public class LogicalModelExample {
     mapField.put("k2", "v2");
     userConfig.setMapField("sampleMap", mapField);
     ResourceConfig.Delta delta =
-        new ResourceConfig.Delta(resource.getId()).setUserConfig(userConfig);
+        new ResourceConfig.Delta(resource.getId()).addUserConfig(userConfig);
     accessor.updateResource(resource.getId(), delta);
   }
 

http://git-wip-us.apache.org/repos/asf/helix/blob/961b9309/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterLauncher.java
----------------------------------------------------------------------
diff --git a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterLauncher.java b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterLauncher.java
index 5a683b0..4064e10 100644
--- a/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterLauncher.java
+++ b/helix-provisioning/src/main/java/org/apache/helix/provisioning/yarn/AppMasterLauncher.java
@@ -166,12 +166,11 @@ public class AppMasterLauncher {
           resourceConfigBuilder
               .provisionerConfig(provisionerConfig)
               .rebalancerConfig(rebalancerConfig)
-              .userConfig(serviceConfig)
               .idealState(
                   PartitionedRebalancerConfig.rebalancerConfigToIdealState(rebalancerConfig, 0,
                       false)) //
               .build();
-      clusterAccessor.addResourceToCluster(resourceConfig);
+      clusterAccessor.addResource(resourceConfig);
     }
     // start controller
     ControllerId controllerId = ControllerId.from("controller1");


Mime
View raw message