private void handleStandbyContainerStop(String standbyContainerID, String resourceID, String preferredHost,
      ContainerAllocator containerAllocator, Duration preferredHostRetryDelay) {

    // if this standbyContainerResource was stopped for a failover, we will find a metadata entry
    Optional<StandbyContainerManager.FailoverMetadata> failoverMetadata = this.checkIfUsedForFailover(resourceID);

    if (failoverMetadata.isPresent()) {
      String activeContainerID = failoverMetadata.get().activeContainerID;
      String standbyContainerHostname = failoverMetadata.get().getStandbyContainerHostname(resourceID);

      log.info("Requesting resource for active container {} on host {}, and backup container {} on any host",
          activeContainerID, standbyContainerHostname, standbyContainerID);

      // request standbycontainer's host for active-container
      SamzaResourceRequest resourceRequestForActive =
        containerAllocator.getResourceRequestWithDelay(activeContainerID, standbyContainerHostname, preferredHostRetryDelay);
      // record the resource request, before issuing it to avoid race with allocation-thread
      failoverMetadata.get().recordResourceRequest(resourceRequestForActive);
      containerAllocator.issueResourceRequest(resourceRequestForActive);

      // request any-host for standby container
      requestResource(containerAllocator, standbyContainerID, ResourceRequestState.ANY_HOST, Duration.ZERO, standbyContainerHostname);
    } else {
      log.info("Issuing request for standby container {} on host {}, since this is not for a failover",
          standbyContainerID, preferredHost);
      String activeContainerHost = getActiveContainerHost(standbyContainerID)
              .orElse(null);
      requestResource(containerAllocator, standbyContainerID, preferredHost, preferredHostRetryDelay, activeContainerHost);
    }
  }
If a standby container has stopped, then there are two possible cases
   Case 1. during a failover, the standby container was stopped for an active's start, then we
      1. request a resource on the standby's host to place the activeContainer, and
      2. request anyhost to place this standby

   Case 2. independent of a failover, the standby container stopped, in which proceed with its resource-request
@param standbyContainerID SamzaContainerID of the standby container
@param preferredHost Preferred host of the standby container
samza-core/src/main/java/org/apache/samza/clustermanager/StandbyContainerManager.java