private void sendBackAggregatedResults() { if (origin != null && originHeaders != null && !aggregatedResults.isEmpty()) { final String responseType = aggregatedResults.get(0).getType(); final AggregatedConnectivityCommandResponse response = AggregatedConnectivityCommandResponse.of(connectionId, aggregatedResults, responseType, HttpStatusCode.OK, originHeaders); log.debug("Aggregated response: {}", response); origin.tell(response, getSelf()); } else if (origin != null && originHeaders != null && !aggregatedStatus.isEmpty()) { log.debug("Aggregated statuses: {}", aggregatedStatus); final Optional<Status.Status> failure = aggregatedStatus.entrySet().stream() .filter(s -> s.getValue() instanceof Status.Failure) .map(Map.Entry::getValue) .findFirst(); if (failure.isPresent()) { origin.tell(failure.get(), getSelf()); } else { final String aggregatedStatusStr = aggregatedStatus.entrySet().stream() .map(Object::toString) .collect(Collectors.joining(",")); origin.tell(new Status.Success(aggregatedStatusStr), getSelf()); } } else { log.warning("No origin was present or results were empty in order to send back aggregated results to"); } getContext().stop(getSelf()); } }
private void sendBackAggregatedResults() { if (origin != null && originHeaders != null && !aggregatedResults.isEmpty()) { final String responseType = aggregatedResults.get(0).getType(); final AggregatedConnectivityCommandResponse response = AggregatedConnectivityCommandResponse.of(connectionId, aggregatedResults, responseType, HttpStatusCode.OK, originHeaders); log.debug("Aggregated response: {}", response); origin.tell(response, getSelf()); } else if (origin != null && originHeaders != null && !aggregatedStatus.isEmpty()) { log.debug("Aggregated statuses: {}", aggregatedStatus); final Optional<Status.Status> failure = aggregatedStatus.entrySet().stream() .filter(s -> s.getValue() instanceof Status.Failure) .map(Map.Entry::getValue) .findFirst(); if (failure.isPresent()) { origin.tell(failure.get(), getSelf()); } else { final String aggregatedStatusStr = aggregatedStatus.entrySet().stream() .map(Object::toString) .collect(Collectors.joining(",")); origin.tell(new Status.Success(aggregatedStatusStr), getSelf()); } } else { log.warning("No origin was present or results were empty in order to send back aggregated results to"); } getContext().stop(getSelf()); } }
originHeaders = command.getDittoHeaders(); origin = getSender(); getContext().setReceiveTimeout( Duration.create(timeout / 2.0, TimeUnit.MILLISECONDS)); })
originHeaders = command.getDittoHeaders(); origin = getSender(); getContext().setReceiveTimeout( Duration.create(timeout / 2.0, TimeUnit.MILLISECONDS)); })