com.bigdata.jini.start.config
Class ZookeeperServerConfiguration

java.lang.Object
  extended by com.bigdata.jini.start.config.ServiceConfiguration
      extended by com.bigdata.jini.start.config.JavaServiceConfiguration
          extended by com.bigdata.jini.start.config.ZookeeperServerConfiguration
All Implemented Interfaces:
Serializable

public class ZookeeperServerConfiguration
extends JavaServiceConfiguration

zookeeper server configuration.

Version:
$Id$
Author:
Bryan Thompson
See Also:
Serialized Form

Nested Class Summary
static interface ZookeeperServerConfiguration.Options
          Zookeeper server configuration options.
static class ZookeeperServerConfiguration.ZookeeperRunningException
          Exception throw if there is already a zookeeper server instance running on the localhost.
 class ZookeeperServerConfiguration.ZookeeperServiceStarter<V extends ZookeeperProcessHelper>
           
 
Nested classes/interfaces inherited from class com.bigdata.jini.start.config.JavaServiceConfiguration
JavaServiceConfiguration.JavaServiceStarter<V extends ProcessHelper>
 
Nested classes/interfaces inherited from class com.bigdata.jini.start.config.ServiceConfiguration
ServiceConfiguration.AbstractServiceStarter<V extends ProcessHelper>
 
Field Summary
 int clientPort
          The zookeeper client port.
 String configFile
          The basename of the generated zookeeper configuration file.
 File dataDir
          The data directory as specified by ZookeeperServerConfiguration.Options.DATA_DIR.
 File dataLogDir
          The data log directory as specified by ZookeeperServerConfiguration.Options.DATA_LOG_DIR.
 Map<String,String> other
          Zookeeper properties that we don't need to know about explictly (just passed through).
 String servers
           
 
Fields inherited from class com.bigdata.jini.start.config.JavaServiceConfiguration
classpath, defaultJavaArgs, javaHome, log4j
 
Fields inherited from class com.bigdata.jini.start.config.ServiceConfiguration
args, className, constraints, log, options, replicationCount, serviceCount, serviceDir, timeout
 
Constructor Summary
ZookeeperServerConfiguration(net.jini.config.Configuration config)
           
 
Method Summary
protected  long getDefaultTimeout()
          The default used for ServiceConfiguration.Options.TIMEOUT (4000 milliseconds).
 ZookeeperServerEntry[] getZookeeperServerEntries()
          Parses out the zookeeper server descriptions.
static ZookeeperServerEntry[] getZookeeperServerEntries(String servers)
          Parses out the zookeeper server descriptions.
 JavaServiceConfiguration.JavaServiceStarter newServiceStarter(IServiceListener listener)
          Not supported.
 ZookeeperServerConfiguration.ZookeeperServiceStarter newServiceStarter(IServiceListener listener, ZookeeperServerEntry entry)
          (Re-)starts the zookeeper server instance identified in the ZookeeperServerEntry unless it is already running using the properties defined in the Configuration.
 
Methods inherited from class com.bigdata.jini.start.config.JavaServiceConfiguration
getClassName, getClasspath, getDefaultJavaArgs, getJavaHome, getLog4j, toString
 
Methods inherited from class com.bigdata.jini.start.config.ServiceConfiguration
canStartService, canStartService, concat, getArgs, getClassPath, getConstraints, getOptions, getReplicationCount, getServiceCount, getServiceDir, getStringArray, getTimeout, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

servers

public final String servers

clientPort

public final int clientPort
The zookeeper client port.


dataDir

public final File dataDir
The data directory as specified by ZookeeperServerConfiguration.Options.DATA_DIR.


dataLogDir

public final File dataLogDir
The data log directory as specified by ZookeeperServerConfiguration.Options.DATA_LOG_DIR.


configFile

public final String configFile
The basename of the generated zookeeper configuration file.

See Also:
ZookeeperServerConfiguration.Options.CONFIG_FILE

other

public final Map<String,String> other
Zookeeper properties that we don't need to know about explictly (just passed through).

Constructor Detail

ZookeeperServerConfiguration

public ZookeeperServerConfiguration(net.jini.config.Configuration config)
                             throws net.jini.config.ConfigurationException
Parameters:
className -
config -
Throws:
net.jini.config.ConfigurationException
Method Detail

getDefaultTimeout

protected long getDefaultTimeout()
The default used for ServiceConfiguration.Options.TIMEOUT (4000 milliseconds).

Overrides:
getDefaultTimeout in class ServiceConfiguration
Returns:
The default timeout in milliseconds.

getZookeeperServerEntries

public ZookeeperServerEntry[] getZookeeperServerEntries()
                                                 throws net.jini.config.ConfigurationException
Parses out the zookeeper server descriptions.

Returns:
An array of zero or more descriptions of zookeeper instances.
Throws:
net.jini.config.ConfigurationException
TODO:
check for duplicate server ids.

getZookeeperServerEntries

public static ZookeeperServerEntry[] getZookeeperServerEntries(String servers)
                                                        throws net.jini.config.ConfigurationException
Parses out the zookeeper server descriptions.

Parameters:
The - servers per ZookeeperServerConfiguration.Options.SERVERS
Returns:
An array of zero or more descriptions of zookeeper instances.
Throws:
net.jini.config.ConfigurationException
TODO:
check for duplicate server ids.

newServiceStarter

public ZookeeperServerConfiguration.ZookeeperServiceStarter newServiceStarter(IServiceListener listener,
                                                                              ZookeeperServerEntry entry)
(Re-)starts the zookeeper server instance identified in the ZookeeperServerEntry unless it is already running using the properties defined in the Configuration.

The difference between a "start" and a "restart" is whether the zookeeper "myid" file exists in the data directory for the service. If it does, then we "restart" zookeeper using the existing configuration. If it does not, then we generate the zookeeper configuration file and the myid file and then start zookeeper. Of course, how a server restart for zookeeper fairs depends on whether you took down the service or if it crashed, etc.

Parameters:
listener -
entry - Identifies the specific server instance to start.
Returns:
TODO:
You CAN NOT start multiple instances using this class.

A tighter zookeeper integration could probably fix this issue. In order to tell whether or not zookeeper is already running we test "ruok" for the client port (it we don't test then we might see a BindException in the process output, but we don't get an error when we execute the JVM to run zookeeper). Since all instances use the same ZookeeperServerConfiguration.Options.CLIENT_PORT, all we know is whether or not there are any instances running which were configured for that client port, but not how many and not which ones.

Also see ZookeeperProcessHelper.kill(boolean), which has difficulties knowing which instance should be killed - it will kill which one is currently answering at the clientPost on the localhost!


newServiceStarter

public JavaServiceConfiguration.JavaServiceStarter newServiceStarter(IServiceListener listener)
Not supported.

Overrides:
newServiceStarter in class JavaServiceConfiguration
See Also:
newServiceStarter(IServiceListener, ZookeeperServerEntry)


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