|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jppf.utils.ThreadSynchronization
org.jppf.process.ProcessLauncher
public class ProcessLauncher
This class is intended as a controller for a subprocess, to enable stopping and restarting it when requested.
It performs the following operations:
| Field Summary |
|---|
| Fields inherited from class org.jppf.utils.ThreadSynchronization |
|---|
stopped |
| Constructor Summary | |
|---|---|
ProcessLauncher(String mainClass)
Initialize this process launcher. |
|
| Method Summary | |
|---|---|
Process |
buildProcess()
Start the JPPF driver subprocess. |
protected void |
createShutdownHook()
Create a shutdown hook that is run when this JVM terminates. |
void |
errorStreamAltered(ProcessWrapperEvent event)
Notification that the process has written to its error stream. |
String |
getOutput(Process process,
String streamType)
Get the output of the driver process. |
void |
idleStateChanged(IdleStateEvent event)
Called when the idle state of the system has changed. |
void |
outputStreamAltered(ProcessWrapperEvent event)
Notification that the process has written to its output stream. |
void |
run()
Start the socket listener and the subprocess. |
protected int |
startDriverSocket()
Start a server socket that will accept one connection at a time with the JPPF driver, so the server can shtutdown properly, when this driver is killed, by a way other than the API (ie CTRL-C or killing the process through the OS shell). |
void |
startProcess()
Start the sub-process. |
| Methods inherited from class org.jppf.utils.ThreadSynchronization |
|---|
goToSleep, goToSleep, goToSleep, isStopped, setStopped, wakeUp |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ProcessLauncher(String mainClass)
mainClass - the fully qualified name of the main class of the sub process to launch.| Method Detail |
|---|
public void run()
run in interface Runnable
public void startProcess()
throws Exception
Exception - if any error occurs.
public Process buildProcess()
throws Exception
Process object representing the JPPF driver suprocess.
Exception - if the process failed to start.protected void createShutdownHook()
protected int startDriverSocket()
new ServerSocket(0).ServerSocket.accept() and the
Socket.getInputStream().read() in the same thread.
public String getOutput(Process process,
String streamType)
process - the process to get the standard or error output from.streamType - detrmines whether to obtain the standard or error output.
public void errorStreamAltered(ProcessWrapperEvent event)
errorStreamAltered in interface ProcessWrapperEventListenerevent - encapsulate the error stream's content.ProcessWrapperEventListener.errorStreamAltered(org.jppf.process.event.ProcessWrapperEvent)public void outputStreamAltered(ProcessWrapperEvent event)
outputStreamAltered in interface ProcessWrapperEventListenerevent - encapsulate the output stream's content.ProcessWrapperEventListener.outputStreamAltered(org.jppf.process.event.ProcessWrapperEvent)public void idleStateChanged(IdleStateEvent event)
idleStateChanged in interface IdleStateListenerevent - the event encapsulating the state change.
|
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||