public SamzaResource peekResource(String host) {
    synchronized (lock) {
      List<SamzaResource> resourcesOnPreferredHostBuffer = this.allocatedResources.get(host);
      List<SamzaResource> resourcesOnAnyHostBuffer = this.allocatedResources.get(ANY_HOST);

      // First search for the preferred host (may be ANY_HOST too)
      if (resourcesOnPreferredHostBuffer != null && !resourcesOnPreferredHostBuffer.isEmpty()) {
        SamzaResource resource = resourcesOnPreferredHostBuffer.get(0);
        log.info("Found Container ID: {} for host: {} in the buffer.", resource.getContainerId(), host);
        return resource;
      } else if (resourcesOnAnyHostBuffer != null && !resourcesOnAnyHostBuffer.isEmpty()) {
        // If no resources for preferred host int he buffer, look for ANY_HOST
        log.debug("No resources on preferred host buffer. Scanning ANY_HOST buffer");
        SamzaResource resource = resourcesOnAnyHostBuffer.stream()
            .filter(resrc -> resrc.getHost().equals(host))
            .findAny().orElse(null);
        if (resource != null) {
          log.info("Found Container ID: {} for host: {} in the buffer.", resource.getContainerId(), host);
        }
        return resource;
      } else {
        log.debug("Could not find any containers on host: {}. Both preferred host and ANY_HOST buffers are empty", host);
        return null;
      }
    }
  }
Retrieves, but does not remove, the first allocated resource on the specified host.

@param host the host for which a resource is needed.
@return a {@link SamzaResource} allocated for the specified host or {@code null} if there isn't one.
samza-core/src/main/java/org/apache/samza/clustermanager/ResourceRequestState.java