com.sun.grid.jgrid.server
Class JCEPVersion10Module

java.lang.Object
  extended bycom.sun.grid.jgrid.server.JCEPProtocolModule
      extended bycom.sun.grid.jgrid.server.JCEPVersion10Module
All Implemented Interfaces:
JCEP

class JCEPVersion10Module
extends JCEPProtocolModule
implements JCEP

This class implements the 1.0 version of JCEP.

Since:
0.2
See Also:
JCEPProtocolModule

Nested Class Summary
private  class JCEPVersion10Module.ListenerThread
          This class reads incoming messages from the input stream and forwards the resulting commands through the protocol module.
 
Field Summary
private  java.io.DataInputStream din
          The input stream used to communicate with the client
private  java.io.DataOutputStream dout
          The output stream used to communicate with the client
private  JCEPListener engine
          The JCEPListener at which to direct command received from the client
private static java.util.logging.Logger log
          The logging mechanism
private  JCEPVersion10Module.ListenerThread reader
          The thread which listens for incoming client messages
private  java.lang.String registeredJobId
          The id of the job with which this protocol module is registered to receive events
private  boolean shuttingDown
          A flag used to prevent multiple shutdown notices
private  java.net.Socket socket
          The socket connected to the client
 
Fields inherited from class com.sun.grid.jgrid.server.JCEPProtocolModule
moduleList, SYSTEM_ID
 
Fields inherited from interface com.sun.grid.jgrid.server.JCEP
CANCEL_JOB, CHECKPOINT_JOB, COMMAND_FAILED, HANDSHAKE, JOB_CHECKPOINTED, JOB_STATE_CHANGE, LOG_ERROR, LOG_MESSAGE, PORT, REGISTER, RESUME, SHUTDOWN, SHUTTING_DOWN, STATE_COMPLETED, STATE_FAILED, STATE_RUNNING, STATE_STOPPED, STATE_SUSPENDED, SUBMIT_JOB, SUSPEND, UNREGISTER, VERSION10
 
Constructor Summary
(package private) JCEPVersion10Module(JCEPListener engine, java.net.Socket socket, java.io.DataInputStream din, java.io.DataOutputStream dout)
          Creates a new instance of JCEPVersion10Module
 
Method Summary
(package private)  void closeConnection()
          This method shuts down the protocol module.
private  void closeSocket()
          Closes the client connection.
(package private)  void logError(java.lang.String jobId, java.lang.String message)
          Tells the protocol module to notify its client of an error from an executing job.
(package private)  void logMessage(java.lang.String jobId, java.lang.String message)
          Tells the protocol module to notify its client of a message from an executing job.
private  void notifyCommandFailed(byte command, java.lang.String jobId, java.lang.String message)
          Tells the protocol module to notify its client that a previously submitted command has failed to execute.
(package private)  void notifyJobCheckpointed(java.lang.String jobId)
          Tells the protocol module to notify its client that a job has been checkpointed.
(package private)  void notifyJobCompleted(java.lang.String jobId)
          Tells the protocol module to notify its client that a job has completed execution normally.
(package private)  void notifyJobFailed(java.lang.String jobId)
          Tells the protocol module to notify its client that a job has terminated execution abnormally because of an error during execution.
(package private)  void notifyJobResumed(java.lang.String jobId)
          Tells the protocol module to notify its client that a job has terminated execution abnormally because of an error during execution.
(package private)  void notifyJobStarted(java.lang.String jobId)
          Tells the protocol module to notify its client that a job has started execution.
private  void notifyJobStateChange(java.lang.String jobId, byte newState)
          Tells the protocol module to notify its client that a job has changed state.
(package private)  void notifyJobStopped(java.lang.String jobId)
          Tells the protocol module to notify its client that a job has terminated execution abnormally by being canceled.
(package private)  void notifyJobSuspended(java.lang.String jobId)
          Tells the protocol module to notify its client that a job has terminated execution abnormally because of an error during execution.
(package private)  void notifyShutdown()
          Tells the protocol module to notify its client that server is shutting down.
(package private)  void startConnection()
          This method tells the protocol module to begin reading messages from the established connection.
 
Methods inherited from class com.sun.grid.jgrid.server.JCEPProtocolModule
establishConnection, notifyAllModules
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

private static java.util.logging.Logger log
The logging mechanism


din

private java.io.DataInputStream din
The input stream used to communicate with the client


dout

private java.io.DataOutputStream dout
The output stream used to communicate with the client


engine

private JCEPListener engine
The JCEPListener at which to direct command received from the client


reader

private JCEPVersion10Module.ListenerThread reader
The thread which listens for incoming client messages


registeredJobId

private java.lang.String registeredJobId
The id of the job with which this protocol module is registered to receive events


socket

private java.net.Socket socket
The socket connected to the client


shuttingDown

private boolean shuttingDown
A flag used to prevent multiple shutdown notices

Constructor Detail

JCEPVersion10Module

JCEPVersion10Module(JCEPListener engine,
                    java.net.Socket socket,
                    java.io.DataInputStream din,
                    java.io.DataOutputStream dout)
Creates a new instance of JCEPVersion10Module

Parameters:
engine - The JCEPListener at which to direct commands received from the client
socket - The socket to use for client communications
din - The socket input stream
dout - The socket output stream
Method Detail

startConnection

void startConnection()
This method tells the protocol module to begin reading messages from the established connection.

Specified by:
startConnection in class JCEPProtocolModule

logError

void logError(java.lang.String jobId,
              java.lang.String message)
        throws java.io.IOException
Tells the protocol module to notify its client of an error from an executing job. Used by the JCEPHandler.

Specified by:
logError in class JCEPProtocolModule
Parameters:
message - The text of the error message
jobId - The id of the job from which the error originated
Throws:
java.io.IOException - Thrown if there's an error sending the error message to the client
See Also:
JCEPHandler

logMessage

void logMessage(java.lang.String jobId,
                java.lang.String message)
          throws java.io.IOException
Tells the protocol module to notify its client of a message from an executing job. Used by the JCEPHandler.

Specified by:
logMessage in class JCEPProtocolModule
Parameters:
jobId - The id of the job from which the message originated
message - The text of the message
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

notifyJobCompleted

void notifyJobCompleted(java.lang.String jobId)
                  throws java.io.IOException
Tells the protocol module to notify its client that a job has completed execution normally. Used by the JCEPHandler.

Specified by:
notifyJobCompleted in class JCEPProtocolModule
Parameters:
jobId - The id of the job which completed execution
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

notifyJobStarted

void notifyJobStarted(java.lang.String jobId)
                throws java.io.IOException
Tells the protocol module to notify its client that a job has started execution. Used by the JCEPHandler.

Specified by:
notifyJobStarted in class JCEPProtocolModule
Parameters:
jobId - The id of the job which started
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

closeConnection

void closeConnection()
This method shuts down the protocol module. It causes the protocol module to stop reading and closes the input and output streams.

Specified by:
closeConnection in class JCEPProtocolModule

notifyJobStopped

void notifyJobStopped(java.lang.String jobId)
                throws java.io.IOException
Tells the protocol module to notify its client that a job has terminated execution abnormally by being canceled.

Specified by:
notifyJobStopped in class JCEPProtocolModule
Parameters:
jobId - The id of the job which has stopped execution
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

notifyJobFailed

void notifyJobFailed(java.lang.String jobId)
               throws java.io.IOException
Tells the protocol module to notify its client that a job has terminated execution abnormally because of an error during execution.

Specified by:
notifyJobFailed in class JCEPProtocolModule
Parameters:
jobId - The id of the job which has stopped execution
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

notifyJobSuspended

void notifyJobSuspended(java.lang.String jobId)
                  throws java.io.IOException
Tells the protocol module to notify its client that a job has terminated execution abnormally because of an error during execution.

Specified by:
notifyJobSuspended in class JCEPProtocolModule
Parameters:
jobId - The id of the job which has stopped execution
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

notifyJobResumed

void notifyJobResumed(java.lang.String jobId)
                throws java.io.IOException
Tells the protocol module to notify its client that a job has terminated execution abnormally because of an error during execution.

Specified by:
notifyJobResumed in class JCEPProtocolModule
Parameters:
jobId - The id of the job which has stopped execution
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

notifyShutdown

void notifyShutdown()
              throws java.io.IOException
Tells the protocol module to notify its client that server is shutting down. Used by the JCEPHandler.

Specified by:
notifyShutdown in class JCEPProtocolModule
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

notifyJobCheckpointed

void notifyJobCheckpointed(java.lang.String jobId)
                     throws java.io.IOException
Tells the protocol module to notify its client that a job has been checkpointed. Used by the JCEPHandler.

Specified by:
notifyJobCheckpointed in class JCEPProtocolModule
Parameters:
jobId - The id of the job which was checkpointed
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

notifyCommandFailed

private void notifyCommandFailed(byte command,
                                 java.lang.String jobId,
                                 java.lang.String message)
                          throws java.io.IOException
Tells the protocol module to notify its client that a previously submitted command has failed to execute.

Parameters:
command - the command that failed
jobId - The id of the job on which the command was supposed to operate
message - A message describing the reason for the command failure
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client
See Also:
JCEPHandler

closeSocket

private void closeSocket()
Closes the client connection. Used by the ListenerThread to tidy up when the client disconnects.


notifyJobStateChange

private void notifyJobStateChange(java.lang.String jobId,
                                  byte newState)
                           throws java.io.IOException
Tells the protocol module to notify its client that a job has changed state.

Parameters:
jobId - The id of the job which completed execution
newState - the job's new state
Throws:
java.io.IOException - Thrown if there's an error sending the message to the client