Repository: incubator-nifi Updated Branches: refs/heads/NIFI-250 80b8c6024 -> 953cb1227
NIFI-250: - Providing access to the merged node response when clustered. This is necessary as custom UIs will need to access to these details. - Ensuring the cluster processor endpoint is merged appropriately. Project: http://git-wip-us.apache.org/repos/asf/incubator-nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-nifi/commit/953cb122 Tree: http://git-wip-us.apache.org/repos/asf/incubator-nifi/tree/953cb122 Diff: http://git-wip-us.apache.org/repos/asf/incubator-nifi/diff/953cb122 Branch: refs/heads/NIFI-250 Commit: 953cb1227af70e846e47416ffdbc6eb3a1686d6a Parents: 80b8c60 Author: Matt Gilman <[email protected]> Authored: Tue Mar 24 12:28:30 2015 -0400 Committer: Matt Gilman <[email protected]> Committed: Tue Mar 24 12:28:30 2015 -0400 ---------------------------------------------------------------------- .../nifi/cluster/manager/NodeResponse.java | 14 ++++++++ .../cluster/manager/impl/WebClusterManager.java | 3 +- .../StandardNiFiWebConfigurationContext.java | 34 +++++++++++++++----- 3 files changed, 42 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/953cb122/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java index 3f966e5..8bc73ab 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/NodeResponse.java @@ -192,6 +192,20 @@ public class NodeResponse { } /** + * If this node response has been merged returns the updated entity, + * otherwise null. Also returns null if hasThrowable() is true. The + * intent of this method is to support getting the response entity + * when it was already consumed during the merge operation. In this + * case the client response rom getClientResponse() will not support + * a getEntity(...) or getEntityInputStream() call. + * + * @return + */ + public Entity getUpdatedEntity() { + return updatedEntity; + } + + /** * Creates a Response by mapping the ClientResponse values to it. Since the * ClientResponse's input stream can only be read once, this method should * only be called once. Furthermore, the caller should not have already read http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/953cb122/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java index 37465e9..4046995 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/manager/impl/WebClusterManager.java @@ -306,6 +306,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C public static final Pattern PROCESSORS_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/processors"); public static final Pattern PROCESSOR_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/processors/[a-f0-9\\-]{36}"); + public static final Pattern CLUSTER_PROCESSOR_URI_PATTERN = Pattern.compile("/nifi-api/cluster/processors/[a-f0-9\\-]{36}"); public static final Pattern REMOTE_PROCESS_GROUPS_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/remote-process-groups"); public static final Pattern REMOTE_PROCESS_GROUP_URI_PATTERN = Pattern.compile("/nifi-api/controller/process-groups/(?:(?:root)|(?:[a-f0-9\\-]{36}))/remote-process-groups/[a-f0-9\\-]{36}"); @@ -2370,7 +2371,7 @@ public class WebClusterManager implements HttpClusterManager, ProtocolHandler, C } private static boolean isProcessorEndpoint(final URI uri, final String method) { - if (("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)) && PROCESSOR_URI_PATTERN.matcher(uri.getPath()).matches()) { + if (("GET".equalsIgnoreCase(method) || "PUT".equalsIgnoreCase(method)) && (PROCESSOR_URI_PATTERN.matcher(uri.getPath()).matches() || CLUSTER_PROCESSOR_URI_PATTERN.matcher(uri.getPath()).matches()) ) { return true; } else if ("POST".equalsIgnoreCase(method) && PROCESSORS_URI_PATTERN.matcher(uri.getPath()).matches()) { return true; http://git-wip-us.apache.org/repos/asf/incubator-nifi/blob/953cb122/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java ---------------------------------------------------------------------- diff --git a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java index eb4b81e..5ef9780 100644 --- a/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java +++ b/nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardNiFiWebConfigurationContext.java @@ -293,7 +293,10 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration checkResponse(nodeResponse, id); // return processor - final ProcessorEntity entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class); + ProcessorEntity entity = (ProcessorEntity) nodeResponse.getUpdatedEntity(); + if (entity == null) { + entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class); + } processor = entity.getProcessor(); } else { processor = serviceFacade.getProcessor(id); @@ -349,7 +352,10 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration checkResponse(nodeResponse, id); // return processor - final ProcessorEntity entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class); + ProcessorEntity entity = (ProcessorEntity) nodeResponse.getUpdatedEntity(); + if (entity == null) { + entity = nodeResponse.getClientResponse().getEntity(ProcessorEntity.class); + } processor = entity.getProcessor(); } else { final ConfigurationSnapshot<ProcessorDTO> response = serviceFacade.setProcessorAnnotationData(revision, id, annotationData); @@ -406,7 +412,10 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration checkResponse(nodeResponse, id); // return controller service - final ControllerServiceEntity entity = nodeResponse.getClientResponse().getEntity(ControllerServiceEntity.class); + ControllerServiceEntity entity = (ControllerServiceEntity) nodeResponse.getUpdatedEntity(); + if (entity == null) { + entity = nodeResponse.getClientResponse().getEntity(ControllerServiceEntity.class); + } controllerService = entity.getControllerService(); } @@ -462,8 +471,11 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // check for issues replicating request checkResponse(nodeResponse, id); - // return processor - final ControllerServiceEntity entity = nodeResponse.getClientResponse().getEntity(ControllerServiceEntity.class); + // return controller service + ControllerServiceEntity entity = (ControllerServiceEntity) nodeResponse.getUpdatedEntity(); + if (entity == null) { + entity = nodeResponse.getClientResponse().getEntity(ControllerServiceEntity.class); + } controllerService = entity.getControllerService(); } @@ -515,8 +527,11 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration // check for issues replicating request checkResponse(nodeResponse, id); - // return processor - final ReportingTaskEntity entity = nodeResponse.getClientResponse().getEntity(ReportingTaskEntity.class); + // return reporting task + ReportingTaskEntity entity = (ReportingTaskEntity) nodeResponse.getUpdatedEntity(); + if (entity == null) { + entity = nodeResponse.getClientResponse().getEntity(ReportingTaskEntity.class); + } reportingTask = entity.getReportingTask(); } @@ -573,7 +588,10 @@ public class StandardNiFiWebConfigurationContext implements NiFiWebConfiguration checkResponse(nodeResponse, id); // return reporting task - final ReportingTaskEntity entity = nodeResponse.getClientResponse().getEntity(ReportingTaskEntity.class); + ReportingTaskEntity entity = (ReportingTaskEntity) nodeResponse.getUpdatedEntity(); + if (entity == null) { + entity = nodeResponse.getClientResponse().getEntity(ReportingTaskEntity.class); + } reportingTask = entity.getReportingTask(); }
