proper.remote
Class JobServer

java.lang.Object
  extended by proper.core.ProperObject
      extended by proper.core.ArgumentObject
          extended by proper.app.Application
              extended by proper.remote.Server
                  extended by proper.remote.JobServer
All Implemented Interfaces:
CommandLineInterface, ProperInterface, XMLAccessInterface

public class JobServer
extends Server

This class is a server for performing distributed computation.
The clients register and unregister themselves with the server, which handles a queue of jobs.
Every Request that is sent between Server and Client has the type of request in the first line.
The job list that the server reads is a simple text file where each line is either a comment (line is starting with a "#") or a real job. A real job consists of the class that should be executed and then the necessary parameters to run this class. The "-log" is added automatically.

For a complete list of commandline parameters just run it with the option "-help".

Version:
$Revision: 1.2 $
Author:
FracPete
See Also:
JobClient

Field Summary
static java.lang.String JOB_DISTRIBUTE
          this "job" means, that the server sends all received files to all the cliens before continuing ("synchronize" should be before this)
static java.lang.String JOB_SYNCHRONIZE
          this "job" means, that all pending jobs have to be finished before continuing
static int JOBLIST
          the identifier for the normal list
static int JOBLIST_DONE
          the identifier for the Done list
static int JOBLIST_FAILED
          the identifier for the Failed list
static int JOBLIST_TODO
          the identifier for the ToDo list
static int LIST_ADDITIONAL
          the identifier for clients with additional jobs, still working
static int LIST_AVAILABLE
          the identifier for the available clients
static int LIST_PENDING
          the identifier for pending clients, still working on something
static int PORT
          the standard port to bind to
static java.lang.String REQUEST_ADDITIONAL
          with this request the server sends back the additional jobs
static java.lang.String REQUEST_ADDITIONALADD
          with this request the client is performing an additional job
static java.lang.String REQUEST_ADDITIONALFAILED
          with this request the client has failed with an additional job
static java.lang.String REQUEST_ADDITIONALREMOVE
          with this request the client has finished an additional job
static java.lang.String REQUEST_ADDJOBS
          with this request the server adds the new jobs to the queue
static java.lang.String REQUEST_CLIENTS
          with this request the server sends back the current clients
static java.lang.String REQUEST_DELETEJOB
          with this request the server deletes the specified job
static java.lang.String REQUEST_FAILED
          with this request the client returns that the job failed
static java.lang.String REQUEST_FILE
          with this request the client sends a file to the server
static java.lang.String REQUEST_GETFILE
          with this request the server requests a file from the client
static java.lang.String REQUEST_JOB
          with this request the client gets a job
static java.lang.String REQUEST_JOBSDONE
          with this request the server sends back the jobs already done
static java.lang.String REQUEST_JOBSFAILED
          with this request the server sends back the jobs that failed
static java.lang.String REQUEST_JOBSTODO
          with this request the server sends back the jobs still in queue
static java.lang.String REQUEST_KILL
          with this request the client must do a System.exit()
static java.lang.String REQUEST_NEXTJOB
          with this request the server conitnues with the next job
static java.lang.String REQUEST_PENDING
          with this request the server sends back the pending jobs
static java.lang.String REQUEST_REGISTER
          with this request the client registers itself with the server
static java.lang.String REQUEST_REREGISTER
          with this request the client re-registers itself with the server
static java.lang.String REQUEST_RESULT
          with this request the client returns the result from a job
static java.lang.String REQUEST_SHUTDOWN
          this request is sent to the clients, when the server shuts down
static java.lang.String REQUEST_UNREGISTER
          with this request the client un-registers itself with the server
 
Fields inherited from class proper.remote.Server
ALIVE_CHECK, LIST_CLIENTS, REQUEST_ISALIVE, REQUEST_NOP
 
Fields inherited from interface proper.core.ProperInterface
VERSION
 
Constructor Summary
JobServer()
          initializes the object
 
Method Summary
 void addJobs(java.util.Vector lines)
          adds the given jobs to the job-queue
 void doDistributing()
          checks whether we have to distribute all the files we received so far to all the clients
 ClientList getClientList(int type)
          returns the specified clientlist
 java.util.Stack getJobs()
          returns the jobs
 java.util.Vector getJobs(int type)
          returns the jobs, depending on the type (NULL if wrong type)
 java.lang.String getJobsFilename()
          returns the name of the Jobs file
 java.lang.String getJobsFilename(int list)
          returns the name of the Jobs file, depending on the list type
 java.util.Vector getReceived()
          returns the list with the received files
 boolean isOperational()
          this method determines whether the server should continue accepting connections or not
 boolean isSynchronizing()
          checks whether we have to wait for all the pending jobs to finished, before we can proceed with the next job
static void main(java.lang.String[] args)
          starts the application
 void printDescription()
          prints a short description of this class
 void sendKill()
          sends a KILL to all the clients
 void sendShutdown()
          sends a shutdown to all the clients
 
Methods inherited from class proper.remote.Server
addToAccessLog, addToErrorLog, checkClients, createMessage, createMessage, getHostName, getPort
 
Methods inherited from class proper.app.Application
checkCommandLine, createInstance, fromXML, parameterError, printUsage, run, run, setArgs, setArgs, toString, toXML
 
Methods inherited from class proper.core.ArgumentObject
fixAdditionalArg
 
Methods inherited from class proper.core.ProperObject
addListener, addOutput, classInVerbose, debugprint, debugprint, debugprint, debugprint, debugprintln, debugprintln, debugprintln, debugprintln, debugprintln, getListeners, getRuntime, getVerbose, getVerboseLevel, getVerboseLevelForClass, getVerboseString, getVerboseStringForClass, notifyListener, notifyListeners, print, print, print, print, println, println, println, println, println, printMemory, removeListener, setOutput, setVerbose, setVerboseLevel, setVerboseString
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PORT

public static final int PORT
the standard port to bind to

See Also:
Constant Field Values

REQUEST_REGISTER

public static final java.lang.String REQUEST_REGISTER
with this request the client registers itself with the server

See Also:
Constant Field Values

REQUEST_UNREGISTER

public static final java.lang.String REQUEST_UNREGISTER
with this request the client un-registers itself with the server

See Also:
Constant Field Values

REQUEST_REREGISTER

public static final java.lang.String REQUEST_REREGISTER
with this request the client re-registers itself with the server

See Also:
Constant Field Values

REQUEST_KILL

public static final java.lang.String REQUEST_KILL
with this request the client must do a System.exit()

See Also:
Constant Field Values

REQUEST_JOB

public static final java.lang.String REQUEST_JOB
with this request the client gets a job

See Also:
Constant Field Values

REQUEST_NEXTJOB

public static final java.lang.String REQUEST_NEXTJOB
with this request the server conitnues with the next job

See Also:
Constant Field Values

REQUEST_DELETEJOB

public static final java.lang.String REQUEST_DELETEJOB
with this request the server deletes the specified job

See Also:
Constant Field Values

REQUEST_RESULT

public static final java.lang.String REQUEST_RESULT
with this request the client returns the result from a job

See Also:
Constant Field Values

REQUEST_FAILED

public static final java.lang.String REQUEST_FAILED
with this request the client returns that the job failed

See Also:
Constant Field Values

REQUEST_GETFILE

public static final java.lang.String REQUEST_GETFILE
with this request the server requests a file from the client

See Also:
Constant Field Values

REQUEST_FILE

public static final java.lang.String REQUEST_FILE
with this request the client sends a file to the server

See Also:
Constant Field Values

REQUEST_ADDJOBS

public static final java.lang.String REQUEST_ADDJOBS
with this request the server adds the new jobs to the queue

See Also:
Constant Field Values

REQUEST_ADDITIONALADD

public static final java.lang.String REQUEST_ADDITIONALADD
with this request the client is performing an additional job

See Also:
Constant Field Values

REQUEST_ADDITIONALREMOVE

public static final java.lang.String REQUEST_ADDITIONALREMOVE
with this request the client has finished an additional job

See Also:
Constant Field Values

REQUEST_ADDITIONALFAILED

public static final java.lang.String REQUEST_ADDITIONALFAILED
with this request the client has failed with an additional job

See Also:
Constant Field Values

REQUEST_JOBSTODO

public static final java.lang.String REQUEST_JOBSTODO
with this request the server sends back the jobs still in queue

See Also:
Constant Field Values

REQUEST_JOBSDONE

public static final java.lang.String REQUEST_JOBSDONE
with this request the server sends back the jobs already done

See Also:
Constant Field Values

REQUEST_JOBSFAILED

public static final java.lang.String REQUEST_JOBSFAILED
with this request the server sends back the jobs that failed

See Also:
Constant Field Values

REQUEST_CLIENTS

public static final java.lang.String REQUEST_CLIENTS
with this request the server sends back the current clients

See Also:
Constant Field Values

REQUEST_PENDING

public static final java.lang.String REQUEST_PENDING
with this request the server sends back the pending jobs

See Also:
Constant Field Values

REQUEST_ADDITIONAL

public static final java.lang.String REQUEST_ADDITIONAL
with this request the server sends back the additional jobs

See Also:
Constant Field Values

REQUEST_SHUTDOWN

public static final java.lang.String REQUEST_SHUTDOWN
this request is sent to the clients, when the server shuts down

See Also:
Constant Field Values

LIST_AVAILABLE

public static final int LIST_AVAILABLE
the identifier for the available clients

See Also:
Constant Field Values

LIST_PENDING

public static final int LIST_PENDING
the identifier for pending clients, still working on something

See Also:
Constant Field Values

LIST_ADDITIONAL

public static final int LIST_ADDITIONAL
the identifier for clients with additional jobs, still working

See Also:
Constant Field Values

JOBLIST

public static final int JOBLIST
the identifier for the normal list

See Also:
Constant Field Values

JOBLIST_TODO

public static final int JOBLIST_TODO
the identifier for the ToDo list

See Also:
Constant Field Values

JOBLIST_DONE

public static final int JOBLIST_DONE
the identifier for the Done list

See Also:
Constant Field Values

JOBLIST_FAILED

public static final int JOBLIST_FAILED
the identifier for the Failed list

See Also:
Constant Field Values

JOB_SYNCHRONIZE

public static final java.lang.String JOB_SYNCHRONIZE
this "job" means, that all pending jobs have to be finished before continuing

See Also:
Constant Field Values

JOB_DISTRIBUTE

public static final java.lang.String JOB_DISTRIBUTE
this "job" means, that the server sends all received files to all the cliens before continuing ("synchronize" should be before this)

See Also:
Constant Field Values
Constructor Detail

JobServer

public JobServer()
initializes the object

Method Detail

printDescription

public void printDescription()
prints a short description of this class

Specified by:
printDescription in interface CommandLineInterface
Overrides:
printDescription in class Application

addJobs

public void addJobs(java.util.Vector lines)
adds the given jobs to the job-queue


getJobsFilename

public java.lang.String getJobsFilename()
returns the name of the Jobs file


getJobsFilename

public java.lang.String getJobsFilename(int list)
returns the name of the Jobs file, depending on the list type

See Also:
JOBLIST_TODO, JOBLIST_DONE, JOBLIST_FAILED

getJobs

public java.util.Stack getJobs()
returns the jobs


getJobs

public java.util.Vector getJobs(int type)
returns the jobs, depending on the type (NULL if wrong type)


isSynchronizing

public boolean isSynchronizing()
checks whether we have to wait for all the pending jobs to finished, before we can proceed with the next job


doDistributing

public void doDistributing()
                    throws java.lang.Exception
checks whether we have to distribute all the files we received so far to all the clients

Throws:
java.lang.Exception

getReceived

public java.util.Vector getReceived()
returns the list with the received files


getClientList

public ClientList getClientList(int type)
returns the specified clientlist

Overrides:
getClientList in class Server

sendShutdown

public void sendShutdown()
sends a shutdown to all the clients


sendKill

public void sendKill()
sends a KILL to all the clients


isOperational

public boolean isOperational()
this method determines whether the server should continue accepting connections or not

Overrides:
isOperational in class Server

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
starts the application

Throws:
java.lang.Exception