com.sun.grid.jgrid
Class Logger

java.lang.Object
  extended bycom.sun.grid.jgrid.Logger

public class Logger
extends java.lang.Object

The purpose of the Logger class is to attach an executing Job to one or more LogListeners for logging messages and event to the client.

Since:
0.2

Field Summary
private  java.lang.String jobId
          The id of the Job to which this Logger is attached.
private  java.util.Set listeners
          The list of LogListener to which this Logger logs messages and events
 
Constructor Summary
Logger(java.lang.String jobId)
          Creates a new instance of Logger
 
Method Summary
static java.lang.String getExceptionAsString(java.lang.Exception e)
          This method is a convenience method used to translate an Exception into a String that looks like what the VM prints out when an uncaught Exception causes a stack trace to be printed.
 void jobCheckpointed()
          Notify the LogListener(s) that the Job has been checkpointed.
 void jobComplete()
          Notify the LogListener(s) that the Job has completed normally.
 void jobFailed()
          Notify the LogListener(s) that the Job has exited abnormally, either due to an uncaught Exception or because the Job was canceled.
 void jobResumed()
          Notify the LogListener(s) that the Job has been resumed.
 void jobStarted()
          Notify the LogListener(s) that the Job has been started.
 void jobStopped()
          Notify the LogListener(s) that the Job has exited abnormally, either due to an uncaught Exception or because the Job was canceled.
 void jobSuspended()
          Notify the LogListener(s) that the Job has been suspended.
 void logError(java.lang.String error)
          Log an error message from the Job to the LogListener(s).
 void logMessage(java.lang.String message)
          Log a message from the Job to the LogListener(s)
 void registerHandler(LogListener listener)
          Register a new LogListener with this Logger
 void unregisterHandler(LogListener listener)
          Unregister a LogListener with this Logger.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

jobId

private java.lang.String jobId
The id of the Job to which this Logger is attached. Used when logging events and messages to the LogListener(s).


listeners

private java.util.Set listeners
The list of LogListener to which this Logger logs messages and events

Constructor Detail

Logger

public Logger(java.lang.String jobId)
Creates a new instance of Logger

Parameters:
jobId - The id of the Job to which this Logger will be attached
Method Detail

registerHandler

public void registerHandler(LogListener listener)
Register a new LogListener with this Logger

Parameters:
listener - The listener to register

unregisterHandler

public void unregisterHandler(LogListener listener)
Unregister a LogListener with this Logger.

Parameters:
listener - The listener to unregister

logError

public void logError(java.lang.String error)
Log an error message from the Job to the LogListener(s).

Parameters:
error - The text of the error message

logMessage

public void logMessage(java.lang.String message)
Log a message from the Job to the LogListener(s)

Parameters:
message - The text of the message

jobStopped

public void jobStopped()
Notify the LogListener(s) that the Job has exited abnormally, either due to an uncaught Exception or because the Job was canceled.


jobCheckpointed

public void jobCheckpointed()
Notify the LogListener(s) that the Job has been checkpointed.


jobComplete

public void jobComplete()
Notify the LogListener(s) that the Job has completed normally.


jobStarted

public void jobStarted()
Notify the LogListener(s) that the Job has been started.


jobFailed

public void jobFailed()
Notify the LogListener(s) that the Job has exited abnormally, either due to an uncaught Exception or because the Job was canceled.


jobSuspended

public void jobSuspended()
Notify the LogListener(s) that the Job has been suspended.


jobResumed

public void jobResumed()
Notify the LogListener(s) that the Job has been resumed.


getExceptionAsString

public static java.lang.String getExceptionAsString(java.lang.Exception e)
This method is a convenience method used to translate an Exception into a String that looks like what the VM prints out when an uncaught Exception causes a stack trace to be printed.

Parameters:
e - the Exception to convert to a String
Returns:
the exception as a String that includes the message and stack tace