edu.rit.pj.cluster.test
Class JobFrontendStub
- java.lang.Object
-
- java.lang.Thread
-
- edu.rit.pj.cluster.test.JobFrontendStub
-
- All Implemented Interfaces:
- JobFrontendRef, java.lang.Runnable
public class JobFrontendStub extends java.lang.Thread implements JobFrontendRef
Class JobFrontendStub provides a stub for the PJ job frontend process. It receives job frontend messages from a channel and prints each message on the console.
-
-
Constructor Summary
Constructors Constructor and Description JobFrontendStub(ChannelGroup theChannelGroup)Construct a new job frontend stub.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description voidassignBackend(JobSchedulerRef theJobScheduler, java.lang.String name, java.lang.String host, java.lang.String jvm, java.lang.String classpath, java.lang.String[] jvmflags, int Nt)Assign a backend process to the job.voidassignJobNumber(JobSchedulerRef theJobScheduler, int jobnum, java.lang.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, java.net.InetSocketAddress middlewareAddress, java.net.InetSocketAddress worldAddress, java.net.InetSocketAddress frontendAddress)Report that a backend process is ready to commence executing the job.voidcancelJob(JobBackendRef theJobBackend, java.lang.String errmsg)Cancel the job.voidcancelJob(JobSchedulerRef theJobScheduler, java.lang.String errmsg)Cancel the job.voidclose()Close communication with this Job Frontend.voidinputFileClose(JobBackendRef theJobBackend, int ffd)Close the given input file.voidinputFileOpen(JobBackendRef theJobBackend, int bfd, java.io.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, java.io.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.voidrequestResource(JobBackendRef theJobBackend, java.lang.String resourceName)Request the given resource from this job frontend's class loader.voidrun()Run this job frontend stub.-
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
-
-
-
-
Constructor Detail
-
JobFrontendStub
public JobFrontendStub(ChannelGroup theChannelGroup)
Construct a new job frontend stub. The stub will receive messages from the given channel group.- Parameters:
theChannelGroup- Channel group.
-
-
Method Detail
-
run
public void run()
Run this job frontend stub.- Specified by:
runin interfacejava.lang.Runnable- Overrides:
runin classjava.lang.Thread
-
assignBackend
public void assignBackend(JobSchedulerRef theJobScheduler, java.lang.String name, java.lang.String host, java.lang.String jvm, java.lang.String classpath, java.lang.String[] jvmflags, int Nt)
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.Nt- Number of CPUs assigned to the process.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
assignJobNumber
public void assignJobNumber(JobSchedulerRef theJobScheduler, int jobnum, java.lang.String pjhost)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
cancelJob
public void cancelJob(JobSchedulerRef theJobScheduler, java.lang.String errmsg)
Cancel the job.- Specified by:
cancelJobin interfaceJobFrontendRef- Parameters:
theJobScheduler- Job Scheduler that is calling this method.errmsg- Error message string.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
renewLease
public void renewLease(JobSchedulerRef theJobScheduler)
Renew the lease on the job.- Specified by:
renewLeasein interfaceJobFrontendRef- Parameters:
theJobScheduler- Job Scheduler that is calling this method.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
backendFinished
public void backendFinished(JobBackendRef theJobBackend)
Report that a backend process has finished executing the job.- Specified by:
backendFinishedin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
backendReady
public void backendReady(JobBackendRef theJobBackend, int rank, java.net.InetSocketAddress middlewareAddress, java.net.InetSocketAddress worldAddress, java.net.InetSocketAddress frontendAddress)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
cancelJob
public void cancelJob(JobBackendRef theJobBackend, java.lang.String errmsg)
Cancel the job.- Specified by:
cancelJobin interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.errmsg- Error message string.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
renewLease
public void renewLease(JobBackendRef theJobBackend)
Renew the lease on the job.- Specified by:
renewLeasein interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
requestResource
public void requestResource(JobBackendRef theJobBackend, java.lang.String resourceName)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
outputFileOpen
public void outputFileOpen(JobBackendRef theJobBackend, int bfd, java.io.File file, boolean append)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
outputFileWrite
public void outputFileWrite(JobBackendRef theJobBackend, int ffd, byte[] buf, int off, int len)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
outputFileFlush
public void outputFileFlush(JobBackendRef theJobBackend, int ffd)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
outputFileClose
public void outputFileClose(JobBackendRef theJobBackend, int ffd)
Close the given output file.- Specified by:
outputFileClosein interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.ffd- Frontend file descriptor.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
inputFileOpen
public void inputFileOpen(JobBackendRef theJobBackend, int bfd, java.io.File file)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
inputFileRead
public void inputFileRead(JobBackendRef theJobBackend, int ffd, int len)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
inputFileSkip
public void inputFileSkip(JobBackendRef theJobBackend, int ffd, long len)
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:
java.io.IOException- Thrown if an I/O error occurred.
-
inputFileClose
public void inputFileClose(JobBackendRef theJobBackend, int ffd)
Close the given input file.- Specified by:
inputFileClosein interfaceJobFrontendRef- Parameters:
theJobBackend- Job Backend that is calling this method.ffd- Frontend file descriptor.- Throws:
java.io.IOException- Thrown if an I/O error occurred.
-
close
public void close()
Close communication with this Job Frontend.- Specified by:
closein interfaceJobFrontendRef
-
-
DMelt 3.0 © DataMelt by jWork.ORG