protected ListResponse<HostResponse> getHostResponses() { ListResponse<HostResponse> response = new ListResponse<>(); if (getVirtualMachineId() == null) { response = _queryService.searchForServers(this); } else { Pair<List<? extends Host>, Integer> result; Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal(), null); result = hostsForMigration.first(); List<? extends Host> hostsWithCapacity = hostsForMigration.second(); List<HostResponse> hostResponses = new ArrayList<HostResponse>(); for (Host host : result.first()) { HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails()); Boolean suitableForMigration = false; if (hostsWithCapacity.contains(host)) { suitableForMigration = true; } hostResponse.setSuitableForMigration(suitableForMigration); hostResponse.setObjectName("host"); hostResponses.add(hostResponse); } response.setResponses(hostResponses, result.second()); } return response; }
_mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal(), this.getKeyword()); result = hostsForMigration.first(); List<? extends Host> hostsWithCapacity = hostsForMigration.second();
_mgr.listHostsForMigrationOfVM(getVirtualMachineId(), this.getStartIndex(), this.getPageSizeVal(), this.getKeyword()); result = hostsForMigration.first(); final List<? extends Host> hostsWithCapacity = hostsForMigration.second();
@Override public void execute() { ListResponse<HostResponse> response = null; if (getVirtualMachineId() == null) { response = _queryService.searchForServers(this); } else { final Pair<List<? extends Host>, Integer> result; final Ternary<Pair<List<? extends Host>, Integer>, List<? extends Host>, Map<Host, Boolean>> hostsForMigration = _mgr.listHostsForMigrationOfVM(getVirtualMachineId(), getStartIndex(), getPageSizeVal(), null); result = hostsForMigration.first(); final List<? extends Host> hostsWithCapacity = hostsForMigration.second(); response = new ListResponse<>(); final List<HostResponse> hostResponses = new ArrayList<>(); for (final Host host : result.first()) { final HostResponse hostResponse = _responseGenerator.createHostResponse(host, getDetails()); Boolean suitableForMigration = false; if (hostsWithCapacity.contains(host)) { suitableForMigration = true; } hostResponse.setSuitableForMigration(suitableForMigration); hostResponse.setObjectName("host"); hostResponses.add(hostResponse); } response.setResponses(hostResponses, result.second()); } response.setResponseName(getCommandName()); setResponseObject(response); }