|
@@ -121,6 +121,7 @@ import org.apache.hadoop.security.token.TokenIdentifier;
|
|
|
|
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.annotations.VisibleForTesting;
|
|
import com.google.common.base.Charsets;
|
|
import com.google.common.base.Charsets;
|
|
|
|
+import com.google.common.collect.Lists;
|
|
import com.sun.jersey.spi.container.ResourceFilters;
|
|
import com.sun.jersey.spi.container.ResourceFilters;
|
|
|
|
|
|
/** Web-hdfs NameNode implementation. */
|
|
/** Web-hdfs NameNode implementation. */
|
|
@@ -712,12 +713,12 @@ public class NamenodeWebHdfsMethods {
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
final BufferSizeParam bufferSize,
|
|
final BufferSizeParam bufferSize,
|
|
@QueryParam(XAttrNameParam.NAME) @DefaultValue(XAttrNameParam.DEFAULT)
|
|
@QueryParam(XAttrNameParam.NAME) @DefaultValue(XAttrNameParam.DEFAULT)
|
|
- final XAttrNameParam xattrName,
|
|
|
|
|
|
+ final List<XAttrNameParam> xattrNames,
|
|
@QueryParam(XAttrEncodingParam.NAME) @DefaultValue(XAttrEncodingParam.DEFAULT)
|
|
@QueryParam(XAttrEncodingParam.NAME) @DefaultValue(XAttrEncodingParam.DEFAULT)
|
|
final XAttrEncodingParam xattrEncoding
|
|
final XAttrEncodingParam xattrEncoding
|
|
) throws IOException, InterruptedException {
|
|
) throws IOException, InterruptedException {
|
|
return get(ugi, delegation, username, doAsUser, ROOT, op, offset, length,
|
|
return get(ugi, delegation, username, doAsUser, ROOT, op, offset, length,
|
|
- renewer, bufferSize, xattrName, xattrEncoding);
|
|
|
|
|
|
+ renewer, bufferSize, xattrNames, xattrEncoding);
|
|
}
|
|
}
|
|
|
|
|
|
/** Handle HTTP GET request. */
|
|
/** Handle HTTP GET request. */
|
|
@@ -744,13 +745,13 @@ public class NamenodeWebHdfsMethods {
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
final BufferSizeParam bufferSize,
|
|
final BufferSizeParam bufferSize,
|
|
@QueryParam(XAttrNameParam.NAME) @DefaultValue(XAttrNameParam.DEFAULT)
|
|
@QueryParam(XAttrNameParam.NAME) @DefaultValue(XAttrNameParam.DEFAULT)
|
|
- final XAttrNameParam xattrName,
|
|
|
|
|
|
+ final List<XAttrNameParam> xattrNames,
|
|
@QueryParam(XAttrEncodingParam.NAME) @DefaultValue(XAttrEncodingParam.DEFAULT)
|
|
@QueryParam(XAttrEncodingParam.NAME) @DefaultValue(XAttrEncodingParam.DEFAULT)
|
|
final XAttrEncodingParam xattrEncoding
|
|
final XAttrEncodingParam xattrEncoding
|
|
) throws IOException, InterruptedException {
|
|
) throws IOException, InterruptedException {
|
|
|
|
|
|
init(ugi, delegation, username, doAsUser, path, op, offset, length,
|
|
init(ugi, delegation, username, doAsUser, path, op, offset, length,
|
|
- renewer, bufferSize, xattrName, xattrEncoding);
|
|
|
|
|
|
+ renewer, bufferSize, xattrEncoding);
|
|
|
|
|
|
return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
@Override
|
|
@Override
|
|
@@ -758,7 +759,7 @@ public class NamenodeWebHdfsMethods {
|
|
try {
|
|
try {
|
|
return get(ugi, delegation, username, doAsUser,
|
|
return get(ugi, delegation, username, doAsUser,
|
|
path.getAbsolutePath(), op, offset, length, renewer, bufferSize,
|
|
path.getAbsolutePath(), op, offset, length, renewer, bufferSize,
|
|
- xattrName, xattrEncoding);
|
|
|
|
|
|
+ xattrNames, xattrEncoding);
|
|
} finally {
|
|
} finally {
|
|
reset();
|
|
reset();
|
|
}
|
|
}
|
|
@@ -777,7 +778,7 @@ public class NamenodeWebHdfsMethods {
|
|
final LengthParam length,
|
|
final LengthParam length,
|
|
final RenewerParam renewer,
|
|
final RenewerParam renewer,
|
|
final BufferSizeParam bufferSize,
|
|
final BufferSizeParam bufferSize,
|
|
- final XAttrNameParam xattrName,
|
|
|
|
|
|
+ final List<XAttrNameParam> xattrNames,
|
|
final XAttrEncodingParam xattrEncoding
|
|
final XAttrEncodingParam xattrEncoding
|
|
) throws IOException, URISyntaxException {
|
|
) throws IOException, URISyntaxException {
|
|
final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
final NameNode namenode = (NameNode)context.getAttribute("name.node");
|
|
@@ -853,15 +854,18 @@ public class NamenodeWebHdfsMethods {
|
|
final String js = JsonUtil.toJsonString(status);
|
|
final String js = JsonUtil.toJsonString(status);
|
|
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
|
|
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
|
|
}
|
|
}
|
|
- case GETXATTR: {
|
|
|
|
- XAttr xAttr = XAttrHelper.getFirstXAttr(np.getXAttrs(fullpath,
|
|
|
|
- XAttrHelper.buildXAttrAsList(xattrName.getXAttrName())));
|
|
|
|
- final String js = JsonUtil.toJsonString(xAttr,
|
|
|
|
- xattrEncoding.getEncoding());
|
|
|
|
- return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
|
|
|
|
- }
|
|
|
|
case GETXATTRS: {
|
|
case GETXATTRS: {
|
|
- List<XAttr> xAttrs = np.getXAttrs(fullpath, null);
|
|
|
|
|
|
+ List<String> names = null;
|
|
|
|
+ if (xattrNames != null) {
|
|
|
|
+ names = Lists.newArrayListWithCapacity(xattrNames.size());
|
|
|
|
+ for (XAttrNameParam xattrName : xattrNames) {
|
|
|
|
+ if (xattrName.getXAttrName() != null) {
|
|
|
|
+ names.add(xattrName.getXAttrName());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ List<XAttr> xAttrs = np.getXAttrs(fullpath, (names != null &&
|
|
|
|
+ !names.isEmpty()) ? XAttrHelper.buildXAttrs(names) : null);
|
|
final String js = JsonUtil.toJsonString(xAttrs,
|
|
final String js = JsonUtil.toJsonString(xAttrs,
|
|
xattrEncoding.getEncoding());
|
|
xattrEncoding.getEncoding());
|
|
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
|
|
return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
|