Class AbstractNodeIO<N extends AbstractCommonNode>

java.lang.Object
org.jppf.server.node.AbstractNodeIO<N>
Type Parameters:
N - the type of node.
All Implemented Interfaces:
NodeIO

public abstract class AbstractNodeIO<N extends AbstractCommonNode> extends Object implements NodeIO
This class performs the I/O operations requested by the JPPFNode, for reading the task bundles and sending the results back.
Author:
Laurent Cohen
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected final N
    The node who owns this TaskIO.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Initialize this TaskIO with the specified node.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected abstract Object[]
    Perform the deserialization of the objects received through the socket connection.
    protected abstract Object[]
    deserializeObjects(org.jppf.node.protocol.TaskBundle bundle)
    Perform the deserialization of the objects received through the socket connection.
    protected void
    finalizeBundleData(org.jppf.node.protocol.TaskBundle bundle, List<org.jppf.node.protocol.Task<?>> tasks)
    Compute the task bundle's data before it is sent back to the server.
    protected abstract void
    Performs the actions required if reloading the classes is necessary.
    protected void
    initializeBundleData(org.jppf.node.protocol.TaskBundle bundle)
    Prepare the task bundle's data that will be sent back to the server.
    protected void
    postSendResults(org.jppf.node.protocol.TaskBundle bundle)
    Perform some cleanup after sending the results.
    org.jppf.node.protocol.BundleWithTasks
    Read a job from the socket connection, along with its header information.
    protected Object[]
    Deserialize the objects read from the socket, and reload the appropriate classes if any class change is detected.
    A class change is triggered when an InvalidClassException is caught.
    protected abstract void
    sendResults(org.jppf.node.protocol.TaskBundle bundle, List<org.jppf.node.protocol.Task<?>> tasks)
    Write the execution results to the socket stream.
    void
    writeResults(org.jppf.node.protocol.TaskBundle bundle, List<org.jppf.node.protocol.Task<?>> tasks)
    Write the execution results to the socket stream.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • AbstractNodeIO

      public AbstractNodeIO(N node)
      Initialize this TaskIO with the specified node.
      Parameters:
      node - - the node who owns this TaskIO.
  • Method Details

    • readJob

      public org.jppf.node.protocol.BundleWithTasks readJob() throws Exception
      Description copied from interface: NodeIO
      Read a job from the socket connection, along with its header information.
      Specified by:
      readJob in interface NodeIO
      Returns:
      a pair of JPPFTaskBundle and a List of Task instances.
      Throws:
      Exception - if an error is raised while reading the task data.
    • writeResults

      public void writeResults(org.jppf.node.protocol.TaskBundle bundle, List<org.jppf.node.protocol.Task<?>> tasks) throws Exception
      Description copied from interface: NodeIO
      Write the execution results to the socket stream.
      Specified by:
      writeResults in interface NodeIO
      Parameters:
      bundle - the task wrapper to send along.
      tasks - the list of tasks with their result field updated.
      Throws:
      Exception - if an error occurs while writing to the socket stream.
    • handleReload

      protected abstract void handleReload() throws Exception
      Performs the actions required if reloading the classes is necessary.
      Throws:
      Exception - if any error occurs.
    • deserializeObjects

      protected abstract Object[] deserializeObjects() throws Exception
      Perform the deserialization of the objects received through the socket connection.
      Returns:
      an array of objects deserialized from the socket stream.
      Throws:
      Exception - if an error occurs while deserializing.
    • deserializeObjects

      protected abstract Object[] deserializeObjects(org.jppf.node.protocol.TaskBundle bundle) throws Exception
      Perform the deserialization of the objects received through the socket connection.
      Parameters:
      bundle - the message header that contains information about the tasks and data provider.
      Returns:
      an array of objects deserialized from the socket stream.
      Throws:
      Exception - if an error occurs while deserializing.
    • sendResults

      protected abstract void sendResults(org.jppf.node.protocol.TaskBundle bundle, List<org.jppf.node.protocol.Task<?>> tasks) throws Exception
      Write the execution results to the socket stream.
      Parameters:
      bundle - the task wrapper to send along.
      tasks - the list of tasks with their result field updated.
      Throws:
      Exception - if an error occurs while writing to the socket stream.
      Since:
      4.2
    • readObjects

      protected Object[] readObjects() throws Exception
      Deserialize the objects read from the socket, and reload the appropriate classes if any class change is detected.
      A class change is triggered when an InvalidClassException is caught. Upon catching this exception, the class loader is reinitialized and the class are reloaded.
      Returns:
      an array of objects deserialized from the socket stream.
      Throws:
      Exception - if the classes could not be reloaded or an error occurred during deserialization.
    • postSendResults

      protected void postSendResults(org.jppf.node.protocol.TaskBundle bundle) throws Exception
      Perform some cleanup after sending the results.
      Parameters:
      bundle - the task wrapper that was sent.
      Throws:
      Exception - if an error occurs while writing to the socket stream.
      Since:
      4.2
    • initializeBundleData

      protected void initializeBundleData(org.jppf.node.protocol.TaskBundle bundle)
      Prepare the task bundle's data that will be sent back to the server.
      Parameters:
      bundle - the bundle to process.
    • finalizeBundleData

      protected void finalizeBundleData(org.jppf.node.protocol.TaskBundle bundle, List<org.jppf.node.protocol.Task<?>> tasks)
      Compute the task bundle's data before it is sent back to the server.
      Parameters:
      bundle - the bundle to process.
      tasks - the list of tasks after they have been executed.