You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by su...@apache.org on 2018/10/24 05:52:30 UTC
[10/50] [abbrv] hadoop git commit: HADOOP-15821. Move YARN Registry to Hadoop Registry. Contributed by Íñigo Goiri
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryUtils.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryUtils.java
deleted file mode 100644
index 1b839c2..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryUtils.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.binding;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.fs.PathNotFoundException;
-import org.apache.hadoop.security.UserGroupInformation;
-import org.apache.hadoop.registry.client.api.RegistryConstants;
-import org.apache.hadoop.registry.client.api.RegistryOperations;
-import org.apache.hadoop.registry.client.exceptions.InvalidPathnameException;
-import org.apache.hadoop.registry.client.exceptions.InvalidRecordException;
-import org.apache.hadoop.registry.client.exceptions.NoRecordException;
-import org.apache.hadoop.registry.client.impl.zk.RegistryInternalConstants;
-import org.apache.hadoop.registry.client.types.RegistryPathStatus;
-import org.apache.hadoop.registry.client.types.ServiceRecord;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import static org.apache.hadoop.registry.client.binding.RegistryPathUtils.*;
-
-import java.io.EOFException;
-import java.io.IOException;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-
-/**
- * Utility methods for working with a registry.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public class RegistryUtils {
- private static final Logger LOG =
- LoggerFactory.getLogger(RegistryUtils.class);
-
- /**
- * Buld the user path -switches to the system path if the user is "".
- * It also cross-converts the username to ascii via punycode
- * @param username username or ""
- * @return the path to the user
- */
- public static String homePathForUser(String username) {
- Preconditions.checkArgument(username != null, "null user");
-
- // catch recursion
- if (username.startsWith(RegistryConstants.PATH_USERS)) {
- return username;
- }
- if (username.isEmpty()) {
- return RegistryConstants.PATH_SYSTEM_SERVICES;
- }
-
- // convert username to registry name
- String convertedName = convertUsername(username);
-
- return RegistryPathUtils.join(RegistryConstants.PATH_USERS,
- encodeForRegistry(convertedName));
- }
-
- /**
- * Convert the username to that which can be used for registry
- * entries. Lower cases it,
- * Strip the kerberos realm off a username if needed, and any "/" hostname
- * entries
- * @param username user
- * @return the converted username
- */
- public static String convertUsername(String username) {
- String converted =
- org.apache.hadoop.util.StringUtils.toLowerCase(username);
- int atSymbol = converted.indexOf('@');
- if (atSymbol > 0) {
- converted = converted.substring(0, atSymbol);
- }
- int slashSymbol = converted.indexOf('/');
- if (slashSymbol > 0) {
- converted = converted.substring(0, slashSymbol);
- }
- return converted;
- }
-
- /**
- * Create a service classpath
- * @param user username or ""
- * @param serviceClass service name
- * @return a full path
- */
- public static String serviceclassPath(String user,
- String serviceClass) {
- String services = join(homePathForUser(user),
- RegistryConstants.PATH_USER_SERVICES);
- return join(services,
- serviceClass);
- }
-
- /**
- * Create a path to a service under a user and service class
- * @param user username or ""
- * @param serviceClass service name
- * @param serviceName service name unique for that user and service class
- * @return a full path
- */
- public static String servicePath(String user,
- String serviceClass,
- String serviceName) {
-
- return join(
- serviceclassPath(user, serviceClass),
- serviceName);
- }
-
- /**
- * Create a path for listing components under a service
- * @param user username or ""
- * @param serviceClass service name
- * @param serviceName service name unique for that user and service class
- * @return a full path
- */
- public static String componentListPath(String user,
- String serviceClass, String serviceName) {
-
- return join(servicePath(user, serviceClass, serviceName),
- RegistryConstants.SUBPATH_COMPONENTS);
- }
-
- /**
- * Create the path to a service record for a component
- * @param user username or ""
- * @param serviceClass service name
- * @param serviceName service name unique for that user and service class
- * @param componentName unique name/ID of the component
- * @return a full path
- */
- public static String componentPath(String user,
- String serviceClass, String serviceName, String componentName) {
-
- return join(
- componentListPath(user, serviceClass, serviceName),
- componentName);
- }
-
- /**
- * List service records directly under a path
- * @param registryOperations registry operations instance
- * @param path path to list
- * @return a mapping of the service records that were resolved, indexed
- * by their full path
- * @throws IOException
- */
- public static Map<String, ServiceRecord> listServiceRecords(
- RegistryOperations registryOperations,
- String path) throws IOException {
- Map<String, RegistryPathStatus> children =
- statChildren(registryOperations, path);
- return extractServiceRecords(registryOperations,
- path,
- children.values());
- }
-
- /**
- * List children of a directory and retrieve their
- * {@link RegistryPathStatus} values.
- * <p>
- * This is not an atomic operation; A child may be deleted
- * during the iteration through the child entries. If this happens,
- * the <code>PathNotFoundException</code> is caught and that child
- * entry ommitted.
- *
- * @param path path
- * @return a possibly empty map of child entries listed by
- * their short name.
- * @throws PathNotFoundException path is not in the registry.
- * @throws InvalidPathnameException the path is invalid.
- * @throws IOException Any other IO Exception
- */
- public static Map<String, RegistryPathStatus> statChildren(
- RegistryOperations registryOperations,
- String path)
- throws PathNotFoundException,
- InvalidPathnameException,
- IOException {
- List<String> childNames = registryOperations.list(path);
- Map<String, RegistryPathStatus> results =
- new HashMap<String, RegistryPathStatus>();
- for (String childName : childNames) {
- String child = join(path, childName);
- try {
- RegistryPathStatus stat = registryOperations.stat(child);
- results.put(childName, stat);
- } catch (PathNotFoundException pnfe) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("stat failed on {}: moved? {}", child, pnfe, pnfe);
- }
- // and continue
- }
- }
- return results;
- }
-
- /**
- * Get the home path of the current user.
- * <p>
- * In an insecure cluster, the environment variable
- * <code>HADOOP_USER_NAME</code> is queried <i>first</i>.
- * <p>
- * This means that in a YARN container where the creator set this
- * environment variable to propagate their identity, the defined
- * user name is used in preference to the actual user.
- * <p>
- * In a secure cluster, the kerberos identity of the current user is used.
- * @return a path for the current user's home dir.
- * @throws RuntimeException if the current user identity cannot be determined
- * from the OS/kerberos.
- */
- public static String homePathForCurrentUser() {
- String shortUserName = currentUsernameUnencoded();
- return homePathForUser(shortUserName);
- }
-
- /**
- * Get the current username, before any encoding has been applied.
- * @return the current user from the kerberos identity, falling back
- * to the user and/or env variables.
- */
- private static String currentUsernameUnencoded() {
- String env_hadoop_username = System.getenv(
- RegistryInternalConstants.HADOOP_USER_NAME);
- return getCurrentUsernameUnencoded(env_hadoop_username);
- }
-
- /**
- * Get the current username, using the value of the parameter
- * <code>env_hadoop_username</code> if it is set on an insecure cluster.
- * This ensures that the username propagates correctly across processes
- * started by YARN.
- * <p>
- * This method is primarly made visible for testing.
- * @param env_hadoop_username the environment variable
- * @return the selected username
- * @throws RuntimeException if there is a problem getting the short user
- * name of the current user.
- */
- @VisibleForTesting
- public static String getCurrentUsernameUnencoded(String env_hadoop_username) {
- String shortUserName = null;
- if (!UserGroupInformation.isSecurityEnabled()) {
- shortUserName = env_hadoop_username;
- }
- if (StringUtils.isEmpty(shortUserName)) {
- try {
- shortUserName = UserGroupInformation.getCurrentUser().getShortUserName();
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
- return shortUserName;
- }
-
- /**
- * Get the current user path formatted for the registry
- * <p>
- * In an insecure cluster, the environment variable
- * <code>HADOOP_USER_NAME </code> is queried <i>first</i>.
- * <p>
- * This means that in a YARN container where the creator set this
- * environment variable to propagate their identity, the defined
- * user name is used in preference to the actual user.
- * <p>
- * In a secure cluster, the kerberos identity of the current user is used.
- * @return the encoded shortname of the current user
- * @throws RuntimeException if the current user identity cannot be determined
- * from the OS/kerberos.
- *
- */
- public static String currentUser() {
- String shortUserName = currentUsernameUnencoded();
- return registryUser(shortUserName);
- }
-
- /**
- * Convert the given user name formatted for the registry.
- *
- * @param shortUserName
- * @return converted user name
- */
- public static String registryUser(String shortUserName) {
- String encodedName = encodeForRegistry(shortUserName);
- // DNS name doesn't allow "_", replace it with "-"
- encodedName = RegistryUtils.convertUsername(encodedName);
- return encodedName.replace("_", "-");
- }
-
- /**
- * Extract all service records under a list of stat operations...this
- * skips entries that are too short or simply not matching
- * @param operations operation support for fetches
- * @param parentpath path of the parent of all the entries
- * @param stats Collection of stat results
- * @return a possibly empty map of fullpath:record.
- * @throws IOException for any IO Operation that wasn't ignored.
- */
- public static Map<String, ServiceRecord> extractServiceRecords(
- RegistryOperations operations,
- String parentpath,
- Collection<RegistryPathStatus> stats) throws IOException {
- Map<String, ServiceRecord> results = new HashMap<String, ServiceRecord>(stats.size());
- for (RegistryPathStatus stat : stats) {
- if (stat.size > ServiceRecord.RECORD_TYPE.length()) {
- // maybe has data
- String path = join(parentpath, stat.path);
- try {
- ServiceRecord serviceRecord = operations.resolve(path);
- results.put(path, serviceRecord);
- } catch (EOFException ignored) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("data too short for {}", path);
- }
- } catch (InvalidRecordException record) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Invalid record at {}", path);
- }
- } catch (NoRecordException record) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("No record at {}", path);
- }
- }
- }
- }
- return results;
- }
-
- /**
- * Extract all service records under a list of stat operations...this
- * non-atomic action skips entries that are too short or simply not matching.
- * <p>
- * @param operations operation support for fetches
- * @param parentpath path of the parent of all the entries
- * @return a possibly empty map of fullpath:record.
- * @throws IOException for any IO Operation that wasn't ignored.
- */
- public static Map<String, ServiceRecord> extractServiceRecords(
- RegistryOperations operations,
- String parentpath,
- Map<String , RegistryPathStatus> stats) throws IOException {
- return extractServiceRecords(operations, parentpath, stats.values());
- }
-
-
- /**
- * Extract all service records under a list of stat operations...this
- * non-atomic action skips entries that are too short or simply not matching.
- * <p>
- * @param operations operation support for fetches
- * @param parentpath path of the parent of all the entries
- * @return a possibly empty map of fullpath:record.
- * @throws IOException for any IO Operation that wasn't ignored.
- */
- public static Map<String, ServiceRecord> extractServiceRecords(
- RegistryOperations operations,
- String parentpath) throws IOException {
- return
- extractServiceRecords(operations,
- parentpath,
- statChildren(operations, parentpath).values());
- }
-
-
-
- /**
- * Static instance of service record marshalling
- */
- public static class ServiceRecordMarshal extends JsonSerDeser<ServiceRecord> {
- public ServiceRecordMarshal() {
- super(ServiceRecord.class);
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/package-info.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/package-info.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/package-info.java
deleted file mode 100644
index f99aa71..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/package-info.java
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Registry binding utility classes.
- */
-package org.apache.hadoop.registry.client.binding;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/AuthenticationFailedException.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/AuthenticationFailedException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/AuthenticationFailedException.java
deleted file mode 100644
index aadb7fc..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/AuthenticationFailedException.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.exceptions;
-
-/**
- * Exception raised when client access wasn't authenticated.
- * That is: the credentials provided were incomplete or invalid.
- */
-public class AuthenticationFailedException extends RegistryIOException {
- public AuthenticationFailedException(String path, Throwable cause) {
- super(path, cause);
- }
-
- public AuthenticationFailedException(String path, String error) {
- super(path, error);
- }
-
- public AuthenticationFailedException(String path,
- String error,
- Throwable cause) {
- super(path, error, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/InvalidPathnameException.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/InvalidPathnameException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/InvalidPathnameException.java
deleted file mode 100644
index c984f41..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/InvalidPathnameException.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.exceptions;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-
-/**
- * A path name was invalid. This is raised when a path string has
- * characters in it that are not permitted.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public class InvalidPathnameException extends RegistryIOException {
- public InvalidPathnameException(String path, String message) {
- super(path, message);
- }
-
- public InvalidPathnameException(String path,
- String message,
- Throwable cause) {
- super(path, message, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/InvalidRecordException.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/InvalidRecordException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/InvalidRecordException.java
deleted file mode 100644
index e4f545e..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/InvalidRecordException.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.exceptions;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-
-/**
- * Raised if an attempt to parse a record failed.
- *
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public class InvalidRecordException extends RegistryIOException {
-
- public InvalidRecordException(String path, String error) {
- super(path, error);
- }
-
- public InvalidRecordException(String path,
- String error,
- Throwable cause) {
- super(path, error, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoChildrenForEphemeralsException.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoChildrenForEphemeralsException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoChildrenForEphemeralsException.java
deleted file mode 100644
index 24070a5..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoChildrenForEphemeralsException.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.exceptions;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-
-/**
- * This is a manifestation of the Zookeeper restrictions about
- * what nodes may act as parents.
- *
- * Children are not allowed under ephemeral nodes. This is an aspect
- * of ZK which isn't directly exposed to the registry API. It may
- * surface if the registry is manipulated outside of the registry API.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public class NoChildrenForEphemeralsException extends RegistryIOException {
- public NoChildrenForEphemeralsException(String path, Throwable cause) {
- super(path, cause);
- }
-
- public NoChildrenForEphemeralsException(String path, String error) {
- super(path, error);
- }
-
- public NoChildrenForEphemeralsException(String path,
- String error,
- Throwable cause) {
- super(path, error, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoPathPermissionsException.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoPathPermissionsException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoPathPermissionsException.java
deleted file mode 100644
index ce84f5b..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoPathPermissionsException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.exceptions;
-
-import org.apache.hadoop.fs.PathIOException;
-
-/**
- * Raised on path permission exceptions.
- * <p>
- * This is similar to PathIOException, except that exception doesn't let
- */
-public class NoPathPermissionsException extends RegistryIOException {
- public NoPathPermissionsException(String path, Throwable cause) {
- super(path, cause);
- }
-
- public NoPathPermissionsException(String path, String error) {
- super(path, error);
- }
-
- public NoPathPermissionsException(String path, String error, Throwable cause) {
- super(path, error, cause);
- }
-
- public NoPathPermissionsException(String message,
- PathIOException cause) {
- super(message, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoRecordException.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoRecordException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoRecordException.java
deleted file mode 100644
index b81b9d4..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/NoRecordException.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.exceptions;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.registry.client.types.ServiceRecord;
-
-/**
- * Raised if there is no {@link ServiceRecord} resolved at the end
- * of the specified path.
- * <p>
- * There may be valid data of some form at the end of the path, but it does
- * not appear to be a Service Record.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public class NoRecordException extends RegistryIOException {
-
- public NoRecordException(String path, String error) {
- super(path, error);
- }
-
- public NoRecordException(String path,
- String error,
- Throwable cause) {
- super(path, error, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/RegistryIOException.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/RegistryIOException.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/RegistryIOException.java
deleted file mode 100644
index ca966db..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/RegistryIOException.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.exceptions;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.fs.PathIOException;
-
-/**
- * Base exception for registry operations.
- * <p>
- * These exceptions include the path of the failing operation wherever possible;
- * this can be retrieved via {@link PathIOException#getPath()}.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public class RegistryIOException extends PathIOException {
-
- /**
- * Build an exception from any other Path IO Exception.
- * This propagates the path of the original exception
- * @param message more specific text
- * @param cause cause
- */
- public RegistryIOException(String message, PathIOException cause) {
- super(cause.getPath() != null ? cause.getPath().toString() : "",
- message,
- cause);
- }
-
- public RegistryIOException(String path, Throwable cause) {
- super(path, cause);
- }
-
- public RegistryIOException(String path, String error) {
- super(path, error);
- }
-
- public RegistryIOException(String path, String error, Throwable cause) {
- super(path, error, cause);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/package-info.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/package-info.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/package-info.java
deleted file mode 100644
index 7d9c8ad..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/exceptions/package-info.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Registry Service Exceptions
- * <p>
- * These are the Registry-specific exceptions that may be raised during
- * Registry operations.
- * <p>
- * Other exceptions may be raised, especially <code>IOExceptions</code>
- * triggered by network problems, and <code>IllegalArgumentException</code>
- * exceptions that may be raised if invalid (often null) arguments are passed
- * to a method call.
- * <p>
- * All exceptions in this package are derived from
- * {@link org.apache.hadoop.registry.client.exceptions.RegistryIOException}
- */
-package org.apache.hadoop.registry.client.exceptions;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/FSRegistryOperationsService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/FSRegistryOperationsService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/FSRegistryOperationsService.java
deleted file mode 100644
index d8cadbf..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/FSRegistryOperationsService.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/**
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.impl;
-
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.commons.lang3.NotImplementedException;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FSDataInputStream;
-import org.apache.hadoop.fs.FSDataOutputStream;
-import org.apache.hadoop.fs.FileAlreadyExistsException;
-import org.apache.hadoop.fs.FileStatus;
-import org.apache.hadoop.fs.FileSystem;
-import org.apache.hadoop.fs.Path;
-import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
-import org.apache.hadoop.fs.PathNotFoundException;
-import org.apache.hadoop.registry.client.api.BindFlags;
-import org.apache.hadoop.registry.client.api.RegistryOperations;
-import org.apache.hadoop.registry.client.binding.RegistryTypeUtils;
-import org.apache.hadoop.registry.client.binding.RegistryUtils;
-import org.apache.hadoop.registry.client.exceptions.InvalidPathnameException;
-import org.apache.hadoop.registry.client.exceptions.InvalidRecordException;
-import org.apache.hadoop.registry.client.exceptions.NoRecordException;
-import org.apache.hadoop.registry.client.types.RegistryPathStatus;
-import org.apache.hadoop.registry.client.types.ServiceRecord;
-import org.apache.hadoop.service.CompositeService;
-import org.apache.hadoop.yarn.exceptions.YarnRuntimeException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-
-/**
- * Filesystem-based implementation of RegistryOperations. This class relies
- * entirely on the configured FS for security and does no extra checks.
- */
-public class FSRegistryOperationsService extends CompositeService
- implements RegistryOperations {
-
- private FileSystem fs;
- private static final Logger LOG =
- LoggerFactory.getLogger(FSRegistryOperationsService.class);
- private final RegistryUtils.ServiceRecordMarshal serviceRecordMarshal =
- new RegistryUtils.ServiceRecordMarshal();
-
- public FSRegistryOperationsService() {
- super(FSRegistryOperationsService.class.getName());
- }
-
- @VisibleForTesting
- public FileSystem getFs() {
- return this.fs;
- }
-
- @Override
- protected void serviceInit(Configuration conf) {
- try {
- this.fs = FileSystem.get(conf);
- LOG.info("Initialized Yarn-registry with Filesystem "
- + fs.getClass().getCanonicalName());
- } catch (IOException e) {
- LOG.error("Failed to get FileSystem for registry", e);
- throw new YarnRuntimeException(e);
- }
- }
-
- private Path makePath(String path) {
- return new Path(path);
- }
-
- private Path formatDataPath(String basePath) {
- return Path.mergePaths(new Path(basePath), new Path("/_record"));
- }
-
- private String relativize(String basePath, String childPath) {
- String relative = new File(basePath).toURI()
- .relativize(new File(childPath).toURI()).getPath();
- return relative;
- }
-
- @Override
- public boolean mknode(String path, boolean createParents)
- throws PathNotFoundException, InvalidPathnameException, IOException {
- Path registryPath = makePath(path);
-
- // getFileStatus throws FileNotFound if the path doesn't exist. If the
- // file already exists, return.
- try {
- fs.getFileStatus(registryPath);
- return false;
- } catch (FileNotFoundException e) {
- }
-
- if (createParents) {
- // By default, mkdirs creates any parent dirs it needs
- fs.mkdirs(registryPath);
- } else {
- FileStatus parentStatus = null;
-
- if (registryPath.getParent() != null) {
- parentStatus = fs.getFileStatus(registryPath.getParent());
- }
-
- if (registryPath.getParent() == null || parentStatus.isDirectory()) {
- fs.mkdirs(registryPath);
- } else {
- throw new PathNotFoundException("no parent for " + path);
- }
- }
- return true;
- }
-
- @Override
- public void bind(String path, ServiceRecord record, int flags)
- throws PathNotFoundException, FileAlreadyExistsException,
- InvalidPathnameException, IOException {
-
- // Preserve same overwrite semantics as ZK implementation
- Preconditions.checkArgument(record != null, "null record");
- RegistryTypeUtils.validateServiceRecord(path, record);
-
- Path dataPath = formatDataPath(path);
- Boolean overwrite = ((flags & BindFlags.OVERWRITE) != 0);
- if (fs.exists(dataPath) && !overwrite) {
- throw new FileAlreadyExistsException();
- } else {
- // Either the file doesn't exist, or it exists and we're
- // overwriting. Create overwrites by default and creates parent dirs if
- // needed.
- FSDataOutputStream stream = fs.create(dataPath);
- byte[] bytes = serviceRecordMarshal.toBytes(record);
- stream.write(bytes);
- stream.close();
- LOG.info("Bound record to path " + dataPath);
- }
- }
-
- @Override
- public ServiceRecord resolve(String path) throws PathNotFoundException,
- NoRecordException, InvalidRecordException, IOException {
- // Read the entire file into byte array, should be small metadata
-
- Long size = fs.getFileStatus(formatDataPath(path)).getLen();
- byte[] bytes = new byte[size.intValue()];
-
- FSDataInputStream instream = fs.open(formatDataPath(path));
- int bytesRead = instream.read(bytes);
- instream.close();
-
- if (bytesRead < size) {
- throw new InvalidRecordException(path,
- "Expected " + size + " bytes, but read " + bytesRead);
- }
-
- // Unmarshal, check, and return
- ServiceRecord record = serviceRecordMarshal.fromBytes(path, bytes);
- RegistryTypeUtils.validateServiceRecord(path, record);
- return record;
- }
-
- @Override
- public RegistryPathStatus stat(String path)
- throws PathNotFoundException, InvalidPathnameException, IOException {
- FileStatus fstat = fs.getFileStatus(formatDataPath(path));
- int numChildren = fs.listStatus(makePath(path)).length;
-
- RegistryPathStatus regstat =
- new RegistryPathStatus(fstat.getPath().toString(),
- fstat.getModificationTime(), fstat.getLen(), numChildren);
-
- return regstat;
- }
-
- @Override
- public boolean exists(String path) throws IOException {
- return fs.exists(makePath(path));
- }
-
- @Override
- public List<String> list(String path)
- throws PathNotFoundException, InvalidPathnameException, IOException {
- FileStatus[] statArray = fs.listStatus(makePath(path));
- String basePath = fs.getFileStatus(makePath(path)).getPath().toString();
-
- List<String> paths = new ArrayList<String>();
-
- FileStatus stat;
- // Only count dirs; the _record files are hidden.
- for (int i = 0; i < statArray.length; i++) {
- stat = statArray[i];
- if (stat.isDirectory()) {
- String relativePath = relativize(basePath, stat.getPath().toString());
- paths.add(relativePath);
- }
- }
-
- return paths;
- }
-
- @Override
- public void delete(String path, boolean recursive)
- throws PathNotFoundException, PathIsNotEmptyDirectoryException,
- InvalidPathnameException, IOException {
- Path dirPath = makePath(path);
- if (!fs.exists(dirPath)) {
- throw new PathNotFoundException(path);
- }
-
- // If recursive == true, or dir is empty, delete.
- if (recursive || list(path).isEmpty()) {
- fs.delete(makePath(path), true);
- return;
- }
-
- throw new PathIsNotEmptyDirectoryException(path);
- }
-
- @Override
- public boolean addWriteAccessor(String id, String pass) throws IOException {
- throw new NotImplementedException("Code is not implemented");
- }
-
- @Override
- public void clearWriteAccessors() {
- throw new NotImplementedException("Code is not implemented");
- }
-
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/RegistryOperationsClient.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/RegistryOperationsClient.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/RegistryOperationsClient.java
deleted file mode 100644
index 44cefed..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/RegistryOperationsClient.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.impl;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.registry.client.impl.zk.RegistryBindingSource;
-import org.apache.hadoop.registry.client.impl.zk.RegistryOperationsService;
-
-
-/**
- * This is the client service for applications to work with the registry.
- *
- * It does not set up the root paths for the registry, is bonded
- * to a user, and can be set to use SASL, anonymous or id:pass auth.
- *
- * For SASL, the client must be operating in the context of an authed user.
- *
- * For id:pass the client must have the relevant id and password, SASL is
- * not used even if the client has credentials.
- *
- * For anonymous, nothing is used.
- *
- * Any SASL-authed client also has the ability to add one or more authentication
- * id:pass pair on all future writes, and to reset them later.
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public class RegistryOperationsClient extends RegistryOperationsService {
-
- public RegistryOperationsClient(String name) {
- super(name);
- }
-
- public RegistryOperationsClient(String name,
- RegistryBindingSource bindingSource) {
- super(name, bindingSource);
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/package-info.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/package-info.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/package-info.java
deleted file mode 100644
index d85b6a7..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/package-info.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-/**
- * Registry client services
- * <p>
- * These are classes which follow the YARN lifecycle and which implement
- * the {@link org.apache.hadoop.registry.client.api.RegistryOperations}
- * API.
- */
-package org.apache.hadoop.registry.client.impl;
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/BindingInformation.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/BindingInformation.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/BindingInformation.java
deleted file mode 100644
index 8ae003d..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/BindingInformation.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.impl.zk;
-
-import org.apache.curator.ensemble.EnsembleProvider;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-
-/**
- * Binding information provided by a {@link RegistryBindingSource}
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public class BindingInformation {
-
- /**
- * The Curator Ensemble Provider
- */
- public EnsembleProvider ensembleProvider;
-
- /**
- * Any information that may be useful for diagnostics
- */
- public String description;
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/CuratorService.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/CuratorService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/CuratorService.java
deleted file mode 100644
index 2eb7aa5..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/CuratorService.java
+++ /dev/null
@@ -1,896 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.impl.zk;
-
-import com.google.common.annotations.VisibleForTesting;
-import com.google.common.base.Preconditions;
-import org.apache.curator.ensemble.EnsembleProvider;
-import org.apache.curator.ensemble.fixed.FixedEnsembleProvider;
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.framework.api.BackgroundCallback;
-import org.apache.curator.framework.api.CreateBuilder;
-import org.apache.curator.framework.api.DeleteBuilder;
-import org.apache.curator.framework.api.GetChildrenBuilder;
-import org.apache.curator.framework.recipes.cache.TreeCache;
-import org.apache.curator.framework.recipes.cache.TreeCacheEvent;
-import org.apache.curator.framework.recipes.cache.TreeCacheListener;
-import org.apache.curator.retry.BoundedExponentialBackoffRetry;
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-import org.apache.hadoop.conf.Configuration;
-import org.apache.hadoop.fs.FileAlreadyExistsException;
-import org.apache.hadoop.fs.PathIsNotEmptyDirectoryException;
-import org.apache.hadoop.fs.PathNotFoundException;
-import org.apache.hadoop.io.IOUtils;
-import org.apache.hadoop.registry.client.api.RegistryConstants;
-import org.apache.hadoop.registry.client.binding.RegistryPathUtils;
-import org.apache.hadoop.registry.client.exceptions.AuthenticationFailedException;
-import org.apache.hadoop.registry.client.exceptions.NoChildrenForEphemeralsException;
-import org.apache.hadoop.registry.client.exceptions.NoPathPermissionsException;
-import org.apache.hadoop.registry.client.exceptions.RegistryIOException;
-import org.apache.hadoop.service.CompositeService;
-import org.apache.hadoop.service.ServiceStateException;
-import org.apache.zookeeper.CreateMode;
-import org.apache.zookeeper.KeeperException;
-import org.apache.zookeeper.ZooDefs;
-import org.apache.zookeeper.data.ACL;
-import org.apache.zookeeper.data.Stat;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.IOException;
-import java.util.List;
-
-/**
- * This service binds to Zookeeper via Apache Curator. It is more
- * generic than just the YARN service registry; it does not implement
- * any of the Registry Operations API.
- */
-@InterfaceAudience.Private
-@InterfaceStability.Evolving
-public class CuratorService extends CompositeService
- implements RegistryConstants, RegistryBindingSource {
-
- private static final Logger LOG =
- LoggerFactory.getLogger(CuratorService.class);
-
- /**
- * the Curator binding.
- */
- private CuratorFramework curator;
-
- /**
- * Path to the registry root.
- */
- private String registryRoot;
-
- /**
- * Supplied binding source. This defaults to being this
- * service itself.
- */
- private final RegistryBindingSource bindingSource;
-
- /**
- * Security service.
- */
- private RegistrySecurity registrySecurity;
-
- /**
- * the connection binding text for messages.
- */
- private String connectionDescription;
-
- /**
- * Security connection diagnostics.
- */
- private String securityConnectionDiagnostics = "";
-
- /**
- * Provider of curator "ensemble"; offers a basis for
- * more flexible bonding in future.
- */
- private EnsembleProvider ensembleProvider;
-
- /**
- * Registry tree cache.
- */
- private TreeCache treeCache;
-
- /**
- * Construct the service.
- *
- * @param name service name
- * @param bindingSource source of binding information.
- * If null: use this instance
- */
- public CuratorService(String name, RegistryBindingSource bindingSource) {
- super(name);
- if (bindingSource != null) {
- this.bindingSource = bindingSource;
- } else {
- this.bindingSource = this;
- }
- registrySecurity = new RegistrySecurity("registry security");
- }
-
- /**
- * Create an instance using this service as the binding source (i.e. read
- * configuration options from the registry).
- *
- * @param name service name
- */
- public CuratorService(String name) {
- this(name, null);
- }
-
- /**
- * Init the service.
- * This is where the security bindings are set up.
- *
- * @param conf configuration of the service
- * @throws Exception
- */
- @Override
- protected void serviceInit(Configuration conf) throws Exception {
-
- registryRoot = conf.getTrimmed(KEY_REGISTRY_ZK_ROOT,
- DEFAULT_ZK_REGISTRY_ROOT);
-
- // add the registy service
- addService(registrySecurity);
-
- if (LOG.isDebugEnabled()) {
- LOG.debug("Creating Registry with root {}", registryRoot);
- }
-
- super.serviceInit(conf);
- }
-
- public void setKerberosPrincipalAndKeytab(String principal, String keytab) {
- registrySecurity.setKerberosPrincipalAndKeytab(principal, keytab);
- }
-
- /**
- * Start the service.
- * This is where the curator instance is started.
- *
- * @throws Exception
- */
- @Override
- protected void serviceStart() throws Exception {
- super.serviceStart();
-
- // create the curator; rely on the registry security code
- // to set up the JVM context and curator
- curator = createCurator();
- }
-
- /**
- * Close the ZK connection if it is open.
- */
- @Override
- protected void serviceStop() throws Exception {
- IOUtils.closeStream(curator);
-
- if (treeCache != null) {
- treeCache.close();
- }
- super.serviceStop();
- }
-
- /**
- * Internal check that a service is in the live state.
- *
- * @throws ServiceStateException if not
- */
- private void checkServiceLive() throws ServiceStateException {
- if (!isInState(STATE.STARTED)) {
- throw new ServiceStateException(
- "Service " + getName() + " is in wrong state: "
- + getServiceState());
- }
- }
-
- /**
- * Flag to indicate whether or not the registry is secure.
- * Valid once the service is inited.
- *
- * @return service security policy
- */
- public boolean isSecure() {
- return registrySecurity.isSecureRegistry();
- }
-
- /**
- * Get the registry security helper.
- *
- * @return the registry security helper
- */
- protected RegistrySecurity getRegistrySecurity() {
- return registrySecurity;
- }
-
- /**
- * Build the security diagnostics string.
- *
- * @return a string for diagnostics
- */
- protected String buildSecurityDiagnostics() {
- // build up the security connection diags
- if (!isSecure()) {
- return "security disabled";
- } else {
- StringBuilder builder = new StringBuilder();
- builder.append("secure cluster; ");
- builder.append(registrySecurity.buildSecurityDiagnostics());
- return builder.toString();
- }
- }
-
- /**
- * Create a new curator instance off the root path; using configuration
- * options provided in the service configuration to set timeouts and
- * retry policy.
- *
- * @return the newly created creator
- */
- private CuratorFramework createCurator() throws IOException {
- Configuration conf = getConfig();
- createEnsembleProvider();
- int sessionTimeout = conf.getInt(KEY_REGISTRY_ZK_SESSION_TIMEOUT,
- DEFAULT_ZK_SESSION_TIMEOUT);
- int connectionTimeout = conf.getInt(KEY_REGISTRY_ZK_CONNECTION_TIMEOUT,
- DEFAULT_ZK_CONNECTION_TIMEOUT);
- int retryTimes = conf.getInt(KEY_REGISTRY_ZK_RETRY_TIMES,
- DEFAULT_ZK_RETRY_TIMES);
- int retryInterval = conf.getInt(KEY_REGISTRY_ZK_RETRY_INTERVAL,
- DEFAULT_ZK_RETRY_INTERVAL);
- int retryCeiling = conf.getInt(KEY_REGISTRY_ZK_RETRY_CEILING,
- DEFAULT_ZK_RETRY_CEILING);
-
- LOG.info("Creating CuratorService with connection {}",
- connectionDescription);
-
- CuratorFramework framework;
-
- synchronized (CuratorService.class) {
- // set the security options
-
- // build up the curator itself
- CuratorFrameworkFactory.Builder builder =
- CuratorFrameworkFactory.builder();
- builder.ensembleProvider(ensembleProvider)
- .connectionTimeoutMs(connectionTimeout)
- .sessionTimeoutMs(sessionTimeout)
-
- .retryPolicy(new BoundedExponentialBackoffRetry(retryInterval,
- retryCeiling,
- retryTimes));
-
- // set up the builder AND any JVM context
- registrySecurity.applySecurityEnvironment(builder);
- //log them
- securityConnectionDiagnostics = buildSecurityDiagnostics();
- if (LOG.isDebugEnabled()) {
- LOG.debug(securityConnectionDiagnostics);
- }
- framework = builder.build();
- framework.start();
- }
-
- return framework;
- }
-
- @Override
- public String toString() {
- return super.toString()
- + " " + bindingDiagnosticDetails();
- }
-
- /**
- * Get the binding diagnostics.
- *
- * @return a diagnostics string valid after the service is started.
- */
- public String bindingDiagnosticDetails() {
- return " Connection=\"" + connectionDescription + "\""
- + " root=\"" + registryRoot + "\""
- + " " + securityConnectionDiagnostics;
- }
-
- /**
- * Create a full path from the registry root and the supplied subdir.
- *
- * @param path path of operation
- * @return an absolute path
- * @throws IllegalArgumentException if the path is invalide
- */
- protected String createFullPath(String path) throws IOException {
- return RegistryPathUtils.createFullPath(registryRoot, path);
- }
-
- /**
- * Get the registry binding source ... this can be used to
- * create new ensemble providers
- *
- * @return the registry binding source in use
- */
- public RegistryBindingSource getBindingSource() {
- return bindingSource;
- }
-
- /**
- * Create the ensemble provider for this registry, by invoking
- * {@link RegistryBindingSource#supplyBindingInformation()} on
- * the provider stored in {@link #bindingSource}.
- * Sets {@link #ensembleProvider} to that value;
- * sets {@link #connectionDescription} to the binding info
- * for use in toString and logging;
- */
- protected void createEnsembleProvider() {
- BindingInformation binding = bindingSource.supplyBindingInformation();
- connectionDescription = binding.description
- + " " + securityConnectionDiagnostics;
- ensembleProvider = binding.ensembleProvider;
- }
-
- /**
- * Supply the binding information.
- * This implementation returns a fixed ensemble bonded to
- * the quorum supplied by {@link #buildConnectionString()}.
- *
- * @return the binding information
- */
- @Override
- public BindingInformation supplyBindingInformation() {
- BindingInformation binding = new BindingInformation();
- String connectString = buildConnectionString();
- binding.ensembleProvider = new FixedEnsembleProvider(connectString);
- binding.description =
- "fixed ZK quorum \"" + connectString + "\"";
- return binding;
- }
-
- /**
- * Override point: get the connection string used to connect to
- * the ZK service.
- *
- * @return a registry quorum
- */
- protected String buildConnectionString() {
- return getConfig().getTrimmed(KEY_REGISTRY_ZK_QUORUM,
- DEFAULT_REGISTRY_ZK_QUORUM);
- }
-
- /**
- * 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) {
- return operationFailure(path, operation, exception, null);
- }
-
- /**
- * 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;
- }
-
- /**
- * Create a path if it does not exist.
- * The check is poll + create; there's a risk that another process
- * may create the same path before the create() operation is executed/
- * propagated to the ZK node polled.
- *
- * @param path path to create
- * @param acl ACL for path -used when creating a new entry
- * @param createParents flag to trigger parent creation
- * @return true iff the path was created
- * @throws IOException
- */
- @VisibleForTesting
- public boolean maybeCreate(String path,
- CreateMode mode,
- List<ACL> acl,
- boolean createParents) throws IOException {
- return zkMkPath(path, mode, createParents, acl);
- }
-
- /**
- * Stat the file.
- *
- * @param path path of operation
- * @return a curator stat entry
- * @throws IOException on a failure
- * @throws PathNotFoundException if the path was not found
- */
- public Stat zkStat(String path) throws IOException {
- checkServiceLive();
- String fullpath = createFullPath(path);
- Stat stat;
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Stat {}", fullpath);
- }
- stat = curator.checkExists().forPath(fullpath);
- } catch (Exception e) {
- throw operationFailure(fullpath, "read()", e);
- }
- if (stat == null) {
- throw new PathNotFoundException(path);
- }
- return stat;
- }
-
- /**
- * Get the ACLs of a path.
- *
- * @param path path of operation
- * @return a possibly empty list of ACLs
- * @throws IOException
- */
- public List<ACL> zkGetACLS(String path) throws IOException {
- checkServiceLive();
- String fullpath = createFullPath(path);
- List<ACL> acls;
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("GetACLS {}", fullpath);
- }
- acls = curator.getACL().forPath(fullpath);
- } catch (Exception e) {
- throw operationFailure(fullpath, "read()", e);
- }
- if (acls == null) {
- throw new PathNotFoundException(path);
- }
- return acls;
- }
-
- /**
- * Probe for a path existing.
- *
- * @param path path of operation
- * @return true if the path was visible from the ZK server
- * queried.
- * @throws IOException on any exception other than
- * {@link PathNotFoundException}
- */
- public boolean zkPathExists(String path) throws IOException {
- checkServiceLive();
- try {
- // if zkStat(path) returns without throwing an exception, the return value
- // is guaranteed to be not null
- zkStat(path);
- return true;
- } catch (PathNotFoundException e) {
- return false;
- } catch (IOException e) {
- throw e;
- }
- }
-
- /**
- * Verify a path exists.
- *
- * @param path path of operation
- * @throws PathNotFoundException if the path is absent
- * @throws IOException
- */
- public String zkPathMustExist(String path) throws IOException {
- zkStat(path);
- return path;
- }
-
- /**
- * Create a directory. It is not an error if it already exists.
- *
- * @param path path to create
- * @param mode mode for path
- * @param createParents flag to trigger parent creation
- * @param acls ACL for path
- * @throws IOException any problem
- */
- public boolean zkMkPath(String path,
- CreateMode mode,
- boolean createParents,
- List<ACL> acls)
- throws IOException {
- checkServiceLive();
- path = createFullPath(path);
- if (acls == null || acls.isEmpty()) {
- throw new NoPathPermissionsException(path, "Empty ACL list");
- }
-
- try {
- RegistrySecurity.AclListInfo aclInfo =
- new RegistrySecurity.AclListInfo(acls);
- if (LOG.isDebugEnabled()) {
- LOG.debug("Creating path {} with mode {} and ACL {}",
- path, mode, aclInfo);
- }
- CreateBuilder createBuilder = curator.create();
- createBuilder.withMode(mode).withACL(acls);
- if (createParents) {
- createBuilder.creatingParentsIfNeeded();
- }
- createBuilder.forPath(path);
-
- } catch (KeeperException.NodeExistsException e) {
- if (LOG.isDebugEnabled()) {
- LOG.debug("path already present: {}", path, e);
- }
- return false;
- } catch (Exception e) {
- throw operationFailure(path, "mkdir() ", e, acls);
- }
- return true;
- }
-
- /**
- * Recursively make a path.
- *
- * @param path path to create
- * @param acl ACL for path
- * @throws IOException any problem
- */
- public void zkMkParentPath(String path,
- List<ACL> acl) throws
- IOException {
- // split path into elements
-
- zkMkPath(RegistryPathUtils.parentOf(path),
- CreateMode.PERSISTENT, true, acl);
- }
-
- /**
- * Create a path with given data. byte[0] is used for a path
- * without data.
- *
- * @param path path of operation
- * @param data initial data
- * @param acls
- * @throws IOException
- */
- public void zkCreate(String path,
- CreateMode mode,
- byte[] data,
- List<ACL> acls) throws IOException {
- Preconditions.checkArgument(data != null, "null data");
- checkServiceLive();
- String fullpath = createFullPath(path);
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Creating {} with {} bytes of data and ACL {}",
- fullpath, data.length,
- new RegistrySecurity.AclListInfo(acls));
- }
- curator.create().withMode(mode).withACL(acls).forPath(fullpath, data);
- } catch (Exception e) {
- throw operationFailure(fullpath, "create()", e, acls);
- }
- }
-
- /**
- * Update the data for a path.
- *
- * @param path path of operation
- * @param data new data
- * @throws IOException
- */
- public void zkUpdate(String path, byte[] data) throws IOException {
- Preconditions.checkArgument(data != null, "null data");
- checkServiceLive();
- path = createFullPath(path);
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Updating {} with {} bytes", path, data.length);
- }
- curator.setData().forPath(path, data);
- } catch (Exception e) {
- throw operationFailure(path, "update()", e);
- }
- }
-
- /**
- * Create or update an entry.
- *
- * @param path path
- * @param data data
- * @param acl ACL for path -used when creating a new entry
- * @param overwrite enable overwrite
- * @return true if the entry was created, false if it was simply updated.
- * @throws IOException
- */
- public boolean zkSet(String path,
- CreateMode mode,
- byte[] data,
- List<ACL> acl, boolean overwrite) throws IOException {
- Preconditions.checkArgument(data != null, "null data");
- checkServiceLive();
- if (!zkPathExists(path)) {
- zkCreate(path, mode, data, acl);
- return true;
- } else {
- if (overwrite) {
- zkUpdate(path, data);
- return false;
- } else {
- throw new FileAlreadyExistsException(path);
- }
- }
- }
-
- /**
- * Delete a directory/directory tree.
- * It is not an error to delete a path that does not exist.
- *
- * @param path path of operation
- * @param recursive flag to trigger recursive deletion
- * @param backgroundCallback callback; this being set converts the operation
- * into an async/background operation.
- * task
- * @throws IOException on problems other than no-such-path
- */
- public void zkDelete(String path,
- boolean recursive,
- BackgroundCallback backgroundCallback) throws IOException {
- checkServiceLive();
- String fullpath = createFullPath(path);
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Deleting {}", fullpath);
- }
- DeleteBuilder delete = curator.delete();
- if (recursive) {
- delete.deletingChildrenIfNeeded();
- }
- if (backgroundCallback != null) {
- delete.inBackground(backgroundCallback);
- }
- delete.forPath(fullpath);
- } catch (KeeperException.NoNodeException e) {
- // not an error
- } catch (Exception e) {
- throw operationFailure(fullpath, "delete()", e);
- }
- }
-
- /**
- * List all children of a path.
- *
- * @param path path of operation
- * @return a possibly empty list of children
- * @throws IOException
- */
- public List<String> zkList(String path) throws IOException {
- checkServiceLive();
- String fullpath = createFullPath(path);
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("ls {}", fullpath);
- }
- GetChildrenBuilder builder = curator.getChildren();
- List<String> children = builder.forPath(fullpath);
- return children;
- } catch (Exception e) {
- throw operationFailure(path, "ls()", e);
- }
- }
-
- /**
- * Read data on a path.
- *
- * @param path path of operation
- * @return the data
- * @throws IOException read failure
- */
- public byte[] zkRead(String path) throws IOException {
- checkServiceLive();
- String fullpath = createFullPath(path);
- try {
- if (LOG.isDebugEnabled()) {
- LOG.debug("Reading {}", fullpath);
- }
- return curator.getData().forPath(fullpath);
- } catch (Exception e) {
- throw operationFailure(fullpath, "read()", e);
- }
- }
-
- /**
- * Return a path dumper instance which can do a full dump
- * of the registry tree in its <code>toString()</code>
- * operation.
- *
- * @param verbose verbose flag - includes more details (such as ACLs)
- * @return a class to dump the registry
- */
- public ZKPathDumper dumpPath(boolean verbose) {
- return new ZKPathDumper(curator, registryRoot, verbose);
- }
-
- /**
- * Add a new write access entry for all future write operations.
- *
- * @param id ID to use
- * @param pass password
- * @throws IOException on any failure to build the digest
- */
- public boolean addWriteAccessor(String id, String pass) throws IOException {
- RegistrySecurity security = getRegistrySecurity();
- ACL digestACL = new ACL(ZooDefs.Perms.ALL,
- security.toDigestId(security.digest(id, pass)));
- return security.addDigestACL(digestACL);
- }
-
- /**
- * Clear all write accessors.
- */
- public void clearWriteAccessors() {
- getRegistrySecurity().resetDigestACLs();
- }
-
- /**
- * Diagnostics method to dump a registry robustly.
- * Any exception raised is swallowed.
- *
- * @param verbose verbose path dump
- * @return the registry tree
- */
- protected String dumpRegistryRobustly(boolean verbose) {
- try {
- ZKPathDumper pathDumper = dumpPath(verbose);
- return pathDumper.toString();
- } catch (Exception e) {
- // ignore
- LOG.debug("Ignoring exception: {}", e);
- }
- return "";
- }
-
- /**
- * Registers a listener to path related events.
- *
- * @param listener the listener.
- * @return a handle allowing for the management of the listener.
- * @throws Exception if registration fails due to error.
- */
- public ListenerHandle registerPathListener(final PathListener listener)
- throws Exception {
-
- final TreeCacheListener pathChildrenCacheListener =
- new TreeCacheListener() {
-
- public void childEvent(CuratorFramework curatorFramework,
- TreeCacheEvent event)
- throws Exception {
- String path = null;
- if (event != null && event.getData() != null) {
- path = event.getData().getPath();
- }
- assert event != null;
- switch (event.getType()) {
- case NODE_ADDED:
- LOG.info("Informing listener of added node {}", path);
- listener.nodeAdded(path);
-
- break;
-
- case NODE_REMOVED:
- LOG.info("Informing listener of removed node {}", path);
- listener.nodeRemoved(path);
-
- break;
-
- case NODE_UPDATED:
- LOG.info("Informing listener of updated node {}", path);
- listener.nodeAdded(path);
-
- break;
-
- default:
- // do nothing
- break;
-
- }
- }
- };
- treeCache.getListenable().addListener(pathChildrenCacheListener);
-
- return new ListenerHandle() {
- @Override
- public void remove() {
- treeCache.getListenable().removeListener(pathChildrenCacheListener);
- }
- };
-
- }
-
- // TODO: should caches be stopped and then restarted if need be?
-
- /**
- * Create the tree cache that monitors the registry for node addition, update,
- * and deletion.
- *
- * @throws Exception if any issue arises during monitoring.
- */
- public void monitorRegistryEntries()
- throws Exception {
- String registryPath =
- getConfig().get(RegistryConstants.KEY_REGISTRY_ZK_ROOT,
- RegistryConstants.DEFAULT_ZK_REGISTRY_ROOT);
- treeCache = new TreeCache(curator, registryPath);
- treeCache.start();
- }
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ListenerHandle.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ListenerHandle.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ListenerHandle.java
deleted file mode 100644
index e43dbbe..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ListenerHandle.java
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.registry.client.impl.zk;
-
-/**
- *
- */
-public interface ListenerHandle {
- void remove();
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/PathListener.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/PathListener.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/PathListener.java
deleted file mode 100644
index db1e509..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/PathListener.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.hadoop.registry.client.impl.zk;
-
-import java.io.IOException;
-
-/**
- *
- */
-public interface PathListener {
-
- void nodeAdded(String path) throws IOException;
-
- void nodeRemoved(String path) throws IOException;
-}
http://git-wip-us.apache.org/repos/asf/hadoop/blob/e2a9fa84/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryBindingSource.java
----------------------------------------------------------------------
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryBindingSource.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryBindingSource.java
deleted file mode 100644
index bab4742..0000000
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryBindingSource.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.hadoop.registry.client.impl.zk;
-
-import org.apache.hadoop.classification.InterfaceAudience;
-import org.apache.hadoop.classification.InterfaceStability;
-
-/**
- * Interface which can be implemented by a registry binding source
- */
-@InterfaceAudience.Public
-@InterfaceStability.Evolving
-public interface RegistryBindingSource {
-
- /**
- * Supply the binding information for this registry
- * @return the binding information data
- */
- BindingInformation supplyBindingInformation();
-}
---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org