private void selectReservation(ReservationTaskState state, LinkedHashMap<String, String> resourcePoolsPerGroupPlacementLinks) { if (resourcePoolsPerGroupPlacementLinks.isEmpty()) { failTask("No suitable host available", null); return; } Iterator<String> iter = resourcePoolsPerGroupPlacementLinks.keySet().iterator(); String placementLink = iter.next(); iter.remove(); logInfo("Current selected placement: %s", placementLink); proceedTo(SubStage.RESERVATION_SELECTED, s -> { s.resourcePoolsPerGroupPlacementLinks = resourcePoolsPerGroupPlacementLinks; s.groupResourcePlacementLink = placementLink; }); }
private void hostsSelected(ReservationTaskState state) { if (state.hostSelections == null || state.hostSelections.isEmpty()) { if (state.tenantLinks != null && !state.tenantLinks.isEmpty()) { proceedTo(SubStage.QUERYING_GLOBAL); } else { failTask("Available compute host can't be selected.", null); } return; } logInfo("Hosts selected %s", state.hostSelections); final Set<String> resourcePools = new HashSet<>(); state.hostSelections.forEach(hs -> resourcePools.addAll(hs.resourcePoolLinks)); if (state.resourcePoolsPerGroupPlacementLinks != null) { state.resourcePoolsPerGroupPlacementLinks = state.resourcePoolsPerGroupPlacementLinks .entrySet().stream().filter((e) -> resourcePools.contains(e.getValue())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (k1, k2) -> k1, LinkedHashMap::new)); } else { state.resourcePoolsPerGroupPlacementLinks = new LinkedHashMap<>(); } selectReservation(state, state.resourcePoolsPerGroupPlacementLinks); }
return; proceedTo(isGlobal(state) ? SubStage.PLACEMENT_GLOBAL : SubStage.PLACEMENT); }));
if (customProperties != null && customProperties .containsKey(ReservationAllocationTaskService.CONTAINER_HOST_ID_CUSTOM_PROPERTY)) { proceedTo(ReservationTaskState.SubStage.RESERVATION_ALLOCATION); return; } else { if (state.tenantLinks != null && !state.tenantLinks.isEmpty()) { proceedTo(SubStage.QUERYING_GLOBAL); } else { failTask("No suitable host available", null); proceedTo(isGlobal(state) ? SubStage.SELECTED_GLOBAL : SubStage.SELECTED, s -> {
return; proceedTo(SubStage.ALLOCATING_RESOURCE_POOL); }));