|
@@ -28,6 +28,7 @@ import java.net.URISyntaxException;
|
|
import java.security.PrivilegedExceptionAction;
|
|
import java.security.PrivilegedExceptionAction;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.EnumSet;
|
|
import java.util.EnumSet;
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
import javax.servlet.ServletContext;
|
|
import javax.servlet.ServletContext;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
@@ -53,8 +54,10 @@ import org.apache.hadoop.conf.Configuration;
|
|
import org.apache.hadoop.fs.ContentSummary;
|
|
import org.apache.hadoop.fs.ContentSummary;
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.FileStatus;
|
|
import org.apache.hadoop.fs.Options;
|
|
import org.apache.hadoop.fs.Options;
|
|
|
|
+import org.apache.hadoop.fs.XAttr;
|
|
import org.apache.hadoop.fs.permission.AclStatus;
|
|
import org.apache.hadoop.fs.permission.AclStatus;
|
|
import org.apache.hadoop.hdfs.StorageType;
|
|
import org.apache.hadoop.hdfs.StorageType;
|
|
|
|
+import org.apache.hadoop.hdfs.XAttrHelper;
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
|
import org.apache.hadoop.hdfs.protocol.DatanodeInfo;
|
|
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
|
import org.apache.hadoop.hdfs.protocol.DirectoryListing;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
import org.apache.hadoop.hdfs.protocol.HdfsFileStatus;
|
|
@@ -101,6 +104,10 @@ import org.apache.hadoop.hdfs.web.resources.ReplicationParam;
|
|
import org.apache.hadoop.hdfs.web.resources.TokenArgumentParam;
|
|
import org.apache.hadoop.hdfs.web.resources.TokenArgumentParam;
|
|
import org.apache.hadoop.hdfs.web.resources.UriFsPathParam;
|
|
import org.apache.hadoop.hdfs.web.resources.UriFsPathParam;
|
|
import org.apache.hadoop.hdfs.web.resources.UserParam;
|
|
import org.apache.hadoop.hdfs.web.resources.UserParam;
|
|
|
|
+import org.apache.hadoop.hdfs.web.resources.XAttrEncodingParam;
|
|
|
|
+import org.apache.hadoop.hdfs.web.resources.XAttrNameParam;
|
|
|
|
+import org.apache.hadoop.hdfs.web.resources.XAttrSetFlagParam;
|
|
|
|
+import org.apache.hadoop.hdfs.web.resources.XAttrValueParam;
|
|
import org.apache.hadoop.io.Text;
|
|
import org.apache.hadoop.io.Text;
|
|
import org.apache.hadoop.ipc.Server;
|
|
import org.apache.hadoop.ipc.Server;
|
|
import org.apache.hadoop.net.NetworkTopology.InvalidTopologyException;
|
|
import org.apache.hadoop.net.NetworkTopology.InvalidTopologyException;
|
|
@@ -341,12 +348,19 @@ public class NamenodeWebHdfsMethods {
|
|
@QueryParam(TokenArgumentParam.NAME) @DefaultValue(TokenArgumentParam.DEFAULT)
|
|
@QueryParam(TokenArgumentParam.NAME) @DefaultValue(TokenArgumentParam.DEFAULT)
|
|
final TokenArgumentParam delegationTokenArgument,
|
|
final TokenArgumentParam delegationTokenArgument,
|
|
@QueryParam(AclPermissionParam.NAME) @DefaultValue(AclPermissionParam.DEFAULT)
|
|
@QueryParam(AclPermissionParam.NAME) @DefaultValue(AclPermissionParam.DEFAULT)
|
|
- final AclPermissionParam aclPermission
|
|
|
|
|
|
+ final AclPermissionParam aclPermission,
|
|
|
|
+ @QueryParam(XAttrNameParam.NAME) @DefaultValue(XAttrNameParam.DEFAULT)
|
|
|
|
+ final XAttrNameParam xattrName,
|
|
|
|
+ @QueryParam(XAttrValueParam.NAME) @DefaultValue(XAttrValueParam.DEFAULT)
|
|
|
|
+ final XAttrValueParam xattrValue,
|
|
|
|
+ @QueryParam(XAttrSetFlagParam.NAME) @DefaultValue(XAttrSetFlagParam.DEFAULT)
|
|
|
|
+ final XAttrSetFlagParam xattrSetFlag
|
|
)throws IOException, InterruptedException {
|
|
)throws IOException, InterruptedException {
|
|
return put(ugi, delegation, username, doAsUser, ROOT, op, destination,
|
|
return put(ugi, delegation, username, doAsUser, ROOT, op, destination,
|
|
owner, group, permission, overwrite, bufferSize, replication,
|
|
owner, group, permission, overwrite, bufferSize, replication,
|
|
blockSize, modificationTime, accessTime, renameOptions, createParent,
|
|
blockSize, modificationTime, accessTime, renameOptions, createParent,
|
|
- delegationTokenArgument,aclPermission);
|
|
|
|
|
|
+ delegationTokenArgument,aclPermission, xattrName, xattrValue,
|
|
|
|
+ xattrSetFlag);
|
|
}
|
|
}
|
|
|
|
|
|
/** Handle HTTP PUT request. */
|
|
/** Handle HTTP PUT request. */
|
|
@@ -392,12 +406,19 @@ public class NamenodeWebHdfsMethods {
|
|
@QueryParam(TokenArgumentParam.NAME) @DefaultValue(TokenArgumentParam.DEFAULT)
|
|
@QueryParam(TokenArgumentParam.NAME) @DefaultValue(TokenArgumentParam.DEFAULT)
|
|
final TokenArgumentParam delegationTokenArgument,
|
|
final TokenArgumentParam delegationTokenArgument,
|
|
@QueryParam(AclPermissionParam.NAME) @DefaultValue(AclPermissionParam.DEFAULT)
|
|
@QueryParam(AclPermissionParam.NAME) @DefaultValue(AclPermissionParam.DEFAULT)
|
|
- final AclPermissionParam aclPermission
|
|
|
|
|
|
+ final AclPermissionParam aclPermission,
|
|
|
|
+ @QueryParam(XAttrNameParam.NAME) @DefaultValue(XAttrNameParam.DEFAULT)
|
|
|
|
+ final XAttrNameParam xattrName,
|
|
|
|
+ @QueryParam(XAttrValueParam.NAME) @DefaultValue(XAttrValueParam.DEFAULT)
|
|
|
|
+ final XAttrValueParam xattrValue,
|
|
|
|
+ @QueryParam(XAttrSetFlagParam.NAME) @DefaultValue(XAttrSetFlagParam.DEFAULT)
|
|
|
|
+ final XAttrSetFlagParam xattrSetFlag
|
|
) throws IOException, InterruptedException {
|
|
) throws IOException, InterruptedException {
|
|
|
|
|
|
init(ugi, delegation, username, doAsUser, path, op, destination, owner,
|
|
init(ugi, delegation, username, doAsUser, path, op, destination, owner,
|
|
group, permission, overwrite, bufferSize, replication, blockSize,
|
|
group, permission, overwrite, bufferSize, replication, blockSize,
|
|
- modificationTime, accessTime, renameOptions, delegationTokenArgument,aclPermission);
|
|
|
|
|
|
+ modificationTime, accessTime, renameOptions, delegationTokenArgument,aclPermission,
|
|
|
|
+ xattrName, xattrValue, xattrSetFlag);
|
|
|
|
|
|
return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
@Override
|
|
@Override
|
|
@@ -407,7 +428,8 @@ public class NamenodeWebHdfsMethods {
|
|
path.getAbsolutePath(), op, destination, owner, group,
|
|
path.getAbsolutePath(), op, destination, owner, group,
|
|
permission, overwrite, bufferSize, replication, blockSize,
|
|
permission, overwrite, bufferSize, replication, blockSize,
|
|
modificationTime, accessTime, renameOptions, createParent,
|
|
modificationTime, accessTime, renameOptions, createParent,
|
|
- delegationTokenArgument,aclPermission);
|
|
|
|
|
|
+ delegationTokenArgument,aclPermission, xattrName,
|
|
|
|
+ xattrValue, xattrSetFlag);
|
|
} finally {
|
|
} finally {
|
|
reset();
|
|
reset();
|
|
}
|
|
}
|
|
@@ -435,7 +457,10 @@ public class NamenodeWebHdfsMethods {
|
|
final RenameOptionSetParam renameOptions,
|
|
final RenameOptionSetParam renameOptions,
|
|
final CreateParentParam createParent,
|
|
final CreateParentParam createParent,
|
|
final TokenArgumentParam delegationTokenArgument,
|
|
final TokenArgumentParam delegationTokenArgument,
|
|
- final AclPermissionParam aclPermission
|
|
|
|
|
|
+ final AclPermissionParam aclPermission,
|
|
|
|
+ final XAttrNameParam xattrName,
|
|
|
|
+ final XAttrValueParam xattrValue,
|
|
|
|
+ final XAttrSetFlagParam xattrSetFlag
|
|
) throws IOException, URISyntaxException {
|
|
) throws IOException, URISyntaxException {
|
|
|
|
|
|
final Configuration conf = (Configuration)context.getAttribute(JspHelper.CURRENT_CONF);
|
|
final Configuration conf = (Configuration)context.getAttribute(JspHelper.CURRENT_CONF);
|
|
@@ -535,6 +560,15 @@ public class NamenodeWebHdfsMethods {
|
|
np.setAcl(fullpath, aclPermission.getAclPermission(true));
|
|
np.setAcl(fullpath, aclPermission.getAclPermission(true));
|
|
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
|
|
return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
|
|
}
|
|
}
|
|
|
|
+ case SETXATTR: {
|
|
|
|
+ np.setXAttr(fullpath, XAttrHelper.buildXAttr(xattrName.getXAttrName(),
|
|
|
|
+ xattrValue.getXAttrValue()), xattrSetFlag.getFlag());
|
|
|
|
+ return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
|
|
|
|
+ }
|
|
|
|
+ case REMOVEXATTR: {
|
|
|
|
+ np.removeXAttr(fullpath, XAttrHelper.buildXAttr(xattrName.getXAttrName()));
|
|
|
|
+ return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build();
|
|
|
|
+ }
|
|
default:
|
|
default:
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
}
|
|
}
|
|
@@ -650,10 +684,14 @@ public class NamenodeWebHdfsMethods {
|
|
@QueryParam(RenewerParam.NAME) @DefaultValue(RenewerParam.DEFAULT)
|
|
@QueryParam(RenewerParam.NAME) @DefaultValue(RenewerParam.DEFAULT)
|
|
final RenewerParam renewer,
|
|
final RenewerParam renewer,
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
- final BufferSizeParam bufferSize
|
|
|
|
|
|
+ final BufferSizeParam bufferSize,
|
|
|
|
+ @QueryParam(XAttrNameParam.NAME) @DefaultValue(XAttrNameParam.DEFAULT)
|
|
|
|
+ final XAttrNameParam xattrName,
|
|
|
|
+ @QueryParam(XAttrEncodingParam.NAME) @DefaultValue(XAttrEncodingParam.DEFAULT)
|
|
|
|
+ final XAttrEncodingParam xattrEncoding
|
|
) throws IOException, InterruptedException {
|
|
) throws IOException, InterruptedException {
|
|
return get(ugi, delegation, username, doAsUser, ROOT, op,
|
|
return get(ugi, delegation, username, doAsUser, ROOT, op,
|
|
- offset, length, renewer, bufferSize);
|
|
|
|
|
|
+ offset, length, renewer, bufferSize, xattrName, xattrEncoding);
|
|
}
|
|
}
|
|
|
|
|
|
/** Handle HTTP GET request. */
|
|
/** Handle HTTP GET request. */
|
|
@@ -678,18 +716,23 @@ public class NamenodeWebHdfsMethods {
|
|
@QueryParam(RenewerParam.NAME) @DefaultValue(RenewerParam.DEFAULT)
|
|
@QueryParam(RenewerParam.NAME) @DefaultValue(RenewerParam.DEFAULT)
|
|
final RenewerParam renewer,
|
|
final RenewerParam renewer,
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
@QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
|
|
- final BufferSizeParam bufferSize
|
|
|
|
|
|
+ final BufferSizeParam bufferSize,
|
|
|
|
+ @QueryParam(XAttrNameParam.NAME) @DefaultValue(XAttrNameParam.DEFAULT)
|
|
|
|
+ final XAttrNameParam xattrName,
|
|
|
|
+ @QueryParam(XAttrEncodingParam.NAME) @DefaultValue(XAttrEncodingParam.DEFAULT)
|
|
|
|
+ final XAttrEncodingParam xattrEncoding
|
|
) throws IOException, InterruptedException {
|
|
) throws IOException, InterruptedException {
|
|
|
|
|
|
init(ugi, delegation, username, doAsUser, path, op,
|
|
init(ugi, delegation, username, doAsUser, path, op,
|
|
- offset, length, renewer, bufferSize);
|
|
|
|
|
|
+ offset, length, renewer, bufferSize, xattrName, xattrEncoding);
|
|
|
|
|
|
return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
return ugi.doAs(new PrivilegedExceptionAction<Response>() {
|
|
@Override
|
|
@Override
|
|
public Response run() throws IOException, URISyntaxException {
|
|
public Response run() throws IOException, URISyntaxException {
|
|
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);
|
|
} finally {
|
|
} finally {
|
|
reset();
|
|
reset();
|
|
}
|
|
}
|
|
@@ -707,7 +750,9 @@ public class NamenodeWebHdfsMethods {
|
|
final OffsetParam offset,
|
|
final OffsetParam offset,
|
|
final LengthParam length,
|
|
final LengthParam length,
|
|
final RenewerParam renewer,
|
|
final RenewerParam renewer,
|
|
- final BufferSizeParam bufferSize
|
|
|
|
|
|
+ final BufferSizeParam bufferSize,
|
|
|
|
+ final XAttrNameParam xattrName,
|
|
|
|
+ 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");
|
|
final NamenodeProtocols np = getRPCServer(namenode);
|
|
final NamenodeProtocols np = getRPCServer(namenode);
|
|
@@ -782,6 +827,17 @@ 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: {
|
|
|
|
+ List<XAttr> xAttrs = np.getXAttrs(fullpath, null);
|
|
|
|
+ final String js = JsonUtil.toJsonString(xAttrs, xattrEncoding.getEncoding());
|
|
|
|
+ return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
|
|
|
|
+ }
|
|
default:
|
|
default:
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
throw new UnsupportedOperationException(op + " is not supported");
|
|
}
|
|
}
|