Source:
private void callExternalSchedulerToReserve(AllocationAttempt attempt, AllocationCandidate candidate) { List<Long> agentIds = getAgentResource(attempt.getAccountId(), attempt.getInstances()); if (agentIds.isEmpty() && !attempt.getInstances().get(0).getSystem() && allocatorDao.schedulerServiceEnabled(attempt.getAccountId()) && allocatorDao.isScheulderIpsEnabled(attempt.getAccountId())) { List<ResourceRequest> resourceRequests = gatherResourceRequests(attempt.getInstances(), attempt.getVolumes(), null); for (ResourceRequest r : resourceRequests) { if (r instanceof PortBindingResourceRequest) { PortBindingResourceRequest pr = (PortBindingResourceRequest)r; for (PortSpec ps : pr.getPortRequests()) { if (StringUtils.isEmpty(ps.getIpAddress()) || !"0.0.0.0".equals(ps.getIpAddress())) { throw new FailedToAllocate("Cannot perform IP scheduling because external scheduler is unavailable"); } } } } } for (Long agentId : agentIds) { EventVO<Map<String, Object>> schedulerEvent = buildEvent(SCHEDULER_RESERVE_EVENT, InstanceConstants.PROCESS_ALLOCATE, attempt.getInstances(), attempt.getVolumes(), agentId); if (schedulerEvent != null) { Map<String, Object> reqData = CollectionUtils.toMap(schedulerEvent.getData().get(SCHEDULER_REQUEST_DATA_NAME)); reqData.put(HOST_ID, candidate.getHostUuid()); if (attempt.getRequestedHostId() != null) { reqData.put(FORCE_RESERVE, true); } RemoteAgent agent = agentLocator.lookupAgent(agentId); Event eventResult = callScheduler("Error reserving resources: %s", schedulerEvent, agent); if (eventResult.getData() == null) { return; } List<Map<String, Object>> data = (List<Map<String, Object>>) CollectionUtils.getNestedValue(eventResult.getData(), PORT_RESERVATION); if (data != null) { attempt.setAllocatedIPs(data); } } } }

Target:
private void callExternalSchedulerToReserve(AllocationAttempt attempt, AllocationCandidate candidate) { List<Long> agentIds = getAgentResource(attempt.getAccountId(), attempt.getInstances()); if (agentIds.isEmpty() && !attempt.getInstances().get(0).getSystem() && allocatorDao.isSchedulerServiceEnabled(attempt.getAccountId()) && allocatorDao.isScheulderIpsEnabled(attempt.getAccountId())) { List<ResourceRequest> resourceRequests = gatherResourceRequests(attempt.getInstances(), attempt.getVolumes(), null); for (ResourceRequest r : resourceRequests) { if (r instanceof PortBindingResourceRequest) { PortBindingResourceRequest pr = (PortBindingResourceRequest)r; for (PortSpec ps : pr.getPortRequests()) { if (!"0.0.0.0".equals(ps.getIpAddress())) { throw new FailedToAllocate("Cannot perform IP scheduling because external scheduler is unavailable"); } } } } } for (Long agentId : agentIds) { EventVO<Map<String, Object>> schedulerEvent = buildEvent(SCHEDULER_RESERVE_EVENT, InstanceConstants.PROCESS_ALLOCATE, attempt.getInstances(), attempt.getVolumes(), agentId); if (schedulerEvent != null) { Map<String, Object> reqData = CollectionUtils.toMap(schedulerEvent.getData().get(SCHEDULER_REQUEST_DATA_NAME)); reqData.put(HOST_ID, candidate.getHostUuid()); if (attempt.getRequestedHostId() != null) { reqData.put(FORCE_RESERVE, true); } RemoteAgent agent = agentLocator.lookupAgent(agentId); Event eventResult = callScheduler("Error reserving resources: %s", schedulerEvent, agent); if (eventResult.getData() == null) { return; } List<Map<String, Object>> data = (List<Map<String, Object>>) CollectionUtils.getNestedValue(eventResult.getData(), PORT_RESERVATION); if (data != null) { attempt.setAllocatedIPs(data); } } } }