Class RegistryAdminService
java.lang.Object
org.apache.hadoop.service.AbstractService
org.apache.hadoop.service.CompositeService
org.apache.hadoop.registry.client.impl.zk.CuratorService
org.apache.hadoop.registry.client.impl.zk.RegistryOperationsService
org.apache.hadoop.registry.server.services.RegistryAdminService
- All Implemented Interfaces:
Closeable,AutoCloseable,RegistryConstants,RegistryOperations,RegistryBindingSource,org.apache.hadoop.service.Service
Administrator service for the registry. This is the one with
permissions to create the base directories and those for users.
It also includes support for asynchronous operations, so that
zookeeper connectivity problems do not hold up the server code
performing the actions.
Any action queued via
submit(Callable) will be
run asynchronously. The createDirAsync(String, List, boolean)
is an example of such an an action
A key async action is the depth-first tree purge, which supports
pluggable policies for deleting entries. The method
purge(String, NodeSelector, PurgePolicy, BackgroundCallback)
implements the recursive purge operation —the class
{{AsyncPurge}} provides the asynchronous scheduling of this.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionclassAn async registry purge action taking a selector which decides what to deletestatic interfaceComparator used for purge logicstatic enumPolicy to purge entriesNested classes/interfaces inherited from class org.apache.hadoop.service.CompositeService
org.apache.hadoop.service.CompositeService.CompositeServiceShutdownHookNested classes/interfaces inherited from interface org.apache.hadoop.service.Service
org.apache.hadoop.service.Service.STATE -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ExecutorServiceExecutor for async operationsstatic final intThe ACL permissions for the user's homedir ACL.Fields inherited from class org.apache.hadoop.service.CompositeService
STOP_ONLY_STARTED_SERVICESFields 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_PREFIX -
Constructor Summary
ConstructorsConstructorDescriptionRegistryAdminService(String name) Construct an instance of the serviceRegistryAdminService(String name, RegistryBindingSource bindingSource) construct an instance of the service, using the specified binding source to bond to ZK -
Method Summary
Modifier and TypeMethodDescriptionList<org.apache.zookeeper.data.ACL>aclsForUser(String username, int perms) Set up the ACL for the user.createDirAsync(String path, List<org.apache.zookeeper.data.ACL> acls, boolean createParents) Asynchronous operation to create a directoryvoidCreate the initial registry pathsprotected ExecutorServiceGet the executorprotected StringGet the path to a user's home dirinitUserRegistry(String username) Create the home path for a user if it does not exist.initUserRegistryAsync(String shortname) Start an async operation to create the home path for a user if it does not existintpurge(String path, RegistryAdminService.NodeSelector selector, RegistryAdminService.PurgePolicy purgePolicy, org.apache.curator.framework.api.BackgroundCallback callback) Recursive operation to purge all matching records under a base path.protected voidserviceInit(org.apache.hadoop.conf.Configuration conf) Init operation sets up the system ACLs.protected voidStart the service, including creating base directories with permissionsprotected voidStop the service: halt the executor.protected voidStop the executor if it is not null.<V> Future<V>Submit a callableprotected voidMethod to validate the validity of the kerberos realm.Methods inherited from class org.apache.hadoop.registry.client.impl.zk.RegistryOperationsService
bind, delete, exists, getClientAcls, list, mknode, resolve, stat, validatePathMethods inherited from class org.apache.hadoop.registry.client.impl.zk.CuratorService
addWriteAccessor, bindingDiagnosticDetails, buildConnectionString, buildSecurityDiagnostics, clearWriteAccessors, createEnsembleProvider, createFullPath, dumpPath, dumpRegistryRobustly, getBindingSource, getRegistrySecurity, instantiateCacheForRegistry, isSecure, maybeCreate, operationFailure, operationFailure, registerPathListener, setKerberosPrincipalAndKeytab, startCache, supplyBindingInformation, toString, zkCreate, zkDelete, zkGetACLS, zkList, zkMkParentPath, zkMkPath, zkPathExists, zkPathMustExist, zkRead, zkSet, zkStat, zkUpdateMethods inherited from class org.apache.hadoop.service.CompositeService
addIfService, addService, getServices, removeServiceMethods 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, waitForServiceToStopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.hadoop.registry.client.api.RegistryOperations
addWriteAccessor, clearWriteAccessorsMethods inherited from interface org.apache.hadoop.service.Service
close, getBlockers, getConfig, getFailureCause, getFailureState, getLifecycleHistory, getName, getServiceState, getStartTime, init, isInState, registerServiceListener, start, stop, unregisterServiceListener, waitForServiceToStop
-
Field Details
-
USER_HOMEDIR_ACL_PERMISSIONS
public static final int USER_HOMEDIR_ACL_PERMISSIONSThe ACL permissions for the user's homedir ACL.- See Also:
-
executor
Executor for async operations
-
-
Constructor Details
-
RegistryAdminService
Construct an instance of the service- Parameters:
name- service name
-
RegistryAdminService
construct an instance of the service, using the specified binding source to bond to ZK- Parameters:
name- service namebindingSource- provider of ZK binding information
-
-
Method Details
-
serviceStop
Stop the service: halt the executor.- Overrides:
serviceStopin classCuratorService- Throws:
Exception- exception.
-
stopExecutor
protected void stopExecutor()Stop the executor if it is not null. This usesExecutorService.shutdownNow()and so does not block until they have completed. -
getExecutor
Get the executor- Returns:
- the executor
-
submit
Submit a callable- Type Parameters:
V- type of the final get- Parameters:
callable- callable- Returns:
- a future to wait on
-
createDirAsync
public Future<Boolean> createDirAsync(String path, List<org.apache.zookeeper.data.ACL> acls, boolean createParents) throws IOException Asynchronous operation to create a directory- Parameters:
path- pathacls- ACL listcreateParents- flag to indicate parent dirs should be created as needed- Returns:
- the future which will indicate whether or not the operation succeeded —and propagate any exceptions
- Throws:
IOException
-
serviceInit
Init operation sets up the system ACLs.- Overrides:
serviceInitin classCuratorService- Parameters:
conf- configuration of the service- Throws:
Exception
-
serviceStart
Start the service, including creating base directories with permissions- Overrides:
serviceStartin classCuratorService- Throws:
Exception
-
createRootRegistryPaths
Create the initial registry paths- Throws:
IOException- any failure
-
homeDir
Get the path to a user's home dir- Parameters:
username- username- Returns:
- a path for services underneath
-
aclsForUser
public List<org.apache.zookeeper.data.ACL> aclsForUser(String username, int perms) throws IOException Set up the ACL for the user. Important: this must run client-side as it needs to know the id:pass tuple for a user- Parameters:
username- user nameperms- permissions- Returns:
- an ACL list
- Throws:
IOException- ACL creation/parsing problems
-
initUserRegistryAsync
Start an async operation to create the home path for a user if it does not exist- Parameters:
shortname- username, without any @REALM in kerberos- Returns:
- the path created
- Throws:
IOException- any failure while setting up the operation
-
initUserRegistry
Create the home path for a user if it does not exist. This usesinitUserRegistryAsync(String)and then waits for the result ... the code path is the same as the async operation; this just picks up and relays/converts exceptions- Parameters:
username- username- Returns:
- the path created
- Throws:
IOException- any failure
-
verifyRealmValidity
protected void verifyRealmValidity() throws org.apache.hadoop.service.ServiceStateExceptionMethod to validate the validity of the kerberos realm.- Insecure: not needed.
- Secure: must have been determined.
- Throws:
org.apache.hadoop.service.ServiceStateException
-
purge
@VisibleForTesting public int purge(String path, RegistryAdminService.NodeSelector selector, RegistryAdminService.PurgePolicy purgePolicy, org.apache.curator.framework.api.BackgroundCallback callback) throws IOException Recursive operation to purge all matching records under a base path.- Uses a depth first search
- A match is on ID and persistence policy, or, if policy==-1, any match
- If a record matches then it is deleted without any child searches
- Deletions will be asynchronous if a callback is provided
- Parameters:
path- base pathselector- selector for the purge policypurgePolicy- what to do if there is a matching record with childrencallback- optional curator callback- Returns:
- the number of delete operations perfomed. As deletes may be for everything under a path, this may be less than the number of records actually deleted
- Throws:
IOException- problemsorg.apache.hadoop.fs.PathIsNotEmptyDirectoryException- if an entry cannot be deleted as it has children and the purge policy is FailOnChildren
-