Class AsynchronousTlsChannelGroup

java.lang.Object
tlschannel.async.AsynchronousTlsChannelGroup

public class AsynchronousTlsChannelGroup extends Object
This class encapsulates the infrastructure for running AsynchronousTlsChannels. Each instance of this class is a singleton-like object that manages a thread pool that makes it possible to run a group of asynchronous channels.
  • Constructor Details

    • AsynchronousTlsChannelGroup

      public AsynchronousTlsChannelGroup(int nThreads)
      Creates an instance of this class.
      Parameters:
      nThreads - number of threads in the executor used to assist the selector loop and run completion handlers.
    • AsynchronousTlsChannelGroup

      public AsynchronousTlsChannelGroup()
      Creates an instance of this class, using as many thread as available processors.
  • Method Details

    • isShutdown

      public boolean isShutdown()
      Whether either shutdown() or shutdownNow() have been called.
      Returns:
      true if this group has initiated shutdown and false if the group is active
    • shutdown

      public void shutdown()
      Starts the shutdown process. New sockets cannot be registered, already registered one continue operating normally until they are closed.
    • shutdownNow

      public void shutdownNow()
      Shuts down this channel group immediately. All registered sockets are closed, pending operations may or may not finish.
    • isTerminated

      public boolean isTerminated()
      Whether this channel group was shut down, and all pending tasks have drained.
      Returns:
      whether the channel is terminated
    • awaitTermination

      public boolean awaitTermination(long timeout, TimeUnit unit) throws InterruptedException
      Blocks until all registers sockets are closed and pending tasks finished execution after a shutdown request, or the timeout occurs, or the current thread is interrupted, whichever happens first.
      Parameters:
      timeout - the maximum time to wait
      unit - the time unit of the timeout argument
      Returns:
      true if this group terminated and false if the group elapsed before termination
      Throws:
      InterruptedException - if interrupted while waiting
    • getStartedReadCount

      public long getStartedReadCount()
      Return the total number of read operations that were started.
      Returns:
      number of operations
    • getStartedWriteCount

      public long getStartedWriteCount()
      Return the total number of write operations that were started.
      Returns:
      number of operations
    • getSuccessfulReadCount

      public long getSuccessfulReadCount()
      Return the total number of read operations that succeeded.
      Returns:
      number of operations
    • getSuccessfulWriteCount

      public long getSuccessfulWriteCount()
      Return the total number of write operations that succeeded.
      Returns:
      number of operations
    • getFailedReadCount

      public long getFailedReadCount()
      Return the total number of read operations that failed.
      Returns:
      number of operations
    • getFailedWriteCount

      public long getFailedWriteCount()
      Return the total number of write operations that failed.
      Returns:
      number of operations
    • getCancelledReadCount

      public long getCancelledReadCount()
      Return the total number of read operations that were cancelled.
      Returns:
      number of operations
    • getCancelledWriteCount

      public long getCancelledWriteCount()
      Return the total number of write operations that were cancelled.
      Returns:
      number of operations
    • getCurrentReadCount

      public long getCurrentReadCount()
      Returns the current number of active read operations.
      Returns:
      number of operations
    • getCurrentWriteCount

      public long getCurrentWriteCount()
      Returns the current number of active write operations.
      Returns:
      number of operations
    • getCurrentRegistrationCount

      public long getCurrentRegistrationCount()
      Returns the current number of registered sockets.
      Returns:
      number of sockets
    • isAlive

      public boolean isAlive()
      Returns whether the selector thread is alive (used for debugging).
      Returns:
      whether the selector thread is alive