Package edu.rit.pj.cluster
Class NonPjJobFrontend
java.lang.Object
edu.rit.pj.cluster.NonPjJobFrontend
- All Implemented Interfaces:
JobFrontendRef,Runnable
Class NonPjJobFrontend provides the message handler for a job frontend
process that communicates with the Job Scheduler to allocate backend nodes
but does not run a PJ program.
- Version:
- 20-Jun-2012
- Author:
- Alan Kaminsky
-
Constructor Summary
ConstructorsConstructorDescriptionNonPjJobFrontend(String username, int Np) Construct a new non-PJ job frontend object. -
Method Summary
Modifier and TypeMethodDescriptionvoidassignBackend(JobSchedulerRef theJobScheduler, String name, String host, String jvm, String classpath, String[] jvmflags, String shellCommand, int Nt) Assign a backend process to the job.voidassignJobNumber(JobSchedulerRef theJobScheduler, int jobnum, String pjhost) Assign a job number to the job.voidbackendFinished(JobBackendRef theJobBackend) Report that a backend process has finished executing the job.voidbackendReady(JobBackendRef theJobBackend, int rank, InetSocketAddress middlewareAddress, InetSocketAddress worldAddress, InetSocketAddress frontendAddress) Report that a backend process is ready to commence executing the job.voidcancelJob(JobBackendRef theJobBackend, String errmsg) Cancel the job.voidcancelJob(JobSchedulerRef theJobScheduler, String errmsg) Cancel the job.voidclose()Close communication with this Job Frontend.Obtain a list of the backend names assigned to this Non-PJ Job Frontend.intObtain the job number assigned to this Non-PJ Job Frontend.voidinputFileClose(JobBackendRef theJobBackend, int ffd) Close the given input file.voidinputFileOpen(JobBackendRef theJobBackend, int bfd, File file) Open the given input file for reading.voidinputFileRead(JobBackendRef theJobBackend, int ffd, int len) Read bytes from the given input file.voidinputFileSkip(JobBackendRef theJobBackend, int ffd, long len) Skip bytes from the given input file.voidoutputFileClose(JobBackendRef theJobBackend, int ffd) Close the given output file.voidoutputFileFlush(JobBackendRef theJobBackend, int ffd) Flush accumulated bytes to the given output file.voidoutputFileOpen(JobBackendRef theJobBackend, int bfd, File file, boolean append) Open the given output file for writing or appending.voidoutputFileWrite(JobBackendRef theJobBackend, int ffd, byte[] buf, int off, int len) Write the given bytes to the given output file.voidrenewLease(JobBackendRef theJobBackend) Renew the lease on the job.voidrenewLease(JobSchedulerRef theJobScheduler) Renew the lease on the job.voidreportComment(JobBackendRef theJobBackend, int rank, String comment) Report a comment for a process.voidrequestResource(JobBackendRef theJobBackend, String resourceName) Request the given resource from this job frontend's class loader.voidrun()Run this Non-PJ Job Frontend.voidterminateJobFinished(int status) Terminate this Non-PJ Job Frontend immediately, sending a "job finished" message to the Job Scheduler.
-
Constructor Details
-
NonPjJobFrontend
Construct a new non-PJ job frontend object. The job frontend object will contact the Job Scheduler Daemon specified by the"pj.host"and"pj.port"Java system properties. See class PJProperties for further information.The non-PJ job frontend object will ask the Job Scheduler Daemon to run one process per node and to use all CPUs on each node. Other possibilities are not supported.
- Parameters:
username- User name.Np- Number of processes (>= 1).- Throws:
JobSchedulerException- (subclass of IOException) Thrown if the job frontend object could not contact the Job Scheduler Daemon.IOException- Thrown if an I/O error occurred.IOException- if any.
-
-
Method Details
-
getJobNumber
Obtain the job number assigned to this Non-PJ Job Frontend. This method blocks until the requested number of backend processes (a constructor parameter) have been assigned.- Returns:
- Job number.
- Throws:
InterruptedException- Thrown if the calling thread is interrupted while blocked in this method.InterruptedException- if any.
-
getBackendNames
Obtain a list of the backend names assigned to this Non-PJ Job Frontend. This method blocks until the requested number of backend processes (a constructor parameter) have been assigned. The returned list is unmodifiable.- Returns:
- List of backend names.
- Throws:
InterruptedException- Thrown if the calling thread is interrupted while blocked in this method.InterruptedException- if any.
-
run
public void run()Run this Non-PJ Job Frontend. -
terminateJobFinished
public void terminateJobFinished(int status) Terminate this Non-PJ Job Frontend immediately, sending a "job finished" message to the Job Scheduler. This method must only be called by a thread other than the thread callingrun(). This method callsSystem.exit(status)to terminate the process.- Parameters:
status- Status value forSystem.exit().
-
assignBackend
public void assignBackend(JobSchedulerRef theJobScheduler, String name, String host, String jvm, String classpath, String[] jvmflags, String shellCommand, int Nt) throws IOException Assign a backend process to the job. Assign a backend process to the job.- Specified by:
assignBackendin interfaceJobFrontendRef- Parameters:
theJobScheduler- Job Scheduler that is calling this method.name- Backend node name.host- Host name for SSH remote login.jvm- Full pathname of Java Virtual Machine.classpath- Java class path for PJ Library.jvmflags- Array of JVM command line flags.shellCommand- Shell command string.Nt- Number of CPUs assigned to the process.- Throws:
IOException- Thrown if an I/O error occurred.
-
assignJobNumber
public void assignJobNumber(JobSchedulerRef theJobScheduler, int jobnum, String pjhost) throws IOException Assign a job number to the job. The host name for the job frontend's middleware channel group is also specified. Assign a job number to the job. The host name for the job frontend's middleware channel group is also specified.- Specified by:
assignJobNumberin interfaceJobFrontendRef- Parameters:
theJobScheduler- Job Scheduler that is calling this method.jobnum- Job number.pjhost- Host name for middleware channel group.- Throws:
IOException- Thrown if an I/O error occurred.
-
cancelJob
Cancel the job. Cancel the job.- Specified by:
cancelJobin interfaceJobFrontendRef- Parameters:
theJobScheduler- Job Scheduler that is calling this method.errmsg- Error message string.- Throws:
IOException- Thrown if an I/O error occurred.
-
renewLease
Renew the lease on the job.- Specified by:
renewLeasein interfaceJobFrontendRef- Parameters:
theJobScheduler- Job Scheduler that is calling this method.- Throws:
IOException- Thrown if an I/O error occurred.IOException- if any.
-
backendFinished
Report that a backend process has finished executing the job. Report that a backend process has finished executing the job.- Specified by:
backendFinishedin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.- Throws:
IOException- Thrown if an I/O error occurred.
-
backendReady
public void backendReady(JobBackendRef theJobBackend, int rank, InetSocketAddress middlewareAddress, InetSocketAddress worldAddress, InetSocketAddress frontendAddress) throws IOException Report that a backend process is ready to commence executing the job. Report that a backend process is ready to commence executing the job.- Specified by:
backendReadyin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.rank- Rank of the job backend process.middlewareAddress- Host/port to which the job backend process is listening for middleware messages.worldAddress- Host/port to which the job backend process is listening for the world communicator.frontendAddress- Host/port to which the job backend process is listening for the frontend communicator, or null if the frontend communicator does not exist.- Throws:
IOException- Thrown if an I/O error occurred.
-
cancelJob
Cancel the job. Cancel the job.- Specified by:
cancelJobin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.errmsg- Error message string.- Throws:
IOException- Thrown if an I/O error occurred.
-
renewLease
Renew the lease on the job. Renew the lease on the job.- Specified by:
renewLeasein interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.- Throws:
IOException- Thrown if an I/O error occurred.
-
requestResource
Request the given resource from this job frontend's class loader. Request the given resource from this job frontend's class loader.- Specified by:
requestResourcein interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.resourceName- Resource name.- Throws:
IOException- Thrown if an I/O error occurred.
-
outputFileOpen
public void outputFileOpen(JobBackendRef theJobBackend, int bfd, File file, boolean append) throws IOException Open the given output file for writing or appending. Open the given output file for writing or appending.- Specified by:
outputFileOpenin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.bfd- Backend file descriptor.file- File.append- True to append, false to overwrite.- Throws:
IOException- Thrown if an I/O error occurred.
-
outputFileWrite
public void outputFileWrite(JobBackendRef theJobBackend, int ffd, byte[] buf, int off, int len) throws IOException Write the given bytes to the given output file.ffd= 1 refers to the job's standard output stream;ffd= 2 refers to the job's standard error stream; other values refer to a previously opened file. Write the given bytes to the given output file.ffd= 1 refers to the job's standard output stream;ffd= 2 refers to the job's standard error stream; other values refer to a previously opened file.- Specified by:
outputFileWritein interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.ffd- Frontend file descriptor.buf- Array of bytes to write.off- Index of first byte to write.len- Number of bytes to write.- Throws:
IOException- Thrown if an I/O error occurred.
-
outputFileFlush
Flush accumulated bytes to the given output file. Flush accumulated bytes to the given output file.- Specified by:
outputFileFlushin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.ffd- Frontend file descriptor.- Throws:
IOException- Thrown if an I/O error occurred.
-
outputFileClose
Close the given output file. Close the given output file.- Specified by:
outputFileClosein interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.ffd- Frontend file descriptor.- Throws:
IOException- Thrown if an I/O error occurred.
-
inputFileOpen
Open the given input file for reading. Open the given input file for reading.- Specified by:
inputFileOpenin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.bfd- Backend file descriptor.file- File.- Throws:
IOException- Thrown if an I/O error occurred.
-
inputFileRead
Read bytes from the given input file.ffd= 1 refers to the job's standard input stream; other values refer to a previously opened file. Read bytes from the given input file.ffd= 1 refers to the job's standard input stream; other values refer to a previously opened file.- Specified by:
inputFileReadin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.ffd- Frontend file descriptor.len- Number of bytes to read.- Throws:
IOException- Thrown if an I/O error occurred.
-
inputFileSkip
Skip bytes from the given input file. Skip bytes from the given input file.- Specified by:
inputFileSkipin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.ffd- Frontend file descriptor.len- Number of bytes to skip.- Throws:
IOException- Thrown if an I/O error occurred.
-
inputFileClose
Close the given input file. Close the given input file.- Specified by:
inputFileClosein interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.ffd- Frontend file descriptor.- Throws:
IOException- Thrown if an I/O error occurred.
-
reportComment
Report a comment for a process. Report a comment for a process.- Specified by:
reportCommentin interfaceJobFrontendRef- Parameters:
theJobBackend- Job backend that is calling this method.rank- Process rank.comment- Comment string.- Throws:
IOException- Thrown if an I/O error occurred.
-
close
public void close()Close communication with this Job Frontend.- Specified by:
closein interfaceJobFrontendRef
-