diff options
Diffstat (limited to 'lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java')
-rw-r--r-- | lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java b/lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java index 0a4d8575f..ae3d292d4 100644 --- a/lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java +++ b/lib/java/src/main/java/org/apache/thrift/server/TThreadedSelectorServer.java @@ -50,10 +50,10 @@ import org.slf4j.LoggerFactory; * reading and writing of client connections. A synchronous worker thread pool handles processing of * requests. * - * <p>Performs better than TNonblockingServer/THsHaServer in multi-core environments when the the + * <p>Performs better than TNonblockingServer/THsHaServer in multi-core environments when the * bottleneck is CPU on the single selector thread handling I/O. In addition, because the accept * handling is decoupled from reads/writes and invocation, the server has better ability to handle - * back- pressure from new connections (e.g. stop accepting when busy). + * back-pressure from new connections (e.g. stop accepting when busy). * * <p>Like TNonblockingServer, it relies on the use of TFramedTransport. */ @@ -183,7 +183,7 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer { private AcceptThread acceptThread; // Threads handling events on client transports - private final Set<SelectorThread> selectorThreads = new HashSet<SelectorThread>(); + private final Set<SelectorThread> selectorThreads = new HashSet<>(); // This wraps all the functionality of queueing and thread pool management // for the passing of Invocations from the selector thread(s) to the workers @@ -257,10 +257,8 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer { if (acceptThread != null) { acceptThread.wakeupSelector(); } - if (selectorThreads != null) { - for (SelectorThread thread : selectorThreads) { - if (thread != null) thread.wakeupSelector(); - } + for (SelectorThread thread : selectorThreads) { + if (thread != null) thread.wakeupSelector(); } } @@ -341,7 +339,7 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer { /** * Set up the AcceptThead * - * @throws IOException + * @throws IOException if failed to register selector */ public AcceptThread( TNonblockingServerTransport serverTransport, SelectorThreadLoadBalancer threadChooser) @@ -464,8 +462,8 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer { // Accepted connections added by the accept thread. private final BlockingQueue<TNonblockingTransport> acceptedQueue; - private int SELECTOR_AUTO_REBUILD_THRESHOLD = 512; - private long MONITOR_PERIOD = 1000L; + private static final int SELECTOR_AUTO_REBUILD_THRESHOLD = 512; + private static final long MONITOR_PERIOD = 1000L; private int jvmBug = 0; /** @@ -581,7 +579,8 @@ public class TThreadedSelectorServer extends AbstractNonblockingServer { } /** - * Do select and judge epoll bug happen. See : https://issues.apache.org/jira/browse/THRIFT-4251 + * Do select and judge epoll bug happen. See <a + * href="https://issues.apache.org/jira/browse/THRIFT-4251">THRIFT-4251</a> */ private void doSelect() throws IOException { long beforeSelect = System.currentTimeMillis(); |