com.bigdata.jini.start.config
Class ZookeeperServerConfiguration.ZookeeperServiceStarter<V extends ZookeeperProcessHelper>

java.lang.Object
  extended by com.bigdata.jini.start.config.ServiceConfiguration.AbstractServiceStarter<V>
      extended by com.bigdata.jini.start.config.JavaServiceConfiguration.JavaServiceStarter<V>
          extended by com.bigdata.jini.start.config.ZookeeperServerConfiguration.ZookeeperServiceStarter<V>
All Implemented Interfaces:
Callable<V>
Enclosing class:
ZookeeperServerConfiguration

public class ZookeeperServerConfiguration.ZookeeperServiceStarter<V extends ZookeeperProcessHelper>
extends JavaServiceConfiguration.JavaServiceStarter<V>

Version:
$Id$
Author:
Bryan Thompson

Field Summary
protected  ZookeeperServerEntry entry
          Identifies the specific server instance to start.
 
Fields inherited from class com.bigdata.jini.start.config.JavaServiceConfiguration.JavaServiceStarter
cls
 
Fields inherited from class com.bigdata.jini.start.config.ServiceConfiguration.AbstractServiceStarter
listener
 
Constructor Summary
protected ZookeeperServerConfiguration.ZookeeperServiceStarter(IServiceListener listener, ZookeeperServerEntry entry)
           
 
Method Summary
protected  void addCommandArgs(List<String> cmds)
          Extended to add the configuration file on the command line after the class name.
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  File getServiceDir()
          Returns the actual service directory, which is dataDir.
protected  V newProcessHelper(String className, ProcessBuilder processBuilder, IServiceListener listener)
          Return the ProcessHelper that will be used to manage the process.
protected  void writeZookeeperConfigFile()
          Writes the zookeeper configuration file.
 
Methods inherited from class com.bigdata.jini.start.config.JavaServiceConfiguration.JavaServiceStarter
addCommand, setUp, setUpEnvironment
 
Methods inherited from class com.bigdata.jini.start.config.ServiceConfiguration.AbstractServiceStarter
addServiceOptions, getCommandLine, newProcessBuilder, newProcessBuilder, writeStartFile
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entry

protected final ZookeeperServerEntry entry
Identifies the specific server instance to start.

Constructor Detail

ZookeeperServerConfiguration.ZookeeperServiceStarter

protected ZookeeperServerConfiguration.ZookeeperServiceStarter(IServiceListener listener,
                                                               ZookeeperServerEntry entry)
Parameters:
entry - Identifies the specific server instance to start.
listener -
Method Detail

getServiceDir

protected File getServiceDir()
Returns the actual service directory, which is dataDir.

Overrides:
getServiceDir in class ServiceConfiguration.AbstractServiceStarter<V extends ZookeeperProcessHelper>
See Also:
ServiceConfiguration.serviceDir, ServiceConfiguration.getServiceDir(String, Configuration)

call

public V call()
                                      throws Exception
Description copied from class: ServiceConfiguration.AbstractServiceStarter
Start a new instance of the service.

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.

Specified by:
call in interface Callable<V extends ZookeeperProcessHelper>
Overrides:
call in class ServiceConfiguration.AbstractServiceStarter<V extends ZookeeperProcessHelper>
Throws:
ZookeeperServerConfiguration.ZookeeperRunningException - if zookeeper answers at the client port or otherwise appears to be running.
Exception - if the service detectably did not start.

addCommandArgs

protected void addCommandArgs(List<String> cmds)
Extended to add the configuration file on the command line after the class name.

Overrides:
addCommandArgs in class JavaServiceConfiguration.JavaServiceStarter<V extends ZookeeperProcessHelper>

newProcessHelper

protected V newProcessHelper(String className,
                             ProcessBuilder processBuilder,
                             IServiceListener listener)
                                                     throws IOException
Description copied from class: ServiceConfiguration.AbstractServiceStarter
Return the ProcessHelper that will be used to manage the process.

Overrides:
newProcessHelper in class ServiceConfiguration.AbstractServiceStarter<V extends ZookeeperProcessHelper>
Returns:
Throws:
IOException

awaitServiceStart

protected void awaitServiceStart(V processHelper,
                                 long timeout,
                                 TimeUnit unit)
                          throws Exception
Description copied from class: ServiceConfiguration.AbstractServiceStarter
Waits a bit to see if the process returns an exit code. If an exit is NOT available after a timeout, then assumes that the process started successfully.

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.

Overrides:
awaitServiceStart in class ServiceConfiguration.AbstractServiceStarter<V extends ZookeeperProcessHelper>
Throws:
Exception - If a service start failure could be detected (the caller will kill the process and log an error if any exception is thrown).

writeZookeeperConfigFile

protected final void writeZookeeperConfigFile()
                                       throws net.jini.config.ConfigurationException,
                                              IOException
Writes the zookeeper configuration file.

Throws:
net.jini.config.ConfigurationException
IOException


Copyright © 2006-2011 SYSTAP, LLC. All Rights Reserved.