Class MicroZookeeperService

java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.registry.server.services.MicroZookeeperService
All Implemented Interfaces:
Closeable, AutoCloseable, RegistryConstants, RegistryBindingSource, ZookeeperConfigOptions, MicroZookeeperServiceKeys, org.apache.hadoop.service.Service

@Evolving public class MicroZookeeperService extends org.apache.hadoop.service.AbstractService implements RegistryBindingSource, RegistryConstants, ZookeeperConfigOptions, MicroZookeeperServiceKeys
This is a small, localhost Zookeeper service instance that is contained in a YARN service...it's been derived from Apache Twill.

It implements RegistryBindingSource and provides binding information, once started. Until AbstractService.start() is called, the hostname and port may be undefined. Accordingly, the service raises an exception in this condition.

If you wish to chain together a registry service with this one under the same CompositeService, this service must be added as a child first.

It also sets the configuration parameter RegistryConstants.KEY_REGISTRY_ZK_QUORUM to its connection string. Any code with access to the service configuration can view it.

  • Constructor Details

    • MicroZookeeperService

      public MicroZookeeperService(String name)
      Create an instance
      Parameters:
      name - service name
  • Method Details

    • getConnectionString

      public String getConnectionString()
      Get the connection string.
      Returns:
      the string
      Throws:
      IllegalStateException - if the connection is not yet valid
    • getConnectionAddress

      public InetSocketAddress getConnectionAddress()
      Get the connection address
      Returns:
      the connection as an address
      Throws:
      IllegalStateException - if the connection is not yet valid
    • serviceInit

      protected void serviceInit(org.apache.hadoop.conf.Configuration conf) throws Exception
      Initialize the service, including choosing a path for the data
      Overrides:
      serviceInit in class org.apache.hadoop.service.AbstractService
      Parameters:
      conf - configuration
      Throws:
      Exception
    • addDiagnostics

      protected void addDiagnostics(String text, Object... args)
      Append a formatted string to the diagnostics.

      A newline is appended afterwards.

      Parameters:
      text - text including any format commands
      args - arguments for the forma operation.
    • getDiagnostics

      public String getDiagnostics()
      Get the diagnostics info
      Returns:
      the diagnostics string built up
    • setupSecurity

      public boolean setupSecurity() throws IOException
      set up security. this must be done prior to creating the ZK instance, as it sets up JAAS if that has not been done already.
      Returns:
      true if the cluster has security enabled.
      Throws:
      IOException
    • serviceStart

      protected void serviceStart() throws Exception
      Startup: start ZK. It is only after this that the binding information is valid.
      Overrides:
      serviceStart in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • serviceStop

      protected void serviceStop() throws Exception
      When the service is stopped, it deletes the data directory and its contents
      Overrides:
      serviceStop in class org.apache.hadoop.service.AbstractService
      Throws:
      Exception
    • supplyBindingInformation

      public BindingInformation supplyBindingInformation()
      Description copied from interface: RegistryBindingSource
      Supply the binding information for this registry
      Specified by:
      supplyBindingInformation in interface RegistryBindingSource
      Returns:
      the binding information data