Class JobBackend
- All Implemented Interfaces:
JobBackendRef
,Runnable
The command line for the job backend main program is:
java edu.rit.pj.cluster.JobBackend username jobnum K
rank hasFrontendComm frontendHost frontendPort
backendHost
username = User name
jobnum = Job number
K = Number of backend processes (>= 1)
rank = Rank of this backend process (0 .. K-1)
hasFrontendComm = Whether the frontend communicator exists
(true
or false
)
frontendHost = Job frontend's middleware channel group host name
frontendPort = Job frontend's middleware channel group port number
backendHost = Job backend's middleware channel group host name
- Version:
- 24-Jan-2012
- Author:
- Alan Kaminsky
-
Method Summary
Modifier and TypeMethodDescriptionvoid
cancelJob
(JobFrontendRef theJobFrontend, String errmsg) Cancel the job.void
close()
Close communication with this Job Backend.void
commenceJob
(JobFrontendRef theJobFrontend, InetSocketAddress[] middlewareAddress, InetSocketAddress[] worldAddress, InetSocketAddress[] frontendAddress, Properties properties, String mainClassName, String[] args) Commence the job.String[]
getArgs()
Obtain this job's command line arguments.Obtain the backend host name on which this job is running.Obtain this job's backend class loader.Obtain this job's backend file reader.Obtain this job's backend file writer.Obtain this job's array of hosts/ports for the frontend communicator.Obtain this job's frontend communicator channel group.static JobBackend
Obtain the Job Backend object.int
Obtain this job's job number.int
getK()
Obtain the number of backend processes in this job.Obtain this job's main class name.Obtain this job's Java system properties.int
getRank()
Obtain the rank of this backend process in this job.Obtain this job's user name.Obtain this job's array of hosts/ports for the world communicator.Obtain this job's world communicator channel group.boolean
Determine whether the frontend communicator exists in this job.void
inputFileCloseResult
(JobFrontendRef theJobFrontend, int ffd, IOException exc) Report the result of closing the given input file.void
inputFileOpenResult
(JobFrontendRef theJobFrontend, int bfd, int ffd, IOException exc) Report the result of opening the given input file.void
inputFileReadResult
(JobFrontendRef theJobFrontend, int ffd, byte[] buf, int len, IOException exc) Report the result of reading the given input file.void
inputFileSkipResult
(JobFrontendRef theJobFrontend, int ffd, long len, IOException exc) Report the result of skipping the given input file.void
jobFinished
(JobFrontendRef theJobFrontend) Report that the job finished.static void
Job Backend main program.void
outputFileCloseResult
(JobFrontendRef theJobFrontend, int ffd, IOException exc) Report the result of closing the given output file.void
outputFileFlushResult
(JobFrontendRef theJobFrontend, int ffd, IOException exc) Report the result of flushing the given output file.void
outputFileOpenResult
(JobFrontendRef theJobFrontend, int bfd, int ffd, IOException exc) Report the result of opening the given output file.void
outputFileWriteResult
(JobFrontendRef theJobFrontend, int ffd, IOException exc) Report the result of writing the given output file.void
renewLease
(JobFrontendRef theJobFrontend) Renew the lease on the job.void
reportResource
(JobFrontendRef theJobFrontend, String resourceName, byte[] content) Report the content for a previously-requested resource.void
reportResource
(JobFrontendRef theJobFrontend, String resourceName, ByteSequence content) Report the content for a previously-requested resource.void
run()
Run this Job Backend.void
setComment
(String comment) Set the comment string for this job backend process.void
Wait until this job commences.
-
Method Details
-
run
public void run()Run this Job Backend. -
cancelJob
Cancel the job.Cancel the job.
- Specified by:
cancelJob
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.errmsg
- Error message string.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
commenceJob
public void commenceJob(JobFrontendRef theJobFrontend, InetSocketAddress[] middlewareAddress, InetSocketAddress[] worldAddress, InetSocketAddress[] frontendAddress, Properties properties, String mainClassName, String[] args) throws IOException Commence the job.- Specified by:
commenceJob
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.middlewareAddress
- Array of hosts/ports for middleware messages. The first K elements are for the job backend processes in rank order, the K+1st element is for the job frontend process. If theworldAddress
- Array of hosts/ports for the world communicator. The K elements are for the job backend processes in rank order.frontendAddress
- Array of hosts/ports for the frontend communicator. The first K elements are for the job backend processes in rank order, the K+1st element is for the job frontend process. If the frontend communicator does not exist,frontendAddress
is null.properties
- Java system properties.mainClassName
- Fully qualified class name of the Java main program class to execute.args
- Array of 0 or more Java command line arguments.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
jobFinished
Report that the job finished.Report that the job finished.
- Specified by:
jobFinished
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job frontend that is calling this method.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
renewLease
Renew the lease on the job.Renew the lease on the job.
- Specified by:
renewLease
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
reportResource
public void reportResource(JobFrontendRef theJobFrontend, String resourceName, byte[] content) throws IOException Report the content for a previously-requested resource.- Specified by:
reportResource
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.resourceName
- Resource name.content
- Resource content, or null if resource not found.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
reportResource
public void reportResource(JobFrontendRef theJobFrontend, String resourceName, ByteSequence content) throws IOException Report the content for a previously-requested resource.Report the content for a previously-requested resource.
- Specified by:
reportResource
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- aJobFrontendRef
objectresourceName
- aString
objectcontent
- aByteSequence
object- Throws:
IOException
- Thrown if an I/O error occurred.
-
outputFileOpenResult
public void outputFileOpenResult(JobFrontendRef theJobFrontend, int bfd, int ffd, IOException exc) throws IOException Report the result of opening the given output file.Report the result of opening the given output file.
- Specified by:
outputFileOpenResult
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.bfd
- Backend file descriptor.ffd
- Frontend file descriptor if success.exc
- Null if success, exception if failure.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
outputFileWriteResult
public void outputFileWriteResult(JobFrontendRef theJobFrontend, int ffd, IOException exc) throws IOException Report the result of writing the given output file.Report the result of writing the given output file.
- Specified by:
outputFileWriteResult
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.ffd
- Frontend file descriptor.exc
- Null if success, exception if failure.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
outputFileFlushResult
public void outputFileFlushResult(JobFrontendRef theJobFrontend, int ffd, IOException exc) throws IOException Report the result of flushing the given output file.Report the result of flushing the given output file.
- Specified by:
outputFileFlushResult
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.ffd
- Frontend file descriptor.exc
- Null if success, exception if failure.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
outputFileCloseResult
public void outputFileCloseResult(JobFrontendRef theJobFrontend, int ffd, IOException exc) throws IOException Report the result of closing the given output file.Report the result of closing the given output file.
- Specified by:
outputFileCloseResult
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.ffd
- Frontend file descriptor.exc
- Null if success, exception if failure.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
inputFileOpenResult
public void inputFileOpenResult(JobFrontendRef theJobFrontend, int bfd, int ffd, IOException exc) throws IOException Report the result of opening the given input file.Report the result of opening the given input file.
- Specified by:
inputFileOpenResult
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.bfd
- Backend file descriptor.ffd
- Frontend file descriptor if success.exc
- Null if success, exception if failure.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
inputFileReadResult
public void inputFileReadResult(JobFrontendRef theJobFrontend, int ffd, byte[] buf, int len, IOException exc) throws IOException Report the result of reading the given input file.Report the result of reading the given input file.
- Specified by:
inputFileReadResult
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.ffd
- Frontend file descriptor.buf
- Bytes read.len
- Number of bytes read, or -1 if EOF.exc
- Null if success, exception if failure.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
inputFileSkipResult
public void inputFileSkipResult(JobFrontendRef theJobFrontend, int ffd, long len, IOException exc) throws IOException Report the result of skipping the given input file.Report the result of skipping the given input file.
- Specified by:
inputFileSkipResult
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.ffd
- Frontend file descriptor.len
- Number of bytes skipped.exc
- Null if success, exception if failure.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
inputFileCloseResult
public void inputFileCloseResult(JobFrontendRef theJobFrontend, int ffd, IOException exc) throws IOException Report the result of closing the given input file.Report the result of closing the given input file.
- Specified by:
inputFileCloseResult
in interfaceJobBackendRef
- Parameters:
theJobFrontend
- Job Frontend that is calling this method.ffd
- Frontend file descriptor.exc
- Null if success, exception if failure.- Throws:
IOException
- Thrown if an I/O error occurred.IOException
- if any.
-
close
public void close()Close communication with this Job Backend.- Specified by:
close
in interfaceJobBackendRef
-
getUserName
Obtain this job's user name.- Returns:
- User name.
-
getJobNumber
public int getJobNumber()Obtain this job's job number.- Returns:
- Job number.
-
getK
public int getK()Obtain the number of backend processes in this job.- Returns:
- K, the number of backend processes.
-
getRank
public int getRank()Obtain the rank of this backend process in this job.- Returns:
- Rank.
-
getBackendHost
Obtain the backend host name on which this job is running.- Returns:
- Host name.
-
hasFrontendCommunicator
public boolean hasFrontendCommunicator()Determine whether the frontend communicator exists in this job.- Returns:
- True if the frontend communicator exists, false if it doesn't.
-
getClassLoader
Obtain this job's backend class loader.- Returns:
- Class loader.
-
getFileWriter
Obtain this job's backend file writer.- Returns:
- Backend file writer.
-
getFileReader
Obtain this job's backend file reader.- Returns:
- Backend file reader.
-
waitForCommence
public void waitForCommence()Wait until this job commences. -
getWorldChannelGroup
Obtain this job's world communicator channel group. If this job has not commenced yet, null is returned.- Returns:
- Channel group.
-
getWorldAddress
Obtain this job's array of hosts/ports for the world communicator. The K elements are for the job backend processes in rank order. If this job has not commenced yet, null is returned.- Returns:
- Array of world communicator addresses.
-
getFrontendChannelGroup
Obtain this job's frontend communicator channel group. If the frontend communicator does not exist, or if this job has not commenced yet, null is returned.- Returns:
- Channel group.
-
getFrontendAddress
Obtain this job's array of hosts/ports for the frontend communicator. The first K elements are for the job backend processes in rank order, the K+1st element is for the job frontend process. If the frontend communicator does not exist, or if this job has not commenced yet, null is returned.- Returns:
- Array of frontend communicator addresses.
-
getProperties
Obtain this job's Java system properties. If this job has not commenced yet, null is returned.- Returns:
- Properties.
-
getMainClassName
Obtain this job's main class name. If this job has not commenced yet, null is returned.- Returns:
- Fully qualified class name of the Java main program class to execute.
-
getArgs
Obtain this job's command line arguments. If this job has not commenced yet, null is returned.- Returns:
- Array of 0 or more Java command line arguments.
-
setComment
Set the comment string for this job backend process. The comment string appears in the detailed job status display in the Job Scheduler's web interface. Each job backend process (rank) has its own comment string. IfsetComment()
is never called, the comment string is empty. The comment string is typically used to display this job backend process's progress. The comment string is rendered by a web browser and can contain HTML tags.Calling
setComment()
causes a message to be sent to the job frontend process, which in turn causes a message to be sent to the Job Scheduler. (Any I/O errors during message sending are ignored.) Consequently, don't callsetComment()
too frequently, or the program's performance will suffer.- Parameters:
comment
- Comment string.
-
getJobBackend
Obtain the Job Backend object. If the Job Backend main program is running, the job backend object for the job is returned. If some other main program is running, null is returned.- Returns:
- Job backend object, or null.
-
main
Job Backend main program.
-