Skip to content

Commit

Permalink
HDFS-8089. Move o.a.h.hdfs.web.resources.* to the client jars. Contri…
Browse files Browse the repository at this point in the history
…buted by Haohui Mai.
  • Loading branch information
Haohui Mai committed Apr 8, 2015
1 parent 5a540c3 commit cc25823
Show file tree
Hide file tree
Showing 47 changed files with 79 additions and 54 deletions.
9 changes: 9 additions & 0 deletions hadoop-hdfs-project/hadoop-hdfs-client/pom.xml
Expand Up @@ -29,6 +29,15 @@ http://maven.apache.org/xsd/maven-4.0.0.xsd">
<description>Apache Hadoop HDFS Client</description>
<name>Apache Hadoop HDFS Client</name>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.apache.hadoop</groupId>
<artifactId>hadoop-common</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
Expand Down
Expand Up @@ -19,8 +19,15 @@

/** Client configuration properties */
public interface HdfsClientConfigKeys {
static final String PREFIX = "dfs.client.";
String DFS_BLOCK_SIZE_KEY = "dfs.blocksize";
long DFS_BLOCK_SIZE_DEFAULT = 128*1024*1024;
String DFS_REPLICATION_KEY = "dfs.replication";
short DFS_REPLICATION_DEFAULT = 3;
String DFS_WEBHDFS_USER_PATTERN_DEFAULT = "^[A-Za-z_][A-Za-z0-9._-]*[$]?$";
String DFS_WEBHDFS_ACL_PERMISSION_PATTERN_DEFAULT =
"^(default:)?(user|group|mask|other):[[A-Za-z_][A-Za-z0-9._-]]*:([rwx-]{3})?(,(default:)?(user|group|mask|other):[[A-Za-z_][A-Za-z0-9._-]]*:([rwx-]{3})?)*$";

static final String PREFIX = "dfs.client.";
/** Client retry configuration properties */
public interface Retry {
static final String PREFIX = HdfsClientConfigKeys.PREFIX + "retry.";
Expand Down
Expand Up @@ -17,7 +17,8 @@
*/
package org.apache.hadoop.hdfs.web.resources;

import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_WEBHDFS_ACL_PERMISSION_PATTERN_DEFAULT;
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys
.DFS_WEBHDFS_ACL_PERMISSION_PATTERN_DEFAULT;

import java.util.List;
import java.util.regex.Pattern;
Expand All @@ -37,7 +38,7 @@ public class AclPermissionParam extends StringParam {

/**
* Constructor.
*
*
* @param str a string representation of the parameter value.
*/
public AclPermissionParam(final String str) {
Expand Down
Expand Up @@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hdfs.web.resources;

import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_SIZE_DEFAULT;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_BLOCK_SIZE_KEY;
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_BLOCK_SIZE_DEFAULT;
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_BLOCK_SIZE_KEY;

import org.apache.hadoop.conf.Configuration;

Expand Down
Expand Up @@ -59,7 +59,7 @@ public String toString() {
public String getValueString() {
return toString(value);
}

/** The domain of the parameter. */
static final class Domain<E extends Enum<E>> extends Param.Domain<EnumSet<E>> {
private final Class<E> enumClass;
Expand Down
Expand Up @@ -50,7 +50,7 @@ public static enum Op implements HttpOpParam.Op {
Op(final boolean redirect, final int expectedHttpResponseCode) {
this(redirect, expectedHttpResponseCode, false);
}

Op(final boolean redirect, final int expectedHttpResponseCode,
final boolean requireAuth) {
this.redirect = redirect;
Expand All @@ -62,7 +62,7 @@ public static enum Op implements HttpOpParam.Op {
public HttpOpParam.Type getType() {
return HttpOpParam.Type.GET;
}

@Override
public boolean getRequireAuth() {
return requireAuth;
Expand Down
Expand Up @@ -45,7 +45,7 @@ public static interface Op {

/** @return true if the operation cannot use a token */
public boolean getRequireAuth();

/** @return true if the operation will do output. */
public boolean getDoOutput();

Expand All @@ -69,7 +69,7 @@ public static class TemporaryRedirectOp implements Op {
GetOpParam.Op.OPEN);
static final TemporaryRedirectOp GETFILECHECKSUM = new TemporaryRedirectOp(
GetOpParam.Op.GETFILECHECKSUM);

static final List<TemporaryRedirectOp> values
= Collections.unmodifiableList(Arrays.asList(CREATE, APPEND, OPEN,
GETFILECHECKSUM));
Expand Down
Expand Up @@ -38,7 +38,7 @@ private void checkRange(final Integer min, final Integer max) {
+ " = " + domain.toString(value) + " > " + domain.toString(max));
}
}

@Override
public String toString() {
return getName() + "=" + domain.toString(getValue());
Expand Down Expand Up @@ -80,7 +80,7 @@ Integer parse(final String str) {
}
}

/** Convert an Integer to a String. */
/** Convert an Integer to a String. */
String toString(final Integer n) {
return n == null? NULL: Integer.toString(n, radix);
}
Expand Down
Expand Up @@ -37,7 +37,7 @@ private void checkRange(final Long min, final Long max) {
+ " = " + domain.toString(value) + " > " + domain.toString(max));
}
}

@Override
public String toString() {
return getName() + "=" + domain.toString(getValue());
Expand Down Expand Up @@ -79,7 +79,7 @@ Long parse(final String str) {
}
}

/** Convert a Long to a String. */
/** Convert a Long to a String. */
String toString(final Long n) {
return n == null? NULL: Long.toString(n, radix);
}
Expand Down
Expand Up @@ -28,7 +28,7 @@ public class OldSnapshotNameParam extends StringParam {
public static final String DEFAULT = "";

private static final Domain DOMAIN = new Domain(NAME, null);

public OldSnapshotNameParam(final String str) {
super(DOMAIN, str != null && !str.equals(DEFAULT) ? str : null);
}
Expand Down
Expand Up @@ -26,7 +26,7 @@
/** Base class of parameters. */
public abstract class Param<T, D extends Param.Domain<T>> {
static final String NULL = "null";

static final Comparator<Param<?,?>> NAME_CMP = new Comparator<Param<?,?>>() {
@Override
public int compare(Param<?, ?> left, Param<?, ?> right) {
Expand Down Expand Up @@ -90,11 +90,11 @@ public String toString() {
static abstract class Domain<T> {
/** Parameter name. */
final String paramName;

Domain(final String paramName) {
this.paramName = paramName;
}

/** @return the parameter name. */
public final String getParamName() {
return paramName;
Expand Down
Expand Up @@ -34,7 +34,7 @@ public class PermissionParam extends ShortParam {
public static FsPermission getDefaultFsPermission() {
return new FsPermission(DEFAULT_PERMISSION);
}

/**
* Constructor.
* @param value the parameter value.
Expand Down
Expand Up @@ -43,7 +43,7 @@ public static enum Op implements HttpOpParam.Op {
public Type getType() {
return Type.POST;
}

@Override
public boolean getRequireAuth() {
return false;
Expand Down
Expand Up @@ -33,22 +33,22 @@ public static enum Op implements HttpOpParam.Op {
SETOWNER(false, HttpURLConnection.HTTP_OK),
SETPERMISSION(false, HttpURLConnection.HTTP_OK),
SETTIMES(false, HttpURLConnection.HTTP_OK),

RENEWDELEGATIONTOKEN(false, HttpURLConnection.HTTP_OK, true),
CANCELDELEGATIONTOKEN(false, HttpURLConnection.HTTP_OK, true),

MODIFYACLENTRIES(false, HttpURLConnection.HTTP_OK),
REMOVEACLENTRIES(false, HttpURLConnection.HTTP_OK),
REMOVEDEFAULTACL(false, HttpURLConnection.HTTP_OK),
REMOVEACL(false, HttpURLConnection.HTTP_OK),
SETACL(false, HttpURLConnection.HTTP_OK),
SETXATTR(false, HttpURLConnection.HTTP_OK),

SETXATTR(false, HttpURLConnection.HTTP_OK),
REMOVEXATTR(false, HttpURLConnection.HTTP_OK),

CREATESNAPSHOT(false, HttpURLConnection.HTTP_OK),
RENAMESNAPSHOT(false, HttpURLConnection.HTTP_OK),

NULL(false, HttpURLConnection.HTTP_NOT_IMPLEMENTED);

final boolean doOutputAndRedirect;
Expand All @@ -58,7 +58,7 @@ public static enum Op implements HttpOpParam.Op {
Op(final boolean doOutputAndRedirect, final int expectedHttpResponseCode) {
this(doOutputAndRedirect, expectedHttpResponseCode, false);
}

Op(final boolean doOutputAndRedirect, final int expectedHttpResponseCode,
final boolean requireAuth) {
this.doOutputAndRedirect = doOutputAndRedirect;
Expand All @@ -70,7 +70,7 @@ public static enum Op implements HttpOpParam.Op {
public HttpOpParam.Type getType() {
return HttpOpParam.Type.PUT;
}

@Override
public boolean getRequireAuth() {
return requireAuth;
Expand Down
Expand Up @@ -17,8 +17,8 @@
*/
package org.apache.hadoop.hdfs.web.resources;

import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_REPLICATION_DEFAULT;
import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_REPLICATION_KEY;
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_REPLICATION_DEFAULT;
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_REPLICATION_KEY;

import org.apache.hadoop.conf.Configuration;

Expand Down
Expand Up @@ -38,7 +38,7 @@ private void checkRange(final Short min, final Short max) {
+ " = " + domain.toString(value) + " > " + domain.toString(max));
}
}

@Override
public String toString() {
return getName() + "=" + domain.toString(getValue());
Expand Down Expand Up @@ -80,7 +80,7 @@ Short parse(final String str) {
}
}

/** Convert a Short to a String. */
/** Convert a Short to a String. */
String toString(final Short n) {
return n == null? NULL: Integer.toString(n, radix);
}
Expand Down
Expand Up @@ -29,7 +29,7 @@ public class SnapshotNameParam extends StringParam {
public static final String DEFAULT = "";

private static final Domain DOMAIN = new Domain(NAME, null);

public SnapshotNameParam(final String str) {
super(DOMAIN, str != null && !str.equals(DEFAULT) ? str : null);
}
Expand Down
Expand Up @@ -17,10 +17,10 @@
*/
package org.apache.hadoop.hdfs.web.resources;

import static org.apache.hadoop.hdfs.DFSConfigKeys.DFS_WEBHDFS_USER_PATTERN_DEFAULT;
import static org.apache.hadoop.hdfs.client.HdfsClientConfigKeys.DFS_WEBHDFS_USER_PATTERN_DEFAULT;
import org.apache.hadoop.security.UserGroupInformation;
import com.google.common.annotations.VisibleForTesting;

import java.text.MessageFormat;
import java.util.regex.Pattern;

Expand Down
Expand Up @@ -24,14 +24,14 @@ public class XAttrEncodingParam extends EnumParam<XAttrCodec> {
public static final String NAME = "encoding";
/** Default parameter value. */
public static final String DEFAULT = "";
private static final Domain<XAttrCodec> DOMAIN =

private static final Domain<XAttrCodec> DOMAIN =
new Domain<XAttrCodec>(NAME, XAttrCodec.class);

public XAttrEncodingParam(final XAttrCodec encoding) {
super(DOMAIN, encoding);
}

/**
* Constructor.
* @param str a string representation of the parameter value.
Expand All @@ -44,12 +44,12 @@ public XAttrEncodingParam(final String str) {
public String getName() {
return NAME;
}

@Override
public String getValueString() {
return value.toString();
}

public XAttrCodec getEncoding() {
return getValue();
}
Expand Down
Expand Up @@ -24,10 +24,10 @@ public class XAttrNameParam extends StringParam {
public static final String NAME = "xattr.name";
/** Default parameter value. **/
public static final String DEFAULT = "";

private static Domain DOMAIN = new Domain(NAME,
Pattern.compile(".*"));

public XAttrNameParam(final String str) {
super(DOMAIN, str == null || str.equals(DEFAULT) ? null : str);
}
Expand All @@ -36,7 +36,7 @@ public XAttrNameParam(final String str) {
public String getName() {
return NAME;
}

public String getXAttrName() {
final String v = getValue();
return v;
Expand Down
Expand Up @@ -33,7 +33,7 @@ public class XAttrSetFlagParam extends EnumSetParam<XAttrSetFlag> {
public XAttrSetFlagParam(final EnumSet<XAttrSetFlag> flag) {
super(DOMAIN, flag);
}

/**
* Constructor.
* @param str a string representation of the parameter value.
Expand All @@ -46,7 +46,7 @@ public XAttrSetFlagParam(final String str) {
public String getName() {
return NAME;
}

public EnumSet<XAttrSetFlag> getFlag() {
return getValue();
}
Expand Down
Expand Up @@ -26,9 +26,9 @@ public class XAttrValueParam extends StringParam {
public static final String NAME = "xattr.value";
/** Default parameter value. **/
public static final String DEFAULT = "";

private static Domain DOMAIN = new Domain(NAME, null);

public XAttrValueParam(final String str) {
super(DOMAIN, str == null || str.equals(DEFAULT) ? null : str);
}
Expand All @@ -37,7 +37,7 @@ public XAttrValueParam(final String str) {
public String getName() {
return NAME;
}

public byte[] getXAttrValue() throws IOException {
final String v = getValue();
return XAttrCodec.decodeValue(v);
Expand Down
2 changes: 2 additions & 0 deletions hadoop-hdfs-project/hadoop-hdfs/CHANGES.txt
Expand Up @@ -402,6 +402,8 @@ Release 2.8.0 - UNRELEASED
HDFS-8025. Addendum fix for HDFS-3087 Decomissioning on NN restart can
complete without blocks being replicated. (Ming Ma via wang)

HDFS-8089. Move o.a.h.hdfs.web.resources.* to the client jars. (wheat9)

OPTIMIZATIONS

HDFS-8026. Trace FSOutputSummer#writeChecksumChunks rather than
Expand Down

0 comments on commit cc25823

Please sign in to comment.