private void auditLog(HostRoleCommandEntity commandEntity, Long requestId) {
    if (!auditLogger.isEnabled()) {
      return;
    }

    if (requestId != null) {
      HostRoleStatus lastTaskStatus = updateAuditlogCache(commandEntity, requestId);

      // details must not be null
      RequestDetails details = auditlogRequestCache.getIfPresent(requestId);
      if (details != null) {
        HostRoleStatus calculatedStatus = calculateStatus(requestId, details.getNumberOfTasks());

        if (details.getLastStatus() != calculatedStatus) {
          RequestEntity request = requestDAO.findByPK(requestId);
          String context = request != null ? request.getRequestContext() : null;
          AuditEvent auditEvent = OperationStatusAuditEvent.builder()
              .withRequestId(String.valueOf(requestId))
              .withStatus(String.valueOf(calculatedStatus))
              .withRequestContext(context)
              .withUserName(details.getUserName())
              .withProxyUserName(details.getProxyUserName())
              .withTimestamp(System.currentTimeMillis())
              .build();
          auditLogger.log(auditEvent);

          details.setLastStatus(calculatedStatus);
        }
      }
      logTask(commandEntity, requestId, lastTaskStatus);
    }
  }
AuditLog operation status change

@param requestId
ambari-server/src/main/java/org/apache/ambari/server/actionmanager/ActionDBAccessorImpl.java