org.apache.hadoop.registry.client.impl.zk
Class RegistryOperationsService

java.lang.Object
  extended by org.apache.hadoop.service.AbstractService
      extended by org.apache.hadoop.service.CompositeService
          extended by org.apache.hadoop.registry.client.impl.zk.CuratorService
              extended by org.apache.hadoop.registry.client.impl.zk.RegistryOperationsService
All Implemented Interfaces:
Closeable, RegistryConstants, RegistryOperations, RegistryBindingSource, Service
Direct Known Subclasses:
RegistryOperationsClient

@InterfaceAudience.Public
@InterfaceStability.Evolving
public class RegistryOperationsService
extends org.apache.hadoop.registry.client.impl.zk.CuratorService
implements RegistryOperations

The Registry operations service.

This service implements the RegistryOperations API by mapping the commands to zookeeper operations, and translating results and exceptions back into those specified by the API.

Factory methods should hide the detail that this has been implemented via the CuratorService by returning it cast to that RegistryOperations interface, rather than this implementation class.


Field Summary
 
Fields inherited from class org.apache.hadoop.service.CompositeService
STOP_ONLY_STARTED_SERVICES
 
Fields inherited from interface org.apache.hadoop.registry.client.api.RegistryConstants
DEFAULT_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 Summary
RegistryOperationsService()
           
RegistryOperationsService(String name)
           
RegistryOperationsService(String name, RegistryBindingSource bindingSource)
           
 
Method Summary
 void bind(String path, ServiceRecord record, int flags)
          Bind a path in the registry to a service record
 void delete(String path, boolean recursive)
          Delete a path.
 boolean exists(String path)
          Probe for a path existing.
 List<org.apache.zookeeper.data.ACL> getClientAcls()
          Get the aggregate set of ACLs the client should use to create directories
 List<String> list(String path)
          List all entries under a registry path, returning the relative names of the entries.
 boolean mknode(String path, boolean createParents)
          Create a path.
 ServiceRecord resolve(String path)
          Resolve the record at a path
 RegistryPathStatus stat(String path)
          Get the status of a path
protected  void validatePath(String path)
          Validate a path
 
Methods inherited from class org.apache.hadoop.registry.client.impl.zk.CuratorService
addWriteAccessor, bindingDiagnosticDetails, buildConnectionString, buildSecurityDiagnostics, clearWriteAccessors, createEnsembleProvider, createFullPath, dumpPath, dumpRegistryRobustly, getBindingSource, getRegistrySecurity, isSecure, maybeCreate, operationFailure, operationFailure, serviceInit, serviceStart, serviceStop, supplyBindingInformation, toString, zkCreate, zkDelete, zkGetACLS, zkList, zkMkParentPath, zkMkPath, zkPathExists, zkPathMustExist, zkRead, zkSet, zkStat, zkUpdate
 
Methods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeService
 
Methods 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, unregisterGlobalListener, unregisterServiceListener, waitForServiceToStop
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.apache.hadoop.registry.client.api.RegistryOperations
addWriteAccessor, clearWriteAccessors
 
Methods inherited from interface org.apache.hadoop.service.Service
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, registerServiceListener, start, stop, unregisterServiceListener, waitForServiceToStop
 

Constructor Detail

RegistryOperationsService

public RegistryOperationsService(String name)

RegistryOperationsService

public RegistryOperationsService()

RegistryOperationsService

public RegistryOperationsService(String name,
                                 RegistryBindingSource bindingSource)
Method Detail

getClientAcls

public List<org.apache.zookeeper.data.ACL> getClientAcls()
Get the aggregate set of ACLs the client should use to create directories

Returns:
the ACL list

validatePath

protected void validatePath(String path)
                     throws InvalidPathnameException
Validate a path

Parameters:
path - path to validate
Throws:
InvalidPathnameException - if a path is considered invalid

mknode

public boolean mknode(String path,
                      boolean createParents)
               throws IOException
Description copied from interface: RegistryOperations
Create a path. It is not an error if the path exists already, be it empty or not. The createParents flag also requests creating the parents. As entries in the registry can hold data while still having child entries, it is not an error if any of the parent path elements have service records.

Specified by:
mknode in interface RegistryOperations
Parameters:
path - path to create
createParents - also create the parents.
Returns:
true if the path was created, false if it existed.
Throws:
org.apache.hadoop.fs.PathNotFoundException - parent path is not in the registry.
InvalidPathnameException - path name is invalid.
IOException - Any other IO Exception.

bind

public void bind(String path,
                 ServiceRecord record,
                 int flags)
          throws IOException
Description copied from interface: RegistryOperations
Bind a path in the registry to a service record

Specified by:
bind in interface RegistryOperations
Parameters:
path - path to service record
record - service record service record to create/update
flags - bind flags
Throws:
org.apache.hadoop.fs.PathNotFoundException - the parent path does not exist
FileAlreadyExistsException - path exists but create flags do not include "overwrite"
InvalidPathnameException - path name is invalid.
IOException - Any other IO Exception.

resolve

public ServiceRecord resolve(String path)
                      throws IOException
Description copied from interface: RegistryOperations
Resolve the record at a path

Specified by:
resolve in interface RegistryOperations
Parameters:
path - path to an entry containing a ServiceRecord
Returns:
the record
Throws:
org.apache.hadoop.fs.PathNotFoundException - path is not in the registry.
NoRecordException - if there is not a service record
InvalidRecordException - if there was a service record but it could not be parsed.
IOException - Any other IO Exception

exists

public boolean exists(String path)
               throws IOException
Description copied from interface: RegistryOperations
Probe for a path existing. This is equivalent to RegistryOperations.stat(String) with any failure downgraded to a

Specified by:
exists in interface RegistryOperations
Parameters:
path - path to query
Returns:
true if the path was found
Throws:
IOException

stat

public RegistryPathStatus stat(String path)
                        throws IOException
Description copied from interface: RegistryOperations
Get the status of a path

Specified by:
stat in interface RegistryOperations
Parameters:
path - path to query
Returns:
the status of the path
Throws:
org.apache.hadoop.fs.PathNotFoundException - path is not in the registry.
InvalidPathnameException - the path is invalid.
IOException - Any other IO Exception

list

public List<String> list(String path)
                  throws IOException
Description copied from interface: RegistryOperations
List all entries under a registry path, returning the relative names of the entries.

Specified by:
list in interface RegistryOperations
Parameters:
path - path to query
Returns:
a possibly empty list of the short path names of child entries.
Throws:
org.apache.hadoop.fs.PathNotFoundException
InvalidPathnameException
IOException

delete

public void delete(String path,
                   boolean recursive)
            throws IOException
Description copied from interface: RegistryOperations
Delete a path. If the operation returns without an error then the entry has been deleted.

Specified by:
delete in interface RegistryOperations
Parameters:
path - path delete recursively
recursive - recursive flag
Throws:
org.apache.hadoop.fs.PathNotFoundException - path is not in the registry.
InvalidPathnameException - the path is invalid.
org.apache.hadoop.fs.PathIsNotEmptyDirectoryException - path has child entries, but recursive is false.
IOException - Any other IO Exception


Copyright © 2014 Apache Software Foundation. All Rights Reserved.