com.parabon.client
Class LocalSessionManager

java.lang.Object
  extended by com.parabon.client.SessionManager
      extended by com.parabon.client.LocalSessionManager

public class LocalSessionManager
extends SessionManager

A run-local implementation of SessionManager. Runs all tasks in local mode; that is, run tasks directly in the same JVM as this client application is running, without attempting to simulate the behaviour of remote mode. This mode is meant for efficiently executing tasks locally as part of an application when the application does not need the power of Frontier, and for debugging tasks and applications without the difficulties of multiple JVMs.

As this mode does not impose the constraints of remote mode (such as restricted security, task isolation in a separate JVM, etc), tasks should be fully evaluated and debugged in simulator mode (via SimulatorSessionManager) to ensure that they run correctly in the Frontier environment attempting to submit them to the Frontier server in remote mode (via RemoteSessionManager).

See Also:
SessionManager, SimulatorSessionManager, RemoteSessionManager

Nested Class Summary
protected  class LocalSessionManager.TaskRunnable
           
protected  class LocalSessionManager.TaskSpawner
           
 
Field Summary
protected  java.util.Map<java.net.URI,com.parabon.io.DataWrapper> clientElements
           
protected static int DEFAULT_MAX_RUNNING_TASKS
           
protected  int nextJobID
           
protected  LocalSessionManager.TaskSpawner taskSpawner
           
protected  com.parabon.util.Queue tasksWaitingToRun
           
 
Fields inherited from class com.parabon.client.SessionManager
DEFAULT_SESSION_MANAGER, destroyed, idGenerator, jobs, LOCAL_SESSION_MANAGER, log, pool, REMOTE_SESSION_MANAGER, SESSION_MODE_PROPERTY, SIMULATOR_SESSION_MANAGER, tempListenerList
 
Constructor Summary
LocalSessionManager()
           
 
Method Summary
 Job createJob(java.util.Map<java.lang.String,java.lang.String> attributes)
          Create and add a new Job with the given attributes.
 void destroy()
          Close this session.
 void destroy(int blockMillis)
          Equivalent to destroy().
 void destroy(com.parabon.util.Listener completionListener)
          Similar to destroy().
 void flush(int blockMillis)
          Block until all actions taken thus far in the current session have been recieved and acknowledged by the server.
protected  java.net.URI getBaseClientURI()
           
 com.parabon.io.DataWrapper getElement(java.net.URI uri)
           
 java.net.URI getGlobalDataURI()
           
 int getMaxRunningTasks()
          Return the number of tasks allowed to run simultaneously.
 int getNumRunningTasks()
          Returns the number of tasks currently running.
 void reestablish(int blockMillis)
          Attempt to retrieve the latest list of jobs from the Frontier server, blocking until complete or until approximately the given number milliseconds have elapsed.
 void reestablish(com.parabon.util.Listener listener)
          Attempt to retrieve the latest list of jobs from the Frontier server, returning immediately without waiting for the operation to complete.
 void setMaxRunningTasks(int i)
          Sets the maximum number of simulateously executing tasks.
protected  void startTask(com.parabon.client.LocalTaskMaster task)
           
protected  void stopTask(com.parabon.client.LocalTaskMaster task, int blockMillis)
           
protected  void submitElement(java.net.URI uri, com.parabon.io.DataWrapper contents)
           
 
Methods inherited from class com.parabon.client.SessionManager
addElement, addElement, addElement, addElement, addJob, getClientDataURI, getInstance, getInstance, getJobDataURI, getJobs, getLog, getTaskDataURI, notifyTaskEventListeners, reestablish, removeJob, setLog
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_MAX_RUNNING_TASKS

protected static final int DEFAULT_MAX_RUNNING_TASKS
See Also:
Constant Field Values

clientElements

protected java.util.Map<java.net.URI,com.parabon.io.DataWrapper> clientElements

nextJobID

protected int nextJobID

tasksWaitingToRun

protected com.parabon.util.Queue tasksWaitingToRun

taskSpawner

protected LocalSessionManager.TaskSpawner taskSpawner
Constructor Detail

LocalSessionManager

public LocalSessionManager()
Method Detail

destroy

public void destroy()
Close this session. Stops all running tasks, and destroys all records associated with all jobs and tasks created as part of this session. Any further operations on this session manager or any jobs or tasks created through it will result in undefined behaviour.

Overrides:
destroy in class SessionManager
See Also:
SessionManager.destroy(int), SessionManager.flush(int)

destroy

public void destroy(int blockMillis)
Equivalent to destroy().

Overrides:
destroy in class SessionManager
See Also:
destroy()

destroy

public void destroy(com.parabon.util.Listener completionListener)
Similar to destroy(). Also calls completionListener.alert(null) after destruction is complete.

Overrides:
destroy in class SessionManager
See Also:
destroy()

getGlobalDataURI

public java.net.URI getGlobalDataURI()
                              throws java.net.URISyntaxException
Specified by:
getGlobalDataURI in class SessionManager
Throws:
java.net.URISyntaxException

getBaseClientURI

protected java.net.URI getBaseClientURI()
                                 throws java.net.URISyntaxException
Specified by:
getBaseClientURI in class SessionManager
Throws:
java.net.URISyntaxException

submitElement

protected void submitElement(java.net.URI uri,
                             com.parabon.io.DataWrapper contents)
Specified by:
submitElement in class SessionManager

getElement

public com.parabon.io.DataWrapper getElement(java.net.URI uri)
                                      throws NoSuchElementException
Throws:
NoSuchElementException

setMaxRunningTasks

public void setMaxRunningTasks(int i)
Sets the maximum number of simulateously executing tasks. Setting to 1 results in pure serial task execution; larger values will result in sequentially larger parallelism, each task running in its own thread.


getMaxRunningTasks

public int getMaxRunningTasks()
Return the number of tasks allowed to run simultaneously.


getNumRunningTasks

public int getNumRunningTasks()
Returns the number of tasks currently running.


createJob

public Job createJob(java.util.Map<java.lang.String,java.lang.String> attributes)
Description copied from class: SessionManager
Create and add a new Job with the given attributes. The given attributes may be modified after createJob returns without affecting the newly-created job.

Specified by:
createJob in class SessionManager

startTask

protected void startTask(com.parabon.client.LocalTaskMaster task)

stopTask

protected void stopTask(com.parabon.client.LocalTaskMaster task,
                        int blockMillis)
                 throws TimeoutException
Throws:
TimeoutException

flush

public void flush(int blockMillis)
Description copied from class: SessionManager
Block until all actions taken thus far in the current session have been recieved and acknowledged by the server. Blocks at most approximately the specified number of milliseconds; if blockMillis==-1, no timeout is used, and blocks until the flush condition is satisfied.

Specified by:
flush in class SessionManager

reestablish

public void reestablish(int blockMillis)
Description copied from class: SessionManager
Attempt to retrieve the latest list of jobs from the Frontier server, blocking until complete or until approximately the given number milliseconds have elapsed. If results are not obtained within the specitied timeout, a TimeoutException will be thrown, but the reestablish attempt might still result in the list of jobs being updated in the future.

If blockMillis==-1, the SessionManager will block indefinitely. Note that this method should never be called (except with a timeout of 0) from within an event listener or any other method which must complete in order for further events to be processed, as this would lead to a possible deadlock.

Specified by:
reestablish in class SessionManager

reestablish

public void reestablish(com.parabon.util.Listener listener)
Description copied from class: SessionManager
Attempt to retrieve the latest list of jobs from the Frontier server, returning immediately without waiting for the operation to complete. completionListener.alert(nul) will be called when reestablishment is complete.

Specified by:
reestablish in class SessionManager