From 6fd1c17ca4907be1f60b312a7a6203be57b09e89 Mon Sep 17 00:00:00 2001 From: Andre F de Miranda Date: Thu, 25 Aug 2016 22:19:25 +1000 Subject: [PATCH] NIFI-2662 - Fix checkstyle violations introduced by NIFI-2635 Signed-off-by: Matt Burgess This closes #940 --- .../http/replication/RequestReplicator.java | 6 +++--- .../ThreadPoolRequestReplicator.java | 12 +++++++----- .../TestThreadPoolRequestReplicator.java | 18 ++++++++++++------ 3 files changed, 22 insertions(+), 14 deletions(-) diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/RequestReplicator.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/RequestReplicator.java index b9bce0a937..2beff221bb 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/RequestReplicator.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/RequestReplicator.java @@ -110,10 +110,10 @@ public interface RequestReplicator { */ AsyncClusterResponse replicate(Set nodeIds, String method, URI uri, Object entity, Map headers, boolean indicateReplicated, boolean performVerification); - + /** * Forwards a request to the Cluster Coordinator so that it is able to replicate the request to all nodes in the cluster. - * + * * @param coordinatorNodeId the node identifier of the Cluster Coordinator * @param method the HTTP method (e.g., POST, PUT) * @param uri the base request URI (up to, but not including, the query string) @@ -123,7 +123,7 @@ public interface RequestReplicator { * @return an AsyncClusterResponse that indicates the current status of the request and provides an identifier for obtaining an updated response later */ AsyncClusterResponse forwardToCoordinator(NodeIdentifier coordinatorNodeId, String method, URI uri, Object entity, Map headers); - + /** *

* Returns an AsyncClusterResponse that provides the most up-to-date status of the request with the given identifier. diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/ThreadPoolRequestReplicator.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/ThreadPoolRequestReplicator.java index e22bb79a72..3342470cd3 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/ThreadPoolRequestReplicator.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/replication/ThreadPoolRequestReplicator.java @@ -262,16 +262,16 @@ public class ThreadPoolRequestReplicator implements RequestReplicator { public AsyncClusterResponse forwardToCoordinator(final NodeIdentifier coordinatorNodeId, final String method, final URI uri, final Object entity, final Map headers) { // If the user is authenticated, add them as a proxied entity so that when the receiving NiFi receives the request, // it knows that we are acting as a proxy on behalf of the current user. - final Map updatedHeaders = new HashMap<>(headers); + final Map updatedHeaders = new HashMap<>(headers); final NiFiUser user = NiFiUserUtils.getNiFiUser(); if (user != null && !user.isAnonymous()) { final String proxiedEntitiesChain = ProxiedEntitiesUtils.buildProxiedEntitiesChainString(user); updatedHeaders.put(ProxiedEntitiesUtils.PROXY_ENTITIES_CHAIN, proxiedEntitiesChain); } - + return replicate(Collections.singleton(coordinatorNodeId), method, uri, entity, updatedHeaders, false, null, false); } - + /** * Replicates the request to all nodes in the given set of node identifiers * @@ -516,8 +516,10 @@ public class ThreadPoolRequestReplicator implements RequestReplicator { } // Visible for testing - overriding this method makes it easy to verify behavior without actually making any web requests - protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, final NodeIdentifier nodeId, final String method, final URI uri, final String requestId, - final Map headers) { + protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, + final NodeIdentifier nodeId, final String method, + final URI uri, final String requestId, + final Map headers) { final ClientResponse clientResponse; final long startNanos = System.nanoTime(); logger.debug("Replicating request to {} {}, request ID = {}, headers = {}", method, uri, requestId, headers); diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/coordination/http/replication/TestThreadPoolRequestReplicator.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/coordination/http/replication/TestThreadPoolRequestReplicator.java index ce7f452de5..1db2602178 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/coordination/http/replication/TestThreadPoolRequestReplicator.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/test/java/org/apache/nifi/cluster/coordination/http/replication/TestThreadPoolRequestReplicator.java @@ -164,8 +164,10 @@ public class TestThreadPoolRequestReplicator { final ThreadPoolRequestReplicator replicator = new ThreadPoolRequestReplicator(2, new Client(), coordinator, "1 sec", "1 sec", null, null, NiFiProperties.createBasicNiFiProperties(null, null)) { @Override - protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, final NodeIdentifier nodeId, final String method, - final URI uri, final String requestId, Map givenHeaders) { + protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, + final NodeIdentifier nodeId, final String method, + final URI uri, final String requestId, + Map givenHeaders) { // the resource builder will not expose its headers to us, so we are using Mockito's Whitebox class to extract them. final OutBoundHeaders headers = (OutBoundHeaders) Whitebox.getInternalState(resourceBuilder, "metadata"); final Object expectsHeader = headers.getFirst(ThreadPoolRequestReplicator.REQUEST_VALIDATION_HTTP_HEADER); @@ -286,8 +288,10 @@ public class TestThreadPoolRequestReplicator { final ThreadPoolRequestReplicator replicator = new ThreadPoolRequestReplicator(2, new Client(), coordinator, "1 sec", "1 sec", null, null, NiFiProperties.createBasicNiFiProperties(null, null)) { @Override - protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, final NodeIdentifier nodeId, final String method, - final URI uri, final String requestId, Map givenHeaders) { + protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, + final NodeIdentifier nodeId, final String method, + final URI uri, final String requestId, + Map givenHeaders) { // the resource builder will not expose its headers to us, so we are using Mockito's Whitebox class to extract them. final OutBoundHeaders headers = (OutBoundHeaders) Whitebox.getInternalState(resourceBuilder, "metadata"); final Object expectsHeader = headers.getFirst(ThreadPoolRequestReplicator.REQUEST_VALIDATION_HTTP_HEADER); @@ -329,8 +333,10 @@ public class TestThreadPoolRequestReplicator { final ThreadPoolRequestReplicator replicator = new ThreadPoolRequestReplicator(2, new Client(), coordinator, "1 sec", "1 sec", null, null, NiFiProperties.createBasicNiFiProperties(null, null)) { @Override - protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, final NodeIdentifier nodeId, final String method, - final URI uri, final String requestId, Map givenHeaders) { + protected NodeResponse replicateRequest(final WebResource.Builder resourceBuilder, + final NodeIdentifier nodeId, final String method, + final URI uri, final String requestId, + Map givenHeaders) { if (delayMillis > 0L) { try { Thread.sleep(delayMillis);