dcf.server
Class Distributer

dcf.server.Distributer
All Implemented Interfaces:
DistributerInt

public class Distributer
implements DistributerInt

This is the RMI server. It handles sending tasks and recieving results.
It also starts the ClassServer to serve classfiles to clients.

Author:
Tal Salmona

Constructor Summary
Distributer(MainFrame parent)
           
 
Method Summary
 void addMessage(dcf.server.String str)
          Posts a message to parent (dcf.server.MainFrame)
 void addPair(Task t, Solver s)
          Adds a Task-Solver pair to the distributer
 dcf.server.HashMap getAssignments()
          Gets the list of assignments
 dcf.server.String getClassServerURL()
           
 ClassServer getCS()
           
 ClientsUpdater getCU()
           
 Task getNextTask(WorkerInt w)
           
 Solver getSolverFor(Task t)
          Returns a solver for the task based on the Task's name.
 Task getTaskByName(dcf.server.String name)
          Gets a task by its name looks in unsolved tasks and then in solved tasks.
 dcf.server.Vector getTasks()
           
 boolean hasMoreTasks()
          Checks if there are more tasks in the list
 void registerClient(WorkerInt w, Task tsk)
          Registers a new client at the server
 void returnTask(WorkerInt w, Task t)
          Return a completed task to the distributer.
 void setTasksList()
          Updates the Worker - Task table on GUI.
 void unregisterClient(WorkerInt w)
          Unregisters a client at the server
 

Constructor Detail

Distributer

public Distributer(MainFrame parent)
            throws dcf.client.RemoteException
Method Detail

addPair

public void addPair(Task t,
                    Solver s)
Adds a Task-Solver pair to the distributer
Parameters:
t - Task to add
s - Solver for this task

getTasks

public dcf.server.Vector getTasks()
Returns:
A Vector of all Task to be proccessed.

getTaskByName

public Task getTaskByName(dcf.server.String name)
Gets a task by its name looks in unsolved tasks and then in solved tasks.
Parameters:
name - - Task's name (String name field in the task)
Returns:
The task or null if it was not found

getCS

public ClassServer getCS()
Returns:
A reference to the ClassServer

getCU

public ClientsUpdater getCU()
Returns:
A reference to the ClientsUpdater

addMessage

public void addMessage(dcf.server.String str)
Posts a message to parent (dcf.server.MainFrame)
Parameters:
str - The message to add to GUI.

registerClient

public void registerClient(WorkerInt w,
                           Task tsk)
Registers a new client at the server
Parameters:
w - The remote reference to the Worker.
tsk - The Task assigned to the Worker.

unregisterClient

public void unregisterClient(WorkerInt w)
Unregisters a client at the server
Parameters:
w - The remote reference to Worker.

getAssignments

public dcf.server.HashMap getAssignments()
Gets the list of assignments
Returns:
The mapping of tasks to Workers.

setTasksList

public void setTasksList()
Updates the Worker - Task table on GUI.

hasMoreTasks

public boolean hasMoreTasks()
                     throws dcf.client.RemoteException
Checks if there are more tasks in the list
Specified by:
hasMoreTasks in interface DistributerInt
Returns:
true if there are more tasks.
Throws:
dcf.client.RemoteException - if some eror occures here.

getNextTask

public Task getNextTask(WorkerInt w)
                 throws dcf.client.RemoteException
Specified by:
getNextTask in interface DistributerInt
Parameters:
w - The remote reference to the Worker.
Returns:
The next available task or null if there are non.
Throws:
dcf.client.RemoteException - if we get some error here.

getSolverFor

public Solver getSolverFor(Task t)
                    throws dcf.client.RemoteException
Returns a solver for the task based on the Task's name.
Specified by:
getSolverFor in interface DistributerInt
Parameters:
t - The task to get the solver for
Returns:
A solver for this task.
Throws:
dcf.client.RemoteException - If we get an error here.

returnTask

public void returnTask(WorkerInt w,
                       Task t)
                throws dcf.client.RemoteException
Return a completed task to the distributer.
Specified by:
returnTask in interface DistributerInt
Parameters:
w - The remote reference to the Worker.
t - The task to return.
Throws:
dcf.client.RemoteException - If we get some kind of error here.

getClassServerURL

public dcf.server.String getClassServerURL()
                                    throws dcf.client.RemoteException
Specified by:
getClassServerURL in interface DistributerInt
Returns:
A String representing the URL for the ClassServer so that the client can request Classfiles via HTTP.
Throws:
dcf.client.RemoteException - If we get some kind of error here.




Distributed Computation Framework