|
@@ -38,11 +38,9 @@ import org.apache.ambari.server.events.MaintenanceModeEvent;
|
|
import org.apache.ambari.server.events.ServiceComponentInstalledEvent;
|
|
import org.apache.ambari.server.events.ServiceComponentInstalledEvent;
|
|
import org.apache.ambari.server.events.ServiceComponentUninstalledEvent;
|
|
import org.apache.ambari.server.events.ServiceComponentUninstalledEvent;
|
|
import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
|
|
import org.apache.ambari.server.events.publishers.AmbariEventPublisher;
|
|
-import org.apache.ambari.server.orm.dao.ClusterVersionDAO;
|
|
|
|
import org.apache.ambari.server.orm.dao.HostComponentDesiredStateDAO;
|
|
import org.apache.ambari.server.orm.dao.HostComponentDesiredStateDAO;
|
|
import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
|
|
import org.apache.ambari.server.orm.dao.HostComponentStateDAO;
|
|
import org.apache.ambari.server.orm.dao.HostDAO;
|
|
import org.apache.ambari.server.orm.dao.HostDAO;
|
|
-import org.apache.ambari.server.orm.dao.HostVersionDAO;
|
|
|
|
import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
|
|
import org.apache.ambari.server.orm.dao.RepositoryVersionDAO;
|
|
import org.apache.ambari.server.orm.dao.ServiceComponentDesiredStateDAO;
|
|
import org.apache.ambari.server.orm.dao.ServiceComponentDesiredStateDAO;
|
|
import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity;
|
|
import org.apache.ambari.server.orm.entities.HostComponentDesiredStateEntity;
|
|
@@ -106,16 +104,12 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
@Inject
|
|
@Inject
|
|
Gson gson;
|
|
Gson gson;
|
|
@Inject
|
|
@Inject
|
|
- ClusterVersionDAO clusterVersionDAO;
|
|
|
|
- @Inject
|
|
|
|
HostComponentStateDAO hostComponentStateDAO;
|
|
HostComponentStateDAO hostComponentStateDAO;
|
|
@Inject
|
|
@Inject
|
|
HostComponentDesiredStateDAO hostComponentDesiredStateDAO;
|
|
HostComponentDesiredStateDAO hostComponentDesiredStateDAO;
|
|
@Inject
|
|
@Inject
|
|
HostDAO hostDAO;
|
|
HostDAO hostDAO;
|
|
@Inject
|
|
@Inject
|
|
- HostVersionDAO hostVersionDAO;
|
|
|
|
- @Inject
|
|
|
|
RepositoryVersionDAO repositoryVersionDAO;
|
|
RepositoryVersionDAO repositoryVersionDAO;
|
|
@Inject
|
|
@Inject
|
|
ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO;
|
|
ServiceComponentDesiredStateDAO serviceComponentDesiredStateDAO;
|
|
@@ -141,9 +135,20 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
@Inject
|
|
@Inject
|
|
private AmbariEventPublisher eventPublisher;
|
|
private AmbariEventPublisher eventPublisher;
|
|
|
|
|
|
|
|
+ // TODO : caching the JPA entities here causes issues if they become stale and get re-merged.
|
|
private HostComponentStateEntity stateEntity;
|
|
private HostComponentStateEntity stateEntity;
|
|
private HostComponentDesiredStateEntity desiredStateEntity;
|
|
private HostComponentDesiredStateEntity desiredStateEntity;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The component state entity PK.
|
|
|
|
+ */
|
|
|
|
+ private final HostComponentStateEntityPK stateEntityPK;
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * The desired component state entity PK.
|
|
|
|
+ */
|
|
|
|
+ private final HostComponentDesiredStateEntityPK desiredStateEntityPK;
|
|
|
|
+
|
|
private long lastOpStartTime;
|
|
private long lastOpStartTime;
|
|
private long lastOpEndTime;
|
|
private long lastOpEndTime;
|
|
private long lastOpLastUpdateTime;
|
|
private long lastOpLastUpdateTime;
|
|
@@ -563,7 +568,6 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
impl.updateLastOpInfo(event.getType(), event.getOpTimestamp());
|
|
impl.updateLastOpInfo(event.getType(), event.getOpTimestamp());
|
|
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -696,6 +700,8 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
stateEntity.setUpgradeState(UpgradeState.NONE);
|
|
stateEntity.setUpgradeState(UpgradeState.NONE);
|
|
stateEntity.setCurrentStackVersion(gson.toJson(new StackId()));
|
|
stateEntity.setCurrentStackVersion(gson.toJson(new StackId()));
|
|
|
|
|
|
|
|
+ stateEntityPK = getHostComponentStateEntityPK(stateEntity);
|
|
|
|
+
|
|
desiredStateEntity = new HostComponentDesiredStateEntity();
|
|
desiredStateEntity = new HostComponentDesiredStateEntity();
|
|
desiredStateEntity.setClusterId(serviceComponent.getClusterId());
|
|
desiredStateEntity.setClusterId(serviceComponent.getClusterId());
|
|
desiredStateEntity.setComponentName(serviceComponent.getName());
|
|
desiredStateEntity.setComponentName(serviceComponent.getName());
|
|
@@ -710,6 +716,8 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
desiredStateEntity.setAdminState(null);
|
|
desiredStateEntity.setAdminState(null);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ desiredStateEntityPK = getHostComponentDesiredStateEntityPK(desiredStateEntity);
|
|
|
|
+
|
|
try {
|
|
try {
|
|
host = clusters.getHost(hostName);
|
|
host = clusters.getHost(hostName);
|
|
} catch (AmbariException e) {
|
|
} catch (AmbariException e) {
|
|
@@ -733,6 +741,9 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
this.desiredStateEntity = desiredStateEntity;
|
|
this.desiredStateEntity = desiredStateEntity;
|
|
this.stateEntity = stateEntity;
|
|
this.stateEntity = stateEntity;
|
|
|
|
|
|
|
|
+ desiredStateEntityPK = getHostComponentDesiredStateEntityPK(desiredStateEntity);
|
|
|
|
+ stateEntityPK = getHostComponentStateEntityPK(stateEntity);
|
|
|
|
+
|
|
//TODO implement State Machine init as now type choosing is hardcoded in above code
|
|
//TODO implement State Machine init as now type choosing is hardcoded in above code
|
|
if (serviceComponent.isClientComponent()) {
|
|
if (serviceComponent.isClientComponent()) {
|
|
stateMachine = clientStateMachineFactory.make(this);
|
|
stateMachine = clientStateMachineFactory.make(this);
|
|
@@ -764,7 +775,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
stateMachine.setCurrentState(state);
|
|
stateMachine.setCurrentState(state);
|
|
- stateEntity.setCurrentState(state);
|
|
|
|
|
|
+ getStateEntity().setCurrentState(state);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -775,7 +786,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public String getVersion() {
|
|
public String getVersion() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- return stateEntity.getVersion();
|
|
|
|
|
|
+ return getStateEntity().getVersion();
|
|
} finally {
|
|
} finally {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
}
|
|
}
|
|
@@ -785,7 +796,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public void setVersion(String version) {
|
|
public void setVersion(String version) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- stateEntity.setVersion(version);
|
|
|
|
|
|
+ getStateEntity().setVersion(version);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -796,7 +807,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public SecurityState getSecurityState() {
|
|
public SecurityState getSecurityState() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- return stateEntity.getSecurityState();
|
|
|
|
|
|
+ return getStateEntity().getSecurityState();
|
|
} finally {
|
|
} finally {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
}
|
|
}
|
|
@@ -806,7 +817,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public void setSecurityState(SecurityState securityState) {
|
|
public void setSecurityState(SecurityState securityState) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- stateEntity.setSecurityState(securityState);
|
|
|
|
|
|
+ getStateEntity().setSecurityState(securityState);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -817,7 +828,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public SecurityState getDesiredSecurityState() {
|
|
public SecurityState getDesiredSecurityState() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- return desiredStateEntity.getSecurityState();
|
|
|
|
|
|
+ return getDesiredStateEntity().getSecurityState();
|
|
} finally {
|
|
} finally {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
}
|
|
}
|
|
@@ -831,7 +842,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
|
|
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- desiredStateEntity.setSecurityState(securityState);
|
|
|
|
|
|
+ getDesiredStateEntity().setSecurityState(securityState);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -844,13 +855,14 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
* If the upgrade completes successfully, the upgradeState should be set back to NONE.
|
|
* If the upgrade completes successfully, the upgradeState should be set back to NONE.
|
|
* If the upgrade fails, then the user can retry to set it back into PENDING or IN_PROGRESS.
|
|
* If the upgrade fails, then the user can retry to set it back into PENDING or IN_PROGRESS.
|
|
* If the upgrade is aborted, then the upgradeState should be set back to NONE.
|
|
* If the upgrade is aborted, then the upgradeState should be set back to NONE.
|
|
- * @param upgradeState
|
|
|
|
|
|
+ *
|
|
|
|
+ * @param upgradeState the upgrade state
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
public void setUpgradeState(UpgradeState upgradeState) {
|
|
public void setUpgradeState(UpgradeState upgradeState) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- stateEntity.setUpgradeState(upgradeState);
|
|
|
|
|
|
+ getStateEntity().setUpgradeState(upgradeState);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -873,7 +885,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
stateMachine.doTransition(event.getType(), event);
|
|
stateMachine.doTransition(event.getType(), event);
|
|
- stateEntity.setCurrentState(stateMachine.getCurrentState());
|
|
|
|
|
|
+ getStateEntity().setCurrentState(stateMachine.getCurrentState());
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
// TODO Audit logs
|
|
// TODO Audit logs
|
|
} catch (InvalidStateTransitionException e) {
|
|
} catch (InvalidStateTransitionException e) {
|
|
@@ -1002,7 +1014,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public StackId getStackVersion() {
|
|
public StackId getStackVersion() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- return gson.fromJson(stateEntity.getCurrentStackVersion(), StackId.class);
|
|
|
|
|
|
+ return gson.fromJson(getStateEntity().getCurrentStackVersion(), StackId.class);
|
|
} finally {
|
|
} finally {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
}
|
|
}
|
|
@@ -1012,7 +1024,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public void setStackVersion(StackId stackVersion) {
|
|
public void setStackVersion(StackId stackVersion) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- stateEntity.setCurrentStackVersion(gson.toJson(stackVersion));
|
|
|
|
|
|
+ getStateEntity().setCurrentStackVersion(gson.toJson(stackVersion));
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -1023,7 +1035,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public State getDesiredState() {
|
|
public State getDesiredState() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- return desiredStateEntity.getDesiredState();
|
|
|
|
|
|
+ return getDesiredStateEntity().getDesiredState();
|
|
} finally {
|
|
} finally {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
}
|
|
}
|
|
@@ -1033,7 +1045,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public void setDesiredState(State state) {
|
|
public void setDesiredState(State state) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- desiredStateEntity.setDesiredState(state);
|
|
|
|
|
|
+ getDesiredStateEntity().setDesiredState(state);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -1044,7 +1056,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public StackId getDesiredStackVersion() {
|
|
public StackId getDesiredStackVersion() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- return gson.fromJson(desiredStateEntity.getDesiredStackVersion(),
|
|
|
|
|
|
+ return gson.fromJson(getDesiredStateEntity().getDesiredStackVersion(),
|
|
StackId.class);
|
|
StackId.class);
|
|
} finally {
|
|
} finally {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
@@ -1055,7 +1067,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public void setDesiredStackVersion(StackId stackVersion) {
|
|
public void setDesiredStackVersion(StackId stackVersion) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- desiredStateEntity.setDesiredStackVersion(gson.toJson(stackVersion));
|
|
|
|
|
|
+ getDesiredStateEntity().setDesiredStackVersion(gson.toJson(stackVersion));
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -1066,7 +1078,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public HostComponentAdminState getComponentAdminState() {
|
|
public HostComponentAdminState getComponentAdminState() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- HostComponentAdminState adminState = desiredStateEntity.getAdminState();
|
|
|
|
|
|
+ HostComponentAdminState adminState = getDesiredStateEntity().getAdminState();
|
|
if (adminState == null && !serviceComponent.isClientComponent()
|
|
if (adminState == null && !serviceComponent.isClientComponent()
|
|
&& !serviceComponent.isMasterComponent()) {
|
|
&& !serviceComponent.isMasterComponent()) {
|
|
adminState = HostComponentAdminState.INSERVICE;
|
|
adminState = HostComponentAdminState.INSERVICE;
|
|
@@ -1081,7 +1093,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public void setComponentAdminState(HostComponentAdminState attribute) {
|
|
public void setComponentAdminState(HostComponentAdminState attribute) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- desiredStateEntity.setAdminState(attribute);
|
|
|
|
|
|
+ getDesiredStateEntity().setAdminState(attribute);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
@@ -1165,7 +1177,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
clusterGlobalLock.writeLock().unlock();
|
|
clusterGlobalLock.writeLock().unlock();
|
|
clusterWriteLockAcquired = false;
|
|
clusterWriteLockAcquired = false;
|
|
|
|
|
|
- // these shoudl still be done with the internal lock
|
|
|
|
|
|
+ // these should still be done with the internal lock
|
|
refresh();
|
|
refresh();
|
|
host.refresh();
|
|
host.refresh();
|
|
serviceComponent.refresh();
|
|
serviceComponent.refresh();
|
|
@@ -1219,26 +1231,11 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- @Transactional
|
|
|
|
public void refresh() {
|
|
public void refresh() {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- if (isPersisted()) {
|
|
|
|
- HostComponentStateEntityPK pk = new HostComponentStateEntityPK();
|
|
|
|
- HostComponentDesiredStateEntityPK dpk = new HostComponentDesiredStateEntityPK();
|
|
|
|
- pk.setClusterId(getClusterId());
|
|
|
|
- pk.setComponentName(getServiceComponentName());
|
|
|
|
- pk.setServiceName(getServiceName());
|
|
|
|
- pk.setHostName(getHostName());
|
|
|
|
- dpk.setClusterId(getClusterId());
|
|
|
|
- dpk.setComponentName(getServiceComponentName());
|
|
|
|
- dpk.setServiceName(getServiceName());
|
|
|
|
- dpk.setHostName(getHostName());
|
|
|
|
- stateEntity = hostComponentStateDAO.findByPK(pk);
|
|
|
|
- desiredStateEntity = hostComponentDesiredStateDAO.findByPK(dpk);
|
|
|
|
- hostComponentStateDAO.refresh(stateEntity);
|
|
|
|
- hostComponentDesiredStateDAO.refresh(desiredStateEntity);
|
|
|
|
- }
|
|
|
|
|
|
+ getDesiredStateEntity();
|
|
|
|
+ getStateEntity();
|
|
} finally {
|
|
} finally {
|
|
writeLock.unlock();
|
|
writeLock.unlock();
|
|
}
|
|
}
|
|
@@ -1259,11 +1256,9 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
try {
|
|
try {
|
|
// if unable to read, then writers are writing; cannot remove SCH
|
|
// if unable to read, then writers are writing; cannot remove SCH
|
|
schLockAcquired = readLock.tryLock();
|
|
schLockAcquired = readLock.tryLock();
|
|
- if (!schLockAcquired) {
|
|
|
|
- return false;
|
|
|
|
- }
|
|
|
|
|
|
|
|
- return (getState().isRemovableState());
|
|
|
|
|
|
+ return schLockAcquired && (getState().isRemovableState());
|
|
|
|
+
|
|
} finally {
|
|
} finally {
|
|
if (schLockAcquired) {
|
|
if (schLockAcquired) {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
@@ -1407,7 +1402,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public void setMaintenanceState(MaintenanceState state) {
|
|
public void setMaintenanceState(MaintenanceState state) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- desiredStateEntity.setMaintenanceState(state);
|
|
|
|
|
|
+ getDesiredStateEntity().setMaintenanceState(state);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
|
|
|
|
// broadcast the maintenance mode change
|
|
// broadcast the maintenance mode change
|
|
@@ -1423,7 +1418,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public MaintenanceState getMaintenanceState() {
|
|
public MaintenanceState getMaintenanceState() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- return desiredStateEntity.getMaintenanceState();
|
|
|
|
|
|
+ return getDesiredStateEntity().getMaintenanceState();
|
|
} finally {
|
|
} finally {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
}
|
|
}
|
|
@@ -1453,7 +1448,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public boolean isRestartRequired() {
|
|
public boolean isRestartRequired() {
|
|
readLock.lock();
|
|
readLock.lock();
|
|
try {
|
|
try {
|
|
- return desiredStateEntity.isRestartRequired();
|
|
|
|
|
|
+ return getDesiredStateEntity().isRestartRequired();
|
|
} finally {
|
|
} finally {
|
|
readLock.unlock();
|
|
readLock.unlock();
|
|
}
|
|
}
|
|
@@ -1463,7 +1458,7 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
public void setRestartRequired(boolean restartRequired) {
|
|
public void setRestartRequired(boolean restartRequired) {
|
|
writeLock.lock();
|
|
writeLock.lock();
|
|
try {
|
|
try {
|
|
- desiredStateEntity.setRestartRequired(restartRequired);
|
|
|
|
|
|
+ getDesiredStateEntity().setRestartRequired(restartRequired);
|
|
saveIfPersisted();
|
|
saveIfPersisted();
|
|
helper.invalidateStaleConfigsCache(this);
|
|
helper.invalidateStaleConfigsCache(this);
|
|
} finally {
|
|
} finally {
|
|
@@ -1475,10 +1470,9 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
private RepositoryVersionEntity createRepositoryVersion(String version, final StackId stackId, final StackInfo stackInfo) throws AmbariException {
|
|
private RepositoryVersionEntity createRepositoryVersion(String version, final StackId stackId, final StackInfo stackInfo) throws AmbariException {
|
|
// During an Ambari Upgrade from 1.7.0 -> 2.0.0, the Repo Version will not exist, so bootstrap it.
|
|
// During an Ambari Upgrade from 1.7.0 -> 2.0.0, the Repo Version will not exist, so bootstrap it.
|
|
LOG.info("Creating new repository version " + stackId.getStackName() + "-" + version);
|
|
LOG.info("Creating new repository version " + stackId.getStackName() + "-" + version);
|
|
- RepositoryVersionEntity repositoryVersion = repositoryVersionDAO.create(stackId.getStackId(), version, stackId.getStackName() + "-" + version,
|
|
|
|
|
|
+ return repositoryVersionDAO.create(stackId.getStackId(), version, stackId.getStackName() + "-" + version,
|
|
repositoryVersionHelper.getUpgradePackageNameSafe(stackId.getStackName(), stackId.getStackVersion(), version),
|
|
repositoryVersionHelper.getUpgradePackageNameSafe(stackId.getStackName(), stackId.getStackVersion(), version),
|
|
repositoryVersionHelper.serializeOperatingSystems(stackInfo.getRepositories()));
|
|
repositoryVersionHelper.serializeOperatingSystems(stackInfo.getRepositories()));
|
|
- return repositoryVersion;
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -1519,4 +1513,42 @@ public class ServiceComponentHostImpl implements ServiceComponentHost {
|
|
}
|
|
}
|
|
return version;
|
|
return version;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Get the cached desired state entity or load it fresh through the DAO.
|
|
|
|
+ private HostComponentDesiredStateEntity getDesiredStateEntity() {
|
|
|
|
+ if (isPersisted()) {
|
|
|
|
+ desiredStateEntity = hostComponentDesiredStateDAO.findByPK(desiredStateEntityPK);
|
|
|
|
+ }
|
|
|
|
+ return desiredStateEntity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // Get the cached state entity or load it fresh through the DAO.
|
|
|
|
+ private HostComponentStateEntity getStateEntity() {
|
|
|
|
+ if (isPersisted()) {
|
|
|
|
+ stateEntity = hostComponentStateDAO.findByPK(stateEntityPK);
|
|
|
|
+ }
|
|
|
|
+ return stateEntity;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // create a PK object from the given desired component state entity.
|
|
|
|
+ private static HostComponentDesiredStateEntityPK getHostComponentDesiredStateEntityPK(
|
|
|
|
+ HostComponentDesiredStateEntity desiredStateEntity) {
|
|
|
|
+
|
|
|
|
+ HostComponentDesiredStateEntityPK dpk = new HostComponentDesiredStateEntityPK();
|
|
|
|
+ dpk.setClusterId(desiredStateEntity.getClusterId());
|
|
|
|
+ dpk.setComponentName(desiredStateEntity.getComponentName());
|
|
|
|
+ dpk.setServiceName(desiredStateEntity.getServiceName());
|
|
|
|
+ dpk.setHostName(desiredStateEntity.getHostName());
|
|
|
|
+ return dpk;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // create a PK object from the given component state entity.
|
|
|
|
+ private static HostComponentStateEntityPK getHostComponentStateEntityPK(HostComponentStateEntity stateEntity) {
|
|
|
|
+ HostComponentStateEntityPK pk = new HostComponentStateEntityPK();
|
|
|
|
+ pk.setClusterId(stateEntity.getClusterId());
|
|
|
|
+ pk.setComponentName(stateEntity.getComponentName());
|
|
|
|
+ pk.setServiceName(stateEntity.getServiceName());
|
|
|
|
+ pk.setHostName(stateEntity.getHostName());
|
|
|
|
+ return pk;
|
|
|
|
+ }
|
|
}
|
|
}
|