|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.grid.jgrid.server.JCEPHandler
The JCEPHandler handles all JCEP communications. The main method listens for incoming socket requests and spins off a new thread to handle each. The new thread runs an instance of JCEPHandler which them gets a JCEPProtocolModule to handle the socket communications. When a client makes a request, the JCEPProtocolModule forwards the request to the JCEPHandler, which them performs the requested action.
Nested Class Summary | |
private static class |
JCEPHandler.LogFlusher
A helper class used as a shutdown hook. |
Field Summary | |
private JCEPProtocolModule |
connection
The JCEPProtocolModule which is handling the client communications |
private static boolean |
debug
Whether debug messages should be printed |
private static long |
GRACE_PERIOD
The default amount of number of miliseconds to wait for jobs to complete after a shutdown before explicitly exiting the VM. |
private static long |
gracePeriod
The amount of time to wait for jobs to complete after a shutdown before explicitly exiting the VM. |
private static java.util.Map |
jobMap
A Map of running and completed Jobs |
private static java.util.logging.Logger |
log
The logging mechanism |
private static java.lang.Thread |
mainThread
The thread running the main() method. |
private static int |
numberOfRunningJobs
The number of running jobs in this engine |
private static int |
port
The port number on which to listen for incoming requests |
private static java.lang.String |
REGISTRY_HOST
The default registry host to use if none is specified on the command line |
private static int |
REGISTRY_PORT
The default registry port to use if none is specified on the command line |
private static java.lang.String |
registryHost
The hostname for the RMI lookup server |
private static int |
registryPort
The port number for the RMI lookup server |
private static ResultChannel |
resultChannel
The ResultChannel retreived from the registry server to be used for returning results |
private static java.lang.String |
USAGE
The usage information String |
Constructor Summary | |
private |
JCEPHandler(java.net.Socket socket)
Creates a new instance of JCEPHandler |
Method Summary | |
void |
cancelJob(java.lang.String jobId)
Cancel the executing Job. |
void |
checkpoint(java.lang.String jobId)
Checkpoint the executing Job. |
private static void |
connectToResultChannel()
This method retrieves the ResultChannel object from the RMI registry server. |
private static void |
decrementNumberOfJobs()
Decrement the number of running jobs by 1 |
private static void |
flushLogs()
Flushes the logs. |
private static int |
getNumberOfJobs()
Get the number of running jobs. |
private static void |
incrementNumberOfJobs()
Increment the number of running jobs by 1 |
void |
logError(java.lang.String jobId,
java.lang.String error)
An error has occured in an executing job. |
void |
logMessage(java.lang.String jobId,
java.lang.String message)
An executing Job has sent a message. |
static void |
main(java.lang.String[] args)
Starts up the server, which listens for incoming socket connections. |
void |
notifyJobCheckpointed(java.lang.String jobId)
An executing Job has been checkpointed. |
void |
notifyJobCompleted(java.lang.String jobId)
An executing Job has completed normally. |
void |
notifyJobFailed(java.lang.String jobId)
An executing Job has exited abnormally by throwing an Exception. |
void |
notifyJobResumed(java.lang.String jobId)
An executing Job has been resumed. |
void |
notifyJobStarted(java.lang.String jobId)
A Job has begun execution. |
void |
notifyJobStopped(java.lang.String jobId)
An executing Job has exited abnormally by being canceled . |
void |
notifyJobSuspended(java.lang.String jobId)
An executing Job has been suspended. |
private static void |
prepareLogging()
This method sets up the Logger object |
private static void |
processArguments(java.lang.String[] args)
Parses the command line arguments and acts accordingly |
void |
register(java.lang.String jobId)
Register this JCEPHandler to receive messages from an executing Job. |
void |
resume(java.lang.String jobId)
Resume a suspended Job If the Job cannot be resume, either because it is not suspended or it is uninterruptable this method will notify the client by throwing a CommandFailedException. |
void |
shutdown()
Shutdown the JCEP server. |
void |
submitJob(Job job)
Submit a Job for execution. |
void |
suspend(java.lang.String jobId)
Suspend an executing Job If the Job cannot be suspended, either because it is no longer executing or it is uninterruptable this method will notify the client by throwing a CommandFailedException. |
void |
unregister(java.lang.String jobId)
Unregister for messages from a Job. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
private static final java.lang.String REGISTRY_HOST
private static final int REGISTRY_PORT
private static final long GRACE_PERIOD
private static final java.lang.String USAGE
private static java.util.Map jobMap
private static java.lang.Thread mainThread
private static ResultChannel resultChannel
private static boolean debug
private static java.lang.String registryHost
private static int registryPort
private static int port
private static java.util.logging.Logger log
private static long gracePeriod
private static int numberOfRunningJobs
private JCEPProtocolModule connection
Constructor Detail |
private JCEPHandler(java.net.Socket socket) throws java.io.IOException
socket
- The socket connection to be used for communicating with the client
java.io.IOException
- Thrown when an error occurs while establishing a client connectionMethod Detail |
public static void main(java.lang.String[] args) throws java.lang.Exception
args
- The command line arguments
java.lang.Exception
- Thrown when something goes wrong. This is a bad thing and should be fixed
before turning this loose on the public.private static void processArguments(java.lang.String[] args)
args
- The command line argumentsprivate static void prepareLogging()
public void register(java.lang.String jobId) throws CommandFailedException
register
in interface JCEPListener
jobId
- The id of the Job to which to attach
CommandFailedException
- thrown if this method cannot complete its task due to errors or failuresLogger
,
Job
public void unregister(java.lang.String jobId) throws CommandFailedException
unregister
in interface JCEPListener
jobId
- The id of the Job from which to detach
CommandFailedException
- thrown if this method cannot complete its task due to errors or failuresregister(String)
public void cancelJob(java.lang.String jobId) throws CommandFailedException
cancelJob
in interface JCEPListener
jobId
- The id of the Job to cancel
CommandFailedException
- thrown if this method cannot complete its task due to errors or failuresJob.cancel()
public void checkpoint(java.lang.String jobId) throws CommandFailedException
checkpoint
in interface JCEPListener
jobId
- The id of the job to checkpoint
CommandFailedException
- thrown if this method cannot complete its task due to errors or failuresJob.checkpoint()
public void shutdown()
shutdown
in interface JCEPListener
Job.cancel()
,
Job.checkpoint()
public void submitJob(Job job)
submitJob
in interface JCEPListener
job
- A Job object representing the job to be executedpublic void logError(java.lang.String jobId, java.lang.String error)
logError
in interface LogListener
jobId
- The id of the Job from which the error originatederror
- A String describing the errorJCEPProtocolModule.logError(String, String)
,
Logger
public void logMessage(java.lang.String jobId, java.lang.String message)
logMessage
in interface LogListener
jobId
- The id of the Job from which the message originatedmessage
- The text of the messageJCEPProtocolModule.logMessage(String, String)
,
Logger
public void notifyJobStopped(java.lang.String jobId)
notifyJobStopped
in interface LogListener
jobId
- The id of the Job which exitedJCEPProtocolModule.notifyJobStopped(String)
,
Logger
public void notifyJobFailed(java.lang.String jobId)
notifyJobFailed
in interface LogListener
jobId
- The id of the Job which exitedJCEPProtocolModule.notifyJobFailed(String)
,
Logger
public void notifyJobCheckpointed(java.lang.String jobId)
notifyJobCheckpointed
in interface LogListener
jobId
- The id of the Job which has been checkpointedJCEPProtocolModule.notifyJobCheckpointed(String)
,
Logger
public void notifyJobSuspended(java.lang.String jobId)
notifyJobSuspended
in interface LogListener
jobId
- The id of the Job which has been suspendedJCEPProtocolModule.notifyJobSuspended(String)
,
Logger
public void notifyJobResumed(java.lang.String jobId)
notifyJobResumed
in interface LogListener
jobId
- The id of the Job which has been resumedJCEPProtocolModule.notifyJobResumed(String)
,
Logger
public void notifyJobCompleted(java.lang.String jobId)
notifyJobCompleted
in interface LogListener
jobId
- The id of the Job which has completedJCEPProtocolModule.notifyJobCompleted(String)
,
Logger
public void notifyJobStarted(java.lang.String jobId)
notifyJobStarted
in interface LogListener
jobId
- The id of the Job which has started executionJCEPProtocolModule.notifyJobStarted(String)
,
Logger
private static void connectToResultChannel() throws java.rmi.RemoteException
java.rmi.RemoteException
- if an error occurs while trying to retrieve the ResultChannel objectprivate static void incrementNumberOfJobs()
private static void decrementNumberOfJobs()
private static int getNumberOfJobs()
private static void flushLogs()
public void resume(java.lang.String jobId) throws CommandFailedException
resume
in interface JCEPListener
jobId
- The id of the Job to resume
CommandFailedException
- if the command was unable to complete sucessfullyJob.resume()
public void suspend(java.lang.String jobId) throws CommandFailedException
suspend
in interface JCEPListener
jobId
- The id of the Job to suspend
CommandFailedException
- if the command was unable to complete sucessfullyJob.suspend()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |