diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/cli/RegistryCli.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/cli/RegistryCli.java
index 480ce0ed5fb20..0f6ad94719634 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/cli/RegistryCli.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/cli/RegistryCli.java
@@ -121,7 +121,7 @@ public static void main(String[] args) throws Exception {
* After this call is made, no operations may be made of this
* object, or of a YARN registry instance used when constructing
* this object.
- * @throws IOException
+ * @throws IOException IO problems
*/
@Override
public void close() throws IOException {
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/BindFlags.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/BindFlags.java
index 5fd2aef5b5845..6e5c61435cafa 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/BindFlags.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/BindFlags.java
@@ -29,7 +29,7 @@
public interface BindFlags {
/**
- * Create the entry.. This is just "0" and can be "or"ed with anything
+ * Create the entry.. This is just "0" and can be "or"ed with anything.
*/
int CREATE = 0;
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryConstants.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryConstants.java
index a6fe216ec91ff..b726c972e2d0e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryConstants.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryConstants.java
@@ -32,12 +32,12 @@ public interface RegistryConstants {
/**
* prefix for registry configuration options: {@value}.
* Why hadoop. and not YARN? It can
- * live outside YARN
+ * live outside YARN.
*/
String REGISTRY_PREFIX = "hadoop.registry.";
/**
- * Prefix for zookeeper-specific options: {@value}
+ * Prefix for zookeeper-specific options: {@value}.
*
* For clients using other protocols, these options are not supported.
*/
@@ -45,12 +45,12 @@ public interface RegistryConstants {
/**
* flag to indicate whether or not the registry should
- * be enabled in the RM: {@value}
+ * be enabled in the RM: {@value}.
*/
String KEY_REGISTRY_ENABLED = REGISTRY_PREFIX + "rm.enabled";
/**
- * Defaut value for enabling the registry in the RM: {@value}
+ * Default value for enabling the registry in the RM: {@value}.
*/
boolean DEFAULT_REGISTRY_ENABLED = false;
@@ -69,12 +69,12 @@ public interface RegistryConstants {
boolean DEFAULT_REGISTRY_SECURE = false;
/**
- * Root path in the ZK tree for the registry: {@value}
+ * Root path in the ZK tree for the registry: {@value}.
*/
String KEY_REGISTRY_ZK_ROOT = ZK_PREFIX + "root";
/**
- * Default root of the yarn registry: {@value}
+ * Default root of the yarn registry: {@value}.
*/
String DEFAULT_ZK_REGISTRY_ROOT = "/registry";
@@ -92,7 +92,7 @@ public interface RegistryConstants {
/**
* Registry client uses Kerberos: authentication is automatic from
- * logged in user
+ * logged in user.
*/
String REGISTRY_CLIENT_AUTH_KERBEROS = "kerberos";
@@ -104,12 +104,12 @@ public interface RegistryConstants {
String REGISTRY_CLIENT_AUTH_DIGEST = "digest";
/**
- * No authentication; client is anonymous
+ * No authentication; client is anonymous.
*/
String REGISTRY_CLIENT_AUTH_ANONYMOUS = "";
/**
- * Registry client authentication ID
+ * Registry client authentication ID.
*
* This is only used in secure clusters with
* {@link #KEY_REGISTRY_CLIENT_AUTH} set to
@@ -134,24 +134,24 @@ public interface RegistryConstants {
/**
* List of hostname:port pairs defining the
- * zookeeper quorum binding for the registry {@value}
+ * zookeeper quorum binding for the registry {@value}.
*/
String KEY_REGISTRY_ZK_QUORUM = ZK_PREFIX + "quorum";
/**
- * The default zookeeper quorum binding for the registry: {@value}
+ * The default zookeeper quorum binding for the registry: {@value}.
*/
String DEFAULT_REGISTRY_ZK_QUORUM = "localhost:2181";
/**
- * Zookeeper session timeout in milliseconds: {@value}
+ * Zookeeper session timeout in milliseconds: {@value}.
*/
String KEY_REGISTRY_ZK_SESSION_TIMEOUT =
ZK_PREFIX + "session.timeout.ms";
/**
- * The default ZK session timeout: {@value}.
- */
+ * The default ZK session timeout: {@value}.
+ */
int DEFAULT_ZK_SESSION_TIMEOUT = 60000;
/**
@@ -224,9 +224,9 @@ public interface RegistryConstants {
/**
* A comma separated list of Zookeeper ACL identifiers with
- * system access to the registry in a secure cluster: {@value}.
+ * user access to the registry in a secure cluster: {@value}.
*
- * These are given full access to all entries.
+ * These are given full access to entries under the user account.
*
* If there is an "@" at the end of an entry it
* instructs the registry client to append the default kerberos domain.
@@ -259,7 +259,7 @@ public interface RegistryConstants {
String KEY_REGISTRY_CLIENT_JAAS_CONTEXT = REGISTRY_PREFIX + "jaas.context";
/**
- * default client-side registry JAAS context: {@value}
+ * default client-side registry JAAS context: {@value}.
*/
String DEFAULT_REGISTRY_CLIENT_JAAS_CONTEXT = "Client";
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryOperations.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryOperations.java
index c51bcf7465d7e..1cbfaeb7a6332 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryOperations.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryOperations.java
@@ -34,7 +34,7 @@
import java.util.List;
/**
- * Registry Operations
+ * Registry Operations.
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
@@ -63,7 +63,7 @@ boolean mknode(String path, boolean createParents)
IOException;
/**
- * Bind a path in the registry to a service record
+ * Bind a path in the registry to a service record.
* @param path path to service record
* @param record service record service record to create/update
* @param flags bind flags
@@ -80,7 +80,7 @@ void bind(String path, ServiceRecord record, int flags)
IOException;
/**
- * Resolve the record at a path
+ * Resolve the record at a path.
* @param path path to an entry containing a {@link ServiceRecord}
* @return the record
* @throws PathNotFoundException path is not in the registry.
@@ -97,7 +97,7 @@ ServiceRecord resolve(String path)
IOException;
/**
- * Get the status of a path
+ * Get the status of a path.
* @param path path to query
* @return the status of the path
* @throws PathNotFoundException path is not in the registry.
@@ -115,7 +115,7 @@ RegistryPathStatus stat(String path)
* any failure downgraded to a
* @param path path to query
* @return true if the path was found
- * @throws IOException
+ * @throws IOException IO problems
*/
boolean exists(String path) throws IOException;
@@ -125,9 +125,9 @@ RegistryPathStatus stat(String path)
* @param path path to query
* @return a possibly empty list of the short path names of
* child entries.
- * @throws PathNotFoundException
- * @throws InvalidPathnameException
- * @throws IOException
+ * @throws PathNotFoundException path is not in the registry.
+ * @throws InvalidPathnameException the path is invalid.
+ * @throws IOException IO problems
*/
List list(String path) throws
PathNotFoundException,
@@ -178,5 +178,5 @@ void delete(String path, boolean recursive)
* Only accessors added via {@link #addWriteAccessor(String, String)}
* are removed.
*/
- public void clearWriteAccessors();
+ void clearWriteAccessors();
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryOperationsFactory.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryOperationsFactory.java
index 443654df37eb9..bd7756a5f679b 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryOperationsFactory.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/api/RegistryOperationsFactory.java
@@ -32,7 +32,7 @@
* Each created instance will be returned initialized.
*
* That is, the service will have had Service.init(conf) applied
- * to it —possibly after the configuration has been modified to
+ * to it, possibly after the configuration has been modified to
* support the specific binding/security mechanism used
*/
public final class RegistryOperationsFactory {
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/JsonSerDeser.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/JsonSerDeser.java
index eddff20e3498a..11a855697aba9 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/JsonSerDeser.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/JsonSerDeser.java
@@ -54,7 +54,7 @@
* which use the mapper
* @param Type to marshal.
*/
-@InterfaceAudience.Private()
+@InterfaceAudience.Private
@InterfaceStability.Evolving
public class JsonSerDeser {
@@ -69,7 +69,7 @@ public class JsonSerDeser {
private final ObjectMapper mapper;
/**
- * Create an instance bound to a specific type
+ * Create an instance bound to a specific type.
* @param classType class to marshall
*/
public JsonSerDeser(Class classType) {
@@ -88,7 +88,7 @@ public String getName() {
}
/**
- * Convert from JSON
+ * Convert from JSON.
*
* @param json input
* @return the parsed JSON
@@ -108,7 +108,7 @@ public synchronized T fromJson(String json)
}
/**
- * Convert from a JSON file
+ * Convert from a JSON file.
* @param jsonFile input file
* @return the parsed JSON
* @throws IOException IO problems
@@ -121,13 +121,13 @@ public synchronized T fromFile(File jsonFile)
try {
return mapper.readValue(jsonFile, classType);
} catch (IOException e) {
- LOG.error("Exception while parsing json file {}: {}", jsonFile, e);
+ LOG.error("Exception while parsing json file {}", jsonFile, e);
throw e;
}
}
/**
- * Convert from a JSON file
+ * Convert from a JSON file.
* @param resource input file
* @return the parsed JSON
* @throws IOException IO problems
@@ -164,7 +164,7 @@ public T fromInstance(T instance) throws IOException {
}
/**
- * Load from a Hadoop filesystem
+ * Load from a Hadoop filesystem.
* @param fs filesystem
* @param path path
* @return a loaded CD
@@ -187,7 +187,7 @@ public T load(FileSystem fs, Path path)
}
/**
- * Save a cluster description to a hadoop filesystem
+ * Save a cluster description to a hadoop filesystem.
* @param fs filesystem
* @param path path
* @param overwrite should any existing file be overwritten
@@ -201,8 +201,8 @@ public void save(FileSystem fs, Path path, T instance,
}
/**
- * Write the json as bytes -then close the file
- * @param dataOutputStream an outout stream that will always be closed
+ * Write the json as bytes -then close the file.
+ * @param dataOutputStream an output stream that will always be closed
* @throws IOException on any failure
*/
private void writeJsonAsBytes(T instance,
@@ -216,10 +216,10 @@ private void writeJsonAsBytes(T instance,
}
/**
- * Convert JSON To bytes
+ * Convert JSON To bytes.
* @param instance instance to convert
* @return a byte array
- * @throws IOException
+ * @throws IOException any problem serializing the instance.
*/
public byte[] toBytes(T instance) throws IOException {
String json = toJson(instance);
@@ -227,9 +227,10 @@ public byte[] toBytes(T instance) throws IOException {
}
/**
- * Deserialize from a byte array
+ * Deserialize from a byte array.
* @param path path the data came from
* @param bytes byte array
+ * @return the deserialized instance
* @throws IOException all problems
* @throws EOFException not enough data
* @throws InvalidRecordException if the parsing failed -the record is invalid
@@ -279,7 +280,7 @@ public T fromBytes(String path, byte[] bytes, String marker)
}
/**
- * Convert an instance to a JSON string
+ * Convert an instance to a JSON string.
* @param instance instance to convert
* @return a JSON string description
* @throws JsonProcessingException Json generation problems
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryPathUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryPathUtils.java
index 5d8ea3f5b15c6..849e394117b6d 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryPathUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryPathUtils.java
@@ -40,14 +40,14 @@
public class RegistryPathUtils {
/**
- * Compiled down pattern to validate single entries in the path
+ * Compiled down pattern to validate single entries in the path.
*/
private static final Pattern PATH_ENTRY_VALIDATION_PATTERN =
Pattern.compile(RegistryInternalConstants.VALID_PATH_ENTRY_PATTERN);
/**
* Validate ZK path with the path itself included in
- * the exception text
+ * the exception text.
* @param path path to validate
* @return the path parameter
* @throws InvalidPathnameException if the pathname is invalid.
@@ -83,7 +83,8 @@ public static String validateElementsAsDNS(String path) throws
}
/**
- * Create a full path from the registry root and the supplied subdir
+ * Create a full path from the registry root and the supplied subdir.
+ * @param base root of the registry
* @param path path of operation
* @return an absolute path
* @throws InvalidPathnameException if the path is invalid
@@ -99,7 +100,7 @@ public static String createFullPath(String base, String path) throws
* Join two paths, guaranteeing that there will not be exactly
* one separator between the two, and exactly one at the front
* of the path. There will be no trailing "/" except for the special
- * case that this is the root path
+ * case that this is the root path.
* @param base base path
* @param path second path to add
* @return a combined path.
@@ -138,14 +139,14 @@ public static String join(String base, String path) {
}
/**
- * split a path into elements, stripping empty elements
+ * split a path into elements, stripping empty elements.
* @param path the path
* @return the split path
*/
public static List split(String path) {
//
String[] pathelements = path.split("/");
- List dirs = new ArrayList(pathelements.length);
+ List dirs = new ArrayList<>(pathelements.length);
for (String pathelement : pathelements) {
if (!pathelement.isEmpty()) {
dirs.add(pathelement);
@@ -172,7 +173,7 @@ public static String lastPathEntry(String path) {
}
/**
- * Get the parent of a path
+ * Get the parent of a path.
* @param path path to look at
* @return the parent path
* @throws PathNotFoundException if the path was at root.
@@ -198,7 +199,7 @@ public static String parentOf(String path) throws PathNotFoundException {
/**
* Perform any formatting for the registry needed to convert
- * non-simple-DNS elements
+ * non-simple-DNS elements.
* @param element element to encode
* @return an encoded string
*/
@@ -208,7 +209,7 @@ public static String encodeForRegistry(String element) {
/**
* Perform whatever transforms are needed to get a YARN ID into
- * a DNS-compatible name
+ * a DNS-compatible name.
* @param yarnId ID as string of YARN application, instance or container
* @return a string suitable for use in registry paths.
*/
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java
index ec59d5985a044..8cd18d5616c91 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/binding/RegistryTypeUtils.java
@@ -37,7 +37,7 @@
import java.util.Map;
/**
- * Static methods to work with registry types —primarily endpoints and the
+ * Static methods to work with registry types, primarily endpoints and the
* list representation of addresses.
*/
@InterfaceAudience.Public
@@ -45,7 +45,7 @@
public class RegistryTypeUtils {
/**
- * Create a URL endpoint from a list of URIs
+ * Create a URL endpoint from a list of URIs.
* @param api implemented API
* @param protocolType protocol type
* @param uris URIs
@@ -58,7 +58,7 @@ public static Endpoint urlEndpoint(String api,
}
/**
- * Create a REST endpoint from a list of URIs
+ * Create a REST endpoint from a list of URIs.
* @param api implemented API
* @param uris URIs
* @return a new endpoint
@@ -69,7 +69,7 @@ public static Endpoint restEndpoint(String api,
}
/**
- * Create a Web UI endpoint from a list of URIs
+ * Create a Web UI endpoint from a list of URIs.
* @param api implemented API
* @param uris URIs
* @return a new endpoint
@@ -80,7 +80,7 @@ public static Endpoint webEndpoint(String api,
}
/**
- * Create an internet address endpoint from a list of URIs
+ * Create an internet address endpoint from a list of URIs.
* @param api implemented API
* @param protocolType protocol type
* @param hostname hostname/FQDN
@@ -102,7 +102,7 @@ public static Endpoint inetAddrEndpoint(String api,
}
/**
- * Create an IPC endpoint
+ * Create an IPC endpoint.
* @param api API
* @param address the address as a tuple of (hostname, port)
* @return the new endpoint
@@ -115,19 +115,19 @@ public static Endpoint ipcEndpoint(String api, InetSocketAddress address) {
}
/**
- * Create a single entry map
+ * Create a single entry map.
* @param key map entry key
* @param val map entry value
* @return a 1 entry map.
*/
public static Map map(String key, String val) {
- Map map = new HashMap(1);
+ Map map = new HashMap<>(1);
map.put(key, val);
return map;
}
/**
- * Create a URI
+ * Create a URI.
* @param uri value
* @return a 1 entry map.
*/
@@ -136,7 +136,7 @@ public static Map uri(String uri) {
}
/**
- * Create a (hostname, port) address pair
+ * Create a (hostname, port) address pair.
* @param hostname hostname
* @param port port
* @return a 1 entry map.
@@ -149,7 +149,7 @@ public static Map hostnamePortPair(String hostname, int port) {
}
/**
- * Create a (hostname, port) address pair
+ * Create a (hostname, port) address pair.
* @param address socket address whose hostname and port are used for the
* generated address.
* @return a 1 entry map.
@@ -159,7 +159,7 @@ public static Map hostnamePortPair(InetSocketAddress address) {
}
/**
- * Require a specific address type on an endpoint
+ * Require a specific address type on an endpoint.
* @param required required type
* @param epr endpoint
* @throws InvalidRecordException if the type is wrong
@@ -176,10 +176,10 @@ public static void requireAddressType(String required, Endpoint epr) throws
}
/**
- * Get a single URI endpoint
+ * Get a single URI endpoint.
* @param epr endpoint
- * @return the uri of the first entry in the address list. Null if the endpoint
- * itself is null
+ * @return the uri of the first entry in the address list.
+ * Null if the endpoint itself is null
* @throws InvalidRecordException if the type is wrong, there are no addresses
* or the payload ill-formatted
*/
@@ -194,7 +194,7 @@ public static List retrieveAddressesUriType(Endpoint epr)
throw new InvalidRecordException(epr.toString(),
"No addresses in endpoint");
}
- List results = new ArrayList(addresses.size());
+ List results = new ArrayList<>(addresses.size());
for (Map address : addresses) {
results.add(getAddressField(address, ADDRESS_URI));
}
@@ -203,7 +203,7 @@ public static List retrieveAddressesUriType(Endpoint epr)
/**
* Get a specific field from an address -raising an exception if
- * the field is not present
+ * the field is not present.
* @param address address to query
* @param field field to resolve
* @return the resolved value. Guaranteed to be non-null.
@@ -219,7 +219,7 @@ public static String getAddressField(Map address,
}
/**
- * Get the address URLs. Guranteed to return at least one address.
+ * Get the address URLs. Guaranteed to return at least one address.
* @param epr endpoint
* @return the address as a URL
* @throws InvalidRecordException if the type is wrong, there are no addresses
@@ -232,7 +232,7 @@ public static List retrieveAddressURLs(Endpoint epr)
throw new InvalidRecordException("", "Null endpoint");
}
List addresses = retrieveAddressesUriType(epr);
- List results = new ArrayList(addresses.size());
+ List results = new ArrayList<>(addresses.size());
for (String address : addresses) {
results.add(new URL(address));
}
@@ -241,7 +241,7 @@ public static List retrieveAddressURLs(Endpoint epr)
/**
* Validate the record by checking for null fields and other invalid
- * conditions
+ * conditions.
* @param path path for exceptions
* @param record record to validate. May be null
* @throws InvalidRecordException on invalid entries
@@ -270,7 +270,7 @@ public static void validateServiceRecord(String path, ServiceRecord record)
/**
* Validate the endpoint by checking for null fields and other invalid
- * conditions
+ * conditions.
* @param path path for exceptions
* @param endpoint endpoint to validate. May be null
* @throws InvalidRecordException on invalid entries
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
index 858b6b123570e..42fa83ac76abf 100644
--- 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
@@ -102,7 +102,7 @@ public static String convertUsername(String username) {
}
/**
- * Create a service classpath
+ * Create a service classpath.
* @param user username or ""
* @param serviceClass service name
* @return a full path
@@ -116,7 +116,7 @@ public static String serviceclassPath(String user,
}
/**
- * Create a path to a service under a user and service class
+ * 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
@@ -132,7 +132,7 @@ public static String servicePath(String user,
}
/**
- * Create a path for listing components under a service
+ * 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
@@ -146,7 +146,7 @@ public static String componentListPath(String user,
}
/**
- * Create the path to a service record for a component
+ * 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
@@ -162,12 +162,12 @@ public static String componentPath(String user,
}
/**
- * List service records directly under a path
+ * 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
+ * @throws IOException IO problems
*/
public static Map listServiceRecords(
RegistryOperations registryOperations,
@@ -186,8 +186,9 @@ public static Map listServiceRecords(
* This is not an atomic operation; A child may be deleted
* during the iteration through the child entries. If this happens,
* the PathNotFoundException is caught and that child
- * entry ommitted.
+ * entry omitted.
*
+ * @param registryOperations operations instance to use
* @param path path
* @return a possibly empty map of child entries listed by
* their short name.
@@ -203,7 +204,7 @@ public static Map statChildren(
IOException {
List childNames = registryOperations.list(path);
Map results =
- new HashMap();
+ new HashMap<>();
for (String childName : childNames) {
String child = join(path, childName);
try {
@@ -279,7 +280,7 @@ public static String getCurrentUsernameUnencoded(String env_hadoop_username) {
}
/**
- * Get the current user path formatted for the registry
+ * Get the current user path formatted for the registry.
*
* In an insecure cluster, the environment variable
* HADOOP_USER_NAME is queried first.
@@ -312,7 +313,7 @@ public static Map extractServiceRecords(
RegistryOperations operations,
String parentpath,
Collection stats) throws IOException {
- Map results = new HashMap(stats.size());
+ Map results = new HashMap<>(stats.size());
for (RegistryPathStatus stat : stats) {
if (stat.size > ServiceRecord.RECORD_TYPE.length()) {
// maybe has data
@@ -344,6 +345,7 @@ public static Map extractServiceRecords(
*
* @param operations operation support for fetches
* @param parentpath path of the parent of all the entries
+ * @param stats list of registry stat values to examine
* @return a possibly empty map of fullpath:record.
* @throws IOException for any IO Operation that wasn't ignored.
*/
@@ -376,7 +378,7 @@ public static Map extractServiceRecords(
/**
- * Static instance of service record marshalling
+ * Static instance of service record marshalling.
*/
public static class ServiceRecordMarshal extends JsonSerDeser {
public ServiceRecordMarshal() {
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
index aadb7fc46d975..c0392a62ac17a 100644
--- 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
@@ -18,10 +18,15 @@
package org.apache.hadoop.registry.client.exceptions;
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
+
/**
* Exception raised when client access wasn't authenticated.
* That is: the credentials provided were incomplete or invalid.
*/
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
public class AuthenticationFailedException extends RegistryIOException {
public AuthenticationFailedException(String path, Throwable cause) {
super(path, cause);
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
index e4f545e5b4ca2..16841a21395e6 100644
--- 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
@@ -23,7 +23,6 @@
/**
* Raised if an attempt to parse a record failed.
- *
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
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
index ce84f5b610279..798265eefaeb6 100644
--- 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
@@ -18,13 +18,15 @@
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;
/**
* Raised on path permission exceptions.
- *
- * This is similar to PathIOException, except that exception doesn't let
*/
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
public class NoPathPermissionsException extends RegistryIOException {
public NoPathPermissionsException(String path, Throwable cause) {
super(path, cause);
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
index 7d9c8ade8356f..f453fbf30e42a 100644
--- 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
@@ -30,4 +30,9 @@
* All exceptions in this package are derived from
* {@link org.apache.hadoop.registry.client.exceptions.RegistryIOException}
*/
+@InterfaceAudience.Public
+@InterfaceStability.Evolving
package org.apache.hadoop.registry.client.exceptions;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
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
index 8ae003d5485fd..5c97fd529ce70 100644
--- 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
@@ -23,19 +23,19 @@
import org.apache.hadoop.classification.InterfaceStability;
/**
- * Binding information provided by a {@link RegistryBindingSource}
+ * Binding information provided by a {@link RegistryBindingSource}.
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public class BindingInformation {
/**
- * The Curator Ensemble Provider
+ * The Curator Ensemble Provider.
*/
public EnsembleProvider ensembleProvider;
/**
- * Any information that may be useful for diagnostics
+ * Any information that may be useful for diagnostics.
*/
public String description;
}
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
index 7f35c3fe62843..85814b229ab73 100644
--- 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
@@ -69,12 +69,12 @@ public class CuratorService extends CompositeService
LoggerFactory.getLogger(CuratorService.class);
/**
- * the Curator binding
+ * the Curator binding.
*/
private CuratorFramework curator;
/**
- * Path to the registry root
+ * Path to the registry root.
*/
private String registryRoot;
@@ -85,17 +85,17 @@ public class CuratorService extends CompositeService
private final RegistryBindingSource bindingSource;
/**
- * Security service
+ * Security service.
*/
private RegistrySecurity registrySecurity;
/**
- * the connection binding text for messages
+ * the connection binding text for messages.
*/
private String connectionDescription;
/**
- * Security connection diagnostics
+ * Security connection diagnostics.
*/
private String securityConnectionDiagnostics = "";
@@ -133,7 +133,7 @@ public CuratorService(String name) {
* Init the service.
* This is where the security bindings are set up
* @param conf configuration of the service
- * @throws Exception
+ * @throws Exception initialization problems.
*/
@Override
protected void serviceInit(Configuration conf) throws Exception {
@@ -155,7 +155,7 @@ protected void serviceInit(Configuration conf) throws Exception {
/**
* Start the service.
* This is where the curator instance is started.
- * @throws Exception
+ * @throws Exception startup problems
*/
@Override
protected void serviceStart() throws Exception {
@@ -167,7 +167,7 @@ protected void serviceStart() throws Exception {
}
/**
- * Close the ZK connection if it is open
+ * Close the ZK connection if it is open.
*/
@Override
protected void serviceStop() throws Exception {
@@ -176,7 +176,7 @@ protected void serviceStop() throws Exception {
}
/**
- * Internal check that a service is in the live state
+ * Internal check that a service is in the live state.
* @throws ServiceStateException if not
*/
private void checkServiceLive() throws ServiceStateException {
@@ -197,7 +197,7 @@ public boolean isSecure() {
}
/**
- * Get the registry security helper
+ * Get the registry security helper.
* @return the registry security helper
*/
protected RegistrySecurity getRegistrySecurity() {
@@ -205,7 +205,7 @@ protected RegistrySecurity getRegistrySecurity() {
}
/**
- * Build the security diagnostics string
+ * Build the security diagnostics string.
* @return a string for diagnostics
*/
protected String buildSecurityDiagnostics() {
@@ -277,7 +277,7 @@ public String toString() {
}
/**
- * Get the binding diagnostics
+ * Get the binding diagnostics.
* @return a diagnostics string valid after the service is started.
*/
public String bindingDiagnosticDetails() {
@@ -287,7 +287,7 @@ public String bindingDiagnosticDetails() {
}
/**
- * Create a full path from the registry root and the supplied subdir
+ * 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
@@ -297,8 +297,8 @@ protected String createFullPath(String path) throws IOException {
}
/**
- * Get the registry binding source ... this can be used to
- * create new ensemble providers
+ * Get the registry binding source; this can be used to
+ * create new ensemble providers.
* @return the registry binding source in use
*/
public RegistryBindingSource getBindingSource() {
@@ -308,7 +308,7 @@ public RegistryBindingSource getBindingSource() {
/**
* Create the ensemble provider for this registry, by invoking
* {@link RegistryBindingSource#supplyBindingInformation()} on
- * the provider stored in {@link #bindingSource}
+ * 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;
@@ -339,7 +339,7 @@ public BindingInformation supplyBindingInformation() {
/**
* Override point: get the connection string used to connect to
- * the ZK service
+ * the ZK service.
* @return a registry quorum
*/
protected String buildConnectionString() {
@@ -348,7 +348,7 @@ protected String buildConnectionString() {
}
/**
- * Create an IOE when an operation fails
+ * Create an IOE when an operation fails.
* @param path path of operation
* @param operation operation attempted
* @param exception caught the exception caught
@@ -361,7 +361,7 @@ protected IOException operationFailure(String path,
}
/**
- * Create an IOE when an operation fails
+ * Create an IOE when an operation fails.
* @param path path of operation
* @param operation operation attempted
* @param exception caught the exception caught
@@ -421,7 +421,7 @@ protected IOException operationFailure(String path,
* @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
+ * @throws IOException problem creating the path.
*/
@VisibleForTesting
public boolean maybeCreate(String path,
@@ -432,11 +432,12 @@ public boolean maybeCreate(String path,
}
/**
- * Stat the file
+ * 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
+ * @throws IOException any other problem
*/
public Stat zkStat(String path) throws IOException {
checkServiceLive();
@@ -457,10 +458,11 @@ public Stat zkStat(String path) throws IOException {
}
/**
- * Get the ACLs of a path
+ * Get the ACLs of a path.
* @param path path of operation
* @return a possibly empty list of ACLs
- * @throws IOException
+ * @throws PathNotFoundException if the path was not found
+ * @throws IOException any other problem
*/
public List zkGetACLS(String path) throws IOException {
checkServiceLive();
@@ -481,10 +483,11 @@ public List zkGetACLS(String path) throws IOException {
}
/**
- * Probe for a path existing
+ * Probe for a path existing.
* @param path path of operation
* @return true if the path was visible from the ZK server
* queried.
+ * @throws PathNotFoundException if the path was not found
* @throws IOException on any exception other than
* {@link PathNotFoundException}
*/
@@ -497,16 +500,14 @@ public boolean zkPathExists(String path) throws IOException {
return true;
} catch (PathNotFoundException e) {
return false;
- } catch (IOException e) {
- throw e;
}
}
/**
- * Verify a path exists
+ * Verify a path exists.
* @param path path of operation
* @throws PathNotFoundException if the path is absent
- * @throws IOException
+ * @throws IOException any other problem
*/
public String zkPathMustExist(String path) throws IOException {
zkStat(path);
@@ -558,7 +559,7 @@ public boolean zkMkPath(String path,
}
/**
- * Recursively make a path
+ * Recursively make a path.
* @param path path to create
* @param acl ACL for path
* @throws IOException any problem
@@ -574,11 +575,11 @@ public void zkMkParentPath(String path,
/**
* Create a path with given data. byte[0] is used for a path
- * without data
+ * without data.
* @param path path of operation
* @param data initial data
- * @param acls
- * @throws IOException
+ * @param acls ACL list
+ * @throws IOException any problem creating the path.
*/
public void zkCreate(String path,
CreateMode mode,
@@ -600,10 +601,10 @@ public void zkCreate(String path,
}
/**
- * Update the data for a path
+ * Update the data for a path.
* @param path path of operation
* @param data new data
- * @throws IOException
+ * @throws IOException any problem updating the path.
*/
public void zkUpdate(String path, byte[] data) throws IOException {
Preconditions.checkArgument(data != null, "null data");
@@ -620,12 +621,13 @@ public void zkUpdate(String path, byte[] data) throws IOException {
}
/**
- * Create or update an entry
+ * 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
- * @throws IOException
+ * @throws FileAlreadyExistsException if the path existed and overwrite==false
+ * @throws IOException IO problem
* @return true if the entry was created, false if it was simply updated.
*/
public boolean zkSet(String path,
@@ -682,10 +684,10 @@ public void zkDelete(String path,
}
/**
- * List all children of a path
+ * List all children of a path.
* @param path path of operation
* @return a possibly empty list of children
- * @throws IOException
+ * @throws IOException read failure
*/
public List zkList(String path) throws IOException {
checkServiceLive();
@@ -703,7 +705,7 @@ public List zkList(String path) throws IOException {
}
/**
- * Read data on a path
+ * Read data on a path.
* @param path path of operation
* @return the data
* @throws IOException read failure
@@ -723,7 +725,7 @@ public byte[] zkRead(String path) throws IOException {
/**
* Return a path dumper instance which can do a full dump
- * of the registry tree in its toString()
+ * of the registry tree in its toString().
* operation
* @return a class to dump the registry
* @param verbose verbose flag - includes more details (such as ACLs)
@@ -746,7 +748,7 @@ public boolean addWriteAccessor(String id, String pass) throws IOException {
}
/**
- * Clear all write accessors
+ * Clear all write accessors.
*/
public void clearWriteAccessors() {
getRegistrySecurity().resetDigestACLs();
@@ -765,7 +767,7 @@ protected String dumpRegistryRobustly(boolean verbose) {
return pathDumper.toString();
} catch (Exception e) {
// ignore
- LOG.debug("Ignoring exception: {}", e);
+ LOG.debug("Ignoring exception", e);
}
return "";
}
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
index bab4742ad6c0e..092351f997e4f 100644
--- 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
@@ -22,14 +22,14 @@
import org.apache.hadoop.classification.InterfaceStability;
/**
- * Interface which can be implemented by a registry binding source
+ * Interface which can be implemented by a registry binding source.
*/
@InterfaceAudience.Public
@InterfaceStability.Evolving
public interface RegistryBindingSource {
/**
- * Supply the binding information for this registry
+ * Supply the binding information for this registry.
* @return the binding information data
*/
BindingInformation supplyBindingInformation();
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryInternalConstants.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryInternalConstants.java
index f04673a08bde6..af9897d28f813 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryInternalConstants.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryInternalConstants.java
@@ -46,7 +46,7 @@ public interface RegistryInternalConstants {
int PERMISSIONS_REGISTRY_READERS = ZooDefs.Perms.READ;
/**
- * Permissions for system services: {@value}
+ * Permissions for system services: {@value}.
*/
int PERMISSIONS_REGISTRY_SYSTEM_SERVICES = ZooDefs.Perms.ALL;
@@ -75,7 +75,7 @@ public interface RegistryInternalConstants {
/**
* This the Hadoop environment variable which propagates the identity
- * of a user in an insecure cluster
+ * of a user in an insecure cluster.
*/
String HADOOP_USER_NAME = "HADOOP_USER_NAME";
}
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryOperationsService.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryOperationsService.java
index 271ab25463335..18915ebbfee68 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryOperationsService.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistryOperationsService.java
@@ -77,7 +77,7 @@ public RegistryOperationsService(String name,
/**
* Get the aggregate set of ACLs the client should use
- * to create directories
+ * to create directories.
* @return the ACL list
*/
public List getClientAcls() {
@@ -85,7 +85,7 @@ public List getClientAcls() {
}
/**
- * Validate a path
+ * Validate a path.
* @param path path to validate
* @throws InvalidPathnameException if a path is considered invalid
*/
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistrySecurity.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistrySecurity.java
index 39325a3f19471..022530c365f89 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistrySecurity.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/RegistrySecurity.java
@@ -24,6 +24,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.security.AccessControlException;
import org.apache.hadoop.security.UserGroupInformation;
import org.apache.hadoop.security.authentication.util.KerberosUtil;
import org.apache.hadoop.service.AbstractService;
@@ -78,45 +79,38 @@ public class RegistrySecurity extends AbstractService {
/**
* there's no default user to add with permissions, so it would be
- * impossible to create nodes with unrestricted user access
+ * impossible to create nodes with unrestricted user access.
*/
public static final String E_NO_USER_DETERMINED_FOR_ACLS =
"No user for ACLs determinable from current user or registry option "
+ KEY_REGISTRY_USER_ACCOUNTS;
/**
- * Error raised when the registry is tagged as secure but this
- * process doesn't have hadoop security enabled.
- */
- public static final String E_NO_KERBEROS =
- "Registry security is enabled -but Hadoop security is not enabled";
-
- /**
- * Access policy options
+ * Access policy options.
*/
private enum AccessPolicy {
anon, sasl, digest
}
/**
- * Access mechanism
+ * Access mechanism.
*/
private AccessPolicy access;
/**
- * User used for digest auth
+ * User used for digest auth.
*/
private String digestAuthUser;
/**
- * Password used for digest auth
+ * Password used for digest auth.
*/
private String digestAuthPassword;
/**
- * Auth data used for digest auth
+ * Auth data used for digest auth.
*/
private byte[] digestAuthData;
@@ -126,13 +120,13 @@ private enum AccessPolicy {
private boolean secureRegistry;
/**
- * An ACL with read-write access for anyone
+ * An ACL with read-write access for anyone.
*/
public static final ACL ALL_READWRITE_ACCESS =
new ACL(ZooDefs.Perms.ALL, ZooDefs.Ids.ANYONE_ID_UNSAFE);
/**
- * An ACL with read access for anyone
+ * An ACL with read access for anyone.
*/
public static final ACL ALL_READ_ACCESS =
new ACL(ZooDefs.Perms.READ, ZooDefs.Ids.ANYONE_ID_UNSAFE);
@@ -144,39 +138,39 @@ private enum AccessPolicy {
public static final List WorldReadWriteACL;
static {
- List acls = new ArrayList();
+ List acls = new ArrayList<>();
acls.add(ALL_READWRITE_ACCESS);
- WorldReadWriteACL = new CopyOnWriteArrayList(acls);
+ WorldReadWriteACL = new CopyOnWriteArrayList<>(acls);
}
/**
- * the list of system ACLs
+ * the list of system ACLs.
*/
- private final List systemACLs = new ArrayList();
+ private final List systemACLs = new ArrayList<>();
/**
* A list of digest ACLs which can be added to permissions
- * —and cleared later.
+ * and cleared later.
*/
- private final List digestACLs = new ArrayList();
+ private final List digestACLs = new ArrayList<>();
/**
- * the default kerberos realm
+ * the default kerberos realm.
*/
private String kerberosRealm;
/**
- * Client context
+ * Client context.
*/
private String jaasClientContext;
/**
- * Client identity
+ * Client identity.
*/
private String jaasClientIdentity;
/**
- * Create an instance
+ * Create an instance.
* @param name service name
*/
public RegistrySecurity(String name) {
@@ -184,9 +178,10 @@ public RegistrySecurity(String name) {
}
/**
- * Init the service: this sets up security based on the configuration
+ * Init the service: this sets up security based on the configuration.
* @param conf configuration
- * @throws Exception
+ * @throws ServiceStateException if the authenticatin mechanism is unknown.
+ * @throws Exception any initialization problem.
*/
@Override
protected void serviceInit(Configuration conf) throws Exception {
@@ -215,7 +210,7 @@ protected void serviceInit(Configuration conf) throws Exception {
* Init security.
*
* After this operation, the {@link #systemACLs} list is valid.
- * @throws IOException
+ * @throws IOException problems initializing security.
*/
private void initSecurity() throws IOException {
@@ -250,51 +245,53 @@ private void initSecurity() throws IOException {
}
}
- // here check for UGI having secure on or digest + ID
+ // configure security access based on settings.
switch (access) {
- case sasl:
- // secure + SASL => has to be authenticated
- if (!UserGroupInformation.isSecurityEnabled()) {
- throw new IOException("Kerberos required for secure registry access");
- }
- UserGroupInformation currentUser =
- UserGroupInformation.getCurrentUser();
- jaasClientContext = getOrFail(KEY_REGISTRY_CLIENT_JAAS_CONTEXT,
- DEFAULT_REGISTRY_CLIENT_JAAS_CONTEXT);
- jaasClientIdentity = currentUser.getShortUserName();
- if (LOG.isDebugEnabled()) {
- LOG.debug("Auth is SASL user=\"{}\" JAAS context=\"{}\"",
- jaasClientIdentity,
- jaasClientContext);
- }
- break;
-
- case digest:
- String id = getOrFail(KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, "");
- String pass = getOrFail(KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD, "");
- if (userACLs.isEmpty()) {
- //
- throw new ServiceStateException(E_NO_USER_DETERMINED_FOR_ACLS);
- }
- digest(id, pass);
- ACL acl = new ACL(ZooDefs.Perms.ALL, toDigestId(id, pass));
- userACLs.add(acl);
- digestAuthUser = id;
- digestAuthPassword = pass;
- String authPair = id + ":" + pass;
- digestAuthData = authPair.getBytes("UTF-8");
- if (LOG.isDebugEnabled()) {
- LOG.debug("Auth is Digest ACL: {}", aclToString(acl));
- }
- break;
+ case sasl:
+ // secure + SASL => has to be authenticated
+ if (!UserGroupInformation.isSecurityEnabled()) {
+ throw new AccessControlException("Kerberos required" +
+ " for secure registry access");
+ }
+ UserGroupInformation currentUser =
+ UserGroupInformation.getCurrentUser();
+ jaasClientContext = getOrFail(KEY_REGISTRY_CLIENT_JAAS_CONTEXT,
+ DEFAULT_REGISTRY_CLIENT_JAAS_CONTEXT);
+ jaasClientIdentity = currentUser.getShortUserName();
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Auth is SASL user=\"{}\" JAAS context=\"{}\"",
+ jaasClientIdentity,
+ jaasClientContext);
+ }
+ break;
+
+ case digest:
+ String id = getOrFail(KEY_REGISTRY_CLIENT_AUTHENTICATION_ID, "");
+ String pass = getOrFail(KEY_REGISTRY_CLIENT_AUTHENTICATION_PASSWORD,
+ "");
+ if (userACLs.isEmpty()) {
+ //
+ throw new ServiceStateException(E_NO_USER_DETERMINED_FOR_ACLS);
+ }
+ digest(id, pass);
+ ACL acl = new ACL(ZooDefs.Perms.ALL, toDigestId(id, pass));
+ userACLs.add(acl);
+ digestAuthUser = id;
+ digestAuthPassword = pass;
+ String authPair = id + ":" + pass;
+ digestAuthData = authPair.getBytes("UTF-8");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Auth is Digest ACL: {}", aclToString(acl));
+ }
+ break;
- case anon:
- // nothing is needed; account is read only.
- if (LOG.isDebugEnabled()) {
- LOG.debug("Auth is anonymous");
- }
- userACLs = new ArrayList(0);
- break;
+ case anon:
+ // nothing is needed; account is read only.
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Auth is anonymous");
+ }
+ userACLs = new ArrayList<>(0);
+ break;
}
systemACLs.addAll(userACLs);
@@ -308,7 +305,7 @@ private void initSecurity() throws IOException {
}
/**
- * Add another system ACL
+ * Add another system ACL.
* @param acl add ACL
*/
public void addSystemACL(ACL acl) {
@@ -316,8 +313,9 @@ public void addSystemACL(ACL acl) {
}
/**
- * Add a digest ACL
+ * Add a digest ACL.
* @param acl add ACL
+ * @return true if the registry is secure and the ACL added
*/
public boolean addDigestACL(ACL acl) {
if (secureRegistry) {
@@ -336,7 +334,7 @@ public boolean addDigestACL(ACL acl) {
}
/**
- * Reset the digest ACL list
+ * Reset the digest ACL list.
*/
public void resetDigestACLs() {
if (LOG.isDebugEnabled()) {
@@ -346,7 +344,7 @@ public void resetDigestACLs() {
}
/**
- * Flag to indicate the cluster is secure
+ * Flag to indicate the cluster is secure.
* @return true if the config enabled security
*/
public boolean isSecureRegistry() {
@@ -354,7 +352,7 @@ public boolean isSecureRegistry() {
}
/**
- * Get the system principals
+ * Get the system principals.
* @return the system principals
*/
public List getSystemACLs() {
@@ -363,21 +361,21 @@ public List getSystemACLs() {
}
/**
- * Get all ACLs needed for a client to use when writing to the repo.
+ * Get all ACLs needed for a client to use when creating a new entry.
* That is: system ACLs, its own ACL, any digest ACLs
* @return the client ACLs
*/
public List getClientACLs() {
- List clientACLs = new ArrayList(systemACLs);
+ List clientACLs = new ArrayList<>(systemACLs);
clientACLs.addAll(digestACLs);
return clientACLs;
}
/**
- * Create a SASL ACL for the user
+ * Create a SASL ACL for the user.
* @param perms permissions
* @return an ACL for the current user or null if they aren't a kerberos user
- * @throws IOException
+ * @throws IOException IO problems
*/
public ACL createSaslACLFromCurrentUser(int perms) throws IOException {
UserGroupInformation currentUser = UserGroupInformation.getCurrentUser();
@@ -389,7 +387,7 @@ public ACL createSaslACLFromCurrentUser(int perms) throws IOException {
}
/**
- * Given a UGI, create a SASL ACL from it
+ * Given a UGI, create a SASL ACL from it.
* @param ugi UGI
* @param perms permissions
* @return a new ACL
@@ -400,7 +398,7 @@ public ACL createSaslACL(UserGroupInformation ugi, int perms) {
}
/**
- * Get a conf option, throw an exception if it is null/empty
+ * Get a conf option, throw an exception if it is null/empty.
* @param key key
* @param defval default value
* @return the value
@@ -439,9 +437,10 @@ public String getKerberosRealm() {
}
/**
- * Generate a base-64 encoded digest of the idPasswordPair pair
+ * Generate a base-64 encoded digest of the idPasswordPair pair.
* @param idPasswordPair id:password
* @return a string that can be used for authentication
+ * @throws IOException on invalid idPasswordPair or digest problems
*/
public String digest(String idPasswordPair) throws IOException {
if (StringUtils.isEmpty(idPasswordPair) || !isValid(idPasswordPair)) {
@@ -457,18 +456,18 @@ public String digest(String idPasswordPair) throws IOException {
}
/**
- * Generate a base-64 encoded digest of the idPasswordPair pair
+ * Generate a base-64 encoded digest of the idPasswordPair pair.
* @param id ID
* @param password pass
* @return a string that can be used for authentication
- * @throws IOException
+ * @throws IOException on invalid idPasswordPair or digest problems
*/
public String digest(String id, String password) throws IOException {
return digest(id + ":" + password);
}
/**
- * Given a digest, create an ID from it
+ * Given a digest, create an ID from it.
* @param digest digest
* @return ID
*/
@@ -477,7 +476,7 @@ public Id toDigestId(String digest) {
}
/**
- * Create a Digest ID from an id:pass pair
+ * Create a Digest ID from an id:pass pair.
* @param id ID
* @param password password
* @return an ID
@@ -544,7 +543,7 @@ public Id parse(String idPair, String realm) {
}
/**
- * Parse the IDs, adding a realm if needed, setting the permissions
+ * Parse the IDs, adding a realm if needed, setting the permissions.
* @param principalList id string
* @param realm realm to add
* @param perms permissions
@@ -554,7 +553,7 @@ public Id parse(String idPair, String realm) {
public List buildACLs(String principalList, String realm, int perms)
throws IOException {
List aclPairs = splitAclPairs(principalList, realm);
- List ids = new ArrayList(aclPairs.size());
+ List ids = new ArrayList<>(aclPairs.size());
for (String aclPair : aclPairs) {
ACL newAcl = new ACL();
newAcl.setId(parse(aclPair, realm));
@@ -565,7 +564,7 @@ public List buildACLs(String principalList, String realm, int perms)
}
/**
- * Parse an ACL list. This includes configuration indirection
+ * Parse an ACL list. This includes configuration indirection.
* {@link ZKUtil#resolveConfIndirection(String)}
* @param zkAclConf configuration string
* @return an ACL list
@@ -585,15 +584,11 @@ public List parseACLs(String zkAclConf) throws IOException {
* @return a JVM-specific kerberos login module classname.
*/
public static String getKerberosAuthModuleForJVM() {
- if (System.getProperty("java.vendor").contains("IBM")) {
- return "com.ibm.security.auth.module.Krb5LoginModule";
- } else {
- return "com.sun.security.auth.module.Krb5LoginModule";
- }
+ return KerberosUtil.getKrb5LoginModuleName();
}
/**
- * JAAS template: {@value}
+ * JAAS template: {@value}.
* Note the semicolon on the last entry
*/
private static final String JAAS_ENTRY =
@@ -621,7 +616,7 @@ public static String getKerberosAuthModuleForJVM() {
);
/**
- * Create a JAAS entry for insertion
+ * Create a JAAS entry for insertion.
* @param context context of the entry
* @param principal kerberos principal
* @param keytab keytab
@@ -665,7 +660,7 @@ public static void bindJVMtoJAASFile(File jaasFile) {
}
/**
- * Set the Zookeeper server property
+ * Set the Zookeeper server property.
* {@link ZookeeperConfigOptions#PROP_ZK_SERVER_SASL_CONTEXT}
* to the SASL context. When the ZK server starts, this is the context
* which it will read in
@@ -676,7 +671,7 @@ public static void bindZKToServerJAASContext(String contextName) {
}
/**
- * Reset any system properties related to JAAS
+ * Reset any system properties related to JAAS.
*/
public static void clearJaasSystemProperties() {
System.clearProperty(Environment.JAAS_CONF_KEY);
@@ -754,7 +749,7 @@ public static void setZKSaslClientProperties(String username,
}
/**
- * Clear all the ZK SASL Client properties
+ * Clear all the ZK SASL Client properties.
* Important:This is JVM-wide
*/
public static void clearZKSaslClientProperties() {
@@ -764,7 +759,7 @@ public static void clearZKSaslClientProperties() {
}
/**
- * Turn ZK SASL on
+ * Turn ZK SASL on.
* Important:This is JVM-wide
*/
protected static void enableZookeeperClientSASL() {
@@ -799,7 +794,7 @@ public void logCurrentHadoopUser() {
UserGroupInformation realUser = currentUser.getRealUser();
LOG.info("Real User = {}" , realUser);
} catch (IOException e) {
- LOG.warn("Failed to get current user {}, {}", e);
+ LOG.warn("Failed to get current user", e);
}
}
@@ -824,7 +819,7 @@ public static String aclsToString(List acls) {
}
/**
- * Convert an ACL to a string, with any obfuscation needed
+ * Convert an ACL to a string, with any obfuscation needed.
* @param acl ACL
* @return ACL string value
*/
@@ -838,7 +833,7 @@ public static String aclToString(ACL acl) {
/**
* Convert an ID to a string, stripping out all but the first few characters
- * of any digest auth hash for security reasons
+ * of any digest auth hash for security reasons.
* @param id ID
* @return a string description of a Zookeeper ID
*/
@@ -858,7 +853,7 @@ public static String idToString(Id id) {
}
/**
- * Build up low-level security diagnostics to aid debugging
+ * Build up low-level security diagnostics to aid debugging.
* @return a string to use in diagnostics
*/
public String buildSecurityDiagnostics() {
@@ -905,8 +900,8 @@ private static String describeProperty(String name, String def) {
}
/**
- * Get the default kerberos realm —returning "" if there
- * is no realm or other problem
+ * Get the default kerberos realm -returning "" if there
+ * is no realm or other problem.
* @return the default realm of the system if it
* could be determined
*/
@@ -929,12 +924,14 @@ public static String getDefaultRealmInJVM() {
/**
* Create an ACL For a user.
* @param ugi User identity
- * @return the ACL For the specified user. Ifthe username doesn't end
+ * @param perms permissions to pass to
+ * {@link #createACLfromUsername(String, int)}
+ * @return the ACL For the specified user. If the username doesn't end
* in "@" then the realm is added
*/
public ACL createACLForUser(UserGroupInformation ugi, int perms) {
if (LOG.isDebugEnabled()) {
- LOG.debug("Creating ACL For ", new UgiInfo(ugi));
+ LOG.debug("Creating ACL For {}", new UgiInfo(ugi));
}
if (!secureRegistry) {
return ALL_READWRITE_ACCESS;
@@ -944,7 +941,7 @@ public ACL createACLForUser(UserGroupInformation ugi, int perms) {
}
/**
- * Given a user name (short or long), create a SASL ACL
+ * Given a user name (short or long), create a SASL ACL.
* @param username user name; if it doesn't contain an "@" symbol, the
* service's kerberos realm is added
* @param perms permissions
@@ -961,7 +958,7 @@ public ACL createACLfromUsername(String username, int perms) {
}
/**
- * On demand string-ifier for UGI with extra details
+ * On demand string-ifier for UGI with extra details.
*/
public static class UgiInfo {
@@ -969,7 +966,7 @@ public static UgiInfo fromCurrentUser() {
try {
return new UgiInfo(UserGroupInformation.getCurrentUser());
} catch (IOException e) {
- LOG.info("Failed to get current user {}", e, e);
+ LOG.info("Failed to get current user", e);
return new UgiInfo(null);
}
}
@@ -991,14 +988,15 @@ public String toString() {
builder.append(" hasKerberosCredentials=").append(
ugi.hasKerberosCredentials());
builder.append(" isFromKeytab=").append(ugi.isFromKeytab());
- builder.append(" kerberos is enabled in Hadoop =").append(UserGroupInformation.isSecurityEnabled());
+ builder.append(" kerberos is enabled in Hadoop =")
+ .append(UserGroupInformation.isSecurityEnabled());
return builder.toString();
}
}
/**
- * on-demand stringifier for a list of ACLs
+ * on-demand stringifier for a list of ACLs.
*/
public static class AclListInfo {
public final List acls;
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ZKPathDumper.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ZKPathDumper.java
index 3c4a730608f6e..44a383903b44e 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ZKPathDumper.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ZKPathDumper.java
@@ -43,7 +43,7 @@ public class ZKPathDumper {
private final boolean verbose;
/**
- * Create a path dumper -but do not dump the path until asked
+ * Create a path dumper -but do not dump the path until asked.
* @param curator curator instance
* @param root root
* @param verbose verbose flag - includes more details (such as ACLs)
@@ -73,7 +73,7 @@ public String toString() {
/**
* Recursively expand the path into the supplied string builder, increasing
* the indentation by {@link #INDENT} as it proceeds (depth first) down
- * the tree
+ * the tree.
* @param builder string build to append to
* @param path path to examine
* @param indent current indentation
@@ -120,7 +120,7 @@ private void expand(StringBuilder builder,
}
/**
- * Append the specified indentation to a builder
+ * Append the specified indentation to a builder.
* @param builder string build to append to
* @param indent current indentation
* @param c charactor to use for indentation
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ZookeeperConfigOptions.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ZookeeperConfigOptions.java
index edcf0859fc345..7c5092af2188c 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ZookeeperConfigOptions.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/ZookeeperConfigOptions.java
@@ -23,13 +23,13 @@
/**
* Configuration options which are internal to Zookeeper,
- * as well as some other ZK constants
+ * as well as some other ZK constants.
*
* Zookeeper options are passed via system properties prior to the ZK
* Methods/classes being invoked. This implies that:
*
* - There can only be one instance of a ZK client or service class
- * in a single JVM —else their configuration options will conflict.
+ * in a single JVM -else their configuration options will conflict.
* - It is safest to set these properties immediately before
* invoking ZK operations.
*
@@ -77,7 +77,7 @@ public interface ZookeeperConfigOptions {
/**
* The SASL Server context, referring to a context in the JVM's
- * JAAS context file: {@value}
+ * JAAS context file: {@value}.
*/
String PROP_ZK_SERVER_SASL_CONTEXT =
ZooKeeperSaslServer.LOGIN_CONTEXT_NAME_KEY;
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/package-info.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/package-info.java
index f7ae98372d8ad..8bb4be9f1c923 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/package-info.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/impl/zk/package-info.java
@@ -34,6 +34,10 @@
* some operations/instantiating some objects. The definitions of these
* are kept in {@link org.apache.hadoop.registry.client.impl.zk.ZookeeperConfigOptions}.
*
- *
*/
+@InterfaceAudience.Private
+@InterfaceStability.Evolving
package org.apache.hadoop.registry.client.impl.zk;
+
+import org.apache.hadoop.classification.InterfaceAudience;
+import org.apache.hadoop.classification.InterfaceStability;
diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/types/Endpoint.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/types/Endpoint.java
index 395f8366f1a54..64837c9da4392 100644
--- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/types/Endpoint.java
+++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-registry/src/main/java/org/apache/hadoop/registry/client/types/Endpoint.java
@@ -50,7 +50,7 @@
public final class Endpoint implements Cloneable {
/**
- * API implemented at the end of the binding
+ * API implemented at the end of the binding.
*/
public String api;
@@ -67,7 +67,7 @@ public final class Endpoint implements Cloneable {
public String protocolType;
/**
- * a list of address tuples —tuples whose format depends on the address type
+ * a list of address tuples -tuples whose format depends on the address type.
*/
public List