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.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
Fields inherited from interface org.apache.hadoop.registry.server.services.MicroZookeeperServiceKeys
DEFAULT_ZKSERVICE_HOST, KEY_REGISTRY_ZKSERVICE_JAAS_CONTEXT, KEY_ZKSERVICE_ALLOW_FAILED_SASL_CLIENTS, KEY_ZKSERVICE_DIR, KEY_ZKSERVICE_HOST, KEY_ZKSERVICE_PORT, KEY_ZKSERVICE_TICK_TIME, ZKSERVICE_PREFIXFields inherited from interface org.apache.hadoop.registry.client.api.RegistryConstants
DEFAULT_DNS_ENABLED, DEFAULT_DNS_PORT, DEFAULT_DNS_SPLIT_REVERSE_ZONE, DEFAULT_DNSSEC_PRIVATE_KEY_FILE, DEFAULT_REGISTRY_CLIENT_JAAS_CONTEXT, DEFAULT_REGISTRY_SECURE, DEFAULT_REGISTRY_SYSTEM_ACCOUNTS, DEFAULT_REGISTRY_USER_ACCOUNTS, DEFAULT_REGISTRY_ZK_QUORUM, DEFAULT_ZK_CONNECTION_TIMEOUT, DEFAULT_ZK_REGISTRY_ROOT, DEFAULT_ZK_RETRY_CEILING, DEFAULT_ZK_RETRY_INTERVAL, DEFAULT_ZK_RETRY_TIMES, DEFAULT_ZK_SESSION_TIMEOUT, DNS_PREFIX, KEY_DNS_BIND_ADDRESS, KEY_DNS_DOMAIN, KEY_DNS_ENABLED, KEY_DNS_PORT, KEY_DNS_SPLIT_REVERSE_ZONE, KEY_DNS_SPLIT_REVERSE_ZONE_RANGE, KEY_DNS_TTL, KEY_DNS_ZONE_IP_MAX, KEY_DNS_ZONE_IP_MIN, KEY_DNS_ZONE_MASK, KEY_DNS_ZONE_SUBNET, KEY_DNS_ZONES_DIR, KEY_DNSSEC_ENABLED, KEY_DNSSEC_PRIVATE_KEY_FILE, KEY_DNSSEC_PUBLIC_KEY, KEY_REGISTRY_CLIENT_AUTH, KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, KEY_REGISTRY_CLIENT_JAAS_CONTEXT, KEY_REGISTRY_KERBEROS_REALM, KEY_REGISTRY_SECURE, KEY_REGISTRY_SYSTEM_ACCOUNTS, KEY_REGISTRY_USER_ACCOUNTS, KEY_REGISTRY_ZK_CONNECTION_TIMEOUT, KEY_REGISTRY_ZK_QUORUM, KEY_REGISTRY_ZK_RETRY_CEILING, KEY_REGISTRY_ZK_RETRY_INTERVAL, KEY_REGISTRY_ZK_RETRY_TIMES, KEY_REGISTRY_ZK_ROOT, KEY_REGISTRY_ZK_SESSION_TIMEOUT, MAX_FQDN_LABEL_LENGTH, PATH_SYSTEM_SERVICES, PATH_USER_SERVICES, PATH_USERS, REGISTRY_CLIENT_AUTH_ANONYMOUS, REGISTRY_CLIENT_AUTH_DIGEST, REGISTRY_CLIENT_AUTH_KERBEROS, REGISTRY_CLIENT_AUTH_SIMPLE, REGISTRY_PREFIX, SUBPATH_COMPONENTS, ZK_PREFIXFields inherited from interface org.apache.hadoop.registry.client.impl.zk.ZookeeperConfigOptions
DEFAULT_ZK_ENABLE_SASL_CLIENT, PROP_ZK_ALLOW_FAILED_SASL_CLIENTS, PROP_ZK_ENABLE_SASL_CLIENT, PROP_ZK_KINIT_PATH, PROP_ZK_SASL_CLIENT_CONTEXT, PROP_ZK_SASL_CLIENT_USERNAME, PROP_ZK_SERVER_MAINTAIN_CONNECTION_DESPITE_SASL_FAILURE, PROP_ZK_SERVER_REALM, PROP_ZK_SERVER_SASL_CONTEXT, SCHEME_DIGEST, SCHEME_SASL -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDiagnostics(String text, Object... args) Append a formatted string to the diagnostics.Get the connection addressGet the connection string.Get the diagnostics infoprotected voidserviceInit(org.apache.hadoop.conf.Configuration conf) Initialize the service, including choosing a path for the dataprotected voidStartup: start ZK.protected voidWhen the service is stopped, it deletes the data directory and its contentsbooleanset up security. this must be done prior to creating the ZK instance, as it sets up JAAS if that has not been done already.Supply the binding information for this registryMethods inherited from class org.apache.hadoop.service.AbstractService
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, toString, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
-
Constructor Details
-
MicroZookeeperService
Create an instance- Parameters:
name- service name
-
-
Method Details
-
getConnectionString
Get the connection string.- Returns:
- the string
- Throws:
IllegalStateException- if the connection is not yet valid
-
getConnectionAddress
Get the connection address- Returns:
- the connection as an address
- Throws:
IllegalStateException- if the connection is not yet valid
-
serviceInit
Initialize the service, including choosing a path for the data- Overrides:
serviceInitin classorg.apache.hadoop.service.AbstractService- Parameters:
conf- configuration- Throws:
Exception
-
addDiagnostics
Append a formatted string to the diagnostics.A newline is appended afterwards.
- Parameters:
text- text including any format commandsargs- arguments for the forma operation.
-
getDiagnostics
Get the diagnostics info- Returns:
- the diagnostics string built up
-
setupSecurity
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
Startup: start ZK. It is only after this that the binding information is valid.- Overrides:
serviceStartin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
serviceStop
When the service is stopped, it deletes the data directory and its contents- Overrides:
serviceStopin classorg.apache.hadoop.service.AbstractService- Throws:
Exception
-
supplyBindingInformation
Description copied from interface:RegistryBindingSourceSupply the binding information for this registry- Specified by:
supplyBindingInformationin interfaceRegistryBindingSource- Returns:
- the binding information data
-