@InterfaceAudience.Private @InterfaceStability.Evolving public class CuratorService extends CompositeService implements RegistryConstants, RegistryBindingSource
CompositeService.CompositeServiceShutdownHookService.STATESTOP_ONLY_STARTED_SERVICESDEFAULT_REGISTRY_CLIENT_JAAS_CONTEXT, DEFAULT_REGISTRY_ENABLED, 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, KEY_REGISTRY_CLIENT_AUTH, KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, KEY_REGISTRY_CLIENT_JAAS_CONTEXT, KEY_REGISTRY_ENABLED, 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, PATH_SYSTEM_SERVICES, PATH_USER_SERVICES, PATH_USERS, REGISTRY_CLIENT_AUTH_ANONYMOUS, REGISTRY_CLIENT_AUTH_DIGEST, REGISTRY_CLIENT_AUTH_KERBEROS, REGISTRY_PREFIX, SUBPATH_COMPONENTS, ZK_PREFIX| Constructor and Description |
|---|
CuratorService(String name)
Create an instance using this service as the binding source (i.e.
|
CuratorService(String name,
RegistryBindingSource bindingSource)
Construct the service.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addWriteAccessor(String id,
String pass)
Add a new write access entry for all future write operations.
|
String |
bindingDiagnosticDetails()
Get the binding diagnostics
|
protected String |
buildConnectionString()
Override point: get the connection string used to connect to
the ZK service
|
protected 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
Sets ensembleProvider to that value;
sets connectionDescription to the binding info
for use in toString and logging; |
protected String |
createFullPath(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 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
|
boolean |
isSecure()
Flag to indicate whether or not the registry is secure.
|
boolean |
maybeCreate(String path,
org.apache.zookeeper.CreateMode mode,
List<org.apache.zookeeper.data.ACL> acl,
boolean createParents)
Create a path if it does not exist.
|
protected IOException |
operationFailure(String path,
String operation,
Exception exception)
Create an IOE when an operation fails
|
protected IOException |
operationFailure(String path,
String operation,
Exception exception,
List<org.apache.zookeeper.data.ACL> acls)
Create an IOE when an operation fails
|
protected void |
serviceInit(Configuration conf)
Init the service.
|
protected void |
serviceStart()
Start the service.
|
protected void |
serviceStop()
Close the ZK connection if it is open
|
BindingInformation |
supplyBindingInformation()
Supply the binding information.
|
String |
toString() |
void |
zkCreate(String path,
org.apache.zookeeper.CreateMode mode,
byte[] data,
List<org.apache.zookeeper.data.ACL> acls)
Create a path with given data.
|
void |
zkDelete(String path,
boolean recursive,
org.apache.curator.framework.api.BackgroundCallback backgroundCallback)
Delete a directory/directory tree.
|
List<org.apache.zookeeper.data.ACL> |
zkGetACLS(String path)
Get the ACLs of a path
|
List<String> |
zkList(String path)
List all children of a path
|
void |
zkMkParentPath(String path,
List<org.apache.zookeeper.data.ACL> acl)
Recursively make a path
|
boolean |
zkMkPath(String path,
org.apache.zookeeper.CreateMode mode,
boolean createParents,
List<org.apache.zookeeper.data.ACL> acls)
Create a directory.
|
boolean |
zkPathExists(String path)
Probe for a path existing
|
String |
zkPathMustExist(String path)
Verify a path exists
|
byte[] |
zkRead(String path)
Read data on a path
|
boolean |
zkSet(String path,
org.apache.zookeeper.CreateMode mode,
byte[] data,
List<org.apache.zookeeper.data.ACL> acl,
boolean overwrite)
Create or update an entry
|
org.apache.zookeeper.data.Stat |
zkStat(String path)
Stat the file
|
void |
zkUpdate(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(String name, RegistryBindingSource bindingSource)
name - service namebindingSource - source of binding information.
If null: use this instancepublic CuratorService(String name)
name - service nameprotected void serviceInit(Configuration conf) throws Exception
serviceInit in class CompositeServiceconf - configuration of the serviceExceptionprotected void serviceStart()
throws Exception
serviceStart in class CompositeServiceExceptionprotected void serviceStop()
throws Exception
serviceStop in class CompositeServiceExceptionpublic boolean isSecure()
protected RegistrySecurity getRegistrySecurity()
protected String buildSecurityDiagnostics()
public String toString()
toString in class AbstractServicepublic String bindingDiagnosticDetails()
protected String createFullPath(String path) throws IOException
path - path of operationIllegalArgumentException - if the path is invalideIOExceptionpublic 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 String buildConnectionString()
protected IOException operationFailure(String path, String operation, Exception exception)
path - path of operationoperation - operation attemptedexception - caught the exception caughtprotected IOException operationFailure(String path, String operation, Exception exception, List<org.apache.zookeeper.data.ACL> acls)
path - path of operationoperation - operation attemptedexception - caught the exception caughtpublic boolean maybeCreate(String path, org.apache.zookeeper.CreateMode mode, List<org.apache.zookeeper.data.ACL> acl, boolean createParents) throws IOException
path - path to createacl - ACL for path -used when creating a new entrycreateParents - flag to trigger parent creationIOExceptionpublic org.apache.zookeeper.data.Stat zkStat(String path) throws IOException
path - path of operationIOException - on a failurePathNotFoundException - if the path was not foundpublic List<org.apache.zookeeper.data.ACL> zkGetACLS(String path) throws IOException
path - path of operationIOExceptionpublic boolean zkPathExists(String path) throws IOException
path - path of operationIOException - on any exception other than
PathNotFoundExceptionpublic String zkPathMustExist(String path) throws IOException
path - path of operationPathNotFoundException - if the path is absentIOExceptionpublic boolean zkMkPath(String path, org.apache.zookeeper.CreateMode mode, boolean createParents, List<org.apache.zookeeper.data.ACL> acls) throws IOException
path - path to createmode - mode for pathcreateParents - flag to trigger parent creationacls - ACL for pathIOException - any problempublic void zkMkParentPath(String path, List<org.apache.zookeeper.data.ACL> acl) throws IOException
path - path to createacl - ACL for pathIOException - any problempublic void zkCreate(String path, org.apache.zookeeper.CreateMode mode, byte[] data, List<org.apache.zookeeper.data.ACL> acls) throws IOException
path - path of operationdata - initial dataacls - IOExceptionpublic void zkUpdate(String path, byte[] data) throws IOException
path - path of operationdata - new dataIOExceptionpublic boolean zkSet(String path, org.apache.zookeeper.CreateMode mode, byte[] data, List<org.apache.zookeeper.data.ACL> acl, boolean overwrite) throws IOException
path - pathdata - dataacl - ACL for path -used when creating a new entryoverwrite - enable overwriteIOExceptionpublic void zkDelete(String path, boolean recursive, org.apache.curator.framework.api.BackgroundCallback backgroundCallback) throws IOException
path - path of operationrecursive - flag to trigger recursive deletionbackgroundCallback - callback; this being set converts the operation
into an async/background operation.
taskIOException - on problems other than no-such-pathpublic List<String> zkList(String path) throws IOException
path - path of operationIOExceptionpublic byte[] zkRead(String path) throws IOException
path - path of operationIOException - read failurepublic ZKPathDumper dumpPath(boolean verbose)
toString()
operationverbose - verbose flag - includes more details (such as ACLs)public boolean addWriteAccessor(String id, String pass) throws IOException
id - ID to usepass - passwordIOException - on any failure to build the digestpublic void clearWriteAccessors()
protected String dumpRegistryRobustly(boolean verbose)
verbose - verbose path dumpCopyright © 2018 CERN. All Rights Reserved.