org.ourgrid.mygrid.ui
Class MyGridUIManager

java.lang.Object
  extended by java.rmi.server.RemoteObject
      extended by java.rmi.server.RemoteServer
          extended by java.rmi.server.UnicastRemoteObject
              extended by org.ourgrid.common.rmi.OurgridUnicastRemoteObject
                  extended by org.ourgrid.mygrid.ui.MyGridUIManager
All Implemented Interfaces:
java.io.Serializable, java.rmi.Remote, UIManager

public class MyGridUIManager
extends OurgridUnicastRemoteObject
implements UIManager

See Also:
Serialized Form

Field Summary
 
Fields inherited from class java.rmi.server.RemoteObject
ref
 
Method Summary
 int addJob(JobSpec newJob)
          Adds a job to be executed by Mygrid.
 int addJob(java.lang.String descriptionFilePath)
          Deprecated. 
 void cancelJob(int jobId)
          Asks Mygrid to cancel a job
 void cleanFinishedJobs()
          Erases all jobs that are not running anymore
 java.util.Collection<GridManagerEntry> getGumEntries(GridManagerListenerRemote listener)
          Obtains a collection with the gums that are currently in use by Mygrid.
 java.util.Collection<GumSpec> getGumSpecs()
          Obtains a collection with the gums that are currently in use by Mygrid
static UIManager getInstance()
           
 java.util.Collection<JobEntry> getJobs(JobManagerListenerRemote newListener)
          Obtains a collection with the jobs that are currently added to Mygrid, no matter the jobs states.
 java.util.Collection<PeerEntry> getPeerEntries(GridManagerListenerRemote newListener)
          Obtains a collection with the peers that are currently set on Mygrid.
 boolean isExecutingInHomeMachine()
           
 boolean isMyGridRunning()
          Checks if Mygrid is running
 void removeGridManagerListener(GridManagerListenerRemote listener)
          Unregisters a Grid Manager listener
 void removeJob(int jobId)
          Erases a specific job if it is not running.
 void removeJobManagerListener(JobManagerListenerRemote listener)
          Unregisters a Job Manager listener
static void reset()
          Resets the singleton.
 void setPeers(java.util.Collection<PeerSpec> peerSpecs)
          Adds a list of peers that will work as a machine provider to Mygrid.
 void setPeers(java.lang.String descriptionFilePath)
          Deprecated. 
 void startMyGridService()
          Start MyGrid service.
 void stopMyGridService(boolean callExit)
          Stop MyGrid service.
 void stopMyGridService(boolean wait, boolean callExit)
          Stop MyGrid service.
 void waitForJob(int jobId)
          The caller will block until the specified job finishes, fails or is cancelled.
 
Methods inherited from class java.rmi.server.UnicastRemoteObject
clone, exportObject, exportObject, exportObject, unexportObject
 
Methods inherited from class java.rmi.server.RemoteServer
getClientHost, getLog, setLog
 
Methods inherited from class java.rmi.server.RemoteObject
equals, getRef, hashCode, toString, toStub
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

reset

public static void reset()
Resets the singleton.


getInstance

public static UIManager getInstance()
                             throws java.rmi.RemoteException
Throws:
java.rmi.RemoteException

startMyGridService

public void startMyGridService()
                        throws NotExecutingInHomeMachine,
                               MyGridIsAlreadyRunningException,
                               StartingMyGridException,
                               ConfigException
Description copied from interface: UIManager
Start MyGrid service. The service will be initiated on the same JVM of the calling application

Specified by:
startMyGridService in interface UIManager
Throws:
NotExecutingInHomeMachine - if Mygrid is starting on a different machine than that specified in the Mygrid configuration file
MyGridIsAlreadyRunningException - if Mygrid is already running
StartingMyGridException - if Mygrid was unable to start correctly
ConfigException - if a configuration problem exists

stopMyGridService

public void stopMyGridService(boolean wait,
                              boolean callExit)
                       throws MyGridIsNotRunningException
Description copied from interface: UIManager
Stop MyGrid service. This method presents an option of waiting Mygrid to stop nicely or forcing Mygrid to stop.

Specified by:
stopMyGridService in interface UIManager
Parameters:
wait - if is desired to wait for Mygrid to stop nicely.
callExit - if is desired to call System.exit() terminating the JVM (which may be the same of a user's application)
Throws:
MyGridIsNotRunningException - if trying contact a Mygrid that is not running

stopMyGridService

public void stopMyGridService(boolean callExit)
                       throws MyGridIsNotRunningException
Description copied from interface: UIManager
Stop MyGrid service. This method does waits for MyGrid to shutdown nicely.

Specified by:
stopMyGridService in interface UIManager
Parameters:
callExit - if is desired to call System.exit() terminating the JVM (which may be the same of a user's application)
Throws:
MyGridIsNotRunningException - if trying to stop a Mygrid that was not started

isMyGridRunning

public boolean isMyGridRunning()
Description copied from interface: UIManager
Checks if Mygrid is running

Specified by:
isMyGridRunning in interface UIManager
Returns:
true if Mygrid is running

isExecutingInHomeMachine

public boolean isExecutingInHomeMachine()

getJobs

public java.util.Collection<JobEntry> getJobs(JobManagerListenerRemote newListener)
                                       throws java.rmi.RemoteException
Description copied from interface: UIManager
Obtains a collection with the jobs that are currently added to Mygrid, no matter the jobs states. Includes an option of becoming a listener of Mygrid's Job Manager to receive updates about the state of jobs. This listener will be notified whenever there is a change on the state of jobs.

Specified by:
getJobs in interface UIManager
Parameters:
newListener - a reference to the listener that is interested on receiving updates about jobs
Returns:
a collection with the jobs currently added to Mygrid
Throws:
java.rmi.RemoteException - if a communication problem occurs

cancelJob

public void cancelJob(int jobId)
               throws JobNotFoundException,
                      java.rmi.RemoteException,
                      JobCouldNotBeCancelledException
Description copied from interface: UIManager
Asks Mygrid to cancel a job

Specified by:
cancelJob in interface UIManager
Parameters:
jobId - the job to cancel
Throws:
JobNotFoundException - the job does not exist
java.rmi.RemoteException - if a communication problem occurs
JobCouldNotBeCancelledException - if some error occurs when trying to cancel the job

waitForJob

public void waitForJob(int jobId)
                throws java.rmi.RemoteException,
                       JobNotFoundException
Description copied from interface: UIManager
The caller will block until the specified job finishes, fails or is cancelled.

Specified by:
waitForJob in interface UIManager
Parameters:
jobId - the job to wait
Throws:
java.rmi.RemoteException - if a communication problem occurs
JobNotFoundException - if the job does not exist

addJob

public int addJob(JobSpec newJob)
           throws java.rmi.RemoteException
Description copied from interface: UIManager
Adds a job to be executed by Mygrid. The JobSpec obtained by compiling a JDF (job description file) with Ourgrid compiler.

Specified by:
addJob in interface UIManager
Parameters:
newJob - a job specification generated by the Ourgrid compiler from a JDF
Returns:
the job ID
Throws:
java.rmi.RemoteException - if a communication problem occurs

cleanFinishedJobs

public void cleanFinishedJobs()
                       throws java.rmi.RemoteException
Description copied from interface: UIManager
Erases all jobs that are not running anymore

Specified by:
cleanFinishedJobs in interface UIManager
Throws:
java.rmi.RemoteException - if a communication problem occurs

removeJob

public void removeJob(int jobId)
               throws java.rmi.RemoteException,
                      JobCannotBeRemovedException
Description copied from interface: UIManager
Erases a specific job if it is not running.

Specified by:
removeJob in interface UIManager
Parameters:
jobId - id of the job to be removed
Throws:
java.rmi.RemoteException - if a communication problem occurs
JobCannotBeRemovedException - if the jobs is still running

getPeerEntries

public java.util.Collection<PeerEntry> getPeerEntries(GridManagerListenerRemote newListener)
                                               throws java.rmi.RemoteException
Description copied from interface: UIManager
Obtains a collection with the peers that are currently set on Mygrid. Includes an option of becoming a listener of Mygrid's Grid Manager to receive updates about the state of peers. This listener will be notified whenever there is a change on the state of peers.

Specified by:
getPeerEntries in interface UIManager
Parameters:
newListener - a reference to the listener that is interested on receiving updates about peers
Returns:
a collection with the peers currently set on Mygrid
Throws:
java.rmi.RemoteException - if a communication problem occurs

setPeers

public void setPeers(java.util.Collection<PeerSpec> peerSpecs)
              throws java.rmi.RemoteException
Description copied from interface: UIManager
Adds a list of peers that will work as a machine provider to Mygrid. A list of PeerSpec is obtained by compiling a SDF (site description file) with Ourgrid compiler.

Specified by:
setPeers in interface UIManager
Parameters:
peerSpecs - a collection of peer specification generated by the compiler
Throws:
java.rmi.RemoteException - if a communication problem occurs
See Also:
DescriptionFileCompile.compileSDF(String)

getGumSpecs

public java.util.Collection<GumSpec> getGumSpecs()
                                          throws java.rmi.RemoteException
Description copied from interface: UIManager
Obtains a collection with the gums that are currently in use by Mygrid

Specified by:
getGumSpecs in interface UIManager
Returns:
a collection with the gums that are currently in use by Mygrid
Throws:
java.rmi.RemoteException - if a communication problem occurs

getGumEntries

public java.util.Collection<GridManagerEntry> getGumEntries(GridManagerListenerRemote listener)
                                                     throws java.rmi.RemoteException
Description copied from interface: UIManager
Obtains a collection with the gums that are currently in use by Mygrid. Includes an option of becoming a listener of Mygrid's Grid Manager to receive updates about the state of machines. This listener will be notified whenever a new machine is received or currently owned machines are disposed.

Specified by:
getGumEntries in interface UIManager
Parameters:
listener - a reference to the listener that is interested on receiving updates about machines
Returns:
a collection with the gums that are currently in use by Mygrid
Throws:
java.rmi.RemoteException - if a communication problem occurs

setPeers

@Deprecated
public void setPeers(java.lang.String descriptionFilePath)
              throws java.rmi.RemoteException,
                     CompilerException
Deprecated. 

Description copied from interface: UIManager
Replaced by UIManager.setPeers(Collection).

Specified by:
setPeers in interface UIManager
Parameters:
descriptionFilePath - the path to a SDF to be compiled
Throws:
java.rmi.RemoteException - if a communication problem occurs
CompilerException - if compiler error occurs

addJob

@Deprecated
public int addJob(java.lang.String descriptionFilePath)
           throws CompilerException,
                  java.rmi.RemoteException,
                  CouldNotAddJobOutsideHomeMachineException
Deprecated. 

Description copied from interface: UIManager
Replaced by UIManager.addJob(JobSpec).

Specified by:
addJob in interface UIManager
Parameters:
descriptionFilePath - the path of a JDF to be compiled
Returns:
the generated job ID
Throws:
CompilerException - if compiler error occurs
java.rmi.RemoteException - if a communication problem occurs
CouldNotAddJobOutsideHomeMachineException - it is only possible to add a job when running on the same machine as Mygrid

removeJobManagerListener

public void removeJobManagerListener(JobManagerListenerRemote listener)
                              throws java.rmi.RemoteException
Description copied from interface: UIManager
Unregisters a Job Manager listener

Specified by:
removeJobManagerListener in interface UIManager
Parameters:
listener - a reference to the listener that will be unregistered
Throws:
java.rmi.RemoteException - if a communication problem occurs

removeGridManagerListener

public void removeGridManagerListener(GridManagerListenerRemote listener)
                               throws java.rmi.RemoteException
Description copied from interface: UIManager
Unregisters a Grid Manager listener

Specified by:
removeGridManagerListener in interface UIManager
Parameters:
listener - listener a reference to the listener that will be unregistered
Throws:
java.rmi.RemoteException - if a communication problem occurs