ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [25/36] ambari git commit: AMBARI-18456 - Refactor Unnecessary In-Memory Locks Around Business Objects (jonathanhurley)
Date Wed, 19 Oct 2016 16:58:35 GMT
AMBARI-18456 - Refactor Unnecessary In-Memory Locks Around Business Objects (jonathanhurley)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: d6a847154e80158a0be0a26ee7dfc0d6dccac686
Parents: 20f2978
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Fri Oct 14 15:01:38 2016 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Sun Oct 16 09:28:50 2016 -0400

----------------------------------------------------------------------
 .../ambari/annotations/ExperimentalFeature.java |   8 +-
 .../internal/ComponentResourceProvider.java     |  26 +-
 .../ambari/server/state/ServiceComponent.java   |   6 -
 .../server/state/ServiceComponentImpl.java      | 465 +++++++------------
 .../apache/ambari/server/state/ServiceImpl.java |  10 -
 .../server/state/cluster/ClusterImpl.java       |   5 +-
 .../server/state/cluster/ClustersImpl.java      |   5 +-
 .../ambari/server/state/host/HostImpl.java      |   4 +-
 .../svccomphost/ServiceComponentHostImpl.java   |   6 -
 .../server/agent/HeartbeatProcessorTest.java    |  54 +--
 .../server/agent/TestHeartbeatHandler.java      |  50 +-
 .../server/agent/TestHeartbeatMonitor.java      |  38 +-
 .../configuration/RecoveryConfigHelperTest.java |   9 -
 .../AmbariManagementControllerTest.java         |  60 +--
 .../apache/ambari/server/events/EventsTest.java |   1 -
 .../apache/ambari/server/orm/OrmTestHelper.java |   3 -
 .../ComponentVersionCheckActionTest.java        |   1 -
 .../upgrades/UpgradeActionTest.java             |   1 -
 .../server/state/ServiceComponentTest.java      |   9 -
 .../apache/ambari/server/state/ServiceTest.java |   6 -
 .../state/cluster/ClusterDeadlockTest.java      |   3 -
 .../server/state/cluster/ClusterImplTest.java   |   4 -
 .../server/state/cluster/ClusterTest.java       |  27 +-
 .../state/cluster/ClustersDeadlockTest.java     |   1 -
 .../server/state/cluster/ClustersTest.java      |   3 -
 .../ConcurrentServiceConfigVersionTest.java     |   1 -
 ...omponentHostConcurrentWriteDeadlockTest.java |   1 -
 .../svccomphost/ServiceComponentHostTest.java   |   1 -
 28 files changed, 289 insertions(+), 519 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java b/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
index 7798f26..1d5ba0e 100644
--- a/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
+++ b/ambari-server/src/main/java/org/apache/ambari/annotations/ExperimentalFeature.java
@@ -18,7 +18,6 @@
 package org.apache.ambari.annotations;
 
 import java.util.concurrent.Executor;
-import java.util.concurrent.locks.Lock;
 
 /**
  * The {@link ExperimentalFeature} enumeration is meant to be used with the
@@ -41,10 +40,5 @@ public enum ExperimentalFeature {
   /**
    * Used for code that is targeted for patch upgrades
    */
-  PATCH_UPGRADES,
-
-  /**
-   * The removal of the cluster global {@link Lock}
-   */
-  CLUSTER_GLOBAL_LOCK_REMOVAL
+  PATCH_UPGRADES
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
index fe89752..241a48f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/controller/internal/ComponentResourceProvider.java
@@ -17,9 +17,16 @@
  */
 package org.apache.ambari.server.controller.internal;
 
-import com.google.inject.assistedinject.Assisted;
-import com.google.inject.assistedinject.AssistedInject;
-import com.google.inject.persist.Transactional;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.EnumSet;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ClusterNotFoundException;
 import org.apache.ambari.server.DuplicateResourceException;
@@ -57,15 +64,9 @@ import org.apache.ambari.server.state.State;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.lang.Validate;
 
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.EnumSet;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import com.google.inject.assistedinject.Assisted;
+import com.google.inject.assistedinject.AssistedInject;
+import com.google.inject.persist.Transactional;
 
 /**
  * Resource provider for component resources.
@@ -379,7 +380,6 @@ public class ComponentResourceProvider extends AbstractControllerResourceProvide
       }
 
       s.addServiceComponent(sc);
-      sc.persist();
     }
   }
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
index 8387ab8..f91a958 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponent.java
@@ -72,12 +72,6 @@ public interface ServiceComponent {
 
   ServiceComponentResponse convertToResponse();
 
-  void refresh();
-
-  boolean isPersisted();
-
-  void persist();
-
   void debugDump(StringBuilder sb);
 
   boolean isClientComponent();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
index 282396d..f383e80 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentImpl.java
@@ -26,8 +26,6 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
-import org.apache.ambari.annotations.Experimental;
-import org.apache.ambari.annotations.ExperimentalFeature;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ObjectNotFoundException;
 import org.apache.ambari.server.ServiceComponentHostNotFoundException;
@@ -50,8 +48,6 @@ import org.apache.ambari.server.state.cluster.ClusterImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.google.inject.Inject;
-import com.google.inject.Injector;
 import com.google.inject.ProvisionException;
 import com.google.inject.assistedinject.Assisted;
 import com.google.inject.assistedinject.AssistedInject;
@@ -68,47 +64,55 @@ public class ServiceComponentImpl implements ServiceComponent {
   private final boolean isClientComponent;
   private final boolean isMasterComponent;
   private final boolean isVersionAdvertised;
-  volatile boolean persisted = false;
-  @Inject
-  private ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO;
-  @Inject
-  private ClusterServiceDAO clusterServiceDAO;
-  @Inject
-  private HostComponentDesiredStateDAO hostComponentDesiredStateDAO;
-  @Inject
-  private ServiceComponentHostFactory serviceComponentHostFactory;
-  @Inject
-  private AmbariMetaInfo ambariMetaInfo;
-  @Inject
-  private AmbariEventPublisher eventPublisher;
-
-  ServiceComponentDesiredStateEntity desiredStateEntity;
-  private ConcurrentMap<String, ServiceComponentHost> hostComponents;
+
+  private final ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO;
+
+  private final ClusterServiceDAO clusterServiceDAO;
+
+  private final ServiceComponentHostFactory serviceComponentHostFactory;
+
+  private final AmbariEventPublisher eventPublisher;
+
+  private final ConcurrentMap<String, ServiceComponentHost> hostComponents = new ConcurrentHashMap<String, ServiceComponentHost>();
+
+  /**
+   * The ID of the persisted {@link ServiceComponentDesiredStateEntity}.
+   */
+  private final long desiredStateEntityId;
 
   /**
    * Data access object used for lookup up stacks.
    */
-  @Inject
-  private StackDAO stackDAO;
+  private final StackDAO stackDAO;
 
   @AssistedInject
-  public ServiceComponentImpl(@Assisted Service service,
-                              @Assisted String componentName, Injector injector) throws AmbariException {
-    injector.injectMembers(this);
+  public ServiceComponentImpl(@Assisted Service service, @Assisted String componentName,
+      AmbariMetaInfo ambariMetaInfo,
+      ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO,
+      ClusterServiceDAO clusterServiceDAO, ServiceComponentHostFactory serviceComponentHostFactory,
+      StackDAO stackDAO, AmbariEventPublisher eventPublisher)
+      throws AmbariException {
+
     this.service = service;
+    this.componentName = componentName;
+    this.serviceComponentDesiredStateDAO = serviceComponentDesiredStateDAO;
+    this.clusterServiceDAO = clusterServiceDAO;
+    this.serviceComponentHostFactory = serviceComponentHostFactory;
+    this.stackDAO = stackDAO;
+    this.eventPublisher = eventPublisher;
+
+    StackId stackId = service.getDesiredStackVersion();
+    StackEntity stackEntity = stackDAO.find(stackId.getStackName(), stackId.getStackVersion());
 
-    desiredStateEntity = new ServiceComponentDesiredStateEntity();
+    ServiceComponentDesiredStateEntity desiredStateEntity = new ServiceComponentDesiredStateEntity();
     desiredStateEntity.setComponentName(componentName);
     desiredStateEntity.setDesiredState(State.INIT);
     desiredStateEntity.setDesiredVersion(State.UNKNOWN.toString());
     desiredStateEntity.setServiceName(service.getName());
     desiredStateEntity.setClusterId(service.getClusterId());
     desiredStateEntity.setRecoveryEnabled(false);
-    setDesiredStackVersion(service.getDesiredStackVersion());
+    desiredStateEntity.setDesiredStack(stackEntity);
 
-    hostComponents = new ConcurrentHashMap<String, ServiceComponentHost>();
-
-    StackId stackId = service.getDesiredStackVersion();
     try {
       ComponentInfo compInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
           stackId.getStackVersion(), service.getName(), componentName);
@@ -124,17 +128,29 @@ public class ServiceComponentImpl implements ServiceComponent {
           + ", componentName=" + componentName
           + ", stackInfo=" + stackId.getStackId());
     }
-    this.componentName = componentName;
+
+    persistEntities(desiredStateEntity);
+    desiredStateEntityId = desiredStateEntity.getId();
   }
 
   @AssistedInject
   public ServiceComponentImpl(@Assisted Service service,
-                              @Assisted ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity,
-                              Injector injector) throws AmbariException {
-    injector.injectMembers(this);
+      @Assisted ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity,
+      AmbariMetaInfo ambariMetaInfo,
+      ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO,
+      ClusterServiceDAO clusterServiceDAO,
+      HostComponentDesiredStateDAO hostComponentDesiredStateDAO,
+      ServiceComponentHostFactory serviceComponentHostFactory, StackDAO stackDAO,
+      AmbariEventPublisher eventPublisher)
+      throws AmbariException {
     this.service = service;
+    this.serviceComponentDesiredStateDAO = serviceComponentDesiredStateDAO;
+    this.clusterServiceDAO = clusterServiceDAO;
+    this.serviceComponentHostFactory = serviceComponentHostFactory;
+    this.stackDAO = stackDAO;
+    this.eventPublisher = eventPublisher;
 
-    desiredStateEntity = serviceComponentDesiredStateEntity;
+    desiredStateEntityId = serviceComponentDesiredStateEntity.getId();
     componentName = serviceComponentDesiredStateEntity.getComponentName();
 
     StackId stackId = service.getDesiredStackVersion();
@@ -155,8 +171,7 @@ public class ServiceComponentImpl implements ServiceComponent {
         + ", stackInfo=" + stackId.getStackId());
     }
 
-    hostComponents = new ConcurrentHashMap<String, ServiceComponentHost>();
-    for (HostComponentStateEntity hostComponentStateEntity : desiredStateEntity.getHostComponentStateEntities()) {
+    for (HostComponentStateEntity hostComponentStateEntity : serviceComponentDesiredStateEntity.getHostComponentStateEntities()) {
       HostComponentDesiredStateEntityPK pk = new HostComponentDesiredStateEntityPK();
       pk.setClusterId(hostComponentStateEntity.getClusterId());
       pk.setServiceName(hostComponentStateEntity.getServiceName());
@@ -176,8 +191,6 @@ public class ServiceComponentImpl implements ServiceComponent {
         ex.printStackTrace();
       }
     }
-
-    persisted = true;
   }
 
   @Override
@@ -192,7 +205,9 @@ public class ServiceComponentImpl implements ServiceComponent {
    */
   @Override
   public boolean isRecoveryEnabled() {
-    ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+        desiredStateEntityId);
+
     if (desiredStateEntity != null) {
       return desiredStateEntity.isRecoveryEnabled();
     } else {
@@ -210,33 +225,29 @@ public class ServiceComponentImpl implements ServiceComponent {
    */
   @Override
   public void setRecoveryEnabled(boolean recoveryEnabled) {
-    readWriteLock.writeLock().lock();
-    try {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Setting RecoveryEnabled of Component" + ", clusterName="
-                + service.getCluster().getClusterName() + ", clusterId="
-                + service.getCluster().getClusterId() + ", serviceName="
-                + service.getName() + ", componentName=" + getName()
-                + ", oldRecoveryEnabled=" + isRecoveryEnabled() + ", newRecoveryEnabled="
-                + recoveryEnabled);
-      }
-      ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        desiredStateEntity.setRecoveryEnabled(recoveryEnabled);
-        saveIfPersisted(desiredStateEntity);
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Setting RecoveryEnabled of Component" + ", clusterName="
+          + service.getCluster().getClusterName() + ", clusterId="
+          + service.getCluster().getClusterId() + ", serviceName=" + service.getName()
+          + ", componentName=" + getName() + ", oldRecoveryEnabled=" + isRecoveryEnabled()
+          + ", newRecoveryEnabled=" + recoveryEnabled);
+    }
 
-        // broadcast the change
-        ServiceComponentRecoveryChangedEvent event = new ServiceComponentRecoveryChangedEvent(
-                getClusterName(), getServiceName(), getName(), isRecoveryEnabled());
-        eventPublisher.publish(event);
+    ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+        desiredStateEntityId);
 
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-                "previously deleted, serviceName = " + service.getName());
-      }
+    if (desiredStateEntity != null) {
+      desiredStateEntity.setRecoveryEnabled(recoveryEnabled);
+      desiredStateEntity = serviceComponentDesiredStateDAO.merge(desiredStateEntity);
 
-    } finally {
-      readWriteLock.writeLock().unlock();
+      // broadcast the change
+      ServiceComponentRecoveryChangedEvent event = new ServiceComponentRecoveryChangedEvent(
+          getClusterName(), getServiceName(), getName(), isRecoveryEnabled());
+      eventPublisher.publish(event);
+
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + service.getName());
     }
   }
 
@@ -251,35 +262,27 @@ public class ServiceComponentImpl implements ServiceComponent {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public Map<String, ServiceComponentHost> getServiceComponentHosts() {
     return new HashMap<String, ServiceComponentHost>(hostComponents);
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void addServiceComponentHosts(
       Map<String, ServiceComponentHost> hostComponents) throws AmbariException {
-    readWriteLock.writeLock().lock();
-    try {
-      // TODO validation
-      for (Entry<String, ServiceComponentHost> entry :
-          hostComponents.entrySet()) {
-        if (!entry.getKey().equals(entry.getValue().getHostName())) {
-          throw new AmbariException("Invalid arguments in map"
-              + ", hostname does not match the key in map");
-        }
-      }
-      for (ServiceComponentHost sch : hostComponents.values()) {
-        addServiceComponentHost(sch);
+    // TODO validation
+    for (Entry<String, ServiceComponentHost> entry : hostComponents.entrySet()) {
+      if (!entry.getKey().equals(entry.getValue().getHostName())) {
+        throw new AmbariException(
+            "Invalid arguments in map" + ", hostname does not match the key in map");
       }
-    } finally {
-      readWriteLock.writeLock().unlock();
+    }
+
+    for (ServiceComponentHost sch : hostComponents.values()) {
+      addServiceComponentHost(sch);
     }
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void addServiceComponentHost(
       ServiceComponentHost hostComponent) throws AmbariException {
     readWriteLock.writeLock().lock();
@@ -311,7 +314,6 @@ public class ServiceComponentImpl implements ServiceComponent {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public ServiceComponentHost addServiceComponentHost(String hostName) throws AmbariException {
     ServiceComponentHost hostComponent = serviceComponentHostFactory.createNew(this, hostName);
     addServiceComponentHost(hostComponent);
@@ -319,23 +321,22 @@ public class ServiceComponentImpl implements ServiceComponent {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public ServiceComponentHost getServiceComponentHost(String hostname)
       throws AmbariException {
-    
+
     if (!hostComponents.containsKey(hostname)) {
       throw new ServiceComponentHostNotFoundException(getClusterName(),
           getServiceName(), getName(), hostname);
     }
-    
+
     return hostComponents.get(hostname);
   }
 
   @Override
   public State getDesiredState() {
-    readWriteLock.readLock().lock();
-    try {
-      ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+        desiredStateEntityId);
+
       if (desiredStateEntity != null) {
         return desiredStateEntity.getDesiredState();
       } else {
@@ -344,124 +345,97 @@ public class ServiceComponentImpl implements ServiceComponent {
           "componentName = " + componentName);
       }
 
-    } finally {
-      readWriteLock.readLock().unlock();
-    }
     return null;
   }
 
   @Override
   public void setDesiredState(State state) {
-    readWriteLock.writeLock().lock();
-    try {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Setting DesiredState of Service" + ", clusterName="
-                + service.getCluster().getClusterName() + ", clusterId="
-                + service.getCluster().getClusterId() + ", serviceName="
-                + service.getName() + ", serviceComponentName=" + getName()
-                + ", oldDesiredState=" + getDesiredState() + ", newDesiredState="
-                + state);
-      }
-      ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        desiredStateEntity.setDesiredState(state);
-        saveIfPersisted(desiredStateEntity);
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + (service != null ? service.getName() : ""));
-      }
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Setting DesiredState of Service" + ", clusterName="
+          + service.getCluster().getClusterName() + ", clusterId="
+          + service.getCluster().getClusterId() + ", serviceName=" + service.getName()
+          + ", serviceComponentName=" + getName() + ", oldDesiredState=" + getDesiredState()
+          + ", newDesiredState=" + state);
+    }
 
-    } finally {
-      readWriteLock.writeLock().unlock();
+    ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+        desiredStateEntityId);
+
+    if (desiredStateEntity != null) {
+      desiredStateEntity.setDesiredState(state);
+      desiredStateEntity = serviceComponentDesiredStateDAO.merge(desiredStateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + (service != null ? service.getName() : ""));
     }
   }
 
   @Override
   public StackId getDesiredStackVersion() {
-    readWriteLock.readLock().lock();
-    try {
-      StackEntity stackEntity = getDesiredStateEntity().getDesiredStack();
-      if (null != stackEntity) {
-        return new StackId(stackEntity.getStackName(),
-            stackEntity.getStackVersion());
-      } else {
-        return null;
-      }
-    } finally {
-      readWriteLock.readLock().unlock();
+    ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+        desiredStateEntityId);
+
+    StackEntity stackEntity = desiredStateEntity.getDesiredStack();
+    if (null != stackEntity) {
+      return new StackId(stackEntity.getStackName(), stackEntity.getStackVersion());
+    } else {
+      return null;
     }
   }
 
   @Override
   public void setDesiredStackVersion(StackId stack) {
-    readWriteLock.writeLock().lock();
-    try {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("Setting DesiredStackVersion of Service" + ", clusterName="
-            + service.getCluster().getClusterName() + ", clusterId="
-            + service.getCluster().getClusterId() + ", serviceName="
-            + service.getName() + ", serviceComponentName=" + getName()
-            + ", oldDesiredStackVersion=" + getDesiredStackVersion()
-            + ", newDesiredStackVersion=" + stack);
-      }
+    if (LOG.isDebugEnabled()) {
+      LOG.debug("Setting DesiredStackVersion of Service" + ", clusterName="
+          + service.getCluster().getClusterName() + ", clusterId="
+          + service.getCluster().getClusterId() + ", serviceName=" + service.getName()
+          + ", serviceComponentName=" + getName() + ", oldDesiredStackVersion="
+          + getDesiredStackVersion() + ", newDesiredStackVersion=" + stack);
+    }
 
-      StackEntity stackEntity = stackDAO.find(stack.getStackName(),
-        stack.getStackVersion());
+    ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+        desiredStateEntityId);
 
-      ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        desiredStateEntity.setDesiredStack(stackEntity);
-        saveIfPersisted(desiredStateEntity);
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + (service != null ? service.getName() : ""));
-      }
-    } finally {
-      readWriteLock.writeLock().unlock();
+    if (desiredStateEntity != null) {
+      StackEntity stackEntity = stackDAO.find(stack.getStackName(), stack.getStackVersion());
+      desiredStateEntity.setDesiredStack(stackEntity);
+      desiredStateEntity = serviceComponentDesiredStateDAO.merge(desiredStateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + (service != null ? service.getName() : ""));
     }
   }
 
   @Override
   public String getDesiredVersion() {
-    readWriteLock.readLock().lock();
-    try {
-      return getDesiredStateEntity().getDesiredVersion();
-    } finally {
-      readWriteLock.readLock().unlock();
-    }
+    ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+        desiredStateEntityId);
+
+    return desiredStateEntity.getDesiredVersion();
   }
 
   @Override
   public void setDesiredVersion(String version) {
-    readWriteLock.writeLock().lock();
-    try {
-      ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+        desiredStateEntityId);
+
       if (desiredStateEntity != null) {
         desiredStateEntity.setDesiredVersion(version);
-        saveIfPersisted(desiredStateEntity);
+      desiredStateEntity = serviceComponentDesiredStateDAO.merge(desiredStateEntity);
       } else {
         LOG.warn("Setting a member on an entity object that may have been " +
           "previously deleted, serviceName = " + (service != null ? service.getName() : ""));
       }
-
-    } finally {
-      readWriteLock.writeLock().unlock();
-    }
   }
 
   @Override
   public ServiceComponentResponse convertToResponse() {
-    readWriteLock.readLock().lock();
-    try {
-      Cluster cluster = service.getCluster();
-      ServiceComponentResponse r = new ServiceComponentResponse(getClusterId(),
-          cluster.getClusterName(), service.getName(), getName(),
-          getDesiredStackVersion().getStackId(), getDesiredState().toString(),
-          getServiceComponentStateCount(), isRecoveryEnabled(), displayName);
-      return r;
-    } finally {
-      readWriteLock.readLock().unlock();
-    }
+    Cluster cluster = service.getCluster();
+    ServiceComponentResponse r = new ServiceComponentResponse(getClusterId(),
+        cluster.getClusterName(), service.getName(), getName(),
+        getDesiredStackVersion().getStackId(), getDesiredState().toString(),
+        getServiceComponentStateCount(), isRecoveryEnabled(), displayName);
+    return r;
   }
 
   @Override
@@ -472,107 +446,37 @@ public class ServiceComponentImpl implements ServiceComponent {
 
   @Override
   public void debugDump(StringBuilder sb) {
-    readWriteLock.readLock().lock();
-    try {
-      sb.append("ServiceComponent={ serviceComponentName=" + getName()
-          + ", recoveryEnabled=" + isRecoveryEnabled()
-          + ", clusterName=" + service.getCluster().getClusterName()
-          + ", clusterId=" + service.getCluster().getClusterId()
-          + ", serviceName=" + service.getName() + ", desiredStackVersion="
-          + getDesiredStackVersion() + ", desiredState="
-          + getDesiredState().toString() + ", hostcomponents=[ ");
-      boolean first = true;
-      for (ServiceComponentHost sch : hostComponents.values()) {
-        if (!first) {
-          sb.append(" , ");
-          first = false;
-        }
-        sb.append("\n        ");
-        sch.debugDump(sb);
-        sb.append(" ");
-      }
-      sb.append(" ] }");
-    } finally {
-      readWriteLock.readLock().unlock();
-    }
-  }
-
-  /**
-   * {@inheritDoc}
-   */
-  @Override
-  public boolean isPersisted() {
-    // a lock around this internal state variable is not required since we
-    // have appropriate locks in the persist() method and this member is
-    // only ever false under the condition that the object is new
-    return persisted;
-  }
-
-  /**
-   * {@inheritDoc}
-   * <p/>
-   * This method uses Java locks and then delegates to internal methods which
-   * perform the JPA merges inside of a transaction. Because of this, a
-   * transaction is not necessary before this calling this method.
-   */
-  @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
-  public void persist() {
-    readWriteLock.writeLock().lock();
-    try {
-      if (!persisted) {
-        // persist the new cluster topology
-        persistEntities();
-        refresh();
-        persisted = true;
-      } else {
-        saveIfPersisted(desiredStateEntity);
+    sb.append("ServiceComponent={ serviceComponentName=" + getName() + ", recoveryEnabled="
+        + isRecoveryEnabled() + ", clusterName=" + service.getCluster().getClusterName()
+        + ", clusterId=" + service.getCluster().getClusterId() + ", serviceName="
+        + service.getName() + ", desiredStackVersion=" + getDesiredStackVersion()
+        + ", desiredState=" + getDesiredState().toString() + ", hostcomponents=[ ");
+    boolean first = true;
+    for (ServiceComponentHost sch : hostComponents.values()) {
+      if (!first) {
+        sb.append(" , ");
+        first = false;
       }
-    } finally {
-      readWriteLock.writeLock().unlock();
+      sb.append("\n        ");
+      sch.debugDump(sb);
+      sb.append(" ");
     }
+    sb.append(" ] }");
   }
 
   @Transactional
-  protected void persistEntities() {
+  protected void persistEntities(ServiceComponentDesiredStateEntity desiredStateEntity) {
     ClusterServiceEntityPK pk = new ClusterServiceEntityPK();
     pk.setClusterId(service.getClusterId());
     pk.setServiceName(service.getName());
     ClusterServiceEntity serviceEntity = clusterServiceDAO.findByPK(pk);
 
-    ServiceComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
     desiredStateEntity.setClusterServiceEntity(serviceEntity);
-
     serviceComponentDesiredStateDAO.create(desiredStateEntity);
     serviceEntity = clusterServiceDAO.merge(serviceEntity);
   }
 
   @Override
-  @Transactional
-  public void refresh() {
-    readWriteLock.writeLock().lock();
-    try {
-      if (isPersisted()) {
-        serviceComponentDesiredStateDAO.refresh(getDesiredStateEntity());
-      }
-    } finally {
-      readWriteLock.writeLock().unlock();
-    }
-  }
-
-  /**
-   * Merges the encapsulated {@link ServiceComponentDesiredStateEntity} inside
-   * of a new transaction. This method assumes that the appropriate write lock
-   * has already been acquired from {@link #readWriteLock}.
-   */
-  @Transactional
-  void saveIfPersisted(ServiceComponentDesiredStateEntity desiredStateEntity) {
-    if (isPersisted()) {
-      desiredStateEntity = serviceComponentDesiredStateDAO.merge(desiredStateEntity);
-    }
-  }
-
-  @Override
   public boolean isClientComponent() {
     return isClientComponent;
   }
@@ -589,31 +493,24 @@ public class ServiceComponentImpl implements ServiceComponent {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public boolean canBeRemoved() {
-    readWriteLock.readLock().lock();
-    try {
-      // A component can be deleted if all it's host components
-      // can be removed, irrespective of the state of
-      // the component itself
-      for (ServiceComponentHost sch : hostComponents.values()) {
-        if (!sch.canBeRemoved()) {
-          LOG.warn("Found non removable hostcomponent when trying to" + " delete service component"
-              + ", clusterName=" + getClusterName() + ", serviceName=" + getServiceName()
-              + ", componentName=" + getName() + ", state=" + sch.getState() + ", hostname="
-              + sch.getHostName());
-          return false;
-        }
+    // A component can be deleted if all it's host components
+    // can be removed, irrespective of the state of
+    // the component itself
+    for (ServiceComponentHost sch : hostComponents.values()) {
+      if (!sch.canBeRemoved()) {
+        LOG.warn("Found non removable hostcomponent when trying to" + " delete service component"
+            + ", clusterName=" + getClusterName() + ", serviceName=" + getServiceName()
+            + ", componentName=" + getName() + ", state=" + sch.getState() + ", hostname="
+            + sch.getHostName());
+        return false;
       }
-      return true;
-    } finally {
-      readWriteLock.readLock().unlock();
     }
+    return true;
   }
 
   @Override
   @Transactional
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void deleteAllServiceComponentHosts() throws AmbariException {
     readWriteLock.writeLock().lock();
     try {
@@ -640,7 +537,6 @@ public class ServiceComponentImpl implements ServiceComponent {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void deleteServiceComponentHosts(String hostname) throws AmbariException {
     readWriteLock.writeLock().lock();
     try {
@@ -666,25 +562,21 @@ public class ServiceComponentImpl implements ServiceComponent {
 
   @Override
   @Transactional
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void delete() throws AmbariException {
     readWriteLock.writeLock().lock();
     try {
       deleteAllServiceComponentHosts();
 
-      if (persisted) {
-        removeEntities();
-        persisted = false;
-      }
+      ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
+          desiredStateEntityId);
+
+      serviceComponentDesiredStateDAO.remove(desiredStateEntity);
+
     } finally {
       readWriteLock.writeLock().unlock();
     }
   }
 
-  @Transactional
-  protected void removeEntities() throws AmbariException {
-    serviceComponentDesiredStateDAO.remove(getDesiredStateEntity());
-  }
 
   private int getSCHCountByState(State state) {
     int count = 0;
@@ -706,13 +598,4 @@ public class ServiceComponentImpl implements ServiceComponent {
     serviceComponentStateCountMap.put("totalCount", hostComponents.size());
     return serviceComponentStateCountMap;
   }
-
-  // Refresh cached reference after ever setter
-  private ServiceComponentDesiredStateEntity getDesiredStateEntity() {
-    if (!isPersisted()) {
-      return desiredStateEntity;
-    }
-
-    return serviceComponentDesiredStateDAO.findById(desiredStateEntity.getId());
-  }
 }

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
index e4adc97..9b56059 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceImpl.java
@@ -27,8 +27,6 @@ import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReentrantLock;
 
-import org.apache.ambari.annotations.Experimental;
-import org.apache.ambari.annotations.ExperimentalFeature;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.ServiceComponentNotFoundException;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -194,7 +192,6 @@ public class ServiceImpl implements Service {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void addServiceComponents(
       Map<String, ServiceComponent> components) throws AmbariException {
     for (ServiceComponent sc : components.values()) {
@@ -203,7 +200,6 @@ public class ServiceImpl implements Service {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void addServiceComponent(ServiceComponent component) throws AmbariException {
     if (components.containsKey(component.getName())) {
       throw new AmbariException("Cannot add duplicate ServiceComponent"
@@ -217,7 +213,6 @@ public class ServiceImpl implements Service {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public ServiceComponent addServiceComponent(String serviceComponentName)
       throws AmbariException {
     ServiceComponent component = serviceComponentFactory.createNew(this, serviceComponentName);
@@ -345,7 +340,6 @@ public class ServiceImpl implements Service {
   /**
    *
    */
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   private void persist(ClusterServiceEntity serviceEntity) {
     persistEntities(serviceEntity);
     refresh();
@@ -382,7 +376,6 @@ public class ServiceImpl implements Service {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public boolean canBeRemoved() {
     //
     // A service can be deleted if all it's components
@@ -439,7 +432,6 @@ public class ServiceImpl implements Service {
 
   @Override
   @Transactional
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void deleteAllComponents() throws AmbariException {
     lock.lock();
     try {
@@ -465,7 +457,6 @@ public class ServiceImpl implements Service {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void deleteServiceComponent(String componentName)
       throws AmbariException {
     lock.lock();
@@ -495,7 +486,6 @@ public class ServiceImpl implements Service {
 
   @Override
   @Transactional
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void delete() throws AmbariException {
     deleteAllComponents();
     deleteAllServiceConfigs();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
index 848036d..5566343 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClusterImpl.java
@@ -396,7 +396,8 @@ public class ClusterImpl implements Cluster {
           String hostname = svchost.getKey();
           ServiceComponentHost svcHostComponent = svchost.getValue();
           if (!serviceComponentHostsByHost.containsKey(hostname)) {
-            serviceComponentHostsByHost.put(hostname, new ArrayList<ServiceComponentHost>());
+            serviceComponentHostsByHost.put(hostname,
+                new CopyOnWriteArrayList<ServiceComponentHost>());
           }
 
           List<ServiceComponentHost> compList = serviceComponentHostsByHost.get(hostname);
@@ -670,7 +671,7 @@ public class ClusterImpl implements Cluster {
 
     if (!serviceComponentHostsByHost.containsKey(hostname)) {
       serviceComponentHostsByHost.put(hostname,
-        new ArrayList<ServiceComponentHost>());
+          new CopyOnWriteArrayList<ServiceComponentHost>());
     }
 
     if (LOG.isDebugEnabled()) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
index bed33d9..706a476 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/cluster/ClustersImpl.java
@@ -28,6 +28,7 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 
 import javax.persistence.RollbackException;
 
@@ -413,10 +414,10 @@ public class ClustersImpl implements Clusters {
     // not stored to DB
     Host host = hostFactory.create(hostEntity);
     host.setAgentVersion(new AgentVersion(""));
-    List<DiskInfo> emptyDiskList = new ArrayList<DiskInfo>();
+    List<DiskInfo> emptyDiskList = new CopyOnWriteArrayList<DiskInfo>();
     host.setDisksInfo(emptyDiskList);
     host.setHealthStatus(new HostHealthStatus(HealthStatus.UNKNOWN, ""));
-    host.setHostAttributes(new HashMap<String, String>());
+    host.setHostAttributes(new ConcurrentHashMap<String, String>());
     host.setState(HostState.INIT);
 
     // the hosts by ID map is updated separately since the host has not yet

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
index 286b5ca..513d924 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/host/HostImpl.java
@@ -18,12 +18,12 @@
 package org.apache.ambari.server.state.host;
 
 import java.lang.reflect.Type;
-import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -141,7 +141,7 @@ public class HostImpl implements Host {
 
   private long lastHeartbeatTime = 0L;
   private AgentEnv lastAgentEnv = null;
-  private List<DiskInfo> disksInfo = new ArrayList<DiskInfo>();
+  private List<DiskInfo> disksInfo = new CopyOnWriteArrayList<DiskInfo>();
   private RecoveryReport recoveryReport = new RecoveryReport();
   private Integer currentPingPort = null;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
index a575456..a6f5040 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java
@@ -30,8 +30,6 @@ import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 
-import org.apache.ambari.annotations.Experimental;
-import org.apache.ambari.annotations.ExperimentalFeature;
 import org.apache.ambari.server.AmbariException;
 import org.apache.ambari.server.agent.AlertDefinitionCommand;
 import org.apache.ambari.server.api.services.AmbariMetaInfo;
@@ -1028,7 +1026,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void handleEvent(ServiceComponentHostEvent event)
       throws InvalidStateTransitionException {
     if (LOG.isDebugEnabled()) {
@@ -1344,7 +1341,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public ServiceComponentHostResponse convertToResponse(Map<String, DesiredConfig> desiredConfigs) {
     readLock.lock();
     try {
@@ -1538,7 +1534,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public boolean canBeRemoved() {
     boolean schLockAcquired = false;
     try {
@@ -1555,7 +1550,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
   }
 
   @Override
-  @Experimental(feature = ExperimentalFeature.CLUSTER_GLOBAL_LOCK_REMOVAL)
   public void delete() {
     boolean fireRemovalEvent = false;
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
index 64305ff..dcffece 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/HeartbeatProcessorTest.java
@@ -159,11 +159,11 @@ public class HeartbeatProcessorTest {
   public void testHeartbeatWithConfigs() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(SECONDARY_NAMENODE).persist();
+    hdfs.addServiceComponent(SECONDARY_NAMENODE);
     hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -228,7 +228,7 @@ public class HeartbeatProcessorTest {
   public void testRestartRequiredAfterInstallClient() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(HDFS_CLIENT).persist();
+    hdfs.addServiceComponent(HDFS_CLIENT);
     hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -293,11 +293,11 @@ public class HeartbeatProcessorTest {
   public void testHeartbeatCustomCommandWithConfigs() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(SECONDARY_NAMENODE).persist();
+    hdfs.addServiceComponent(SECONDARY_NAMENODE);
     hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -377,11 +377,11 @@ public class HeartbeatProcessorTest {
   public void testHeartbeatCustomStartStop() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(SECONDARY_NAMENODE).persist();
+    hdfs.addServiceComponent(SECONDARY_NAMENODE);
     hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -461,11 +461,11 @@ public class HeartbeatProcessorTest {
   public void testStatusHeartbeat() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(SECONDARY_NAMENODE).persist();
+    hdfs.addServiceComponent(SECONDARY_NAMENODE);
     hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -590,7 +590,7 @@ public class HeartbeatProcessorTest {
       throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -709,7 +709,7 @@ public class HeartbeatProcessorTest {
   public void testUpgradeSpecificHandling() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -803,7 +803,7 @@ public class HeartbeatProcessorTest {
   public void testCommandStatusProcesses() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
 
@@ -884,11 +884,11 @@ public class HeartbeatProcessorTest {
   public void testComponentUpgradeCompleteReport() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(HDFS_CLIENT).persist();
+    hdfs.addServiceComponent(HDFS_CLIENT);
     hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
 
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
@@ -968,11 +968,11 @@ public class HeartbeatProcessorTest {
   public void testComponentUpgradeFailReport() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(HDFS_CLIENT).persist();
+    hdfs.addServiceComponent(HDFS_CLIENT);
     hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
 
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
@@ -1088,11 +1088,11 @@ public class HeartbeatProcessorTest {
   public void testComponentUpgradeInProgressReport() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(HDFS_CLIENT).persist();
+    hdfs.addServiceComponent(HDFS_CLIENT);
     hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
 
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
@@ -1294,10 +1294,10 @@ public class HeartbeatProcessorTest {
   public void testComponentInProgressStatusSafeAfterStatusReport() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).
         addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).
         addServiceComponentHost(DummyHostname1).persist();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
index 6205f59..cd41929 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatHandler.java
@@ -221,9 +221,9 @@ public class TestHeartbeatHandler {
   public void testStatusHeartbeatWithAnnotation() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
-    hdfs.addServiceComponent(SECONDARY_NAMENODE).persist();
+    hdfs.addServiceComponent(DATANODE);
+    hdfs.addServiceComponent(NAMENODE);
+    hdfs.addServiceComponent(SECONDARY_NAMENODE);
 
     ActionQueue aq = new ActionQueue();
 
@@ -272,10 +272,10 @@ public class TestHeartbeatHandler {
   public void testLiveStatusUpdateAfterStopFailed() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).
             addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).
             addServiceComponentHost(DummyHostname1).persist();
 
@@ -385,14 +385,14 @@ public class TestHeartbeatHandler {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).persist();
+    hdfs.getServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
 
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(NAMENODE).persist();
+    hdfs.getServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
-    hdfs.addServiceComponent(HDFS_CLIENT).persist();
+    hdfs.addServiceComponent(HDFS_CLIENT);
     hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
 
     Host hostObject = clusters.getHost(DummyHostname1);
@@ -451,15 +451,15 @@ public class TestHeartbeatHandler {
      * Add three service components enabled for auto start.
      */
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).persist();
+    hdfs.getServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
 
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(NAMENODE).persist();
+    hdfs.getServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     hdfs.addServiceComponent(HDFS_CLIENT).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(HDFS_CLIENT).persist();
+    hdfs.getServiceComponent(HDFS_CLIENT);
     hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
 
     Host hostObject = clusters.getHost(DummyHostname1);
@@ -780,11 +780,11 @@ public class TestHeartbeatHandler {
   public void testTaskInProgressHandling() throws Exception, InvalidStateTransitionException {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(SECONDARY_NAMENODE).persist();
+    hdfs.addServiceComponent(SECONDARY_NAMENODE);
     hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -837,11 +837,11 @@ public class TestHeartbeatHandler {
   public void testOPFailedEventForAbortedTask() throws Exception, InvalidStateTransitionException {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(SECONDARY_NAMENODE).persist();
+    hdfs.addServiceComponent(SECONDARY_NAMENODE);
     hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     ActionQueue aq = new ActionQueue();
@@ -911,11 +911,11 @@ public class TestHeartbeatHandler {
   public void testStatusHeartbeatWithVersion() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(HDFS_CLIENT).persist();
+    hdfs.addServiceComponent(HDFS_CLIENT);
     hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
 
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
@@ -988,9 +988,9 @@ public class TestHeartbeatHandler {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Host hostObject = clusters.getHost(DummyHostname1);
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
     hdfs.getServiceComponent(NAMENODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
@@ -1069,9 +1069,9 @@ public class TestHeartbeatHandler {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Host hostObject = clusters.getHost(DummyHostname1);
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
-    hdfs.addServiceComponent(NAMENODE).persist();
+    hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
     hdfs.getServiceComponent(NAMENODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
@@ -1403,7 +1403,7 @@ public class TestHeartbeatHandler {
   public void testCommandStatusProcesses_empty() throws Exception {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
-    hdfs.addServiceComponent(DATANODE).persist();
+    hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
index e6a3ee6..c4d735d 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/agent/TestHeartbeatMonitor.java
@@ -168,11 +168,11 @@ public class TestHeartbeatMonitor {
 
     clusters.mapHostsToCluster(hostNames, clusterName);
     Service hdfs = cluster.addService(serviceName);
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.DATANODE.name());
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.NAMENODE.name());
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
     hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
 
     hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
@@ -260,16 +260,16 @@ public class TestHeartbeatMonitor {
 
     clusters.mapHostsToCluster(hostNames, clusterName);
     Service hdfs = cluster.addService(serviceName);
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.DATANODE.name());
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost
       (hostname1).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.NAMENODE.name());
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost
       (hostname1).persist();
-    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
     hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).
       addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
+    hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost
       (hostname1).persist();
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost
@@ -368,11 +368,11 @@ public class TestHeartbeatMonitor {
     clusters.mapHostsToCluster(hostNames, clusterName);
 
     Service hdfs = cluster.addService(serviceName);
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.DATANODE.name());
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.NAMENODE.name());
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
     hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
 
     hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
@@ -408,12 +408,12 @@ public class TestHeartbeatMonitor {
     hm.start();
     Thread.sleep(3 * heartbeatMonitorWakeupIntervalMS);
     hm.shutdown();
-    
+
     int tryNumber = 0;
     while(hm.isAlive()) {
       hm.join(2*heartbeatMonitorWakeupIntervalMS);
       tryNumber++;
-      
+
       if(tryNumber >= 5) {
         fail("HeartbeatMonitor should be already stopped");
       }
@@ -450,13 +450,13 @@ public class TestHeartbeatMonitor {
     clusters.mapHostsToCluster(hostNames, clusterName);
 
     Service hdfs = cluster.addService(serviceName);
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.DATANODE.name());
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.NAMENODE.name());
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
     hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
+    hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(hostname1);
 
     ActionQueue aq = new ActionQueue();
@@ -570,11 +570,11 @@ public class TestHeartbeatMonitor {
 
     Service hdfs = cluster.addService(serviceName);
 
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.DATANODE.name());
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.NAMENODE.name());
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
-    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name()).persist();
+    hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
     hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
 
     hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java b/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
index 351d473..b082145 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/configuration/RecoveryConfigHelperTest.java
@@ -137,7 +137,6 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).persist();
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
 
     // Get the recovery configuration
@@ -146,7 +145,6 @@ public class RecoveryConfigHelperTest {
 
     // Install HDFS::NAMENODE to trigger a component installed event
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(NAMENODE).persist();
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     // Verify that the config is stale now
@@ -172,11 +170,9 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).persist();
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
 
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(NAMENODE).persist();
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     // Get the recovery configuration
@@ -209,7 +205,6 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).persist();
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setDesiredState(State.INSTALLED);
 
@@ -249,11 +244,9 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).persist();
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
 
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(NAMENODE).persist();
     hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
 
     // Get the recovery configuration
@@ -285,7 +278,6 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).persist();
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
 
     // Get the recovery configuration
@@ -327,7 +319,6 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).persist();
 
     // Add SCH to Host1 and Host2
     hdfs.getServiceComponent(DATANODE).addServiceComponentHost("Host1").persist();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
index d61a3e7..7b3f671 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/controller/AmbariManagementControllerTest.java
@@ -1637,13 +1637,10 @@ public class AmbariManagementControllerTest {
 
     ServiceComponent sc1 = serviceComponentFactory.createNew(s1, "NAMENODE");
     s1.addServiceComponent(sc1);
-    sc1.persist();
     ServiceComponent sc2 = serviceComponentFactory.createNew(s2, "NAMENODE");
     s2.addServiceComponent(sc2);
-    sc2.persist();
     ServiceComponent sc3 = serviceComponentFactory.createNew(s3, "NAMENODE");
     s3.addServiceComponent(sc3);
-    sc3.persist();
 
 
     try {
@@ -2365,7 +2362,6 @@ public class AmbariManagementControllerTest {
     s1.setDesiredState(State.INSTALLED);
     ServiceComponent sc1 = serviceComponentFactory.createNew(s1, "DATANODE");
     s1.addServiceComponent(sc1);
-    sc1.persist();
     sc1.setDesiredStackVersion(new StackId("HDP-0.1"));
     sc1.setDesiredState(State.UNINSTALLED);
 
@@ -2443,15 +2439,6 @@ public class AmbariManagementControllerTest {
     sc7.setDesiredState(State.UNINSTALLED);
     sc8.setDesiredState(State.UNINSTALLED);
 
-    sc1.persist();
-    sc2.persist();
-    sc3.persist();
-    sc4.persist();
-    sc5.persist();
-    sc6.persist();
-    sc7.persist();
-    sc8.persist();
-
     ServiceComponentRequest r = new ServiceComponentRequest(null, null,
         null, null);
 
@@ -2529,7 +2516,6 @@ public class AmbariManagementControllerTest {
     ServiceComponent sc1 = serviceComponentFactory.createNew(s1, "DATANODE");
     s1.addServiceComponent(sc1);
     sc1.setDesiredState(State.UNINSTALLED);
-    sc1.persist();
     ServiceComponentHost sch1 = serviceComponentHostFactory.createNew(sc1, host1);
     sc1.addServiceComponentHost(sch1);
     sch1.setDesiredState(State.INSTALLED);
@@ -2953,10 +2939,6 @@ public class AmbariManagementControllerTest {
     sc1.setDesiredState(State.UNINSTALLED);
     sc3.setDesiredState(State.UNINSTALLED);
 
-    sc1.persist();
-    sc2.persist();
-    sc3.persist();
-
     ServiceComponentHost sch1 = serviceComponentHostFactory.createNew(sc1, host1);
     ServiceComponentHost sch2 = serviceComponentHostFactory.createNew(sc1, host2);
     ServiceComponentHost sch3 = serviceComponentHostFactory.createNew(sc1, host3);
@@ -4260,11 +4242,11 @@ public class AmbariManagementControllerTest {
     Service hdfs = cluster.addService("HDFS");
     Service mapred = cluster.addService("YARN");
 
-    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
+    hdfs.addServiceComponent(Role.NAMENODE.name());
+    hdfs.addServiceComponent(Role.DATANODE.name());
 
-    mapred.addServiceComponent(Role.RESOURCEMANAGER.name()).persist();
+    mapred.addServiceComponent(Role.RESOURCEMANAGER.name());
 
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(host1).persist();
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(host1).persist();
@@ -4425,9 +4407,9 @@ public class AmbariManagementControllerTest {
 
     Service hdfs = cluster.addService("HDFS");
 
-    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
+    hdfs.addServiceComponent(Role.NAMENODE.name());
+    hdfs.addServiceComponent(Role.DATANODE.name());
 
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(host1).persist();
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(host1).persist();
@@ -4535,11 +4517,11 @@ public class AmbariManagementControllerTest {
     Service hdfs = cluster.addService("HDFS");
     Service hive = cluster.addService("HIVE");
 
-    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
+    hdfs.addServiceComponent(Role.NAMENODE.name());
+    hdfs.addServiceComponent(Role.DATANODE.name());
 
-    hive.addServiceComponent(Role.HIVE_SERVER.name()).persist();
+    hive.addServiceComponent(Role.HIVE_SERVER.name());
 
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(host1).persist();
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(host1).persist();
@@ -4819,8 +4801,8 @@ public class AmbariManagementControllerTest {
     Service hdfs = cluster.addService("HDFS");
     Service mapReduce = cluster.addService("MAPREDUCE");
 
-    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
-    mapReduce.addServiceComponent(Role.MAPREDUCE_CLIENT.name()).persist();
+    hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
+    mapReduce.addServiceComponent(Role.MAPREDUCE_CLIENT.name());
 
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(host1).persist();
     mapReduce.getServiceComponent(Role.MAPREDUCE_CLIENT.name()).addServiceComponentHost(host2).persist();
@@ -6498,11 +6480,11 @@ public class AmbariManagementControllerTest {
     Service hdfs = cluster.addService("HDFS");
     Service mapred = cluster.addService("YARN");
 
-    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
+    hdfs.addServiceComponent(Role.NAMENODE.name());
+    hdfs.addServiceComponent(Role.DATANODE.name());
 
-    mapred.addServiceComponent(Role.RESOURCEMANAGER.name()).persist();
+    mapred.addServiceComponent(Role.RESOURCEMANAGER.name());
 
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(host1).persist();
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(host1).persist();
@@ -6604,11 +6586,11 @@ public class AmbariManagementControllerTest {
     Service hdfs = cluster.addService("HDFS");
     Service mapred = cluster.addService("YARN");
 
-    hdfs.addServiceComponent(Role.HDFS_CLIENT.name()).persist();
-    hdfs.addServiceComponent(Role.NAMENODE.name()).persist();
-    hdfs.addServiceComponent(Role.DATANODE.name()).persist();
+    hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
+    hdfs.addServiceComponent(Role.NAMENODE.name());
+    hdfs.addServiceComponent(Role.DATANODE.name());
 
-    mapred.addServiceComponent(Role.RESOURCEMANAGER.name()).persist();
+    mapred.addServiceComponent(Role.RESOURCEMANAGER.name());
 
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(host1).persist();
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(host1).persist();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java b/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
index 4066d8f..43de27f 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/events/EventsTest.java
@@ -387,7 +387,6 @@ public class EventsTest {
     ServiceComponent component = m_componentFactory.createNew(service, "DATANODE");
     service.addServiceComponent(component);
     component.setDesiredState(State.INSTALLED);
-    component.persist();
 
     ServiceComponentHost sch = m_schFactory.createNew(component, HOSTNAME);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
index 1d1f77e..fffda6c 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/orm/OrmTestHelper.java
@@ -438,7 +438,6 @@ public class OrmTestHelper {
 
     service.addServiceComponent(datanode);
     datanode.setDesiredState(State.INSTALLED);
-    datanode.persist();
 
     ServiceComponentHost sch = schFactory.createNew(datanode, hostName);
 
@@ -454,7 +453,6 @@ public class OrmTestHelper {
 
     service.addServiceComponent(namenode);
     namenode.setDesiredState(State.INSTALLED);
-    namenode.persist();
 
     sch = schFactory.createNew(namenode, hostName);
     namenode.addServiceComponentHost(sch);
@@ -483,7 +481,6 @@ public class OrmTestHelper {
 
     service.addServiceComponent(resourceManager);
     resourceManager.setDesiredState(State.INSTALLED);
-    resourceManager.persist();
 
     ServiceComponentHost sch = schFactory.createNew(resourceManager, hostName);
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
index 3a597fd..6d19113 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/ComponentVersionCheckActionTest.java
@@ -389,7 +389,6 @@ public class ComponentVersionCheckActionTest {
       serviceComponent = serviceComponentFactory.createNew(service, componentName);
       service.addServiceComponent(serviceComponent);
       serviceComponent.setDesiredState(State.INSTALLED);
-      serviceComponent.persist();
     }
 
     return serviceComponent;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
index 30eb149..60027c2 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/upgrades/UpgradeActionTest.java
@@ -1034,7 +1034,6 @@ public class UpgradeActionTest {
       serviceComponent = serviceComponentFactory.createNew(service, componentName);
       service.addServiceComponent(serviceComponent);
       serviceComponent.setDesiredState(State.INSTALLED);
-      serviceComponent.persist();
     }
 
     return serviceComponent;

http://git-wip-us.apache.org/repos/asf/ambari/blob/d6a84715/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
index 8d16e3f..59bb393 100644
--- a/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
+++ b/ambari-server/src/test/java/org/apache/ambari/server/state/ServiceComponentTest.java
@@ -118,7 +118,6 @@ public class ServiceComponentTest {
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -141,7 +140,6 @@ public class ServiceComponentTest {
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -198,7 +196,6 @@ public class ServiceComponentTest {
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -299,7 +296,6 @@ public class ServiceComponentTest {
     ServiceComponent component = serviceComponentFactory.createNew(service,
         componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     addHostToCluster("h1", service.getCluster().getClusterName());
     ServiceComponentHost sch =
@@ -376,7 +372,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -427,7 +422,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -495,7 +489,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -562,7 +555,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);
@@ -613,7 +605,6 @@ public class ServiceComponentTest {
     String componentName = "NAMENODE";
     ServiceComponent component = serviceComponentFactory.createNew(service, componentName);
     service.addServiceComponent(component);
-    component.persist();
 
     ServiceComponent sc = service.getServiceComponent(componentName);
     Assert.assertNotNull(sc);


Mime
View raw message