java.io.Closeable, java.lang.AutoCloseable, RegistryConstants, RegistryBindingSource, org.apache.hadoop.service.ServiceRegistryOperationsService@Private @Evolving public class CuratorService extends org.apache.hadoop.service.CompositeService implements RegistryConstants, RegistryBindingSource
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_PREFIX| Constructor | Description |
|---|---|
CuratorService(java.lang.String name) |
Create an instance using this service as the binding source (i.e.
|
CuratorService(java.lang.String name,
RegistryBindingSource bindingSource) |
Construct the service.
|
| Modifier and Type | Method | Description |
|---|---|---|
boolean |
addWriteAccessor(java.lang.String id,
java.lang.String pass) |
Add a new write access entry for all future write operations.
|
java.lang.String |
bindingDiagnosticDetails() |
Get the binding diagnostics.
|
protected java.lang.String |
buildConnectionString() |
Override point: get the connection string used to connect to
the ZK service.
|
protected java.lang.String |
buildSecurityDiagnostics() |
Build the security diagnostics string.
|
void |
clearWriteAccessors() |
Clear all write accessors.
|
protected void |
createEnsembleProvider() |
Create the ensemble provider for this registry, by invoking
RegistryBindingSource.supplyBindingInformation() on
the provider stored in bindingSource. |
protected java.lang.String |
createFullPath(java.lang.String path) |
Create a full path from the registry root and the supplied subdir.
|
ZKPathDumper |
dumpPath(boolean verbose) |
Return a path dumper instance which can do a full dump
of the registry tree in its
toString()
operation. |
protected java.lang.String |
dumpRegistryRobustly(boolean verbose) |
Diagnostics method to dump a registry robustly.
|
RegistryBindingSource |
getBindingSource() |
Get the registry binding source ...
|
protected RegistrySecurity |
getRegistrySecurity() |
Get the registry security helper.
|
void |
instantiateCacheForRegistry() |
Instantiate the Curator cache that monitors the registry for node
addition, update and deletion.
|
boolean |
isSecure() |
Flag to indicate whether or not the registry is secure.
|
boolean |
maybeCreate(java.lang.String path,
org.apache.zookeeper.CreateMode mode,
java.util.List<org.apache.zookeeper.data.ACL> acl,
boolean createParents) |
Create a path if it does not exist.
|
protected java.io.IOException |
operationFailure(java.lang.String path,
java.lang.String operation,
java.lang.Exception exception) |
Create an IOE when an operation fails.
|
protected java.io.IOException |
operationFailure(java.lang.String path,
java.lang.String operation,
java.lang.Exception exception,
java.util.List<org.apache.zookeeper.data.ACL> acls) |
Create an IOE when an operation fails.
|
void |
registerPathListener(PathListener listener) |
Registers a listener to path related events.
|
protected void |
serviceInit(org.apache.hadoop.conf.Configuration conf) |
Init the service.
|
protected void |
serviceStart() |
Start the service.
|
protected void |
serviceStop() |
Close the ZK connection if it is open.
|
void |
setKerberosPrincipalAndKeytab(java.lang.String principal,
java.lang.String keytab) |
|
void |
startCache() |
|
BindingInformation |
supplyBindingInformation() |
Supply the binding information.
|
java.lang.String |
toString() |
|
void |
zkCreate(java.lang.String path,
org.apache.zookeeper.CreateMode mode,
byte[] data,
java.util.List<org.apache.zookeeper.data.ACL> acls) |
Create a path with given data.
|
void |
zkDelete(java.lang.String path,
boolean recursive,
org.apache.curator.framework.api.BackgroundCallback backgroundCallback) |
Delete a directory/directory tree.
|
java.util.List<org.apache.zookeeper.data.ACL> |
zkGetACLS(java.lang.String path) |
Get the ACLs of a path.
|
java.util.List<java.lang.String> |
zkList(java.lang.String path) |
List all children of a path.
|
void |
zkMkParentPath(java.lang.String path,
java.util.List<org.apache.zookeeper.data.ACL> acl) |
Recursively make a path.
|
boolean |
zkMkPath(java.lang.String path,
org.apache.zookeeper.CreateMode mode,
boolean createParents,
java.util.List<org.apache.zookeeper.data.ACL> acls) |
Create a directory.
|
boolean |
zkPathExists(java.lang.String path) |
Probe for a path existing.
|
java.lang.String |
zkPathMustExist(java.lang.String path) |
Verify a path exists.
|
byte[] |
zkRead(java.lang.String path) |
Read data on a path.
|
boolean |
zkSet(java.lang.String path,
org.apache.zookeeper.CreateMode mode,
byte[] data,
java.util.List<org.apache.zookeeper.data.ACL> acl,
boolean overwrite) |
Create or update an entry.
|
org.apache.zookeeper.data.Stat |
zkStat(java.lang.String path) |
Stat the file.
|
void |
zkUpdate(java.lang.String path,
byte[] data) |
Update the data for a path.
|
addIfService, addService, getServices, removeServiceclose, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, noteFailure, putBlocker, registerGlobalListener, registerServiceListener, removeBlocker, setConfig, start, stop, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStoppublic CuratorService(java.lang.String name,
RegistryBindingSource bindingSource)
name - service namebindingSource - source of binding information.
If null: use this instancepublic CuratorService(java.lang.String name)
name - service nameprotected void serviceInit(org.apache.hadoop.conf.Configuration conf)
throws java.lang.Exception
serviceInit in class org.apache.hadoop.service.CompositeServiceconf - configuration of the servicejava.lang.Exceptionpublic void setKerberosPrincipalAndKeytab(java.lang.String principal,
java.lang.String keytab)
protected void serviceStart()
throws java.lang.Exception
serviceStart in class org.apache.hadoop.service.CompositeServicejava.lang.Exceptionprotected void serviceStop()
throws java.lang.Exception
serviceStop in class org.apache.hadoop.service.CompositeServicejava.lang.Exceptionpublic boolean isSecure()
protected RegistrySecurity getRegistrySecurity()
protected java.lang.String buildSecurityDiagnostics()
public java.lang.String toString()
toString in class org.apache.hadoop.service.AbstractServicepublic java.lang.String bindingDiagnosticDetails()
protected java.lang.String createFullPath(java.lang.String path)
throws java.io.IOException
path - path of operationjava.lang.IllegalArgumentException - if the path is invalidejava.io.IOExceptionpublic RegistryBindingSource getBindingSource()
protected void createEnsembleProvider()
RegistryBindingSource.supplyBindingInformation() on
the provider stored in bindingSource.
Sets ensembleProvider to that value;
sets connectionDescription to the binding info
for use in toString and logging;public BindingInformation supplyBindingInformation()
buildConnectionString().supplyBindingInformation in interface RegistryBindingSourceprotected java.lang.String buildConnectionString()
protected java.io.IOException operationFailure(java.lang.String path,
java.lang.String operation,
java.lang.Exception exception)
path - path of operationoperation - operation attemptedexception - caught the exception caughtprotected java.io.IOException operationFailure(java.lang.String path,
java.lang.String operation,
java.lang.Exception exception,
java.util.List<org.apache.zookeeper.data.ACL> acls)
path - path of operationoperation - operation attemptedexception - caught the exception caught@VisibleForTesting
public boolean maybeCreate(java.lang.String path,
org.apache.zookeeper.CreateMode mode,
java.util.List<org.apache.zookeeper.data.ACL> acl,
boolean createParents)
throws java.io.IOException
path - path to createacl - ACL for path -used when creating a new entrycreateParents - flag to trigger parent creationjava.io.IOExceptionpublic org.apache.zookeeper.data.Stat zkStat(java.lang.String path)
throws java.io.IOException
path - path of operationjava.io.IOException - on a failureorg.apache.hadoop.fs.PathNotFoundException - if the path was not foundpublic java.util.List<org.apache.zookeeper.data.ACL> zkGetACLS(java.lang.String path)
throws java.io.IOException
path - path of operationjava.io.IOExceptionpublic boolean zkPathExists(java.lang.String path)
throws java.io.IOException
path - path of operationjava.io.IOException - on any exception other than
PathNotFoundExceptionpublic java.lang.String zkPathMustExist(java.lang.String path)
throws java.io.IOException
path - path of operationorg.apache.hadoop.fs.PathNotFoundException - if the path is absentjava.io.IOExceptionpublic boolean zkMkPath(java.lang.String path,
org.apache.zookeeper.CreateMode mode,
boolean createParents,
java.util.List<org.apache.zookeeper.data.ACL> acls)
throws java.io.IOException
path - path to createmode - mode for pathcreateParents - flag to trigger parent creationacls - ACL for pathjava.io.IOException - any problempublic void zkMkParentPath(java.lang.String path,
java.util.List<org.apache.zookeeper.data.ACL> acl)
throws java.io.IOException
path - path to createacl - ACL for pathjava.io.IOException - any problempublic void zkCreate(java.lang.String path,
org.apache.zookeeper.CreateMode mode,
byte[] data,
java.util.List<org.apache.zookeeper.data.ACL> acls)
throws java.io.IOException
path - path of operationdata - initial dataacls - java.io.IOExceptionpublic void zkUpdate(java.lang.String path,
byte[] data)
throws java.io.IOException
path - path of operationdata - new datajava.io.IOExceptionpublic boolean zkSet(java.lang.String path,
org.apache.zookeeper.CreateMode mode,
byte[] data,
java.util.List<org.apache.zookeeper.data.ACL> acl,
boolean overwrite)
throws java.io.IOException
path - pathdata - dataacl - ACL for path -used when creating a new entryoverwrite - enable overwritejava.io.IOExceptionpublic void zkDelete(java.lang.String path,
boolean recursive,
org.apache.curator.framework.api.BackgroundCallback backgroundCallback)
throws java.io.IOException
path - path of operationrecursive - flag to trigger recursive deletionbackgroundCallback - callback; this being set converts the operation
into an async/background operation.
taskjava.io.IOException - on problems other than no-such-pathpublic java.util.List<java.lang.String> zkList(java.lang.String path)
throws java.io.IOException
path - path of operationjava.io.IOExceptionpublic byte[] zkRead(java.lang.String path)
throws java.io.IOException
path - path of operationjava.io.IOException - read failurepublic ZKPathDumper dumpPath(boolean verbose)
toString()
operation.verbose - verbose flag - includes more details (such as ACLs)public boolean addWriteAccessor(java.lang.String id,
java.lang.String pass)
throws java.io.IOException
id - ID to usepass - passwordjava.io.IOException - on any failure to build the digestpublic void clearWriteAccessors()
protected java.lang.String dumpRegistryRobustly(boolean verbose)
verbose - verbose path dumppublic void registerPathListener(PathListener listener)
listener - the listener.public void instantiateCacheForRegistry()
public void startCache()
Copyright © 2008–2025 Apache Software Foundation. All rights reserved.