|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.bigdata.jini.start.config.ServiceConfiguration.AbstractServiceStarter<V>
V - public abstract class ServiceConfiguration.AbstractServiceStarter<V extends ProcessHelper>
A task that will (re-)start an instance of a service described by its
ServiceConfiguration.
| Field Summary | |
|---|---|
protected IServiceListener |
listener
|
| Constructor Summary | |
|---|---|
protected |
ServiceConfiguration.AbstractServiceStarter(IServiceListener listener)
|
| Method Summary | |
|---|---|
protected abstract void |
addCommand(List<String> cmds)
Add the command to be executed (eg, "java", etc). |
protected void |
addCommandArgs(List<String> cmds)
Adds command arguments immediately following the executable name. |
protected void |
addServiceOptions(List<String> cmds)
Add options at the end of the command line. |
protected void |
awaitServiceStart(V processHelper,
long timeout,
TimeUnit unit)
Waits a bit to see if the process returns an exit code. |
V |
call()
Start a new instance of the service. |
protected List<String> |
getCommandLine()
Generate the command line that will be used to start the service. |
protected File |
getServiceDir()
Hook for overriding the service directory. |
ProcessBuilder |
newProcessBuilder()
Return the fully prepared ProcessBuilder that will be used to
execute the command. |
protected ProcessBuilder |
newProcessBuilder(List<String> cmds)
Create (and possibly configure) a ProcessBuilder that will be
used to start the service. |
protected V |
newProcessHelper(String className,
ProcessBuilder processBuilder,
IServiceListener listener)
Return the ProcessHelper that will be used to manage the
process. |
protected void |
setUp()
Hook for extending the pre-start setup for the service. |
protected void |
setUpEnvironment(Map<String,String> env)
Hook for modification of the child environment. |
protected void |
writeStartFile(ProcessBuilder processBuilder)
Write a file named start in the serviceDir
whose contents are the command line which may be used to start the
service. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected final IServiceListener listener
| Constructor Detail |
|---|
protected ServiceConfiguration.AbstractServiceStarter(IServiceListener listener)
listener - | Method Detail |
|---|
public V call()
throws Exception
Note: Output of the child process will be copied onto the output of the parent process. That is where to look for any output that is written onto stdout or stderr. Normally you will want the services to write their logs on a file, syslogd, or an async appender.
call in interface Callable<V extends ProcessHelper>Exception - if the service detectably did not start.
protected void setUp()
throws Exception
Exceptionprotected File getServiceDir()
ServiceConfiguration.serviceDir. It SHOULD be overriden to
return the actual directory in which the specific service instance
will be started.
ServiceConfiguration.serviceDir,
ServiceConfiguration.getServiceDir(String, Configuration)
protected V newProcessHelper(String className,
ProcessBuilder processBuilder,
IServiceListener listener)
throws IOException
ProcessHelper that will be used to manage the
process.
className - processBuilder - listener -
IOExceptionpublic ProcessBuilder newProcessBuilder()
ProcessBuilder that will be used to
execute the command. You may obtain the environment and command line
to be used from this object.
protected void setUpEnvironment(Map<String,String> env)
env - A map. Modifications to the map will be written into the
child environment.ProcessBuilder.environment()protected List<String> getCommandLine()
protected ProcessBuilder newProcessBuilder(List<String> cmds)
ProcessBuilder that will be
used to start the service.
cmds -
protected abstract void addCommand(List<String> cmds)
cmds - protected void addCommandArgs(List<String> cmds)
cmds - protected void addServiceOptions(List<String> cmds)
cmds -
protected void awaitServiceStart(V processHelper,
long timeout,
TimeUnit unit)
throws Exception
Note: This DOES NOT provide direct confirmation that the service is running in a non-error and available for answering requests. You SHOULD override this method if you have a service specific means of obtaining such confirmation.
Exception - If a service start failure could be detected (the caller
will kill the process and log an error if any exception
is thrown).
protected void writeStartFile(ProcessBuilder processBuilder)
throws IOException
start in the serviceDir
whose contents are the command line which may be used to start the
service. This file is not normally used to start the service, but it
may be used as a debugging aid permitting service start from the
command line.
processBuilder - The configured process builder.
IOException
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||