|
@@ -18,12 +18,14 @@
|
|
|
|
|
|
package org.apache.ambari.server.state;
|
|
|
|
|
|
-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;
|
|
|
-import com.google.inject.persist.Transactional;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
+import java.util.concurrent.ConcurrentMap;
|
|
|
+import java.util.concurrent.locks.ReadWriteLock;
|
|
|
+import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
|
+
|
|
|
import org.apache.ambari.server.AmbariException;
|
|
|
import org.apache.ambari.server.ObjectNotFoundException;
|
|
|
import org.apache.ambari.server.ServiceComponentHostNotFoundException;
|
|
@@ -46,66 +48,71 @@ import org.apache.ambari.server.state.cluster.ClusterImpl;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Map.Entry;
|
|
|
-import java.util.concurrent.locks.ReadWriteLock;
|
|
|
-import java.util.concurrent.locks.ReentrantReadWriteLock;
|
|
|
+import com.google.inject.ProvisionException;
|
|
|
+import com.google.inject.assistedinject.Assisted;
|
|
|
+import com.google.inject.assistedinject.AssistedInject;
|
|
|
+import com.google.inject.persist.Transactional;
|
|
|
|
|
|
public class ServiceComponentImpl implements ServiceComponent {
|
|
|
|
|
|
private final static Logger LOG =
|
|
|
LoggerFactory.getLogger(ServiceComponentImpl.class);
|
|
|
private final Service service;
|
|
|
- private final ReadWriteLock clusterGlobalLock;
|
|
|
private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
|
|
|
private final String componentName;
|
|
|
private final String displayName;
|
|
|
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 Map<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);
|
|
|
- clusterGlobalLock = service.getClusterGlobalLock();
|
|
|
+ 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());
|
|
|
-
|
|
|
- hostComponents = new HashMap<String, ServiceComponentHost>();
|
|
|
+ desiredStateEntity.setDesiredStack(stackEntity);
|
|
|
|
|
|
- StackId stackId = service.getDesiredStackVersion();
|
|
|
try {
|
|
|
ComponentInfo compInfo = ambariMetaInfo.getComponent(stackId.getStackName(),
|
|
|
stackId.getStackVersion(), service.getName(), componentName);
|
|
@@ -121,18 +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);
|
|
|
- clusterGlobalLock = service.getClusterGlobalLock();
|
|
|
+ @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();
|
|
@@ -153,8 +171,7 @@ public class ServiceComponentImpl implements ServiceComponent {
|
|
|
+ ", stackInfo=" + stackId.getStackId());
|
|
|
}
|
|
|
|
|
|
- hostComponents = new HashMap<String, ServiceComponentHost>();
|
|
|
- for (HostComponentStateEntity hostComponentStateEntity : desiredStateEntity.getHostComponentStateEntities()) {
|
|
|
+ for (HostComponentStateEntity hostComponentStateEntity : serviceComponentDesiredStateEntity.getHostComponentStateEntities()) {
|
|
|
HostComponentDesiredStateEntityPK pk = new HostComponentDesiredStateEntityPK();
|
|
|
pk.setClusterId(hostComponentStateEntity.getClusterId());
|
|
|
pk.setServiceName(hostComponentStateEntity.getServiceName());
|
|
@@ -174,13 +191,6 @@ public class ServiceComponentImpl implements ServiceComponent {
|
|
|
ex.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- persisted = true;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ReadWriteLock getClusterGlobalLock() {
|
|
|
- return clusterGlobalLock;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -195,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 {
|
|
@@ -213,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());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -255,151 +263,80 @@ public class ServiceComponentImpl implements ServiceComponent {
|
|
|
|
|
|
@Override
|
|
|
public Map<String, ServiceComponentHost> getServiceComponentHosts() {
|
|
|
- clusterGlobalLock.readLock().lock();
|
|
|
- try {
|
|
|
- readWriteLock.readLock().lock();
|
|
|
- try {
|
|
|
- return new HashMap<String, ServiceComponentHost>(hostComponents);
|
|
|
- } finally {
|
|
|
- readWriteLock.readLock().unlock();
|
|
|
- }
|
|
|
- } finally {
|
|
|
- clusterGlobalLock.readLock().unlock();
|
|
|
- }
|
|
|
+ return new HashMap<String, ServiceComponentHost>(hostComponents);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void addServiceComponentHosts(
|
|
|
Map<String, ServiceComponentHost> hostComponents) throws AmbariException {
|
|
|
- clusterGlobalLock.writeLock().lock();
|
|
|
- try {
|
|
|
- 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);
|
|
|
- }
|
|
|
- } finally {
|
|
|
- readWriteLock.writeLock().unlock();
|
|
|
+ // 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 {
|
|
|
- clusterGlobalLock.writeLock().unlock();
|
|
|
+ }
|
|
|
+
|
|
|
+ for (ServiceComponentHost sch : hostComponents.values()) {
|
|
|
+ addServiceComponentHost(sch);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void addServiceComponentHost(
|
|
|
ServiceComponentHost hostComponent) throws AmbariException {
|
|
|
- clusterGlobalLock.writeLock().lock();
|
|
|
+ readWriteLock.writeLock().lock();
|
|
|
try {
|
|
|
- readWriteLock.writeLock().lock();
|
|
|
- try {
|
|
|
- // TODO validation
|
|
|
- // TODO ensure host belongs to cluster
|
|
|
- if (LOG.isDebugEnabled()) {
|
|
|
- LOG.debug("Adding a ServiceComponentHost to ServiceComponent"
|
|
|
- + ", clusterName=" + service.getCluster().getClusterName()
|
|
|
- + ", clusterId=" + service.getCluster().getClusterId()
|
|
|
- + ", serviceName=" + service.getName()
|
|
|
- + ", serviceComponentName=" + getName()
|
|
|
- + ", hostname=" + hostComponent.getHostName()
|
|
|
- + ", recoveryEnabled=" + isRecoveryEnabled());
|
|
|
- }
|
|
|
- if (hostComponents.containsKey(hostComponent.getHostName())) {
|
|
|
- throw new AmbariException("Cannot add duplicate ServiceComponentHost"
|
|
|
- + ", clusterName=" + service.getCluster().getClusterName()
|
|
|
- + ", clusterId=" + service.getCluster().getClusterId()
|
|
|
- + ", serviceName=" + service.getName()
|
|
|
- + ", serviceComponentName=" + getName()
|
|
|
- + ", hostname=" + hostComponent.getHostName()
|
|
|
- + ", recoveryEnabled=" + isRecoveryEnabled());
|
|
|
- }
|
|
|
- // FIXME need a better approach of caching components by host
|
|
|
- ClusterImpl clusterImpl = (ClusterImpl) service.getCluster();
|
|
|
- clusterImpl.addServiceComponentHost(hostComponent);
|
|
|
- hostComponents.put(hostComponent.getHostName(), hostComponent);
|
|
|
- } finally {
|
|
|
- readWriteLock.writeLock().unlock();
|
|
|
+ // TODO validation
|
|
|
+ // TODO ensure host belongs to cluster
|
|
|
+ if (LOG.isDebugEnabled()) {
|
|
|
+ LOG.debug("Adding a ServiceComponentHost to ServiceComponent" + ", clusterName="
|
|
|
+ + service.getCluster().getClusterName() + ", clusterId="
|
|
|
+ + service.getCluster().getClusterId() + ", serviceName=" + service.getName()
|
|
|
+ + ", serviceComponentName=" + getName() + ", hostname=" + hostComponent.getHostName()
|
|
|
+ + ", recoveryEnabled=" + isRecoveryEnabled());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (hostComponents.containsKey(hostComponent.getHostName())) {
|
|
|
+ throw new AmbariException("Cannot add duplicate ServiceComponentHost" + ", clusterName="
|
|
|
+ + service.getCluster().getClusterName() + ", clusterId="
|
|
|
+ + service.getCluster().getClusterId() + ", serviceName=" + service.getName()
|
|
|
+ + ", serviceComponentName=" + getName() + ", hostname=" + hostComponent.getHostName()
|
|
|
+ + ", recoveryEnabled=" + isRecoveryEnabled());
|
|
|
}
|
|
|
+ // FIXME need a better approach of caching components by host
|
|
|
+ ClusterImpl clusterImpl = (ClusterImpl) service.getCluster();
|
|
|
+ clusterImpl.addServiceComponentHost(hostComponent);
|
|
|
+ hostComponents.put(hostComponent.getHostName(), hostComponent);
|
|
|
} finally {
|
|
|
- clusterGlobalLock.writeLock().unlock();
|
|
|
+ readWriteLock.writeLock().unlock();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ServiceComponentHost addServiceComponentHost(String hostName) throws AmbariException {
|
|
|
- clusterGlobalLock.writeLock().lock();
|
|
|
- try {
|
|
|
- readWriteLock.writeLock().lock();
|
|
|
- try {
|
|
|
- // TODO validation
|
|
|
- // TODO ensure host belongs to cluster
|
|
|
- if (LOG.isDebugEnabled()) {
|
|
|
- LOG.debug("Adding a ServiceComponentHost to ServiceComponent"
|
|
|
- + ", clusterName=" + service.getCluster().getClusterName()
|
|
|
- + ", clusterId=" + service.getCluster().getClusterId()
|
|
|
- + ", serviceName=" + service.getName()
|
|
|
- + ", serviceComponentName=" + getName()
|
|
|
- + ", recoveryEnabled=" + isRecoveryEnabled()
|
|
|
- + ", hostname=" + hostName);
|
|
|
- }
|
|
|
- if (hostComponents.containsKey(hostName)) {
|
|
|
- throw new AmbariException("Cannot add duplicate ServiceComponentHost"
|
|
|
- + ", clusterName=" + service.getCluster().getClusterName()
|
|
|
- + ", clusterId=" + service.getCluster().getClusterId()
|
|
|
- + ", serviceName=" + service.getName()
|
|
|
- + ", serviceComponentName=" + getName()
|
|
|
- + ", recoveryEnabled=" + isRecoveryEnabled()
|
|
|
- + ", hostname=" + hostName);
|
|
|
- }
|
|
|
- ServiceComponentHost hostComponent = serviceComponentHostFactory.createNew(this, hostName);
|
|
|
- // FIXME need a better approach of caching components by host
|
|
|
- ClusterImpl clusterImpl = (ClusterImpl) service.getCluster();
|
|
|
- clusterImpl.addServiceComponentHost(hostComponent);
|
|
|
-
|
|
|
- hostComponents.put(hostComponent.getHostName(), hostComponent);
|
|
|
-
|
|
|
- return hostComponent;
|
|
|
- } finally {
|
|
|
- readWriteLock.writeLock().unlock();
|
|
|
- }
|
|
|
- } finally {
|
|
|
- clusterGlobalLock.writeLock().unlock();
|
|
|
- }
|
|
|
+ ServiceComponentHost hostComponent = serviceComponentHostFactory.createNew(this, hostName);
|
|
|
+ addServiceComponentHost(hostComponent);
|
|
|
+ return hostComponent;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public ServiceComponentHost getServiceComponentHost(String hostname)
|
|
|
throws AmbariException {
|
|
|
- clusterGlobalLock.readLock().lock();
|
|
|
- try {
|
|
|
- readWriteLock.readLock().lock();
|
|
|
- try {
|
|
|
- if (!hostComponents.containsKey(hostname)) {
|
|
|
- throw new ServiceComponentHostNotFoundException(getClusterName(),
|
|
|
- getServiceName(), getName(), hostname);
|
|
|
- }
|
|
|
- return hostComponents.get(hostname);
|
|
|
- } finally {
|
|
|
- readWriteLock.readLock().unlock();
|
|
|
- }
|
|
|
- } finally {
|
|
|
- clusterGlobalLock.readLock().unlock();
|
|
|
+
|
|
|
+ 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 {
|
|
@@ -408,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
|
|
@@ -536,124 +446,36 @@ 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
|
|
|
- public void persist() {
|
|
|
- boolean clusterWriteLockAcquired = false;
|
|
|
- if (!persisted) {
|
|
|
- clusterGlobalLock.writeLock().lock();
|
|
|
- clusterWriteLockAcquired = true;
|
|
|
- }
|
|
|
-
|
|
|
- try {
|
|
|
- readWriteLock.writeLock().lock();
|
|
|
- try {
|
|
|
- if (!persisted) {
|
|
|
- // persist the new cluster topology and then release the cluster lock
|
|
|
- // as it has no more bearing on the rest of this persist() method
|
|
|
- persistEntities();
|
|
|
- clusterGlobalLock.writeLock().unlock();
|
|
|
- clusterWriteLockAcquired = false;
|
|
|
-
|
|
|
- refresh();
|
|
|
- // There refresh calls are no longer needed with cached references
|
|
|
- // not used on getters/setters
|
|
|
- // service.refresh();
|
|
|
- persisted = true;
|
|
|
- } else {
|
|
|
- saveIfPersisted(desiredStateEntity);
|
|
|
- }
|
|
|
- } finally {
|
|
|
- readWriteLock.writeLock().unlock();
|
|
|
- }
|
|
|
- } finally {
|
|
|
- if (clusterWriteLockAcquired) {
|
|
|
- clusterGlobalLock.writeLock().unlock();
|
|
|
+ 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(" ] }");
|
|
|
}
|
|
|
|
|
|
@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;
|
|
@@ -672,129 +494,89 @@ public class ServiceComponentImpl implements ServiceComponent {
|
|
|
|
|
|
@Override
|
|
|
public boolean canBeRemoved() {
|
|
|
- clusterGlobalLock.readLock().lock();
|
|
|
- try {
|
|
|
- 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;
|
|
|
- }
|
|
|
- }
|
|
|
- return true;
|
|
|
- } finally {
|
|
|
- readWriteLock.readLock().unlock();
|
|
|
+ // 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;
|
|
|
}
|
|
|
- } finally {
|
|
|
- clusterGlobalLock.readLock().unlock();
|
|
|
}
|
|
|
+ return true;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void deleteAllServiceComponentHosts() throws AmbariException {
|
|
|
- clusterGlobalLock.writeLock().lock();
|
|
|
+ readWriteLock.writeLock().lock();
|
|
|
try {
|
|
|
- readWriteLock.writeLock().lock();
|
|
|
- try {
|
|
|
- LOG.info("Deleting all servicecomponenthosts for component"
|
|
|
- + ", clusterName=" + getClusterName()
|
|
|
- + ", serviceName=" + getServiceName()
|
|
|
- + ", componentName=" + getName()
|
|
|
- + ", recoveryEnabled=" + isRecoveryEnabled());
|
|
|
- for (ServiceComponentHost sch : hostComponents.values()) {
|
|
|
- if (!sch.canBeRemoved()) {
|
|
|
- throw new AmbariException("Found non removable hostcomponent "
|
|
|
- + " when trying to delete"
|
|
|
- + " all hostcomponents from servicecomponent"
|
|
|
- + ", clusterName=" + getClusterName()
|
|
|
- + ", serviceName=" + getServiceName()
|
|
|
- + ", componentName=" + getName()
|
|
|
- + ", recoveryEnabled=" + isRecoveryEnabled()
|
|
|
- + ", hostname=" + sch.getHostName());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- for (ServiceComponentHost serviceComponentHost : hostComponents.values()) {
|
|
|
- serviceComponentHost.delete();
|
|
|
+ LOG.info("Deleting all servicecomponenthosts for component" + ", clusterName="
|
|
|
+ + getClusterName() + ", serviceName=" + getServiceName() + ", componentName=" + getName()
|
|
|
+ + ", recoveryEnabled=" + isRecoveryEnabled());
|
|
|
+ for (ServiceComponentHost sch : hostComponents.values()) {
|
|
|
+ if (!sch.canBeRemoved()) {
|
|
|
+ throw new AmbariException("Found non removable hostcomponent " + " when trying to delete"
|
|
|
+ + " all hostcomponents from servicecomponent" + ", clusterName=" + getClusterName()
|
|
|
+ + ", serviceName=" + getServiceName() + ", componentName=" + getName()
|
|
|
+ + ", recoveryEnabled=" + isRecoveryEnabled() + ", hostname=" + sch.getHostName());
|
|
|
}
|
|
|
+ }
|
|
|
|
|
|
- hostComponents.clear();
|
|
|
- } finally {
|
|
|
- readWriteLock.writeLock().unlock();
|
|
|
+ for (ServiceComponentHost serviceComponentHost : hostComponents.values()) {
|
|
|
+ serviceComponentHost.delete();
|
|
|
}
|
|
|
+
|
|
|
+ hostComponents.clear();
|
|
|
} finally {
|
|
|
- clusterGlobalLock.writeLock().unlock();
|
|
|
+ readWriteLock.writeLock().unlock();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void deleteServiceComponentHosts(String hostname) throws AmbariException {
|
|
|
- clusterGlobalLock.writeLock().lock();
|
|
|
+ readWriteLock.writeLock().lock();
|
|
|
try {
|
|
|
- readWriteLock.writeLock().lock();
|
|
|
- try {
|
|
|
- ServiceComponentHost sch = getServiceComponentHost(hostname);
|
|
|
- LOG.info("Deleting servicecomponenthost for cluster"
|
|
|
+ ServiceComponentHost sch = getServiceComponentHost(hostname);
|
|
|
+ LOG.info("Deleting servicecomponenthost for cluster" + ", clusterName=" + getClusterName()
|
|
|
+ + ", serviceName=" + getServiceName() + ", componentName=" + getName()
|
|
|
+ + ", recoveryEnabled=" + isRecoveryEnabled() + ", hostname=" + sch.getHostName());
|
|
|
+ if (!sch.canBeRemoved()) {
|
|
|
+ throw new AmbariException("Could not delete hostcomponent from cluster"
|
|
|
+ ", clusterName=" + getClusterName()
|
|
|
+ ", serviceName=" + getServiceName()
|
|
|
+ ", componentName=" + getName()
|
|
|
+ ", recoveryEnabled=" + isRecoveryEnabled()
|
|
|
+ ", hostname=" + sch.getHostName());
|
|
|
- if (!sch.canBeRemoved()) {
|
|
|
- throw new AmbariException("Could not delete hostcomponent from cluster"
|
|
|
- + ", clusterName=" + getClusterName()
|
|
|
- + ", serviceName=" + getServiceName()
|
|
|
- + ", componentName=" + getName()
|
|
|
- + ", recoveryEnabled=" + isRecoveryEnabled()
|
|
|
- + ", hostname=" + sch.getHostName());
|
|
|
- }
|
|
|
- sch.delete();
|
|
|
- hostComponents.remove(hostname);
|
|
|
-
|
|
|
- } finally {
|
|
|
- readWriteLock.writeLock().unlock();
|
|
|
}
|
|
|
+ sch.delete();
|
|
|
+ hostComponents.remove(hostname);
|
|
|
+
|
|
|
} finally {
|
|
|
- clusterGlobalLock.writeLock().unlock();
|
|
|
+ readWriteLock.writeLock().unlock();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@Transactional
|
|
|
public void delete() throws AmbariException {
|
|
|
- clusterGlobalLock.writeLock().lock();
|
|
|
+ readWriteLock.writeLock().lock();
|
|
|
try {
|
|
|
- readWriteLock.writeLock().lock();
|
|
|
- try {
|
|
|
- deleteAllServiceComponentHosts();
|
|
|
+ deleteAllServiceComponentHosts();
|
|
|
+
|
|
|
+ ServiceComponentDesiredStateEntity desiredStateEntity = serviceComponentDesiredStateDAO.findById(
|
|
|
+ desiredStateEntityId);
|
|
|
+
|
|
|
+ serviceComponentDesiredStateDAO.remove(desiredStateEntity);
|
|
|
|
|
|
- if (persisted) {
|
|
|
- removeEntities();
|
|
|
- persisted = false;
|
|
|
- }
|
|
|
- } finally {
|
|
|
- readWriteLock.writeLock().unlock();
|
|
|
- }
|
|
|
} finally {
|
|
|
- clusterGlobalLock.writeLock().unlock();
|
|
|
+ readWriteLock.writeLock().unlock();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- @Transactional
|
|
|
- protected void removeEntities() throws AmbariException {
|
|
|
- serviceComponentDesiredStateDAO.remove(getDesiredStateEntity());
|
|
|
- }
|
|
|
|
|
|
private int getSCHCountByState(State state) {
|
|
|
int count = 0;
|
|
@@ -816,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());
|
|
|
- }
|
|
|
}
|