ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jonathanhur...@apache.org
Subject [29/32] ambari git commit: AMBARI-18614 - Remove Unnecessary Locks Inside Of SCH Business Object Implementations (jonathanhurley)
Date Wed, 19 Oct 2016 16:08:42 GMT
AMBARI-18614 - Remove Unnecessary Locks Inside Of SCH Business Object Implementations (jonathanhurley)


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

Branch: refs/heads/trunk
Commit: 2c6008293a664ab3b0f24a3f22be54fe0e5f1faf
Parents: aa29f56
Author: Jonathan Hurley <jhurley@hortonworks.com>
Authored: Tue Oct 18 08:21:08 2016 -0400
Committer: Jonathan Hurley <jhurley@hortonworks.com>
Committed: Tue Oct 18 08:21:08 2016 -0400

----------------------------------------------------------------------
 .../apache/ambari/server/state/HostConfig.java  |  12 +-
 .../server/state/ServiceComponentHost.java      |   6 -
 .../server/state/cluster/ClusterImpl.java       |   9 +-
 .../svccomphost/ServiceComponentHostImpl.java   | 968 +++++++------------
 .../server/agent/HeartbeatProcessorTest.java    |  54 +-
 .../server/agent/TestHeartbeatHandler.java      |  46 +-
 .../server/agent/TestHeartbeatMonitor.java      |  34 +-
 .../configuration/RecoveryConfigHelperTest.java |  22 +-
 .../AmbariManagementControllerTest.java         |  56 +-
 .../apache/ambari/server/events/EventsTest.java |   2 -
 .../apache/ambari/server/orm/OrmTestHelper.java |   7 -
 .../ComponentVersionCheckActionTest.java        |   1 -
 .../upgrades/UpgradeActionTest.java             |   2 -
 .../server/state/ServiceComponentTest.java      |  29 +-
 .../state/cluster/ClusterDeadlockTest.java      |   1 -
 .../server/state/cluster/ClusterImplTest.java   |  14 +-
 .../server/state/cluster/ClusterTest.java       |  37 -
 .../state/cluster/ClustersDeadlockTest.java     |   1 -
 .../server/state/cluster/ClustersTest.java      |   3 -
 .../ConcurrentServiceConfigVersionTest.java     |   1 -
 ...omponentHostConcurrentWriteDeadlockTest.java |   1 -
 .../svccomphost/ServiceComponentHostTest.java   |   2 -
 22 files changed, 467 insertions(+), 841 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2c600829/ambari-server/src/main/java/org/apache/ambari/server/state/HostConfig.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/HostConfig.java b/ambari-server/src/main/java/org/apache/ambari/server/state/HostConfig.java
index fc22ba5..3e767e1 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/HostConfig.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/HostConfig.java
@@ -17,12 +17,13 @@
  */
 package org.apache.ambari.server.state;
 
-import com.google.common.base.Objects;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
 import org.codehaus.jackson.annotate.JsonProperty;
 import org.codehaus.jackson.map.annotate.JsonSerialize;
 
-import java.util.HashMap;
-import java.util.Map;
+import com.google.common.base.Objects;
 
 /**
  * Data structure that hangs off of the Host and points to what tags are
@@ -30,7 +31,7 @@ import java.util.Map;
  */
 
 public class HostConfig {
-  private final Map<Long, String> configGroupOverrides = new HashMap<Long, String>();
+  private final Map<Long, String> configGroupOverrides = new ConcurrentHashMap<Long, String>();
   private String defaultVersionTag;
 
   public HostConfig() {
@@ -67,8 +68,9 @@ public class HostConfig {
       sb.append(", overrides = [ ");
       int i = 0;
       for (Map.Entry<Long, String> entry : configGroupOverrides.entrySet()) {
-        if (i++ != 0)
+        if (i++ != 0) {
           sb.append(", ");
+        }
         sb.append(entry.getKey().toString() + " : " + entry.getValue());
       }
       sb.append("]");

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c600829/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
index 586134c..e76ebf7 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/state/ServiceComponentHost.java
@@ -182,12 +182,6 @@ public interface ServiceComponentHost {
    */
   ServiceComponentHostResponse convertToResponse(Map<String, DesiredConfig> desiredConfigs);
 
-  boolean isPersisted();
-
-  void persist();
-
-  void refresh();
-
   void debugDump(StringBuilder sb);
 
   boolean canBeRemoved();

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c600829/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 5566343..84697b8 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
@@ -606,20 +606,13 @@ public class ClusterImpl implements Cluster {
   }
 
   @Override
+  @Transactional
   public void addServiceComponentHosts(Collection<ServiceComponentHost> serviceComponentHosts) throws AmbariException {
     for (ServiceComponentHost serviceComponentHost : serviceComponentHosts) {
       Service service = getService(serviceComponentHost.getServiceName());
       ServiceComponent serviceComponent = service.getServiceComponent(serviceComponentHost.getServiceComponentName());
       serviceComponent.addServiceComponentHost(serviceComponentHost);
     }
-    persistServiceComponentHosts(serviceComponentHosts);
-  }
-
-  @Transactional
-  void persistServiceComponentHosts(Collection<ServiceComponentHost> serviceComponentHosts) {
-    for (ServiceComponentHost serviceComponentHost : serviceComponentHosts) {
-      serviceComponentHost.persist();
-    }
   }
 
   public void addServiceComponentHost(ServiceComponentHost svcCompHost)

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c600829/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 a6f5040..485329b 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
@@ -19,13 +19,13 @@
 package org.apache.ambari.server.state.svccomphost;
 
 import java.text.MessageFormat;
-import java.util.ArrayList;
 import java.util.Collections;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.ReadWriteLock;
 import java.util.concurrent.locks.ReentrantReadWriteLock;
@@ -78,11 +78,12 @@ import org.apache.ambari.server.state.fsm.SingleArcTransition;
 import org.apache.ambari.server.state.fsm.StateMachine;
 import org.apache.ambari.server.state.fsm.StateMachineFactory;
 import org.apache.ambari.server.state.stack.upgrade.RepositoryVersionHelper;
+import org.jboss.netty.util.internal.ConcurrentHashMap;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.collect.ImmutableList;
 import com.google.inject.Inject;
-import com.google.inject.Injector;
 import com.google.inject.assistedinject.Assisted;
 import com.google.inject.assistedinject.AssistedInject;
 import com.google.inject.persist.Transactional;
@@ -93,31 +94,33 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
       LoggerFactory.getLogger(ServiceComponentHostImpl.class);
 
   private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
-  private final Lock readLock = readWriteLock.readLock();
   private final Lock writeLock = readWriteLock.writeLock();
 
   private final ServiceComponent serviceComponent;
+
   private final Host host;
-  private volatile boolean persisted = false;
+
+  private final HostComponentStateDAO hostComponentStateDAO;
+
+  private final HostComponentDesiredStateDAO hostComponentDesiredStateDAO;
+
+  private final HostDAO hostDAO;
 
   @Inject
-  HostComponentStateDAO hostComponentStateDAO;
-  @Inject
-  HostComponentDesiredStateDAO hostComponentDesiredStateDAO;
-  @Inject
-  HostDAO hostDAO;
-  @Inject
-  RepositoryVersionDAO repositoryVersionDAO;
-  @Inject
-  ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO;
-  @Inject
-  Clusters clusters;
+  private RepositoryVersionDAO repositoryVersionDAO;
+
+  private final ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO;
+
+  private final Clusters clusters;
+
   @Inject
-  ConfigHelper helper;
+  private ConfigHelper helper;
+
   @Inject
-  AmbariMetaInfo ambariMetaInfo;
+  private AmbariMetaInfo ambariMetaInfo;
+
   @Inject
-  RepositoryVersionHelper repositoryVersionHelper;
+  private RepositoryVersionHelper repositoryVersionHelper;
 
   /**
    * Used for creating commands to send to the agents when alert definitions are
@@ -129,18 +132,12 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
   /**
    * Used to publish events relating to service CRUD operations.
    */
-  @Inject
-  private AmbariEventPublisher eventPublisher;
+  private final AmbariEventPublisher eventPublisher;
 
   /**
    * Data access object for stack.
    */
-  @Inject
-  private StackDAO stackDAO;
-
-  // Only used when object state is not persisted
-  private HostComponentStateEntity stateEntity;
-  private HostComponentDesiredStateEntity desiredStateEntity;
+  private final StackDAO stackDAO;
 
   /**
    * The desired component state entity PK.
@@ -150,14 +147,19 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
   /**
    * Cache the generated id for host component state for fast lookups.
    */
-  private Long hostComponentStateId;
+  private final Long hostComponentStateId;
 
   private long lastOpStartTime;
   private long lastOpEndTime;
   private long lastOpLastUpdateTime;
-  private Map<String, HostConfig> actualConfigs = new HashMap<String,
-    HostConfig>();
-  private List<Map<String, String>> processes = new ArrayList<Map<String, String>>();
+
+  private ConcurrentMap<String, HostConfig> actualConfigs = new ConcurrentHashMap<>();
+  private ImmutableList<Map<String, String>> processes = ImmutableList.of();
+
+  /**
+   * The name of the host (which should never, ever change)
+   */
+  private final String hostName;
 
   private static final StateMachineFactory
   <ServiceComponentHostImpl, State,
@@ -698,14 +700,9 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
   }
 
   private void resetLastOpInfo() {
-    try {
-      writeLock.lock();
-      setLastOpStartTime(-1);
-      setLastOpLastUpdateTime(-1);
-      setLastOpEndTime(-1);
-    } finally {
-      writeLock.unlock();
-    }
+    setLastOpStartTime(-1);
+    setLastOpLastUpdateTime(-1);
+    setLastOpEndTime(-1);
   }
 
   private void updateLastOpInfo(ServiceComponentHostEventType eventType,
@@ -740,8 +737,21 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
   @AssistedInject
   public ServiceComponentHostImpl(@Assisted ServiceComponent serviceComponent,
-                                  @Assisted String hostName, Injector injector) {
-    injector.injectMembers(this);
+      @Assisted String hostName, Clusters clusters, StackDAO stackDAO, HostDAO hostDAO,
+      ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO,
+      HostComponentStateDAO hostComponentStateDAO,
+      HostComponentDesiredStateDAO hostComponentDesiredStateDAO,
+      AmbariEventPublisher eventPublisher) {
+
+    this.serviceComponent = serviceComponent;
+    this.hostName = hostName;
+    this.clusters = clusters;
+    this.stackDAO = stackDAO;
+    this.hostDAO = hostDAO;
+    this.serviceComponentDesiredStateDAO = serviceComponentDesiredStateDAO;
+    this.hostComponentStateDAO = hostComponentStateDAO;
+    this.hostComponentDesiredStateDAO = hostComponentDesiredStateDAO;
+    this.eventPublisher = eventPublisher;
 
     if (serviceComponent.isClientComponent()) {
       stateMachine = clientStateMachineFactory.make(this);
@@ -749,8 +759,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
       stateMachine = daemonStateMachineFactory.make(this);
     }
 
-    this.serviceComponent = serviceComponent;
-
     HostEntity hostEntity = null;
     try {
       host = clusters.getHost(hostName);
@@ -767,7 +775,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
     StackEntity stackEntity = stackDAO.find(stackId.getStackName(),
         stackId.getStackVersion());
 
-    stateEntity = new HostComponentStateEntity();
+    HostComponentStateEntity stateEntity = new HostComponentStateEntity();
     stateEntity.setClusterId(serviceComponent.getClusterId());
     stateEntity.setComponentName(serviceComponent.getName());
     stateEntity.setServiceName(serviceComponent.getServiceName());
@@ -777,7 +785,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
     stateEntity.setUpgradeState(UpgradeState.NONE);
     stateEntity.setCurrentStack(stackEntity);
 
-    desiredStateEntity = new HostComponentDesiredStateEntity();
+    HostComponentDesiredStateEntity desiredStateEntity = new HostComponentDesiredStateEntity();
     desiredStateEntity.setClusterId(serviceComponent.getClusterId());
     desiredStateEntity.setComponentName(serviceComponent.getName());
     desiredStateEntity.setServiceName(serviceComponent.getServiceName());
@@ -793,19 +801,40 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
     desiredStateEntityPK = getHostComponentDesiredStateEntityPK(desiredStateEntity);
 
+    persistEntities(hostEntity, stateEntity, desiredStateEntity);
+
+    // publish the service component installed event
+    ServiceComponentInstalledEvent event = new ServiceComponentInstalledEvent(getClusterId(),
+        stackId.getStackName(), stackId.getStackVersion(), getServiceName(),
+        getServiceComponentName(), getHostName(), isRecoveryEnabled());
+
+    eventPublisher.publish(event);
+
+    hostComponentStateId = stateEntity.getId();
+
     resetLastOpInfo();
   }
 
   @AssistedInject
   public ServiceComponentHostImpl(@Assisted ServiceComponent serviceComponent,
-                                  @Assisted HostComponentStateEntity stateEntity,
-                                  @Assisted HostComponentDesiredStateEntity desiredStateEntity,
-                                  Injector injector) {
-    injector.injectMembers(this);
-    this.serviceComponent = serviceComponent;
+      @Assisted HostComponentStateEntity stateEntity,
+      @Assisted HostComponentDesiredStateEntity desiredStateEntity, Clusters clusters,
+      StackDAO stackDAO, HostDAO hostDAO,
+      ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO,
+      HostComponentStateDAO hostComponentStateDAO,
+      HostComponentDesiredStateDAO hostComponentDesiredStateDAO,
+      AmbariEventPublisher eventPublisher) {
+
+    hostName = stateEntity.getHostName();
 
-    this.desiredStateEntity = desiredStateEntity;
-    this.stateEntity = stateEntity;
+    this.serviceComponent = serviceComponent;
+    this.clusters = clusters;
+    this.stackDAO = stackDAO;
+    this.hostDAO = hostDAO;
+    this.serviceComponentDesiredStateDAO = serviceComponentDesiredStateDAO;
+    this.hostComponentStateDAO = hostComponentStateDAO;
+    this.hostComponentDesiredStateDAO = hostComponentDesiredStateDAO;
+    this.eventPublisher = eventPublisher;
 
     desiredStateEntityPK = getHostComponentDesiredStateEntityPK(desiredStateEntity);
     hostComponentStateId = stateEntity.getId();
@@ -825,8 +854,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
       LOG.error("Host '{}' was not found " + stateEntity.getHostName());
       throw new RuntimeException(e);
     }
-
-    persisted = true;
   }
 
   @Override
@@ -838,119 +865,81 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
   @Override
   public void setState(State state) {
-    writeLock.lock();
-    try {
-      stateMachine.setCurrentState(state);
-      HostComponentStateEntity stateEntity = getStateEntity();
-      if (stateEntity != null) {
-        getStateEntity().setCurrentState(state);
-        saveComponentStateEntityIfPersisted();
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      writeLock.unlock();
+    stateMachine.setCurrentState(state);
+    HostComponentStateEntity stateEntity = getStateEntity();
+    if (stateEntity != null) {
+      stateEntity.setCurrentState(state);
+      stateEntity = hostComponentStateDAO.merge(stateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
   }
 
   @Override
   public String getVersion() {
-    readLock.lock();
-    try {
-      HostComponentStateEntity stateEntity = getStateEntity();
-      if (stateEntity != null) {
-        return stateEntity.getVersion();
-      } else {
-        LOG.warn("Trying to fetch a member from an entity object that may " +
-          "have been previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-    } finally {
-      readLock.unlock();
+    HostComponentStateEntity stateEntity = getStateEntity();
+    if (stateEntity != null) {
+      return stateEntity.getVersion();
+    } else {
+      LOG.warn("Trying to fetch a member from an entity object that may "
+          + "have been previously deleted, serviceName = " + getServiceName() + ", "
+          + "componentName = " + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
+
     return null;
   }
 
   @Override
   public void setVersion(String version) {
-    writeLock.lock();
-    try {
-      HostComponentStateEntity stateEntity = getStateEntity();
-      if (stateEntity != null) {
-        getStateEntity().setVersion(version);
-        saveComponentStateEntityIfPersisted();
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-    } finally {
-      writeLock.unlock();
+    HostComponentStateEntity stateEntity = getStateEntity();
+    if (stateEntity != null) {
+      stateEntity.setVersion(version);
+      stateEntity = hostComponentStateDAO.merge(stateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
   }
 
   @Override
   public SecurityState getSecurityState() {
-    readLock.lock();
-    try {
-      HostComponentStateEntity stateEntity = getStateEntity();
-      if (stateEntity != null) {
-        return getStateEntity().getSecurityState();
-      } else {
-        LOG.warn("Trying to fetch a member from an entity object that may " +
-          "have been previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      readLock.unlock();
+    HostComponentStateEntity stateEntity = getStateEntity();
+    if (stateEntity != null) {
+      return stateEntity.getSecurityState();
+    } else {
+      LOG.warn("Trying to fetch a member from an entity object that may "
+          + "have been previously deleted, serviceName = " + getServiceName() + ", "
+          + "componentName = " + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
+
     return null;
   }
 
   @Override
   public void setSecurityState(SecurityState securityState) {
-    writeLock.lock();
-    try {
-      HostComponentStateEntity stateEntity = getStateEntity();
-      if (stateEntity != null) {
-        getStateEntity().setSecurityState(securityState);
-        saveComponentStateEntityIfPersisted();
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      writeLock.unlock();
+    HostComponentStateEntity stateEntity = getStateEntity();
+    if (stateEntity != null) {
+      stateEntity.setSecurityState(securityState);
+      stateEntity = hostComponentStateDAO.merge(stateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
   }
 
   @Override
   public SecurityState getDesiredSecurityState() {
-    readLock.lock();
-    try {
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        return getDesiredStateEntity().getSecurityState();
-      } else {
-        LOG.warn("Trying to fetch a member from an entity object that may " +
-          "have been previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      readLock.unlock();
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      return desiredStateEntity.getSecurityState();
+    } else {
+      LOG.warn("Trying to fetch a member from an entity object that may "
+          + "have been previously deleted, serviceName = " + getServiceName() + ", "
+          + "componentName = " + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
     return null;
   }
@@ -961,16 +950,12 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
       throw new AmbariException("The security state must be an endpoint state");
     }
 
-    writeLock.lock();
-    try {
-      LOG.debug("Set DesiredSecurityState on serviceName = {} componentName = {} hostName = {} to {}",
+    LOG.debug("Set DesiredSecurityState on serviceName = {} componentName = {} hostName = {} to {}",
         getServiceName(), getServiceComponentName(), getHostName(), securityState);
 
-      getDesiredStateEntity().setSecurityState(securityState);
-      saveComponentDesiredStateEntityIfPersisted();
-    } finally {
-      writeLock.unlock();
-    }
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    desiredStateEntity.setSecurityState(securityState);
+    hostComponentDesiredStateDAO.merge(desiredStateEntity);
   }
 
   /**
@@ -984,41 +969,26 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
    */
   @Override
   public void setUpgradeState(UpgradeState upgradeState) {
-    writeLock.lock();
-    try {
-      HostComponentStateEntity stateEntity = getStateEntity();
-      if (stateEntity != null) {
-        stateEntity.setUpgradeState(upgradeState);
-        saveComponentStateEntityIfPersisted();
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      writeLock.unlock();
+    HostComponentStateEntity stateEntity = getStateEntity();
+    if (stateEntity != null) {
+      stateEntity.setUpgradeState(upgradeState);
+      stateEntity = hostComponentStateDAO.merge(stateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
   }
 
   @Override
   public UpgradeState getUpgradeState() {
-    readLock.lock();
-
-    try {
-      HostComponentStateEntity stateEntity = getStateEntity();
-      if (stateEntity != null) {
-        return stateEntity.getUpgradeState();
-      } else {
-        LOG.warn("Trying to fetch a state entity from an object that may " +
-          "have been previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      readLock.unlock();
+    HostComponentStateEntity stateEntity = getStateEntity();
+    if (stateEntity != null) {
+      return stateEntity.getUpgradeState();
+    } else {
+      LOG.warn("Trying to fetch a state entity from an object that may "
+          + "have been previously deleted, serviceName = " + getServiceName() + ", "
+          + "componentName = " + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
 
     return UpgradeState.NONE;
@@ -1038,8 +1008,9 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
       writeLock.lock();
       try {
         stateMachine.doTransition(event.getType(), event);
-        getStateEntity().setCurrentState(stateMachine.getCurrentState());
-        saveComponentStateEntityIfPersisted();
+        HostComponentStateEntity stateEntity = getStateEntity();
+        stateEntity.setCurrentState(stateMachine.getCurrentState());
+        stateEntity = hostComponentStateDAO.merge(stateEntity);
         // TODO Audit logs
       } catch (InvalidStateTransitionException e) {
         LOG.error("Can't handle ServiceComponentHostEvent event at"
@@ -1092,72 +1063,42 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
    * @return the lastOpStartTime
    */
   public long getLastOpStartTime() {
-    readLock.lock();
-    try {
-      return lastOpStartTime;
-    } finally {
-      readLock.unlock();
-    }
+    return lastOpStartTime;
   }
 
   /**
    * @param lastOpStartTime the lastOpStartTime to set
    */
   public void setLastOpStartTime(long lastOpStartTime) {
-    writeLock.lock();
-    try {
-      this.lastOpStartTime = lastOpStartTime;
-    } finally {
-      writeLock.unlock();
-    }
+    this.lastOpStartTime = lastOpStartTime;
   }
 
   /**
    * @return the lastOpEndTime
    */
   public long getLastOpEndTime() {
-    readLock.lock();
-    try {
-      return lastOpEndTime;
-    } finally {
-      readLock.unlock();
-    }
+    return lastOpEndTime;
   }
 
   /**
    * @param lastOpEndTime the lastOpEndTime to set
    */
   public void setLastOpEndTime(long lastOpEndTime) {
-    writeLock.lock();
-    try {
-      this.lastOpEndTime = lastOpEndTime;
-    } finally {
-      writeLock.unlock();
-    }
+    this.lastOpEndTime = lastOpEndTime;
   }
 
   /**
    * @return the lastOpLastUpdateTime
    */
   public long getLastOpLastUpdateTime() {
-    readLock.lock();
-    try {
-      return lastOpLastUpdateTime;
-    } finally {
-      readLock.unlock();
-    }
+    return lastOpLastUpdateTime;
   }
 
   /**
    * @param lastOpLastUpdateTime the lastOpLastUpdateTime to set
    */
   public void setLastOpLastUpdateTime(long lastOpLastUpdateTime) {
-    writeLock.lock();
-    try {
-      this.lastOpLastUpdateTime = lastOpLastUpdateTime;
-    } finally {
-      writeLock.unlock();
-    }
+    this.lastOpLastUpdateTime = lastOpLastUpdateTime;
   }
 
   @Override
@@ -1177,220 +1118,163 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
   @Override
   public StackId getStackVersion() {
-    readLock.lock();
-    try {
-      HostComponentStateEntity schStateEntity = stateEntity;
-      if (schStateEntity == null) {
-        return new StackId();
-      }
-
-      StackEntity currentStackEntity = schStateEntity.getCurrentStack();
-      return new StackId(currentStackEntity.getStackName(),
-          currentStackEntity.getStackVersion());
-    } finally {
-      readLock.unlock();
+    HostComponentStateEntity schStateEntity = getStateEntity();
+    if (schStateEntity == null) {
+      return new StackId();
     }
+
+    StackEntity currentStackEntity = schStateEntity.getCurrentStack();
+    return new StackId(currentStackEntity.getStackName(), currentStackEntity.getStackVersion());
   }
 
   @Override
   public void setStackVersion(StackId stackId) {
     StackEntity stackEntity = stackDAO.find(stackId.getStackName(), stackId.getStackVersion());
 
-    writeLock.lock();
-    try {
-      HostComponentStateEntity stateEntity = getStateEntity();
-      if (stateEntity != null) {
-        stateEntity.setCurrentStack(stackEntity);
-        saveComponentStateEntityIfPersisted();
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      writeLock.unlock();
+    HostComponentStateEntity stateEntity = getStateEntity();
+    if (stateEntity != null) {
+      stateEntity.setCurrentStack(stackEntity);
+      stateEntity = hostComponentStateDAO.merge(stateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
   }
 
   @Override
   public State getDesiredState() {
-    readLock.lock();
-    try {
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        return desiredStateEntity.getDesiredState();
-      } else {
-        LOG.warn("Trying to fetch a member from an entity object that may " +
-          "have been previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      readLock.unlock();
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      return desiredStateEntity.getDesiredState();
+    } else {
+      LOG.warn("Trying to fetch a member from an entity object that may "
+          + "have been previously deleted, serviceName = " + getServiceName() + ", "
+          + "componentName = " + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
+
     return null;
   }
 
   @Override
   public void setDesiredState(State state) {
-    writeLock.lock();
-    try {
-      LOG.debug("Set DesiredState on serviceName = {} componentName = {} hostName = {} to {} ",
+    LOG.debug("Set DesiredState on serviceName = {} componentName = {} hostName = {} to {} ",
         getServiceName(), getServiceComponentName(), getHostName(), state);
 
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        desiredStateEntity.setDesiredState(state);
-        saveComponentDesiredStateEntityIfPersisted();
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() +
-          "hostName = " + getHostName());
-      }
-    } finally {
-      writeLock.unlock();
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      desiredStateEntity.setDesiredState(state);
+      hostComponentDesiredStateDAO.merge(desiredStateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + "hostName = " + getHostName());
     }
   }
 
   @Override
   public StackId getDesiredStackVersion() {
-    readLock.lock();
-    try {
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        StackEntity desiredStackEntity = desiredStateEntity.getDesiredStack();
-        return new StackId(desiredStackEntity.getStackName(),
-          desiredStackEntity.getStackVersion());
-      } else {
-        LOG.warn("Trying to fetch a member from an entity object that may " +
-          "have been previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() + ", " +
-          "hostName = " + getHostName());
-      }
-
-    } finally {
-      readLock.unlock();
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      StackEntity desiredStackEntity = desiredStateEntity.getDesiredStack();
+      return new StackId(desiredStackEntity.getStackName(), desiredStackEntity.getStackVersion());
+    } else {
+      LOG.warn("Trying to fetch a member from an entity object that may "
+          + "have been previously deleted, serviceName = " + getServiceName() + ", "
+          + "componentName = " + getServiceComponentName() + ", " + "hostName = " + getHostName());
     }
     return null;
   }
 
   @Override
   public void setDesiredStackVersion(StackId stackId) {
-    writeLock.lock();
-    try {
-      LOG.debug("Set DesiredStackVersion on serviceName = {} componentName = {} hostName = {} to {}",
+    LOG.debug("Set DesiredStackVersion on serviceName = {} componentName = {} hostName = {} to {}",
         getServiceName(), getServiceComponentName(), getHostName(), stackId);
 
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        StackEntity stackEntity = stackDAO.find(stackId.getStackName(),
-          stackId.getStackVersion());
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      StackEntity stackEntity = stackDAO.find(stackId.getStackName(), stackId.getStackVersion());
 
-        desiredStateEntity.setDesiredStack(stackEntity);
-        saveComponentDesiredStateEntityIfPersisted();
-      }
-    } finally {
-      writeLock.unlock();
+      desiredStateEntity.setDesiredStack(stackEntity);
+      hostComponentDesiredStateDAO.merge(desiredStateEntity);
     }
   }
 
   @Override
   public HostComponentAdminState getComponentAdminState() {
-    readLock.lock();
-    try {
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        HostComponentAdminState adminState = desiredStateEntity.getAdminState();
-        if (adminState == null && !serviceComponent.isClientComponent()
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      HostComponentAdminState adminState = desiredStateEntity.getAdminState();
+      if (adminState == null && !serviceComponent.isClientComponent()
           && !serviceComponent.isMasterComponent()) {
-          adminState = HostComponentAdminState.INSERVICE;
-        }
-        return adminState;
+        adminState = HostComponentAdminState.INSERVICE;
       }
-
-    } finally {
-      readLock.unlock();
+      return adminState;
     }
+
     return null;
   }
 
   @Override
   public void setComponentAdminState(HostComponentAdminState attribute) {
-    writeLock.lock();
-    try {
-      LOG.debug("Set ComponentAdminState on serviceName = {} componentName = {} hostName = {} to {}",
+    LOG.debug("Set ComponentAdminState on serviceName = {} componentName = {} hostName = {} to {}",
         getServiceName(), getServiceComponentName(), getHostName(), attribute);
 
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        desiredStateEntity.setAdminState(attribute);
-        saveComponentDesiredStateEntityIfPersisted();
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() +
-          "hostName = " + getHostName());
-      }
-    } finally {
-      writeLock.unlock();
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      desiredStateEntity.setAdminState(attribute);
+      hostComponentDesiredStateDAO.merge(desiredStateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + "hostName = " + getHostName());
     }
   }
 
   @Override
   public ServiceComponentHostResponse convertToResponse(Map<String, DesiredConfig> desiredConfigs) {
-    readLock.lock();
-    try {
-      HostComponentStateEntity hostComponentStateEntity = getStateEntity();
-      if (null == hostComponentStateEntity) {
-        LOG.warn(
-            "Could not convert ServiceComponentHostResponse to a response. It's possible that Host {} was deleted.",
-            getHostName());
-        return null;
-      }
+    HostComponentStateEntity hostComponentStateEntity = getStateEntity();
+    if (null == hostComponentStateEntity) {
+      LOG.warn(
+          "Could not convert ServiceComponentHostResponse to a response. It's possible that Host {} was deleted.",
+          getHostName());
+      return null;
+    }
 
-      String clusterName = serviceComponent.getClusterName();
-      String serviceName = serviceComponent.getServiceName();
-      String serviceComponentName = serviceComponent.getName();
-      String hostName = getHostName();
-      String state = getState().toString();
-      String stackId = getStackVersion().getStackId();
-      String desiredState = getDesiredState().toString();
-      String desiredStackId = getDesiredStackVersion().getStackId();
-      HostComponentAdminState componentAdminState = getComponentAdminState();
-      UpgradeState upgradeState = hostComponentStateEntity.getUpgradeState();
-
-      String displayName = null;
-      try {
-        ComponentInfo compInfo = ambariMetaInfo.getComponent(getStackVersion().getStackName(),
-          getStackVersion().getStackVersion(), serviceName, serviceComponentName);
-        displayName = compInfo.getDisplayName();
-      } catch (AmbariException e) {
-        displayName = serviceComponentName;
-      }
+    String clusterName = serviceComponent.getClusterName();
+    String serviceName = serviceComponent.getServiceName();
+    String serviceComponentName = serviceComponent.getName();
+    String hostName = getHostName();
+    String state = getState().toString();
+    String stackId = getStackVersion().getStackId();
+    String desiredState = getDesiredState().toString();
+    String desiredStackId = getDesiredStackVersion().getStackId();
+    HostComponentAdminState componentAdminState = getComponentAdminState();
+    UpgradeState upgradeState = hostComponentStateEntity.getUpgradeState();
 
-      ServiceComponentHostResponse r = new ServiceComponentHostResponse(
-          clusterName, serviceName,
-          serviceComponentName, displayName, hostName, state,
-          stackId, desiredState,
-          desiredStackId, componentAdminState);
+    String displayName = null;
+    try {
+      ComponentInfo compInfo = ambariMetaInfo.getComponent(getStackVersion().getStackName(),
+          getStackVersion().getStackVersion(), serviceName, serviceComponentName);
+      displayName = compInfo.getDisplayName();
+    } catch (AmbariException e) {
+      displayName = serviceComponentName;
+    }
 
-      r.setActualConfigs(actualConfigs);
-      r.setUpgradeState(upgradeState);
+    ServiceComponentHostResponse r = new ServiceComponentHostResponse(clusterName, serviceName,
+        serviceComponentName, displayName, hostName, state, stackId, desiredState, desiredStackId,
+        componentAdminState);
 
-      try {
-        r.setStaleConfig(helper.isStaleConfigs(this, desiredConfigs));
-      } catch (Exception e) {
-        LOG.error("Could not determine stale config", e);
-      }
+    r.setActualConfigs(actualConfigs);
+    r.setUpgradeState(upgradeState);
 
-      return r;
-    } finally {
-      readLock.unlock();
+    try {
+      r.setStaleConfig(helper.isStaleConfigs(this, desiredConfigs));
+    } catch (Exception e) {
+      LOG.error("Could not determine stale config", e);
     }
+
+    return r;
   }
 
   @Override
@@ -1400,79 +1284,35 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
   @Override
   public void debugDump(StringBuilder sb) {
-    readLock.lock();
-    try {
-      sb.append("ServiceComponentHost={ hostname=").append(getHostName()).append(
-          ", serviceComponentName=").append(serviceComponent.getName()).append(
-          ", clusterName=").append(serviceComponent.getClusterName()).append(
-          ", serviceName=").append(serviceComponent.getServiceName()).append(
-          ", desiredStackVersion=").append(getDesiredStackVersion()).append(
-          ", desiredState=").append(getDesiredState()).append(", stackVersion=").append(
-          getStackVersion()).append(", state=").append(getState()).append(
-          ", securityState=").append(getSecurityState()).append(
-          ", desiredSecurityState=").append(getDesiredSecurityState()).append(
-        " }");
-    } finally {
-      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
-  public void persist() {
-    writeLock.lock();
-    try {
-      if (!persisted) {
-        // persist the new cluster topology
-        persistEntities();
-        persisted = true;
-
-        refresh();
-
-        // publish the service component installed event
-        StackId stackId = getDesiredStackVersion();
-
-        ServiceComponentInstalledEvent event = new ServiceComponentInstalledEvent(getClusterId(),
-            stackId.getStackName(), stackId.getStackVersion(), getServiceName(),
-            getServiceComponentName(), getHostName(), isRecoveryEnabled());
-
-        eventPublisher.publish(event);
-      } else {
-        saveComponentStateEntityIfPersisted();
-        saveComponentDesiredStateEntityIfPersisted();
-      }
-    } finally {
-      writeLock.unlock();
-    }
+    sb.append("ServiceComponentHost={ hostname=").append(getHostName())
+    .append(", serviceComponentName=")
+    .append(serviceComponent.getName())
+    .append(", clusterName=")
+    .append(serviceComponent.getClusterName())
+    .append(", serviceName=")
+    .append(serviceComponent.getServiceName())
+    .append(", desiredStackVersion=")
+    .append(getDesiredStackVersion())
+    .append(", desiredState=")
+    .append(getDesiredState())
+    .append(", stackVersion=")
+    .append(getStackVersion())
+    .append(", state=")
+    .append(getState())
+    .append(", securityState=")
+    .append(getSecurityState())
+    .append(", desiredSecurityState=")
+    .append(getDesiredSecurityState())
+    .append(" }");
   }
 
   @Transactional
-  protected void persistEntities() {
+  private void persistEntities(HostEntity hostEntity, HostComponentStateEntity stateEntity,
+      HostComponentDesiredStateEntity desiredStateEntity) {
     ServiceComponentDesiredStateEntity serviceComponentDesiredStateEntity = serviceComponentDesiredStateDAO.findByName(
         serviceComponent.getClusterId(), serviceComponent.getServiceName(),
         serviceComponent.getName());
 
-    HostEntity hostEntity = hostDAO.findByName(getHostName());
-    hostEntity.addHostComponentStateEntity(stateEntity);
-    hostEntity.addHostComponentDesiredStateEntity(desiredStateEntity);
-
     desiredStateEntity.setServiceComponentDesiredStateEntity(serviceComponentDesiredStateEntity);
     desiredStateEntity.setHostEntity(hostEntity);
 
@@ -1485,68 +1325,17 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
     serviceComponentDesiredStateEntity.getHostComponentDesiredStateEntities().add(
         desiredStateEntity);
 
-    HostComponentStateEntity stateEntity = hostComponentStateDAO.findByIndex(serviceComponent.getClusterId(),
-      serviceComponent.getServiceName(), serviceComponent.getName(), hostEntity.getHostId());
-
-    hostComponentStateId = stateEntity.getId();
-
-    serviceComponentDesiredStateDAO.merge(serviceComponentDesiredStateEntity);
-    hostDAO.merge(hostEntity);
-  }
-
-  @Override
-  public void refresh() {
-    writeLock.lock();
-    try {
-      getDesiredStateEntity();
-      getStateEntity();
-    } finally {
-      writeLock.unlock();
-    }
-  }
-
-  /**
-   * Merges the encapsulated {@link HostComponentStateEntity} inside of a new transaction. This
-   * method assumes that the appropriate write lock has already been acquired
-   * from {@link #readWriteLock}.
-   */
-  @Transactional
-  void saveComponentStateEntityIfPersisted() {
-    if (isPersisted()) {
-      hostComponentStateDAO.merge(stateEntity);
-    }
-  }
-
-  /**
-   * Merges the encapsulated {@link HostComponentDesiredStateEntity} inside of a new transaction. This
-   * method assumes that the appropriate write lock has already been acquired
-   * from {@link #readWriteLock}.
-   */
-  @Transactional
-  void saveComponentDesiredStateEntityIfPersisted() {
-    if (isPersisted()) {
-      LOG.debug("Save desiredStateEntity serviceName = {} componentName = {} hostName = {} desiredState = {}",
-        getServiceName(), getServiceComponentName(), getHostName(), desiredStateEntity.getDesiredState());
+    serviceComponentDesiredStateEntity = serviceComponentDesiredStateDAO.merge(
+        serviceComponentDesiredStateEntity);
 
-      hostComponentDesiredStateDAO.merge(desiredStateEntity);
-    }
+    hostEntity.addHostComponentStateEntity(stateEntity);
+    hostEntity.addHostComponentDesiredStateEntity(desiredStateEntity);
+    hostEntity = hostDAO.merge(hostEntity);
   }
 
-
   @Override
   public boolean canBeRemoved() {
-    boolean schLockAcquired = false;
-    try {
-      // if unable to read, then writers are writing; cannot remove SCH
-      schLockAcquired = readLock.tryLock();
-
-      return schLockAcquired && (getState().isRemovableState());
-
-    } finally {
-      if (schLockAcquired) {
-        readLock.unlock();
-      }
-    }
+    return getState().isRemovableState();
   }
 
   @Override
@@ -1555,12 +1344,8 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
     writeLock.lock();
     try {
-      if (persisted) {
-        removeEntities();
-        persisted = false;
-        fireRemovalEvent = true;
-      }
-
+      removeEntities();
+      fireRemovalEvent = true;
       clusters.getCluster(getClusterName()).removeServiceComponentHost(this);
     } catch (AmbariException ex) {
       LOG.error("Unable to remove a service component from a host", ex);
@@ -1618,56 +1403,43 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
       return;
     }
 
-    writeLock.lock();
-    try {
-      LOG.debug("Updating actual config tags: " + configTags);
-      actualConfigs = new HashMap<String, HostConfig>();
-
-      for (Entry<String, Map<String, String>> entry : configTags.entrySet()) {
-        String type = entry.getKey();
-        Map<String, String> values = new HashMap<String, String>(
-            entry.getValue());
-
-        String tag = values.get(ConfigHelper.CLUSTER_DEFAULT_TAG);
-        values.remove(ConfigHelper.CLUSTER_DEFAULT_TAG);
-
-        HostConfig hc = new HostConfig();
-        hc.setDefaultVersionTag(tag);
-        actualConfigs.put(type, hc);
-
-        if (!values.isEmpty()) {
-          for (Entry<String, String> overrideEntry : values.entrySet()) {
-            Long groupId = Long.parseLong(overrideEntry.getKey());
-            hc.getConfigGroupOverrides().put(groupId, overrideEntry.getValue());
-            if (!configGroupMap.containsKey(groupId)) {
-              LOG.debug("Config group does not exist, id = " + groupId);
-            }
+    LOG.debug("Updating configuration tags for {}: {}", hostName, configTags);
+    final ConcurrentMap<String, HostConfig> newActualConfigs = new ConcurrentHashMap<>();
+
+    for (Entry<String, Map<String, String>> entry : configTags.entrySet()) {
+      String type = entry.getKey();
+      Map<String, String> values = new HashMap<String, String>(entry.getValue());
+
+      String tag = values.get(ConfigHelper.CLUSTER_DEFAULT_TAG);
+      values.remove(ConfigHelper.CLUSTER_DEFAULT_TAG);
+
+      HostConfig hc = new HostConfig();
+      hc.setDefaultVersionTag(tag);
+      newActualConfigs.put(type, hc);
+
+      if (!values.isEmpty()) {
+        for (Entry<String, String> overrideEntry : values.entrySet()) {
+          Long groupId = Long.parseLong(overrideEntry.getKey());
+          hc.getConfigGroupOverrides().put(groupId, overrideEntry.getValue());
+          if (!configGroupMap.containsKey(groupId)) {
+            LOG.debug("Config group does not exist, id = " + groupId);
           }
         }
       }
-    } finally {
-      writeLock.unlock();
     }
+
+    // update internal stateful collection in an "atomic" manner
+    actualConfigs = newActualConfigs;
   }
 
   @Override
   public Map<String, HostConfig> getActualConfigs() {
-    readLock.lock();
-    try {
-      return actualConfigs;
-    } finally {
-      readLock.unlock();
-    }
+    return actualConfigs;
   }
 
   @Override
   public HostState getHostState() {
-    readLock.lock();
-    try {
-      return host.getState();
-    } finally {
-      readLock.unlock();
-    }
+    return host.getState();
   }
 
   @Override
@@ -1677,90 +1449,57 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
 
   @Override
   public void setMaintenanceState(MaintenanceState state) {
-    writeLock.lock();
-    try {
-      LOG.debug("Set MaintenanceState on serviceName = {} componentName = {} hostName = {} to {}",
+    LOG.debug("Set MaintenanceState on serviceName = {} componentName = {} hostName = {} to {}",
         getServiceName(), getServiceComponentName(), getHostName(), state);
 
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        desiredStateEntity.setMaintenanceState(state);
-        saveComponentDesiredStateEntityIfPersisted();
-
-        // broadcast the maintenance mode change
-        MaintenanceModeEvent event = new MaintenanceModeEvent(state, this);
-        eventPublisher.publish(event);
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() +
-          ", hostName = " + getHostName());
-      }
-    } finally {
-      writeLock.unlock();
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      desiredStateEntity.setMaintenanceState(state);
+      hostComponentDesiredStateDAO.merge(desiredStateEntity);
+
+      // broadcast the maintenance mode change
+      MaintenanceModeEvent event = new MaintenanceModeEvent(state, this);
+      eventPublisher.publish(event);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + ", hostName = " + getHostName());
     }
   }
 
   @Override
   public MaintenanceState getMaintenanceState() {
-    readLock.lock();
-    try {
-      return getDesiredStateEntity().getMaintenanceState();
-    } finally {
-      readLock.unlock();
-    }
+    return getDesiredStateEntity().getMaintenanceState();
   }
 
   @Override
   public void setProcesses(List<Map<String, String>> procs) {
-    writeLock.lock();
-    try {
-      processes = Collections.unmodifiableList(procs);
-    } finally {
-      writeLock.unlock();
-    }
+    processes = ImmutableList.copyOf(procs);
   }
 
   @Override
   public List<Map<String, String>> getProcesses() {
-    readLock.lock();
-    try {
-      return processes;
-    } finally {
-      readLock.unlock();
-    }
+    return processes;
   }
 
   @Override
   public boolean isRestartRequired() {
-    readLock.lock();
-    try {
-      return getDesiredStateEntity().isRestartRequired();
-    } finally {
-      readLock.unlock();
-    }
+    return getDesiredStateEntity().isRestartRequired();
   }
 
   @Override
   public void setRestartRequired(boolean restartRequired) {
-    writeLock.lock();
-    try {
-      LOG.debug("Set RestartRequired on serviceName = {} componentName = {} hostName = {} to {}",
+    LOG.debug("Set RestartRequired on serviceName = {} componentName = {} hostName = {} to {}",
         getServiceName(), getServiceComponentName(), getHostName(), restartRequired);
 
-      HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
-      if (desiredStateEntity != null) {
-        desiredStateEntity.setRestartRequired(restartRequired);
-        saveComponentDesiredStateEntityIfPersisted();
-      } else {
-        LOG.warn("Setting a member on an entity object that may have been " +
-          "previously deleted, serviceName = " + getServiceName() + ", " +
-          "componentName = " + getServiceComponentName() +
-          ", hostName = " + getHostName());
-      }
-
-    } finally {
-      writeLock.unlock();
+    HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
+    if (desiredStateEntity != null) {
+      desiredStateEntity.setRestartRequired(restartRequired);
+      hostComponentDesiredStateDAO.merge(desiredStateEntity);
+    } else {
+      LOG.warn("Setting a member on an entity object that may have been "
+          + "previously deleted, serviceName = " + getServiceName() + ", " + "componentName = "
+          + getServiceComponentName() + ", hostName = " + getHostName());
     }
   }
 
@@ -1815,30 +1554,27 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
     final StackId stackId = cluster.getDesiredStackVersion();
     final StackInfo stackInfo = ambariMetaInfo.getStack(stackId.getStackName(), stackId.getStackVersion());
 
-    writeLock.lock();
-    try {
-      // Check if there is a Repo Version already for the version.
-      // If it doesn't exist, will have to create it.
-      repositoryVersion = repositoryVersionDAO.findByStackNameAndVersion(stackId.getStackName(), version);
-
-      if (null == repositoryVersion) {
-        repositoryVersion = createRepositoryVersion(version, stackId, stackInfo);
-      }
+    // Check if there is a Repo Version already for the version.
+    // If it doesn't exist, will have to create it.
+    repositoryVersion = repositoryVersionDAO.findByStackNameAndVersion(stackId.getStackName(), version);
 
-      final HostEntity host = hostDAO.findById(hostId);
-      cluster.transitionHostVersionState(host, repositoryVersion, stackId);
-    } finally {
-      writeLock.unlock();
+    if (null == repositoryVersion) {
+      repositoryVersion = createRepositoryVersion(version, stackId, stackInfo);
     }
+
+    final HostEntity host = hostDAO.findById(hostId);
+    cluster.transitionHostVersionState(host, repositoryVersion, stackId);
+
     return repositoryVersion;
   }
 
-  // Get the cached desired state entity or load it fresh through the DAO.
+  /**
+   * Gets the desired state entity for this {@link ServiceComponentHost}.
+   *
+   * @return
+   */
   private HostComponentDesiredStateEntity getDesiredStateEntity() {
-    if (isPersisted()) {
-      desiredStateEntity = hostComponentDesiredStateDAO.findByPK(desiredStateEntityPK);
-    }
-    return desiredStateEntity;
+    return hostComponentDesiredStateDAO.findByPK(desiredStateEntityPK);
   }
 
   /**
@@ -1848,11 +1584,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
    *         {@link ServiceComponentHost}, or {@code null} if there is none.
    */
   private HostComponentStateEntity getStateEntity() {
-    if (isPersisted()) {
-      stateEntity = hostComponentStateDAO.findById(hostComponentStateId);
-    }
-
-    return stateEntity;
+    return hostComponentStateDAO.findById(hostComponentStateId);
   }
 
   // create a PK object from the given desired component state entity.

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c600829/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 dcffece..6ebd11a 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
@@ -160,11 +160,11 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(SECONDARY_NAMENODE);
-    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -229,7 +229,7 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(HDFS_CLIENT);
-    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -294,11 +294,11 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(SECONDARY_NAMENODE);
-    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -378,11 +378,11 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(SECONDARY_NAMENODE);
-    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -462,11 +462,11 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(SECONDARY_NAMENODE);
-    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -591,7 +591,7 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -710,7 +710,7 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -804,7 +804,7 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
 
     ActionQueue aq = new ActionQueue();
@@ -885,11 +885,11 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(HDFS_CLIENT);
-    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
 
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
         getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
@@ -969,11 +969,11 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(HDFS_CLIENT);
-    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
 
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
         getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
@@ -1089,11 +1089,11 @@ public class HeartbeatProcessorTest {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(HDFS_CLIENT);
-    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
 
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
         getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
@@ -1296,10 +1296,10 @@ public class HeartbeatProcessorTest {
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).
-        addServiceComponentHost(DummyHostname1).persist();
+        addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).
-        addServiceComponentHost(DummyHostname1).persist();
+        addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c600829/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 cd41929..e50b8c9 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
@@ -250,7 +250,7 @@ public class TestHeartbeatHandler {
     HeartBeatResponse resp = handler.handleHeartBeat(hb);
     Assert.assertFalse(resp.hasMappedComponents());
 
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
         getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
     serviceComponentHost1.setState(State.INIT);
@@ -274,10 +274,10 @@ public class TestHeartbeatHandler {
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
     hdfs.getServiceComponent(DATANODE).
-            addServiceComponentHost(DummyHostname1).persist();
+        addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
     hdfs.getServiceComponent(NAMENODE).
-            addServiceComponentHost(DummyHostname1).persist();
+        addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -386,14 +386,14 @@ public class TestHeartbeatHandler {
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
     hdfs.getServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
 
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
     hdfs.getServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
 
     hdfs.addServiceComponent(HDFS_CLIENT);
-    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
 
     Host hostObject = clusters.getHost(DummyHostname1);
     hostObject.setIPv4("ipv4");
@@ -452,15 +452,15 @@ public class TestHeartbeatHandler {
      */
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
     hdfs.getServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
 
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
     hdfs.getServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
 
     hdfs.addServiceComponent(HDFS_CLIENT).setRecoveryEnabled(true);
     hdfs.getServiceComponent(HDFS_CLIENT);
-    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
 
     Host hostObject = clusters.getHost(DummyHostname1);
     hostObject.setIPv4("ipv4");
@@ -781,11 +781,11 @@ public class TestHeartbeatHandler {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(SECONDARY_NAMENODE);
-    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -838,11 +838,11 @@ public class TestHeartbeatHandler {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(SECONDARY_NAMENODE);
-    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(SECONDARY_NAMENODE).addServiceComponentHost(DummyHostname1);
 
     ActionQueue aq = new ActionQueue();
 
@@ -912,11 +912,11 @@ public class TestHeartbeatHandler {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(HDFS_CLIENT);
-    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(HDFS_CLIENT).addServiceComponentHost(DummyHostname1);
 
     ServiceComponentHost serviceComponentHost1 = clusters.getCluster(DummyCluster).getService(HDFS).
         getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1);
@@ -989,9 +989,9 @@ public class TestHeartbeatHandler {
     Host hostObject = clusters.getHost(DummyHostname1);
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.getServiceComponent(NAMENODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
 
@@ -1070,9 +1070,9 @@ public class TestHeartbeatHandler {
     Host hostObject = clusters.getHost(DummyHostname1);
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.addServiceComponent(NAMENODE);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
     hdfs.getServiceComponent(NAMENODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
 
@@ -1404,7 +1404,7 @@ public class TestHeartbeatHandler {
     Cluster cluster = heartbeatTestHelper.getDummyCluster();
     Service hdfs = cluster.addService(HDFS);
     hdfs.addServiceComponent(DATANODE);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setState(State.STARTED);
 
     ActionQueue aq = new ActionQueue();

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c600829/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 c4d735d..76ab45c 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
@@ -169,11 +169,11 @@ public class TestHeartbeatMonitor {
     clusters.mapHostsToCluster(hostNames, clusterName);
     Service hdfs = cluster.addService(serviceName);
     hdfs.addServiceComponent(Role.DATANODE.name());
-    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.NAMENODE.name());
-    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
-    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1);
 
     hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
     hdfs.getServiceComponent(Role.NAMENODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
@@ -262,18 +262,18 @@ public class TestHeartbeatMonitor {
     Service hdfs = cluster.addService(serviceName);
     hdfs.addServiceComponent(Role.DATANODE.name());
     hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost
-      (hostname1).persist();
+    (hostname1);
     hdfs.addServiceComponent(Role.NAMENODE.name());
     hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost
-      (hostname1).persist();
+    (hostname1);
     hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
     hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).
-      addServiceComponentHost(hostname1).persist();
+        addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost
-      (hostname1).persist();
+    (hostname1);
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost
-      (hostname2).persist();
+    (hostname2);
 
     hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
     hdfs.getServiceComponent(Role.NAMENODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
@@ -369,11 +369,11 @@ public class TestHeartbeatMonitor {
 
     Service hdfs = cluster.addService(serviceName);
     hdfs.addServiceComponent(Role.DATANODE.name());
-    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.NAMENODE.name());
-    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
-    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1);
 
     hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
     hdfs.getServiceComponent(Role.NAMENODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
@@ -451,11 +451,11 @@ public class TestHeartbeatMonitor {
 
     Service hdfs = cluster.addService(serviceName);
     hdfs.addServiceComponent(Role.DATANODE.name());
-    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.NAMENODE.name());
-    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
-    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.HDFS_CLIENT.name());
     hdfs.getServiceComponent(Role.HDFS_CLIENT.name()).addServiceComponentHost(hostname1);
 
@@ -571,11 +571,11 @@ public class TestHeartbeatMonitor {
     Service hdfs = cluster.addService(serviceName);
 
     hdfs.addServiceComponent(Role.DATANODE.name());
-    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.DATANODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.NAMENODE.name());
-    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.NAMENODE.name()).addServiceComponentHost(hostname1);
     hdfs.addServiceComponent(Role.SECONDARY_NAMENODE.name());
-    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1).persist();
+    hdfs.getServiceComponent(Role.SECONDARY_NAMENODE.name()).addServiceComponentHost(hostname1);
 
     hdfs.getServiceComponent(Role.DATANODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);
     hdfs.getServiceComponent(Role.NAMENODE.name()).getServiceComponentHost(hostname1).setState(State.INSTALLED);

http://git-wip-us.apache.org/repos/asf/ambari/blob/2c600829/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 b082145..6533e1c 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
@@ -107,7 +107,7 @@ public class RecoveryConfigHelperTest {
 
   /**
    * Test cluster-env properties from a dummy cluster
-   * 
+   *
    * @throws Exception
    */
   @Test
@@ -137,7 +137,7 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
 
     // Get the recovery configuration
     RecoveryConfig recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
@@ -145,7 +145,7 @@ public class RecoveryConfigHelperTest {
 
     // Install HDFS::NAMENODE to trigger a component installed event
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
 
     // Verify that the config is stale now
     boolean isConfigStale = recoveryConfigHelper.isConfigStale(cluster.getClusterName(), DummyHostname1,
@@ -170,10 +170,10 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
 
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
 
     // Get the recovery configuration
     RecoveryConfig recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
@@ -205,7 +205,7 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
     hdfs.getServiceComponent(DATANODE).getServiceComponentHost(DummyHostname1).setDesiredState(State.INSTALLED);
 
     // Get the recovery configuration
@@ -244,10 +244,10 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
 
     hdfs.addServiceComponent(NAMENODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(NAMENODE).addServiceComponentHost(DummyHostname1);
 
     // Get the recovery configuration
     RecoveryConfig recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
@@ -278,7 +278,7 @@ public class RecoveryConfigHelperTest {
     Service hdfs = cluster.addService(HDFS);
 
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1).persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost(DummyHostname1);
 
     // Get the recovery configuration
     RecoveryConfig recoveryConfig = recoveryConfigHelper.getRecoveryConfig(cluster.getClusterName(), DummyHostname1);
@@ -321,8 +321,8 @@ public class RecoveryConfigHelperTest {
     hdfs.addServiceComponent(DATANODE).setRecoveryEnabled(true);
 
     // Add SCH to Host1 and Host2
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost("Host1").persist();
-    hdfs.getServiceComponent(DATANODE).addServiceComponentHost("Host2").persist();
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost("Host1");
+    hdfs.getServiceComponent(DATANODE).addServiceComponentHost("Host2");
 
     // Simulate registration for Host1: Get the recovery configuration right away for Host1.
     // It makes an entry for cluster name and Host1 in the timestamp dictionary.


Mime
View raw message