org.jppf.server.node
Class AbstractNodeIO

java.lang.Object
  extended by org.jppf.server.node.AbstractNodeIO
All Implemented Interfaces:
NodeIO
Direct Known Subclasses:
LocalNodeIO, RemoteNodeIO

public abstract class AbstractNodeIO
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

Nested Class Summary
protected static class AbstractNodeIO.BufferList
          A pairing of a list of buffers and the total length of their usable data.
protected  class AbstractNodeIO.ObjectSerializationTask
          The goal of this class is to serialize an object before sending it back to the server, and catch an eventual exception.
 
Field Summary
protected  JPPFTaskBundle currentBundle
          The task bundle currently being processed.
protected  JPPFNode node
          The node who owns this TaskIO.
protected  ObjectSerializer serializer
          Used to serialize/deserialize tasks and data providers.
 
Constructor Summary
AbstractNodeIO(JPPFNode node)
          Initialize this TaskIO with the specified node.
 
Method Summary
protected abstract  Object[] deserializeObjects()
          Perform the deserialization of the objects received through the socket connection.
protected abstract  Object[] deserializeObjects(JPPFTaskBundle bundle)
          Perform the deserialization of the objects received through the socket connection.
protected abstract  void handleReload()
          Performs the actions required if reloading the classes is necessary.
protected  Object[] readObjects()
          Deserialize the objects read from the socket, and reload the appropriate classes if any class change is detected.
 Pair<JPPFTaskBundle,List<JPPFTask>> readTask()
          Read a task from the socket connection, along with its header information.
abstract  void writeResults(JPPFTaskBundle bundle, List<JPPFTask> 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 Detail

node

protected JPPFNode node
The node who owns this TaskIO.


currentBundle

protected JPPFTaskBundle currentBundle
The task bundle currently being processed.


serializer

protected ObjectSerializer serializer
Used to serialize/deserialize tasks and data providers.

Constructor Detail

AbstractNodeIO

public AbstractNodeIO(JPPFNode node)
Initialize this TaskIO with the specified node.

Parameters:
node - - the node who owns this TaskIO.
Method Detail

readTask

public Pair<JPPFTaskBundle,List<JPPFTask>> readTask()
                                             throws Exception
Read a task from the socket connection, along with its header information.

Specified by:
readTask in interface NodeIO
Returns:
a pair of JPPFTaskBundle and a List of JPPFTask instances.
Throws:
Exception - if an error is raised while reading the task data.
See Also:
NodeIO.readTask()

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.

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(JPPFTaskBundle 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.

writeResults

public abstract void writeResults(JPPFTaskBundle bundle,
                                  List<JPPFTask> tasks)
                           throws Exception
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 writtng to the socket stream.
See Also:
NodeIO.writeResults(org.jppf.server.protocol.JPPFTaskBundle, java.util.List)


Copyright © 2005-2010 JPPF Team.