edu.rit.pj.cluster
Class JobBackend
- java.lang.Object
-
- edu.rit.pj.cluster.JobBackend
-
- All Implemented Interfaces:
- JobBackendRef, java.lang.Runnable
public class JobBackend extends java.lang.Object implements java.lang.Runnable, JobBackendRef
Class JobBackend is the main program for a job backend process in the PJ cluster middleware. The job backend process is launched by an SSH remote login from the job frontend process (class JobFrontend).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
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidcancelJob(JobFrontendRef theJobFrontend, java.lang.String errmsg)Cancel the job.voidclose()Close communication with this Job Backend.voidcommenceJob(JobFrontendRef theJobFrontend, java.net.InetSocketAddress[] middlewareAddress, java.net.InetSocketAddress[] worldAddress, java.net.InetSocketAddress[] frontendAddress, java.util.Properties properties, java.lang.String mainClassName, java.lang.String[] args)Commence the job.java.lang.String[]getArgs()Obtain this job's command line arguments.java.lang.StringgetBackendHost()Obtain the backend host name on which this job is running.java.lang.ClassLoadergetClassLoader()Obtain this job's backend class loader.BackendFileReadergetFileReader()Obtain this job's backend file reader.BackendFileWritergetFileWriter()Obtain this job's backend file writer.java.net.InetSocketAddress[]getFrontendAddress()Obtain this job's array of hosts/ports for the frontend communicator.ChannelGroupgetFrontendChannelGroup()Obtain this job's frontend communicator channel group.static JobBackendgetJobBackend()Obtain the Job Backend object.intgetJobNumber()Obtain this job's job number.intgetK()Obtain the number of backend processes in this job.java.lang.StringgetMainClassName()Obtain this job's main class name.java.util.PropertiesgetProperties()Obtain this job's Java system properties.intgetRank()Obtain the rank of this backend process in this job.java.lang.StringgetUserName()Obtain this job's user name.java.net.InetSocketAddress[]getWorldAddress()Obtain this job's array of hosts/ports for the world communicator.ChannelGroupgetWorldChannelGroup()Obtain this job's world communicator channel group.booleanhasFrontendCommunicator()Determine whether the frontend communicator exists in this job.voidinputFileCloseResult(JobFrontendRef theJobFrontend, int ffd, java.io.IOException exc)Report the result of closing the given input file.voidinputFileOpenResult(JobFrontendRef theJobFrontend, int bfd, int ffd, java.io.IOException exc)Report the result of opening the given input file.voidinputFileReadResult(JobFrontendRef theJobFrontend, int ffd, byte[] buf, int len, java.io.IOException exc)Report the result of reading the given input file.voidinputFileSkipResult(JobFrontendRef theJobFrontend, int ffd, long len, java.io.IOException exc)Report the result of skipping the given input file.voidjobFinished(JobFrontendRef theJobFrontend)Report that the job finished.static voidmain(java.lang.String[] args)Job Backend main program.voidoutputFileCloseResult(JobFrontendRef theJobFrontend, int ffd, java.io.IOException exc)Report the result of closing the given output file.voidoutputFileFlushResult(JobFrontendRef theJobFrontend, int ffd, java.io.IOException exc)Report the result of flushing the given output file.voidoutputFileOpenResult(JobFrontendRef theJobFrontend, int bfd, int ffd, java.io.IOException exc)Report the result of opening the given output file.voidoutputFileWriteResult(JobFrontendRef theJobFrontend, int ffd, java.io.IOException exc)Report the result of writing the given output file.voidrenewLease(JobFrontendRef theJobFrontend)Renew the lease on the job.voidreportResource(JobFrontendRef theJobFrontend, java.lang.String resourceName, byte[] content)Report the content for a previously-requested resource.voidreportResource(JobFrontendRef theJobFrontend, java.lang.String resourceName, ByteSequence content)Report the content for a previously-requested resource.voidrun()Run this Job Backend.voidwaitForCommence()Wait until this job commences.
-
-
-
Method Detail
-
run
public void run()
Run this Job Backend.- Specified by:
runin interfacejava.lang.Runnable
-
cancelJob
public void cancelJob(JobFrontendRef theJobFrontend, java.lang.String errmsg) throws java.io.IOException
Cancel the job.- Specified by:
cancelJobin interfaceJobBackendRef- Parameters:
theJobFrontend- Job Frontend that is calling this method.errmsg- Error message string.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
commenceJob
public void commenceJob(JobFrontendRef theJobFrontend, java.net.InetSocketAddress[] middlewareAddress, java.net.InetSocketAddress[] worldAddress, java.net.InetSocketAddress[] frontendAddress, java.util.Properties properties, java.lang.String mainClassName, java.lang.String[] args) throws java.io.IOException
Commence the job.- Specified by:
commenceJobin 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:
java.io.IOException- Thrown if an I/O error occurred.
-
jobFinished
public void jobFinished(JobFrontendRef theJobFrontend) throws java.io.IOException
Report that the job finished.- Specified by:
jobFinishedin interfaceJobBackendRef- Parameters:
theJobFrontend- Job frontend that is calling this method.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
renewLease
public void renewLease(JobFrontendRef theJobFrontend) throws java.io.IOException
Renew the lease on the job.- Specified by:
renewLeasein interfaceJobBackendRef- Parameters:
theJobFrontend- Job Frontend that is calling this method.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
reportResource
public void reportResource(JobFrontendRef theJobFrontend, java.lang.String resourceName, byte[] content) throws java.io.IOException
Report the content for a previously-requested resource.- Specified by:
reportResourcein interfaceJobBackendRef- Parameters:
theJobFrontend- Job Frontend that is calling this method.resourceName- Resource name.content- Resource content, or null if resource not found.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
reportResource
public void reportResource(JobFrontendRef theJobFrontend, java.lang.String resourceName, ByteSequence content) throws java.io.IOException
Report the content for a previously-requested resource.- Specified by:
reportResourcein interfaceJobBackendRef- Parameters:
theJobFrontend- Job Frontend that is calling this method.resourceName- Resource name.content- Resource content, or null if resource not found.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
outputFileOpenResult
public void outputFileOpenResult(JobFrontendRef theJobFrontend, int bfd, int ffd, java.io.IOException exc) throws java.io.IOException
Report the result of opening the given output file.- Specified by:
outputFileOpenResultin 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:
java.io.IOException- Thrown if an I/O error occurred.
-
outputFileWriteResult
public void outputFileWriteResult(JobFrontendRef theJobFrontend, int ffd, java.io.IOException exc) throws java.io.IOException
Report the result of writing the given output file.- Specified by:
outputFileWriteResultin interfaceJobBackendRef- Parameters:
theJobFrontend- Job Frontend that is calling this method.ffd- Frontend file descriptor.exc- Null if success, exception if failure.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
outputFileFlushResult
public void outputFileFlushResult(JobFrontendRef theJobFrontend, int ffd, java.io.IOException exc) throws java.io.IOException
Report the result of flushing the given output file.- Specified by:
outputFileFlushResultin interfaceJobBackendRef- Parameters:
theJobFrontend- Job Frontend that is calling this method.ffd- Frontend file descriptor.exc- Null if success, exception if failure.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
outputFileCloseResult
public void outputFileCloseResult(JobFrontendRef theJobFrontend, int ffd, java.io.IOException exc) throws java.io.IOException
Report the result of closing the given output file.- Specified by:
outputFileCloseResultin interfaceJobBackendRef- Parameters:
theJobFrontend- Job Frontend that is calling this method.ffd- Frontend file descriptor.exc- Null if success, exception if failure.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
inputFileOpenResult
public void inputFileOpenResult(JobFrontendRef theJobFrontend, int bfd, int ffd, java.io.IOException exc) throws java.io.IOException
Report the result of opening the given input file.- Specified by:
inputFileOpenResultin 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:
java.io.IOException- Thrown if an I/O error occurred.
-
inputFileReadResult
public void inputFileReadResult(JobFrontendRef theJobFrontend, int ffd, byte[] buf, int len, java.io.IOException exc) throws java.io.IOException
Report the result of reading the given input file.- Specified by:
inputFileReadResultin 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:
java.io.IOException- Thrown if an I/O error occurred.
-
inputFileSkipResult
public void inputFileSkipResult(JobFrontendRef theJobFrontend, int ffd, long len, java.io.IOException exc) throws java.io.IOException
Report the result of skipping the given input file.- Specified by:
inputFileSkipResultin 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:
java.io.IOException- Thrown if an I/O error occurred.
-
inputFileCloseResult
public void inputFileCloseResult(JobFrontendRef theJobFrontend, int ffd, java.io.IOException exc) throws java.io.IOException
Report the result of closing the given input file.- Specified by:
inputFileCloseResultin interfaceJobBackendRef- Parameters:
theJobFrontend- Job Frontend that is calling this method.ffd- Frontend file descriptor.exc- Null if success, exception if failure.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
close
public void close()
Close communication with this Job Backend.- Specified by:
closein interfaceJobBackendRef
-
getUserName
public java.lang.String 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
public java.lang.String 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
public java.lang.ClassLoader getClassLoader()
Obtain this job's backend class loader.- Returns:
- Class loader.
-
getFileWriter
public BackendFileWriter getFileWriter()
Obtain this job's backend file writer.- Returns:
- Backend file writer.
-
getFileReader
public BackendFileReader getFileReader()
Obtain this job's backend file reader.- Returns:
- Backend file reader.
-
waitForCommence
public void waitForCommence()
Wait until this job commences.
-
getWorldChannelGroup
public ChannelGroup getWorldChannelGroup()
Obtain this job's world communicator channel group. If this job has not commenced yet, null is returned.- Returns:
- Channel group.
-
getWorldAddress
public java.net.InetSocketAddress[] 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
public ChannelGroup 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
public java.net.InetSocketAddress[] 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
public java.util.Properties getProperties()
Obtain this job's Java system properties. If this job has not commenced yet, null is returned.- Returns:
- Properties.
-
getMainClassName
public java.lang.String 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
public java.lang.String[] 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.
-
getJobBackend
public static JobBackend 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
public static void main(java.lang.String[] args) throws java.lang.ExceptionJob Backend main program.- Throws:
java.lang.Exception
-
-
DMelt 3.0 © DataMelt by jWork.ORG