@Override
  @Transactional
  public void handleEvent(ServiceComponentHostEvent event)
      throws InvalidStateTransitionException {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Handling ServiceComponentHostEvent event, eventType={}, event={}", event.getType().name(), event);
    }
    State oldState = getState();
    try {
      writeLock.lock();
      try {
        stateMachine.doTransition(event.getType(), event);
        HostComponentStateEntity stateEntity = getStateEntity();
        boolean statusUpdated = !stateEntity.getCurrentState().equals(stateMachine.getCurrentState());
        stateEntity.setCurrentState(stateMachine.getCurrentState());
        stateEntity = hostComponentStateDAO.merge(stateEntity);
        if (statusUpdated) {
          STOMPUpdatePublisher.publish(new HostComponentsUpdateEvent(Collections.singletonList(
              HostComponentUpdate.createHostComponentStatusUpdate(stateEntity, oldState))));
        }
        if (event.getType().equals(ServiceComponentHostEventType.HOST_SVCCOMP_STARTED)) {
          HostComponentDesiredStateEntity desiredStateEntity = getDesiredStateEntity();
          if (desiredStateEntity.getBlueprintProvisioningState() == BlueprintProvisioningState.IN_PROGRESS) {
            desiredStateEntity.setBlueprintProvisioningState(BlueprintProvisioningState.FINISHED);
            hostComponentDesiredStateDAO.merge(desiredStateEntity);
            m_hostLevelParamsHolder.get().updateData(m_hostLevelParamsHolder.get().getCurrentData(getHost().getHostId()));
          }
        }
        // TODO Audit logs
      } catch (InvalidStateTransitionException e) {
        LOG.error("Can't handle ServiceComponentHostEvent event at"
            + " current state"
            + ", serviceComponentName=" + getServiceComponentName()
            + ", hostName=" + getHostName()
          + ", currentState=" + oldState
            + ", eventType=" + event.getType()
            + ", event=" + event);
        throw e;
      } catch (AmbariException e) {
        LOG.error("Can't update topology on hosts on ServiceComponentHostEvent event: "
            + "serviceComponentName=" + getServiceComponentName()
            + ", hostName=" + getHostName()
            + ", currentState=" + oldState
            + ", eventType=" + event.getType()
            + ", event=" + event);
      }
    } finally {
      writeLock.unlock();
    }

    if (!oldState.equals(getState())) {
      LOG.info("Host role transitioned to a new state"
               + ", serviceComponentName=" + getServiceComponentName()
               + ", hostName=" + getHostName()
               + ", oldState=" + oldState
               + ", currentState=" + getState());
      if (LOG.isDebugEnabled()) {
        LOG.debug("ServiceComponentHost transitioned to a new state, serviceComponentName={}, hostName={}, oldState={}, currentState={}, eventType={}, event={}",
          getServiceComponentName(), getHostName(), oldState, getState(), event.getType().name(), event);
      }
    }
  }
To be called during the upgrade of a specific Component in a host.
The potential upgrade states are NONE (default), PENDING, IN_PROGRESS, FAILED.
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 is aborted, then the upgradeState should be set back to NONE.

@param upgradeState  the upgrade state
ambari-server/src/main/java/org/apache/ambari/server/state/svccomphost/ServiceComponentHostImpl.java