From 250c4a89416b0150e5a90488e72464e431efb540 Mon Sep 17 00:00:00 2001 From: Andrew Psaltis Date: Thu, 26 Jan 2017 00:48:35 -0500 Subject: [PATCH] NIFI-2615 Addressing documentation issues that caused checkstyle failures and the build to fail This closes #1447. Signed-off-by: Andy LoPresto --- .../gettcp/AbstractSocketHandler.java | 22 +++++++++++++++++-- .../apache/nifi/processors/gettcp/GetTCP.java | 5 +++-- .../processors/gettcp/ReceivingClient.java | 6 +++-- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/AbstractSocketHandler.java b/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/AbstractSocketHandler.java index 5477053d34..547ee79c64 100644 --- a/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/AbstractSocketHandler.java +++ b/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/AbstractSocketHandler.java @@ -56,6 +56,8 @@ abstract class AbstractSocketHandler { protected final byte endOfMessageByte; /** + * This constructor configures the address to bind to, the size of the buffer to use for reading, and + * the byte pattern to use for demarcating the end of a message. * * @param address the socket address * @param readingBufferSize the buffer size @@ -70,7 +72,10 @@ abstract class AbstractSocketHandler { } /** + * Once the handler is constructed this should be called to start the handler. Although + * this method is safe to be called by multiple threads, it should only be called once. * + * @throws IllegalStateException if it fails to start listening on the port that is configured * */ public void start() { @@ -96,7 +101,9 @@ abstract class AbstractSocketHandler { } /** - * + * This should be called to stop the handler from listening on the socket. Although it is recommended + * that this is called once, by a single thread, this method does protect itself from being called by more + * than one thread and more than one time. * */ public void stop() { @@ -135,13 +142,15 @@ abstract class AbstractSocketHandler { } /** + * This must be overridden by an implementing class and should establish the socket connection. * * @throws Exception if an exception occurs */ abstract InetSocketAddress connect() throws Exception; /** - * Will process the data received from the channel + * Will process the data received from the channel. + * * @param selectionKey key for the channel the data came from * @param buffer buffer of received data * @throws IOException if there is a problem processing the data @@ -149,6 +158,8 @@ abstract class AbstractSocketHandler { abstract void processData(SelectionKey selectionKey, ByteBuffer buffer) throws IOException; /** + * This does not perform any work at this time as all current implementations of this class + * provide the client side of the connection and thus do not accept connections. * * @param selectionKey the selection key * @throws IOException if there is a problem @@ -193,14 +204,21 @@ abstract class AbstractSocketHandler { } /** + * Accept the selectable channel * + * @throws IOException in the event that something goes wrong accepting it */ private void accept(SelectionKey selectionKey) throws IOException { AbstractSocketHandler.this.doAccept(selectionKey); } /** + * This will connect the channel; if it is in a pending state then this will finish + * establishing the connection. Finally the socket handler is registered with this + * channel. * + * @throws IOException if anything goes wrong during the connection establishment + * or registering of the handler */ private void connect(SelectionKey selectionKey) throws IOException { SocketChannel clientChannel = (SocketChannel) selectionKey.channel(); diff --git a/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/GetTCP.java b/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/GetTCP.java index 172a4f904e..eecb66224e 100644 --- a/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/GetTCP.java +++ b/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/GetTCP.java @@ -28,7 +28,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ScheduledThreadPoolExecutor; import java.util.concurrent.TimeUnit; - import org.apache.nifi.annotation.behavior.InputRequirement; import org.apache.nifi.annotation.behavior.SideEffectFree; import org.apache.nifi.annotation.behavior.TriggerSerially; @@ -269,7 +268,9 @@ public class GetTCP extends AbstractSessionFactoryProcessor { } /** - * + * This handles taking the message that has been received off the wire and writing it to the + * content of a flowfile. If only a partial message is received then the flowfile is sent to + * the Partial relationship. If a full message is received then it is sent to the Success relationship. */ private class NiFiDelegatingMessageHandler implements MessageHandler { private final ProcessSessionFactory sessionFactory; diff --git a/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/ReceivingClient.java b/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/ReceivingClient.java index 2fb7c33fb8..1927b9934e 100644 --- a/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/ReceivingClient.java +++ b/nifi-nar-bundles/nifi-tcp-bundle/nifi-tcp-processors/src/main/java/org/apache/nifi/processors/gettcp/ReceivingClient.java @@ -59,7 +59,9 @@ class ReceivingClient extends AbstractSocketHandler { } /** - * + * Connects to the endpoint specified and if that fails, will attempt to connect to the + * secondary endpoint up to the number of reconnection attempts (inclusive) using the + * configured delay between attempts. */ @Override InetSocketAddress connect() throws Exception { @@ -119,7 +121,7 @@ class ReceivingClient extends AbstractSocketHandler { } /** - * + * Process the message that has arrived off the wire. */ @Override void processData(SelectionKey selectionKey, ByteBuffer messageBuffer) throws IOException {