system
Class Space

java.lang.Object
  extended by system.Space
All Implemented Interfaces:
Client2Space, java.rmi.Remote, Computer2Space

public class Space
extends java.lang.Object
implements Computer2Space, Client2Space

A Space that will Q new tasks issued to it by a client and hand them out to registered computers. Performs load balancing across different available machines, and stores the results for the client.

Author:
Diana Abbas, Ryan Neal

Field Summary
 
Fields inherited from interface system.Computer2Space
SERVICE_NAME
 
Fields inherited from interface client.Client2Space
SERVICE_NAME
 
Constructor Summary
Space()
           
 
Method Summary
 Result compute(Task task, java.lang.Object input, Shared shared)
          Takes in a task to be handled by the space.
 void enqueueResult(Result result)
          If the result is non-null it determines if the Result should be drain to a task in the waiting Queue, or if it should be returned to the client.
 void enqueueTask(Task task)
          Puts a computer task into the task queue
 Task getNextTask()
          Removes the next task from the task queue.
 Shared getShared()
          Gets the current shared value from the system.
 Statistics getStatistics()
          Gets the statistics package from the space Can be extended to include any needed.
 int getUniqueTaskID()
          returns the system wide unique Task ID
 void hello()
           
static void main(java.lang.String[] args)
          Creates a registry and binds itself to that registry.
 void put(GUI_Client client, Task task)
          Takes in a task to be done.
 void register(Computer computer)
          Adds the Computer to the list of valid computers the space can utilize.
 void setShared(Shared proposedShared)
          Set the shared object on the Space and propagates this Shared object to all the registered computers
 Result take()
          Returns a result from the Result Queue.
 boolean unregister(ComputerProxy proxy, Task currentRunningTask)
          Unregister the computer proxy that has thrown a remote exception
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Space

public Space()
Method Detail

getShared

public Shared getShared()
Gets the current shared value from the system.

Specified by:
getShared in interface Client2Space

compute

public Result compute(Task task,
                      java.lang.Object input,
                      Shared shared)
Takes in a task to be handled by the space. It then waits for the result to come back, and returns it. Uses the shared property of the space/computer/task setup.

Specified by:
compute in interface Client2Space
Parameters:
task -
userShared; -

put

public void put(GUI_Client client,
                Task task)
         throws java.rmi.RemoteException
Takes in a task to be done. Will be handed out to a Computer.

Specified by:
put in interface Client2Space
Parameters:
task - The task that should be completed by a Computer.
Throws:
java.rmi.RemoteException

take

public Result take()
            throws java.rmi.RemoteException
Returns a result from the Result Queue.

Specified by:
take in interface Client2Space
Returns:
Result object specifying the result of the calculation.
Throws:
java.rmi.RemoteException

getStatistics

public Statistics getStatistics()
Gets the statistics package from the space Can be extended to include any needed.

Specified by:
getStatistics in interface Client2Space

getUniqueTaskID

public int getUniqueTaskID()
returns the system wide unique Task ID

Specified by:
getUniqueTaskID in interface Computer2Space
Returns:
returns the system wide unique Task ID

getNextTask

public Task getNextTask()
                 throws java.rmi.RemoteException
Removes the next task from the task queue.

Specified by:
getNextTask in interface Computer2Space
Returns:
task The next task in the queue.
Throws:
java.rmi.RemoteException

register

public void register(Computer computer)
              throws java.rmi.RemoteException
Adds the Computer to the list of valid computers the space can utilize.

Specified by:
register in interface Computer2Space
Parameters:
computer - A reference to the new available computer.
Throws:
java.rmi.RemoteException

unregister

public boolean unregister(ComputerProxy proxy,
                          Task currentRunningTask)
Unregister the computer proxy that has thrown a remote exception

Parameters:
proxy -
Returns:
true if removed from queue successfully

enqueueTask

public void enqueueTask(Task task)
                 throws java.rmi.RemoteException
Puts a computer task into the task queue

Specified by:
enqueueTask in interface Computer2Space
Parameters:
task -
Throws:
java.rmi.RemoteException

enqueueResult

public void enqueueResult(Result result)
                   throws java.rmi.RemoteException
If the result is non-null it determines if the Result should be drain to a task in the waiting Queue, or if it should be returned to the client.

Specified by:
enqueueResult in interface Computer2Space
Parameters:
result - The result to be placed in the queue.
Throws:
java.rmi.RemoteException

setShared

public void setShared(Shared proposedShared)
               throws java.rmi.RemoteException
Set the shared object on the Space and propagates this Shared object to all the registered computers

Specified by:
setShared in interface Computer2Space
Parameters:
propposedShared - the proposed shared object
Throws:
java.rmi.RemoteException

hello

public void hello()
           throws java.rmi.RemoteException
Specified by:
hello in interface Computer2Space
Throws:
java.rmi.RemoteException

main

public static void main(java.lang.String[] args)
Creates a registry and binds itself to that registry.

Parameters:
args -