org.ispheres.server.core
Class ThreadPool

java.lang.Object
  extended by org.ispheres.server.core.ThreadPool

public final class ThreadPool
extends java.lang.Object

Thread Pool is responsible for managing all the processes that the ISphere is currently performing. The Thread Pool is a Singleton. ThreadPool is final so that nothing can extend it. About the concurrent programming, please refer to http:// gee.cs.oswego.edu/dl/classes/EDU/oswego/cs/dl/util/concurrent/intro.html

Author:
Clinton Freeman mochumbo@users.sourceforge.net, Ted Zhou

Method Summary
 void addProcessHandle(int index, ProcessHandle handle)
          Add the ProcessHandle to the Thread Pool.
 java.util.concurrent.Future<?> getFuture(int index)
          This function fetches a Future to a process that iSphere is currently performing.
 int getNextProcessHandleIndex()
          This function generates an index for the next available process handle.
 ProcessHandle getProcessHandle(int index)
          This function fetches a handle to a process that iSphere is currently performing.
 java.util.Set<java.lang.Integer> getProcessHandleListing()
          This function returns the unique id's of all the process handles currently being tracked by this iSphere.
static ThreadPool instance()
          Get the single instance of ThreadPool.
 void restart(long newRunningPeriod, long idlePeriod)
          Restart Thread Pool.
 void start(long newRunningPeriod, long idlePeriod)
          Start Thread Pool.
 void stop()
          Stop the Thread Pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

instance

public static ThreadPool instance()
Get the single instance of ThreadPool.

Returns:
Single instance of ThreadPool

start

public void start(long newRunningPeriod,
                  long idlePeriod)
Start Thread Pool.

Parameters:
newRunningPeriod - The maximum time a process is permitted to be executed on iSpheres
idlePeriod - The maximum time a process is permitted to exist within the manager, without being accessed

restart

public void restart(long newRunningPeriod,
                    long idlePeriod)
Restart Thread Pool.

Parameters:
newRunningPeriod - The maximum time a process is permitted to be executed on iSpheres
idlePeriod - The maximum time a process is permitted to exist within the manager, without being accessed

stop

public void stop()
Stop the Thread Pool.


addProcessHandle

public void addProcessHandle(int index,
                             ProcessHandle handle)
                      throws ProcessException
Add the ProcessHandle to the Thread Pool.

Parameters:
index - The index to use for the processHandle (this should be generated by getNextProcessHandleIndex)
handle - The ProcessHandle to add to the Thread Pool
Throws:
ProcessException - When unable to add the ProcessHandle to the Thread Pool.

getNextProcessHandleIndex

public int getNextProcessHandleIndex()
This function generates an index for the next available process handle.

Returns:
A positive int, that can be used to add a processHandle to the Thread Pool.

getProcessHandle

public ProcessHandle getProcessHandle(int index)
                               throws ProcessException
This function fetches a handle to a process that iSphere is currently performing.

Parameters:
index - The index of the handler within the Thread Pool.
Returns:
A handle to a process that is being performed on this iSphere.
Throws:
ProcessException - when unable to getProcessHandle.

getFuture

public java.util.concurrent.Future<?> getFuture(int index)
                                         throws ProcessException
This function fetches a Future to a process that iSphere is currently performing. Users then can get control of the Process with this Future.

Parameters:
index - The index of the Future within the Thread Pool.
Returns:
A Future to a process that is being performed on this iSphere.
Throws:
ProcessException - when unable to getProcessHandle.

getProcessHandleListing

public java.util.Set<java.lang.Integer> getProcessHandleListing()
This function returns the unique id's of all the process handles currently being tracked by this iSphere.

Returns:
A set of handle ids.


Copyright © 2004-2005 The Archaeological Computing Laboratory, University of Sydney. All Rights Reserved.