Source:
public void assignResourceRequests() { while (hasPendingRequest()) { SamzaResourceRequest request = peekPendingRequest(); log.info("Handling request: " + request.getContainerID() + " " + request.getRequestTimestampMs() + " " + request.getPreferredHost()); String preferredHost = request.getPreferredHost(); String containerID = request.getContainerID(); if (hasAllocatedResource(preferredHost)) { log.info("Found a matched-container on the preferred host. Running on {}", containerID, preferredHost); checkStandbyConstraintsAndRunStreamProcessor(request, preferredHost, peekAllocatedResource(preferredHost)); state.matchedResourceRequests.incrementAndGet(); } else { log.info("Did not find any allocated resources on preferred host for running container id {}", preferredHost, containerID); boolean expired = requestExpired(request); boolean resourceAvailableOnAnyHost = hasAllocatedResource(ResourceRequestState.ANY_HOST); if (expired) { updateExpiryMetrics(request); if (standbyContainerManager.isPresent()) { if (resourceAvailableOnAnyHost) { standbyContainerManager.get().handleExpiredResourceRequest(containerID, request, Optional.of(peekAllocatedResource(ResourceRequestState.ANY_HOST)), this, resourceRequestState); } else { standbyContainerManager.get().handleExpiredResourceRequest(containerID, request, Optional.empty(), this, resourceRequestState); } } else { if (resourceAvailableOnAnyHost) { log.info("Request for container: on has expired. Running on ANY_HOST", request.getContainerID(), request.getPreferredHost()); runStreamProcessor(request, ResourceRequestState.ANY_HOST); } else { log.info("Request for container: on has expired. Requesting additional resources on ANY_HOST.", request.getContainerID(), request.getPreferredHost()); resourceRequestState.cancelResourceRequest(request); requestResource(containerID, ResourceRequestState.ANY_HOST); } } } else { log.info("Request for container: on has not yet expired. Request creation time: {}. Request timeout: {}", new Object[]{request.getContainerID(), request.getPreferredHost(), request.getRequestTimestampMs(), requestTimeout}); break; } } } }

Target:
public void assignResourceRequests() { while (hasPendingRequest()) { SamzaResourceRequest request = peekPendingRequest(); log.info("Handling request: " + request.getContainerID() + " " + request.getRequestTimestampMs() + " " + request.getPreferredHost()); String preferredHost = request.getPreferredHost(); String containerID = request.getContainerID(); if (hasAllocatedResource(preferredHost)) { log.info("Found a matched-container on the preferred host. Running on {}", containerID, preferredHost); checkStandbyConstraintsAndRunStreamProcessor(request, preferredHost, peekAllocatedResource(preferredHost)); state.matchedResourceRequests.incrementAndGet(); } else { log.info("Did not find any allocated resources on preferred host for running container id {}", preferredHost, containerID); boolean expired = requestExpired(request); boolean resourceAvailableOnAnyHost = hasAllocatedResource(ResourceRequestState.ANY_HOST); if (expired) { updateExpiryMetrics(request); if (standbyContainerManager.isPresent()) { standbyContainerManager.get().handleExpiredResourceRequest(containerID, request, Optional.ofNullable(peekAllocatedResource(ResourceRequestState.ANY_HOST)), this, resourceRequestState); } else if (resourceAvailableOnAnyHost) { log.info("Request for container: on has expired. Running on ANY_HOST", request.getContainerID(), request.getPreferredHost()); runStreamProcessor(request, ResourceRequestState.ANY_HOST); } else { log.info("Request for container: on has expired. Requesting additional resources on ANY_HOST.", request.getContainerID(), request.getPreferredHost()); resourceRequestState.cancelResourceRequest(request); requestResource(containerID, ResourceRequestState.ANY_HOST); } } else { log.info("Request for container: on has not yet expired. Request creation time: {}. Request timeout: {}", new Object[]{request.getContainerID(), request.getPreferredHost(), request.getRequestTimestampMs(), requestTimeout}); break; } } } }