private void selectHost(ContainerNetworkProvisionTaskState state, Consumer<ComputeState> callback) { getContextContainerStates(state, (states) -> { getContextContainerDescriptions(states, (descriptions) -> { List<ContainerState> containerStatesForNetwork = getDependantContainerStates( descriptions, states, networkDescription); if (containerStatesForNetwork.isEmpty()) { String err = String.format( "No container states depending on network description [%s] found.", networkDescription.name); failTask(err, null); } else { String hostLink = containerStatesForNetwork.get(0).parentLink; getHost(hostLink, (host) -> { callback.accept(host); }); } }); }); }