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); }
private void getContainerDescription(String resourceDescriptionLink, Consumer<ReservationComponentDescription> callbackFunction) { if (description != null) { callbackFunction.accept(description); return; } sendRequest(Operation.createGet(this, resourceDescriptionLink) .setCompletion((o, e) -> { if (e != null) { failTask("Failure retrieving description state", e); return; } ReservationComponentDescription cd = new ReservationComponentDescription(); if (resourceDescriptionLink .startsWith(CompositeDescriptionFactoryService.SELF_LINK)) { cd.updateServiceDocument(o.getBody(CompositeDescription.class)); } else { ComponentMeta metaByDescriptionLink = CompositeComponentRegistry .metaByDescriptionLink(resourceDescriptionLink); cd.updateServiceDocument(o.getBody(metaByDescriptionLink.descriptionClass)); } this.description = cd; callbackFunction.accept(cd); })); }
.setCompletion((o, e) -> { if (e != null) { failTask("Failure creating placement task", e); return;
(o, e) -> { if (e != null) { failTask("Failure creating reservation allocation task", e); return;