You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2021/07/26 10:58:55 UTC
[GitHub] [nifi] pvillard31 opened a new pull request #5250: NIFI-8785 - Confluent Schema Registry REST client - refactoring, debu…
pvillard31 opened a new pull request #5250:
URL: https://github.com/apache/nifi/pull/5250
…g logs and a new method to get schema info without making subjects API calls
Thank you for submitting a contribution to Apache NiFi.
Please provide a short description of the PR here:
#### Description of PR
_Enables X functionality; fixes bug NIFI-YYYY._
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [ ] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [ ] Does your PR title start with **NIFI-XXXX** where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [ ] Has your PR been rebased against the latest commit within the target branch (typically `main`)?
- [ ] Is your initial contribution a single, squashed commit? _Additional commits in response to PR reviewer feedback should be made on this branch and pushed to allow change tracking. Do not `squash` or use `--force` when pushing to allow for clean monitoring of changes._
### For code changes:
- [ ] Have you ensured that the full suite of tests is executed via `mvn -Pcontrib-check clean install` at the root `nifi` folder?
- [ ] Have you written or updated unit tests to verify your changes?
- [ ] Have you verified that the full build is successful on JDK 8?
- [ ] Have you verified that the full build is successful on JDK 11?
- [ ] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [ ] If applicable, have you updated the `LICENSE` file, including the main `LICENSE` file under `nifi-assembly`?
- [ ] If applicable, have you updated the `NOTICE` file, including the main `NOTICE` file found under `nifi-assembly`?
- [ ] If adding new Properties, have you added `.displayName` in addition to .name (programmatic access) for each of the new properties?
### For documentation related changes:
- [ ] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI for build issues and submit an update to your PR as soon as possible.
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] asfgit closed pull request #5250: NIFI-8785 - Confluent Schema Registry REST client - refactoring, debu…
Posted by GitBox <gi...@apache.org>.
asfgit closed pull request #5250:
URL: https://github.com/apache/nifi/pull/5250
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] pvillard31 commented on pull request #5250: NIFI-8785 - Confluent Schema Registry REST client - refactoring, debu…
Posted by GitBox <gi...@apache.org>.
pvillard31 commented on pull request #5250:
URL: https://github.com/apache/nifi/pull/5250#issuecomment-888157130
Hey @exceptionfactory - thanks for the review and suggestions.
Regarding the version of the schema registry and what APIs can be used or not, I didn't find anything that could be used to simplify the retrieval logic and, in the end, ensure to have the smallest number of calls against the schema registry. However, since the schemas are cached, we're not making too many calls. The initial implementation that was listing all subjects and checking the schema for each of the subject was super expensive (when the schema registry contains a lot of schemas). The recently added option (#4872) and this new option should make things much better in terms of performance.
https://docs.confluent.io/platform/current/schema-registry/develop/api.html
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on pull request #5250: NIFI-8785 - Confluent Schema Registry REST client - refactoring, debu…
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on pull request #5250:
URL: https://github.com/apache/nifi/pull/5250#issuecomment-888765938
Thanks for the updates and reply @pvillard31, that's a helpful point regarding caching. I will look at verifying the changes soon.
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi] exceptionfactory commented on a change in pull request #5250: NIFI-8785 - Confluent Schema Registry REST client - refactoring, debu…
Posted by GitBox <gi...@apache.org>.
exceptionfactory commented on a change in pull request #5250:
URL: https://github.com/apache/nifi/pull/5250#discussion_r677952002
##########
File path: nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
##########
@@ -196,6 +243,11 @@ private JsonNode postJsonResponse(final String pathSuffix, final JsonNode schema
final String path = getPath(pathSuffix);
final String trimmedBase = getTrimmedBase(baseUrl);
final String url = trimmedBase + path;
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("POST JSON response from " + url);
+ }
Review comment:
This logging statement could be adjusted to use placeholders, which would also remove the need to wrap it in the conditional.
```suggestion
logger.debug("POST JSON response URL {}", url);
```
##########
File path: nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
##########
@@ -232,20 +301,29 @@ private JsonNode fetchJsonResponse(final String pathSuffix, final String schemaD
final Response response = builder.get();
final int responseCode = response.getStatus();
- if (responseCode == Response.Status.OK.getStatusCode()) {
- return response.readEntity(JsonNode.class);
- }
+ switch (Response.Status.fromStatusCode(responseCode)) {
+ case OK:
+ JsonNode jsonResponse = response.readEntity(JsonNode.class);
- if (responseCode == Response.Status.NOT_FOUND.getStatusCode()) {
- throw new SchemaNotFoundException("Could not find Schema with " + schemaDescription + " from the Confluent Schema Registry located at " + baseUrl);
- }
+ if(logger.isDebugEnabled()) {
+ logger.debug("Response: " + jsonResponse.toString());
+ }
+
+ return jsonResponse;
- if (errorMessage == null) {
- errorMessage = response.readEntity(String.class);
+ case NOT_FOUND:
+ logger.debug("Could not find Schema with " + schemaDescription
+ + " from the Confluent Schema Registry located at " + baseUrl);
Review comment:
```suggestion
logger.debug("Could not find Schema {} from Registry {}", schemaDescription, baseUrl);
```
##########
File path: nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
##########
@@ -232,20 +301,29 @@ private JsonNode fetchJsonResponse(final String pathSuffix, final String schemaD
final Response response = builder.get();
final int responseCode = response.getStatus();
- if (responseCode == Response.Status.OK.getStatusCode()) {
- return response.readEntity(JsonNode.class);
- }
+ switch (Response.Status.fromStatusCode(responseCode)) {
+ case OK:
+ JsonNode jsonResponse = response.readEntity(JsonNode.class);
- if (responseCode == Response.Status.NOT_FOUND.getStatusCode()) {
- throw new SchemaNotFoundException("Could not find Schema with " + schemaDescription + " from the Confluent Schema Registry located at " + baseUrl);
- }
+ if(logger.isDebugEnabled()) {
+ logger.debug("Response: " + jsonResponse.toString());
+ }
Review comment:
```suggestion
if (logger.isDebugEnabled()) {
logger.debug("JSON Response {}", jsonResponse);
}
```
##########
File path: nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
##########
@@ -204,26 +256,43 @@ private JsonNode postJsonResponse(final String pathSuffix, final JsonNode schema
final Response response = builder.post(Entity.json(schema.toString()));
final int responseCode = response.getStatus();
- if (responseCode == Response.Status.NOT_FOUND.getStatusCode()) {
- continue;
- }
+ switch (Response.Status.fromStatusCode(responseCode)) {
+ case OK:
+ JsonNode jsonResponse = response.readEntity(JsonNode.class);
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("Response: " + jsonResponse.toString());
+ }
- if(responseCode == Response.Status.OK.getStatusCode()) {
- return response.readEntity(JsonNode.class);
+ return jsonResponse;
+
+ case NOT_FOUND:
+ logger.debug("Could not find Schema with " + schemaDescription
+ + " from the Confluent Schema Registry located at " + baseUrl);
Review comment:
```suggestion
logger.debug("Could not find Schema {} from Registry {}", schemaDescription, baseUrl);
```
##########
File path: nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
##########
@@ -204,26 +256,43 @@ private JsonNode postJsonResponse(final String pathSuffix, final JsonNode schema
final Response response = builder.post(Entity.json(schema.toString()));
final int responseCode = response.getStatus();
- if (responseCode == Response.Status.NOT_FOUND.getStatusCode()) {
- continue;
- }
+ switch (Response.Status.fromStatusCode(responseCode)) {
+ case OK:
+ JsonNode jsonResponse = response.readEntity(JsonNode.class);
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("Response: " + jsonResponse.toString());
+ }
- if(responseCode == Response.Status.OK.getStatusCode()) {
- return response.readEntity(JsonNode.class);
+ return jsonResponse;
+
+ case NOT_FOUND:
+ logger.debug("Could not find Schema with " + schemaDescription
+ + " from the Confluent Schema Registry located at " + baseUrl);
+ continue;
+
+ default:
+ errorMessage = response.readEntity(String.class);
+ continue;
}
}
- throw new SchemaNotFoundException("Failed to retrieve Schema with " + schemaDescription + " from any of the Confluent Schema Registry URL's provided; failure response message: "
+ throw new SchemaNotFoundException("Failed to retrieve Schema with " + schemaDescription
+ + " from any of the Confluent Schema Registry URL's provided; failure response message: "
+ errorMessage);
}
- private JsonNode fetchJsonResponse(final String pathSuffix, final String schemaDescription) throws SchemaNotFoundException, IOException {
+ private JsonNode fetchJsonResponse(final String pathSuffix, final String schemaDescription) throws SchemaNotFoundException {
String errorMessage = null;
for (final String baseUrl : baseUrls) {
final String path = getPath(pathSuffix);
final String trimmedBase = getTrimmedBase(baseUrl);
final String url = trimmedBase + path;
+ if(logger.isDebugEnabled()) {
+ logger.debug("GET JSON response from " + url);
+ }
Review comment:
```suggestion
logger.debug("GET JSON response URL {}", url);
```
##########
File path: nifi-nar-bundles/nifi-confluent-platform-bundle/nifi-confluent-schema-registry-service/src/main/java/org/apache/nifi/confluent/schemaregistry/client/RestSchemaRegistryClient.java
##########
@@ -204,26 +256,43 @@ private JsonNode postJsonResponse(final String pathSuffix, final JsonNode schema
final Response response = builder.post(Entity.json(schema.toString()));
final int responseCode = response.getStatus();
- if (responseCode == Response.Status.NOT_FOUND.getStatusCode()) {
- continue;
- }
+ switch (Response.Status.fromStatusCode(responseCode)) {
+ case OK:
+ JsonNode jsonResponse = response.readEntity(JsonNode.class);
+
+ if(logger.isDebugEnabled()) {
+ logger.debug("Response: " + jsonResponse.toString());
+ }
Review comment:
Conditional logging seems reasonable here given the serialization of the JsonNode, but using placeholders would be helpful.
```suggestion
if (logger.isDebugEnabled()) {
logger.debug("JSON Response: {}", jsonResponse);
}
```
--
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-unsubscribe@nifi.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org