private void respondWithEmptyMetrics(final RetrieveConnectionMetrics command, final ActorRef origin) { log.debug("ClientActor not started, responding with empty connection metrics with status closed."); final ConnectionMetrics metrics = ConnectivityModelFactory.newConnectionMetrics(ConnectionStatus.CLOSED, "connection is closed", connectionClosedAt != null ? connectionClosedAt : Instant.ofEpochSecond(0), BaseClientState.DISCONNECTED.name(), Collections.emptyList(), Collections.emptyList()); final RetrieveConnectionMetricsResponse metricsResponse = RetrieveConnectionMetricsResponse.of(connectionId, metrics, command.getDittoHeaders()); final String responseType = metricsResponse.getType(); final AggregatedConnectivityCommandResponse response = AggregatedConnectivityCommandResponse.of(connectionId, Collections.singletonList(metricsResponse), responseType, HttpStatusCode.OK, command.getDittoHeaders()); origin.tell(response, getSelf()); }
private void respondWithEmptyMetrics(final RetrieveConnectionMetrics command, final ActorRef origin) { log.debug("ClientActor not started, responding with empty connection metrics with status closed."); final ConnectionMetrics metrics = ConnectivityModelFactory.newConnectionMetrics(ConnectionStatus.CLOSED, "connection is closed", connectionClosedAt != null ? connectionClosedAt : Instant.ofEpochSecond(0), BaseClientState.DISCONNECTED.name(), Collections.emptyList(), Collections.emptyList()); final RetrieveConnectionMetricsResponse metricsResponse = RetrieveConnectionMetricsResponse.of(connectionId, metrics, command.getDittoHeaders()); final String responseType = metricsResponse.getType(); final AggregatedConnectivityCommandResponse response = AggregatedConnectivityCommandResponse.of(connectionId, Collections.singletonList(metricsResponse), responseType, HttpStatusCode.OK, command.getDittoHeaders()); origin.tell(response, getSelf()); }
private FSM.State<BaseClientState, BaseClientData> retrieveConnectionMetrics( final RetrieveConnectionMetrics command, final BaseClientData data) { final ActorRef sender = getSender(); final ActorRef self = getSelf(); final DittoHeaders dittoHeaders = command.getDittoHeaders().toBuilder() .source(org.eclipse.ditto.services.utils.config.ConfigUtil.instanceIdentifier()) .build(); final CompletionStage<List<SourceMetrics>> sourceMetricsFuture = getCurrentSourcesMetrics(); final CompletionStage<List<TargetMetrics>> targetMetricsFuture = getCurrentTargetsMetrics(); final CompletionStage<ConnectionMetrics> metricsFuture = sourceMetricsFuture.thenCompose(sourceMetrics -> targetMetricsFuture.thenApply(targetMetrics -> ConnectivityModelFactory.newConnectionMetrics( getCurrentConnectionStatus(), getCurrentConnectionStatusDetails().orElse(null), getInConnectionStatusSince(), stateName().name(), sourceMetrics, targetMetrics) ) ); metricsFuture.thenAccept(connectionMetrics -> { final Object response = RetrieveConnectionMetricsResponse.of(connectionId(), connectionMetrics, dittoHeaders); sender.tell(response, self); }); return stay(); }
private FSM.State<BaseClientState, BaseClientData> retrieveConnectionMetrics( final RetrieveConnectionMetrics command, final BaseClientData data) { final ActorRef sender = getSender(); final ActorRef self = getSelf(); final DittoHeaders dittoHeaders = command.getDittoHeaders().toBuilder() .source(org.eclipse.ditto.services.utils.config.ConfigUtil.instanceIdentifier()) .build(); final CompletionStage<List<SourceMetrics>> sourceMetricsFuture = getCurrentSourcesMetrics(); final CompletionStage<List<TargetMetrics>> targetMetricsFuture = getCurrentTargetsMetrics(); final CompletionStage<ConnectionMetrics> metricsFuture = sourceMetricsFuture.thenCompose(sourceMetrics -> targetMetricsFuture.thenApply(targetMetrics -> ConnectivityModelFactory.newConnectionMetrics( getCurrentConnectionStatus(), getCurrentConnectionStatusDetails().orElse(null), getInConnectionStatusSince(), stateName().name(), sourceMetrics, targetMetrics) ) ); metricsFuture.thenAccept(connectionMetrics -> { final Object response = RetrieveConnectionMetricsResponse.of(connectionId(), connectionMetrics, dittoHeaders); sender.tell(response, self); }); return stay(); }