edu.rit.pj.cluster
Class JobFrontend

java.lang.Object
  extended by edu.rit.pj.cluster.JobFrontend
All Implemented Interfaces:
JobFrontendRef, Runnable

public class JobFrontend
extends Object
implements Runnable, JobFrontendRef

Class JobFrontend provides the message handler for the PJ job frontend process.


Constructor Summary
JobFrontend(String username, int Nn, int Np, int Nt, boolean hasFrontendComm, String mainClassName, String[] args)
          Construct a new job frontend object.
 
Method Summary
 void assignBackend(JobSchedulerRef theJobScheduler, String name, String host, String jvm, String classpath, String[] jvmflags, String shellCommand, int Nt)
          Assign a backend process to the job.
 void assignJobNumber(JobSchedulerRef theJobScheduler, int jobnum, String pjhost)
          Assign a job number to the job.
 void backendFinished(JobBackendRef theJobBackend)
          Report that a backend process has finished executing the job.
 void backendReady(JobBackendRef theJobBackend, int rank, InetSocketAddress middlewareAddress, InetSocketAddress worldAddress, InetSocketAddress frontendAddress)
          Report that a backend process is ready to commence executing the job.
 void cancelJob(JobBackendRef theJobBackend, String errmsg)
          Cancel the job.
 void cancelJob(JobSchedulerRef theJobScheduler, String errmsg)
          Cancel the job.
 void close()
          Close communication with this Job Frontend.
 void inputFileClose(JobBackendRef theJobBackend, int ffd)
          Close the given input file.
 void inputFileOpen(JobBackendRef theJobBackend, int bfd, File file)
          Open the given input file for reading.
 void inputFileRead(JobBackendRef theJobBackend, int ffd, int len)
          Read bytes from the given input file.
 void inputFileSkip(JobBackendRef theJobBackend, int ffd, long len)
          Skip bytes from the given input file.
 void outputFileClose(JobBackendRef theJobBackend, int ffd)
          Close the given output file.
 void outputFileFlush(JobBackendRef theJobBackend, int ffd)
          Flush accumulated bytes to the given output file.
 void outputFileOpen(JobBackendRef theJobBackend, int bfd, File file, boolean append)
          Open the given output file for writing or appending.
 void outputFileWrite(JobBackendRef theJobBackend, int ffd, byte[] buf, int off, int len)
          Write the given bytes to the given output file.
 void renewLease(JobBackendRef theJobBackend)
          Renew the lease on the job.
 void renewLease(JobSchedulerRef theJobScheduler)
          Renew the lease on the job.
 void reportComment(JobBackendRef theJobBackend, int rank, String comment)
          Report a comment for a process.
 void requestResource(JobBackendRef theJobBackend, String resourceName)
          Request the given resource from this job frontend's class loader.
 void run()
          Run this Job Frontend.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JobFrontend

public JobFrontend(String username,
                   int Nn,
                   int Np,
                   int Nt,
                   boolean hasFrontendComm,
                   String mainClassName,
                   String[] args)
            throws IOException
Construct a new 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.

Parameters:
username - User name.
Nn - Number of backend nodes (>= 1).
Np - Number of processes (>= 1).
Nt - Number of CPUs per process (>= 0). 0 means "all CPUs."
hasFrontendComm - True if the job has the frontend communicator, false if it doesn't.
mainClassName - Main class name.
args - Command line arguments.
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.
Method Detail

run

public void run()
Run this Job Frontend.

Specified by:
run in interface Runnable

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.

Specified by:
assignBackend in interface JobFrontendRef
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.

Specified by:
assignJobNumber in interface JobFrontendRef
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

public void cancelJob(JobSchedulerRef theJobScheduler,
                      String errmsg)
               throws IOException
Cancel the job.

Specified by:
cancelJob in interface JobFrontendRef
Parameters:
theJobScheduler - Job Scheduler that is calling this method.
errmsg - Error message string.
Throws:
IOException - Thrown if an I/O error occurred.

renewLease

public void renewLease(JobSchedulerRef theJobScheduler)
                throws IOException
Renew the lease on the job.

Specified by:
renewLease in interface JobFrontendRef
Parameters:
theJobScheduler - Job Scheduler that is calling this method.
Throws:
IOException - Thrown if an I/O error occurred.

backendFinished

public void backendFinished(JobBackendRef theJobBackend)
                     throws IOException
Report that a backend process has finished executing the job.

Specified by:
backendFinished in interface JobFrontendRef
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.

Specified by:
backendReady in interface JobFrontendRef
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

public void cancelJob(JobBackendRef theJobBackend,
                      String errmsg)
               throws IOException
Cancel the job.

Specified by:
cancelJob in interface JobFrontendRef
Parameters:
theJobBackend - Job Backend that is calling this method.
errmsg - Error message string.
Throws:
IOException - Thrown if an I/O error occurred.

renewLease

public void renewLease(JobBackendRef theJobBackend)
                throws IOException
Renew the lease on the job.

Specified by:
renewLease in interface JobFrontendRef
Parameters:
theJobBackend - Job Backend that is calling this method.
Throws:
IOException - Thrown if an I/O error occurred.

requestResource

public void requestResource(JobBackendRef theJobBackend,
                            String resourceName)
                     throws IOException
Request the given resource from this job frontend's class loader.

Specified by:
requestResource in interface JobFrontendRef
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.

Specified by:
outputFileOpen in interface JobFrontendRef
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.

Specified by:
outputFileWrite in interface JobFrontendRef
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

public void outputFileFlush(JobBackendRef theJobBackend,
                            int ffd)
                     throws IOException
Flush accumulated bytes to the given output file.

Specified by:
outputFileFlush in interface JobFrontendRef
Parameters:
theJobBackend - Job Backend that is calling this method.
ffd - Frontend file descriptor.
Throws:
IOException - Thrown if an I/O error occurred.

outputFileClose

public void outputFileClose(JobBackendRef theJobBackend,
                            int ffd)
                     throws IOException
Close the given output file.

Specified by:
outputFileClose in interface JobFrontendRef
Parameters:
theJobBackend - Job Backend that is calling this method.
ffd - Frontend file descriptor.
Throws:
IOException - Thrown if an I/O error occurred.

inputFileOpen

public void inputFileOpen(JobBackendRef theJobBackend,
                          int bfd,
                          File file)
                   throws IOException
Open the given input file for reading.

Specified by:
inputFileOpen in interface JobFrontendRef
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

public void inputFileRead(JobBackendRef theJobBackend,
                          int ffd,
                          int len)
                   throws IOException
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:
inputFileRead in interface JobFrontendRef
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

public void inputFileSkip(JobBackendRef theJobBackend,
                          int ffd,
                          long len)
                   throws IOException
Skip bytes from the given input file.

Specified by:
inputFileSkip in interface JobFrontendRef
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

public void inputFileClose(JobBackendRef theJobBackend,
                           int ffd)
                    throws IOException
Close the given input file.

Specified by:
inputFileClose in interface JobFrontendRef
Parameters:
theJobBackend - Job Backend that is calling this method.
ffd - Frontend file descriptor.
Throws:
IOException - Thrown if an I/O error occurred.

reportComment

public void reportComment(JobBackendRef theJobBackend,
                          int rank,
                          String comment)
                   throws IOException
Report a comment for a process.

Specified by:
reportComment in interface JobFrontendRef
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:
close in interface JobFrontendRef


Copyright © 2005-2012 by Alan Kaminsky. All rights reserved. Send comments to ark­@­cs.rit.edu.