@Override protected StatusType.Family featureValueOf(StatusType item) { return item.family(); } };
@Override public void response(Response<ByteString> response) { requestRateCounter.ifPresent(consumer -> consumer.accept(response)); responseSizeHistogram .ifPresent(histogram -> response.payload() .ifPresent(payload -> histogram.update(payload.size()))); sentReplies.mark(); timerContext.ifPresent(timer -> { final long duration = timer.stop(); final long durationMs = TimeUnit.NANOSECONDS.toMillis(duration); durationThresholdTracker.ifPresent(counter -> { counter.markDurationThresholds(durationMs); }); }); StatusType.Family family = response.status().family(); if (family != INFORMATIONAL && family != SUCCESSFUL) { sentErrors.mark(); } if (family == CLIENT_ERROR) { sentErrors4xx.mark(); } if (family == SERVER_ERROR) { sentErrors5xx.mark(); } }
private static boolean setPayloadForStatus(StatusType statusType) { return statusType.code() != Status.NOT_MODIFIED.code() && statusType.code() != Status.NO_CONTENT.code() && statusType.family() != StatusType.Family.INFORMATIONAL; }
@Override protected StatusType.Family featureValueOf(StatusType item) { return item.family(); } };
private CompletionStage<Boolean> haltActiveBackfillInstance(WorkflowInstance workflowInstance, Client client) { try { final ByteString payload = serialize(Event.halt(workflowInstance)); final Request request = Request.forUri(schedulerApiUrl("events"), "POST") .withPayload(payload); return client.send(request) .thenApply(response -> response.status().family().equals(SUCCESSFUL)); } catch (JsonProcessingException e) { return CompletableFuture.completedFuture(false); } }