exceptionfactory commented on code in PR #6149: URL: https://github.com/apache/nifi/pull/6149#discussion_r906383862
########## c2/c2-client-bundle/c2-client-http/src/main/java/org/apache/nifi/c2/client/http/C2HttpClient.java: ########## @@ -91,6 +92,45 @@ public Optional<C2HeartbeatResponse> publishHeartbeat(C2Heartbeat heartbeat) { return serializer.serialize(heartbeat).flatMap(this::sendHeartbeat); } + @Override + public Optional<byte[]> retrieveUpdateContent(String flowUpdateUrl) { + final Request.Builder requestBuilder = new Request.Builder() + .get() + .url(flowUpdateUrl); + final Request request = requestBuilder.build(); + + Optional<ResponseBody> body; + try (Response response = httpClientReference.get().newCall(request).execute()) { + int code = response.code(); + body = Optional.ofNullable(response.body()); + + if (code >= HTTP_STATUS_BAD_REQUEST) { + StringBuilder messageBuilder = new StringBuilder(String.format("Configuration retrieval failed: HTTP %d", code)); + body.map(Object::toString).ifPresent(messageBuilder::append); + throw new C2ServerException(messageBuilder.toString()); + } + + if (!body.isPresent()) { + logger.warn("No body returned when pulling a new configuration"); + return Optional.empty(); + } + + return Optional.of(body.get().bytes()); + } catch (Exception e) { + logger.warn("Configuration retrieval failed", e); + return Optional.empty(); + } + } + + @Override + public void acknowledgeOperation(C2OperationAck operationAck) { + logger.info("Performing acknowledgement request to {} for operation {}", clientConfig.getC2AckUrl(), operationAck.getOperationId()); Review Comment: Thanks, that sounds good. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org