Search in sources :

Example 1 with NoChildrenForEphemeralsException

use of org.apache.hadoop.registry.client.exceptions.NoChildrenForEphemeralsException in project hadoop by apache.

the class CuratorService method operationFailure.

/**
   * Create an IOE when an operation fails
   * @param path path of operation
   * @param operation operation attempted
   * @param exception caught the exception caught
   * @return an IOE to throw that contains the path and operation details.
   */
protected IOException operationFailure(String path, String operation, Exception exception, List<ACL> acls) {
    IOException ioe;
    String aclList = "[" + RegistrySecurity.aclsToString(acls) + "]";
    if (exception instanceof KeeperException.NoNodeException) {
        ioe = new PathNotFoundException(path);
    } else if (exception instanceof KeeperException.NodeExistsException) {
        ioe = new FileAlreadyExistsException(path);
    } else if (exception instanceof KeeperException.NoAuthException) {
        ioe = new NoPathPermissionsException(path, "Not authorized to access path; ACLs: " + aclList);
    } else if (exception instanceof KeeperException.NotEmptyException) {
        ioe = new PathIsNotEmptyDirectoryException(path);
    } else if (exception instanceof KeeperException.AuthFailedException) {
        ioe = new AuthenticationFailedException(path, "Authentication Failed: " + exception + "; " + securityConnectionDiagnostics, exception);
    } else if (exception instanceof KeeperException.NoChildrenForEphemeralsException) {
        ioe = new NoChildrenForEphemeralsException(path, "Cannot create a path under an ephemeral node: " + exception, exception);
    } else if (exception instanceof KeeperException.InvalidACLException) {
        // this is a security exception of a kind
        // include the ACLs to help the diagnostics
        StringBuilder builder = new StringBuilder();
        builder.append("Path access failure ").append(aclList);
        builder.append(" ");
        builder.append(securityConnectionDiagnostics);
        ioe = new NoPathPermissionsException(path, builder.toString());
    } else {
        ioe = new RegistryIOException(path, "Failure of " + operation + " on " + path + ": " + exception.toString(), exception);
    }
    if (ioe.getCause() == null) {
        ioe.initCause(exception);
    }
    return ioe;
}
Also used : NoPathPermissionsException(org.apache.hadoop.registry.client.exceptions.NoPathPermissionsException) FileAlreadyExistsException(org.apache.hadoop.fs.FileAlreadyExistsException) AuthenticationFailedException(org.apache.hadoop.registry.client.exceptions.AuthenticationFailedException) PathIsNotEmptyDirectoryException(org.apache.hadoop.fs.PathIsNotEmptyDirectoryException) IOException(java.io.IOException) RegistryIOException(org.apache.hadoop.registry.client.exceptions.RegistryIOException) NoChildrenForEphemeralsException(org.apache.hadoop.registry.client.exceptions.NoChildrenForEphemeralsException) PathNotFoundException(org.apache.hadoop.fs.PathNotFoundException) RegistryIOException(org.apache.hadoop.registry.client.exceptions.RegistryIOException) KeeperException(org.apache.zookeeper.KeeperException)

Aggregations

IOException (java.io.IOException)1 FileAlreadyExistsException (org.apache.hadoop.fs.FileAlreadyExistsException)1 PathIsNotEmptyDirectoryException (org.apache.hadoop.fs.PathIsNotEmptyDirectoryException)1 PathNotFoundException (org.apache.hadoop.fs.PathNotFoundException)1 AuthenticationFailedException (org.apache.hadoop.registry.client.exceptions.AuthenticationFailedException)1 NoChildrenForEphemeralsException (org.apache.hadoop.registry.client.exceptions.NoChildrenForEphemeralsException)1 NoPathPermissionsException (org.apache.hadoop.registry.client.exceptions.NoPathPermissionsException)1 RegistryIOException (org.apache.hadoop.registry.client.exceptions.RegistryIOException)1 KeeperException (org.apache.zookeeper.KeeperException)1