public void releaseUnstartableContainer(SamzaResource resource, String preferredHost) {
    synchronized (lock) {
      String containerId = resource.getContainerId();
      log.info("Releasing unstartable Container ID: {} on host: {}", containerId, resource.getHost());
      manager.releaseResources(resource);

      // A reference for the resource could either be held in the preferred host buffer or in the ANY_HOST buffer.
      if (allocatedResources.get(preferredHost) != null) {
        allocatedResources.get(preferredHost).remove(resource);
        log.info("Unstartable Container ID: {} removed from the buffer for host: {}", containerId, preferredHost);
      }
      if (allocatedResources.get(ANY_HOST) != null) {
        allocatedResources.get(ANY_HOST).remove(resource);
        log.info("Unstartable Container ID: {} removed from the buffer for ANY_HOST", containerId);
      }
    }
  }
Releases a container that was allocated and assigned but could not be started.
e.g. because of a ConnectException while trying to communicate with the NM.
This method assumes the specified container and associated request have already
been removed from their respective queues.

@param resource the {@link SamzaResource} to release.
samza-core/src/main/java/org/apache/samza/clustermanager/ResourceRequestState.java