Class AsyncNodeNioServer

java.lang.Object
java.lang.Thread
org.jppf.nio.NioServer
org.jppf.nio.StatelessNioServer<AsyncNodeContext>
org.jppf.server.nio.nodeserver.async.AsyncNodeNioServer
All Implemented Interfaces:
Runnable, NodeConnectionCompletionListener

public final class AsyncNodeNioServer extends org.jppf.nio.StatelessNioServer<AsyncNodeContext> implements NodeConnectionCompletionListener
The NIO server that handles asynchronous client connections, which can handle multiple jobs concurrently.
Author:
Laurent Cohen
  • Constructor Details

    • AsyncNodeNioServer

      public AsyncNodeNioServer(JPPFDriver driver, int identifier, boolean useSSL) throws Exception
      Parameters:
      driver - reference to the driver.
      identifier - the channel identifier for channels handled by this server.
      useSSL - determines whether an SSLContext should be created for this server.
      Throws:
      Exception - if any error occurs.
  • Method Details

    • initReaderAndWriter

      protected void initReaderAndWriter()
      Specified by:
      initReaderAndWriter in class org.jppf.nio.StatelessNioServer<AsyncNodeContext>
    • handleSelectionException

      protected void handleSelectionException(SelectionKey key, Exception e)
      Specified by:
      handleSelectionException in class org.jppf.nio.StatelessNioServer<AsyncNodeContext>
    • accept

      public void accept(ServerSocketChannel serverSocketChannel, SocketChannel channel, org.jppf.nio.SSLHandler sslHandler, boolean ssl, boolean peer, Object... params)
      Specified by:
      accept in class org.jppf.nio.NioServer
    • createNioContext

      public AsyncNodeContext createNioContext(Object... params)
      Specified by:
      createNioContext in class org.jppf.nio.NioServer
    • closeConnection

      public void closeConnection(AsyncNodeContext context)
      Close the specified channel.
      Parameters:
      context - the channel to close.
    • removeAllConnections

      public void removeAllConnections()
      Overrides:
      removeAllConnections in class org.jppf.nio.NioServer
    • getMessageHandler

      public AsyncNodeMessageHandler getMessageHandler()
      Returns:
      the message handler for this server.
    • initNioHandlers

      protected void initNioHandlers()
      Overrides:
      initNioHandlers in class org.jppf.nio.StatelessNioServer<AsyncNodeContext>
    • getDriver

      public JPPFDriver getDriver()
      Returns:
      a reference to the driver.
    • getJPPFContext

      public org.jppf.load.balancer.JPPFContext getJPPFContext()
      Get the corresponding node's context information.
      Returns:
      a JPPFContext instance.
    • getOfflineNodeHandler

      public OfflineNodeHandler getOfflineNodeHandler()
      Get the object that holds the node bundles waiting for a node to reconnect and send the rsults.
      Returns:
      a OfflineNodeHandler instance.
    • getDispatchExpirationHandler

      public org.jppf.scheduling.JPPFScheduleHandler getDispatchExpirationHandler()
      Get the handler for the expiration of dispatched bundles.
      Returns:
      a JPPFScheduleHandler instance.
    • getPeerHandler

      public PeerAttributesHandler getPeerHandler()
      Get the peer handler.
      Returns:
      a AsyncPeerAttributesHandler instance.
    • getNodeReservationHandler

      public NodeReservationHandler getNodeReservationHandler()
      Get the object that handles reservation of nodes to jobs.
      Returns:
      a AsyncNodeReservationHandler instance.
    • getJobScheduler

      public AsyncJobScheduler getJobScheduler()
      Get the task that dispatches queued jobs to available nodes.
      Returns:
      a AsyncJobScheduler object.
    • getBundlerHandler

      public org.jppf.load.balancer.persistence.LoadBalancerPersistenceManager getBundlerHandler()
      Returns:
      the handler for the persistence fo the state of the load-balancers.
    • getBundlerFactory

      public org.jppf.load.balancer.spi.JPPFBundlerFactory getBundlerFactory()
      Get the factory object used to create bundler instances.
      Returns:
      an instance of JPPFBundlerFactory.
    • getAllChannels

      public List<BaseNodeContext> getAllChannels()
      Get all the node connections handled by this server.
      Returns:
      a list of BaseNodeContext instances.
    • getAllChannelsAsSet

      public Set<BaseNodeContext> getAllChannelsAsSet()
      Returns:
      a set of BaseNodeContext instances.
    • connectionFailed

      public void connectionFailed(BaseNodeContext context)
      Called when the node failed to respond to a heartbeat message.
      Parameters:
      context - the channel to close.
    • getConnection

      public AsyncNodeContext getConnection(String uuid)
      Get the connection wrapper for the specified uuid.
      Parameters:
      uuid - the id of the connection to get.
      Returns:
      the context of the connect that was found, or null if the channel was not found.
    • nodeConnected

      public void nodeConnected(BaseNodeContext context)
      Description copied from interface: NodeConnectionCompletionListener
      Called when a channel is connected.
      Specified by:
      nodeConnected in interface NodeConnectionCompletionListener
      Parameters:
      context - the connected channel.
    • getHandshakeBundle

      public ServerTaskBundleNode getHandshakeBundle()
      Get the task bundle sent to a newly connected node, so that it can check whether it is up to date, without having to wait for an actual request to be sent.
      Returns:
      a ServerJob instance, with no task in it.
    • activateNode

      public AsyncNodeContext activateNode(String uuid, boolean activate)
      Remove the specified connection wrapper from the list of connections handled by this manager.
      Parameters:
      uuid - the id of the node to activate or deactivate.
      activate - true to activate the node, false to deactivate it.
      Returns:
      the context of th channel that was removed, or null if the channel was not found.