Source:
public void checkStandbyConstraintsAndRunStreamProcessor(SamzaResourceRequest request, String preferredHost, SamzaResource samzaResource, ContainerAllocator containerAllocator, ResourceRequestState resourceRequestState) { String containerID = request.getProcessorId(); if (checkStandbyConstraints(containerID, samzaResource.getHost())) { log.info("Running container on meets standby constraints, preferredHost = {}", containerID, samzaResource.getHost(), preferredHost); containerAllocator.runStreamProcessor(request, preferredHost); samzaApplicationState.faultDomainAwareContainersStarted.incrementAndGet(); } else if (StandbyTaskUtil.isStandbyContainer(containerID)) { log.info( "Running standby container on host does not meet standby constraints, cancelling resource request, releasing resource, and making a new ANY_HOST request", containerID, samzaResource.getHost()); releaseUnstartableContainer(request, samzaResource, preferredHost, resourceRequestState); containerAllocator.requestResource(containerID, ResourceRequestState.ANY_HOST, getAllowedFaultDomainsForSchedulingStandbyContainer(getActiveContainerHost(containerID))); samzaApplicationState.failedStandbyAllocations.incrementAndGet(); } else { log.warn( "Running active container on host does not meet standby constraints, cancelling resource request, releasing resource", containerID, samzaResource.getHost()); releaseUnstartableContainer(request, samzaResource, preferredHost, resourceRequestState); Optional<FailoverMetadata> failoverMetadata = getFailoverMetadata(request); String lastKnownResourceID = failoverMetadata.isPresent() ? failoverMetadata.get().activeContainerResourceID : "unknown-" + containerID; initiateStandbyAwareAllocation(containerID, lastKnownResourceID, containerAllocator); samzaApplicationState.failedStandbyAllocations.incrementAndGet(); } }

Target:
public void checkStandbyConstraintsAndRunStreamProcessor(SamzaResourceRequest request, String preferredHost, SamzaResource samzaResource, ContainerAllocator containerAllocator, ResourceRequestState resourceRequestState) { String containerID = request.getProcessorId(); if (checkStandbyConstraints(containerID, samzaResource.getHost())) { log.info("Running container on meets standby constraints, preferredHost = {}", containerID, samzaResource.getHost(), preferredHost); containerAllocator.runStreamProcessor(request, preferredHost); if (isFaultDomainAwareStandbyEnabled && StandbyTaskUtil.isStandbyContainer(containerID)) { samzaApplicationState.faultDomainAwareContainersStarted.incrementAndGet(); } } else if (StandbyTaskUtil.isStandbyContainer(containerID)) { log.info( "Running standby container on host does not meet standby constraints, cancelling resource request, releasing resource, and making a new ANY_HOST request", containerID, samzaResource.getHost()); releaseUnstartableContainer(request, samzaResource, preferredHost, resourceRequestState); String activeContainerHost = getActiveContainerHost(containerID) .orElse(null); requestResource(containerAllocator, containerID, ResourceRequestState.ANY_HOST, Duration.ZERO, activeContainerHost); samzaApplicationState.failedStandbyAllocations.incrementAndGet(); } else { log.warn( "Running active container on host does not meet standby constraints, cancelling resource request, releasing resource", containerID, samzaResource.getHost()); releaseUnstartableContainer(request, samzaResource, preferredHost, resourceRequestState); Optional<FailoverMetadata> failoverMetadata = getFailoverMetadata(request); String lastKnownResourceID = failoverMetadata.isPresent() ? failoverMetadata.get().activeContainerResourceID : "unknown-" + containerID; initiateStandbyAwareAllocation(containerID, lastKnownResourceID, containerAllocator); samzaApplicationState.failedStandbyAllocations.incrementAndGet(); } }