Java 类org.apache.hadoop.hdfs.web.resources.DelegationParam 实例源码

项目:hadoop-2.6.0-cdh5.4.3    文件:DatanodeWebHdfsMethods.java   
private void init(final UserGroupInformation ugi,
    final DelegationParam delegation, final String nnId,
    final UriFsPathParam path, final HttpOpParam<?> op,
    final Param<?, ?>... parameters) throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path
        + ", ugi=" + ugi + Param.toSortedString(", ", parameters));
  }
  if (nnId == null) {
    throw new IllegalArgumentException(NamenodeAddressParam.NAME
        + " is not specified.");
  }

  //clear content type
  response.setContentType(null);

  if (UserGroupInformation.isSecurityEnabled()) {
    //add a token for RPC.
    final Token<DelegationTokenIdentifier> token = deserializeToken
            (delegation.getValue(), nnId);
    ugi.addToken(token);
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    final InputStream in,
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeAddressParam.NAME)
    @DefaultValue(NamenodeAddressParam.DEFAULT)
        final NamenodeAddressParam namenode,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(in, ugi, delegation, namenode, ROOT, op, bufferSize);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeAddressParam.NAME)
    @DefaultValue(NamenodeAddressParam.DEFAULT)
        final NamenodeAddressParam namenode,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return get(ugi, delegation, namenode, ROOT, op, offset, length,
      bufferSize);
}
项目:hadoop-plus    文件:WebHdfsFileSystem.java   
Param<?,?>[] getAuthParameters(final HttpOpParam.Op op) throws IOException {
  List<Param<?,?>> authParams = Lists.newArrayList();    
  // Skip adding delegation token for token operations because these
  // operations require authentication.
  Token<?> token = null;
  if (UserGroupInformation.isSecurityEnabled() && !op.getRequireAuth()) {
    token = getDelegationToken();
  }
  if (token != null) {
    authParams.add(new DelegationParam(token.encodeToUrlString()));
  } else {
    UserGroupInformation userUgi = ugi;
    UserGroupInformation realUgi = userUgi.getRealUser();
    if (realUgi != null) { // proxy user
      authParams.add(new DoAsParam(userUgi.getShortUserName()));
      userUgi = realUgi;
    }
    authParams.add(new UserParam(userUgi.getShortUserName()));
  }
  return authParams.toArray(new Param<?,?>[0]);
}
项目:hadoop-plus    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(ConcatSourcesParam.NAME) @DefaultValue(ConcatSourcesParam.DEFAULT)
        final ConcatSourcesParam concatSrcs,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(ugi, delegation, username, doAsUser, ROOT, op, concatSrcs, bufferSize);
}
项目:hadoop-plus    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(RenewerParam.NAME) @DefaultValue(RenewerParam.DEFAULT)
        final RenewerParam renewer,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return get(ugi, delegation, username, doAsUser, ROOT, op,
      offset, length, renewer, bufferSize);
}
项目:hadoop-plus    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP DELETE request for the root. */
@DELETE
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT)
        final DeleteOpParam op,
    @QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT)
        final RecursiveParam recursive
    ) throws IOException, InterruptedException {
  return delete(ugi, delegation, username, doAsUser, ROOT, op, recursive);
}
项目:hadoop-plus    文件:NamenodeWebHdfsMethods.java   
private Response delete(
    final UserGroupInformation ugi,
    final DelegationParam delegation,
    final UserParam username,
    final DoAsParam doAsUser,
    final String fullpath,
    final DeleteOpParam op,
    final RecursiveParam recursive
    ) throws IOException {
  final NameNode namenode = (NameNode)context.getAttribute("name.node");

  switch(op.getValue()) {
  case DELETE:
  {
    final boolean b = namenode.getRpcServer().delete(fullpath, recursive.getValue());
    final String js = JsonUtil.toJsonString("boolean", b);
    return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
  }
  default:
    throw new UnsupportedOperationException(op + " is not supported");
  }
}
项目:hadoop-plus    文件:DatanodeWebHdfsMethods.java   
private void init(final UserGroupInformation ugi,
    final DelegationParam delegation, final InetSocketAddress nnRpcAddr,
    final UriFsPathParam path, final HttpOpParam<?> op,
    final Param<?, ?>... parameters) throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path
        + ", ugi=" + ugi + Param.toSortedString(", ", parameters));
  }
  if (nnRpcAddr == null) {
    throw new IllegalArgumentException(NamenodeRpcAddressParam.NAME
        + " is not specified.");
  }

  //clear content type
  response.setContentType(null);

  if (UserGroupInformation.isSecurityEnabled()) {
    //add a token for RPC.
    final Token<DelegationTokenIdentifier> token = 
        new Token<DelegationTokenIdentifier>();
    token.decodeFromUrlString(delegation.getValue());
    SecurityUtil.setTokenService(token, nnRpcAddr);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
    ugi.addToken(token);
  }
}
项目:hadoop-plus    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    final InputStream in,
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
        final NamenodeRpcAddressParam namenodeRpcAddress,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(in, ugi, delegation, namenodeRpcAddress, ROOT, op, bufferSize);
}
项目:hadoop-plus    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
        final NamenodeRpcAddressParam namenodeRpcAddress,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return get(ugi, delegation, namenodeRpcAddress, ROOT, op, offset, length,
      bufferSize);
}
项目:FlexMap    文件:DatanodeWebHdfsMethods.java   
private void init(final UserGroupInformation ugi,
    final DelegationParam delegation, final String nnId,
    final UriFsPathParam path, final HttpOpParam<?> op,
    final Param<?, ?>... parameters) throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path
        + ", ugi=" + ugi + Param.toSortedString(", ", parameters));
  }
  if (nnId == null) {
    throw new IllegalArgumentException(NamenodeAddressParam.NAME
        + " is not specified.");
  }

  //clear content type
  response.setContentType(null);

  if (UserGroupInformation.isSecurityEnabled()) {
    //add a token for RPC.
    final Token<DelegationTokenIdentifier> token = deserializeToken
            (delegation.getValue(), nnId);
    ugi.addToken(token);
  }
}
项目:FlexMap    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    final InputStream in,
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeAddressParam.NAME)
    @DefaultValue(NamenodeAddressParam.DEFAULT)
        final NamenodeAddressParam namenode,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(in, ugi, delegation, namenode, ROOT, op, bufferSize);
}
项目:FlexMap    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeAddressParam.NAME)
    @DefaultValue(NamenodeAddressParam.DEFAULT)
        final NamenodeAddressParam namenode,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return get(ugi, delegation, namenode, ROOT, op, offset, length,
      bufferSize);
}
项目:hops    文件:NamenodeWebHdfsMethods.java   
private Response post(final UserGroupInformation ugi,
    final DelegationParam delegation, final UserParam username,
    final DoAsParam doAsUser, final String fullpath, final PostOpParam op,
    final ConcatSourcesParam concatSrcs, final BufferSizeParam bufferSize)
    throws IOException, URISyntaxException {
  final NameNode namenode = (NameNode) context.getAttribute("name.node");

  switch (op.getValue()) {
    case APPEND: {
      final URI uri =
          redirectURI(namenode, ugi, delegation, username, doAsUser, fullpath,
              op.getValue(), -1L, -1L, bufferSize);
      return Response.temporaryRedirect(uri)
          .type(MediaType.APPLICATION_OCTET_STREAM).build();
    }
    case CONCAT: {
      namenode.getRpcServer().concat(fullpath, concatSrcs.getAbsolutePaths());
      return Response.ok().build();
    }
    default:
      throw new UnsupportedOperationException(op + " is not supported");
  }
}
项目:hops    文件:NamenodeWebHdfsMethods.java   
/**
 * Handle HTTP DELETE request for the root.
 */
@DELETE
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteRoot(
    @Context
    final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME)
    @DefaultValue(DelegationParam.DEFAULT)
    final DelegationParam delegation,
    @QueryParam(UserParam.NAME)
    @DefaultValue(UserParam.DEFAULT)
    final UserParam username,
    @QueryParam(DoAsParam.NAME)
    @DefaultValue(DoAsParam.DEFAULT)
    final DoAsParam doAsUser,
    @QueryParam(DeleteOpParam.NAME)
    @DefaultValue(DeleteOpParam.DEFAULT)
    final DeleteOpParam op,
    @QueryParam(RecursiveParam.NAME)
    @DefaultValue(RecursiveParam.DEFAULT)
    final RecursiveParam recursive) throws IOException, InterruptedException {
  return delete(ugi, delegation, username, doAsUser, ROOT, op, recursive);
}
项目:hops    文件:NamenodeWebHdfsMethods.java   
private Response delete(final UserGroupInformation ugi,
    final DelegationParam delegation, final UserParam username,
    final DoAsParam doAsUser, final String fullpath, final DeleteOpParam op,
    final RecursiveParam recursive) throws IOException {
  final NameNode namenode = (NameNode) context.getAttribute("name.node");

  switch (op.getValue()) {
    case DELETE: {
      final boolean b =
          namenode.getRpcServer().delete(fullpath, recursive.getValue());
      final String js = JsonUtil.toJsonString("boolean", b);
      return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
    }
    default:
      throw new UnsupportedOperationException(op + " is not supported");
  }
}
项目:hops    文件:DatanodeWebHdfsMethods.java   
private void init(final UserGroupInformation ugi,
    final DelegationParam delegation, final InetSocketAddress nnRpcAddr,
    final UriFsPathParam path, final HttpOpParam<?> op,
    final Param<?, ?>... parameters) throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path +
        ", ugi=" + ugi + Param.toSortedString(", ", parameters));
  }
  if (nnRpcAddr == null) {
    throw new IllegalArgumentException(
        NamenodeRpcAddressParam.NAME + " is not specified.");
  }

  //clear content type
  response.setContentType(null);

  if (UserGroupInformation.isSecurityEnabled()) {
    //add a token for RPC.
    final Token<DelegationTokenIdentifier> token =
        new Token<>();
    token.decodeFromUrlString(delegation.getValue());
    SecurityUtil.setTokenService(token, nnRpcAddr);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
    ugi.addToken(token);
  }
}
项目:hops    文件:DatanodeWebHdfsMethods.java   
/**
 * Handle HTTP POST request for the root for the root.
 */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(final InputStream in,
    @Context
    final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME)
    @DefaultValue(DelegationParam.DEFAULT)
    final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
    final NamenodeRpcAddressParam namenodeRpcAddress,
    @QueryParam(PostOpParam.NAME)
    @DefaultValue(PostOpParam.DEFAULT)
    final PostOpParam op,
    @QueryParam(BufferSizeParam.NAME)
    @DefaultValue(BufferSizeParam.DEFAULT)
    final BufferSizeParam bufferSize)
    throws IOException, InterruptedException {
  return post(in, ugi, delegation, namenodeRpcAddress, ROOT, op, bufferSize);
}
项目:hadoop-TCP    文件:WebHdfsFileSystem.java   
Param<?,?>[] getAuthParameters(final HttpOpParam.Op op) throws IOException {
  List<Param<?,?>> authParams = Lists.newArrayList();    
  // Skip adding delegation token for token operations because these
  // operations require authentication.
  Token<?> token = null;
  if (UserGroupInformation.isSecurityEnabled() && !op.getRequireAuth()) {
    token = getDelegationToken();
  }
  if (token != null) {
    authParams.add(new DelegationParam(token.encodeToUrlString()));
  } else {
    UserGroupInformation userUgi = ugi;
    UserGroupInformation realUgi = userUgi.getRealUser();
    if (realUgi != null) { // proxy user
      authParams.add(new DoAsParam(userUgi.getShortUserName()));
      userUgi = realUgi;
    }
    authParams.add(new UserParam(userUgi.getShortUserName()));
  }
  return authParams.toArray(new Param<?,?>[0]);
}
项目:hadoop-TCP    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(ConcatSourcesParam.NAME) @DefaultValue(ConcatSourcesParam.DEFAULT)
        final ConcatSourcesParam concatSrcs,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(ugi, delegation, username, doAsUser, ROOT, op, concatSrcs, bufferSize);
}
项目:hadoop-TCP    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(RenewerParam.NAME) @DefaultValue(RenewerParam.DEFAULT)
        final RenewerParam renewer,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return get(ugi, delegation, username, doAsUser, ROOT, op,
      offset, length, renewer, bufferSize);
}
项目:hadoop-TCP    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP DELETE request for the root. */
@DELETE
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT)
        final DeleteOpParam op,
    @QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT)
        final RecursiveParam recursive
    ) throws IOException, InterruptedException {
  return delete(ugi, delegation, username, doAsUser, ROOT, op, recursive);
}
项目:hadoop-TCP    文件:NamenodeWebHdfsMethods.java   
private Response delete(
    final UserGroupInformation ugi,
    final DelegationParam delegation,
    final UserParam username,
    final DoAsParam doAsUser,
    final String fullpath,
    final DeleteOpParam op,
    final RecursiveParam recursive
    ) throws IOException {
  final NameNode namenode = (NameNode)context.getAttribute("name.node");

  switch(op.getValue()) {
  case DELETE:
  {
    final boolean b = namenode.getRpcServer().delete(fullpath, recursive.getValue());
    final String js = JsonUtil.toJsonString("boolean", b);
    return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
  }
  default:
    throw new UnsupportedOperationException(op + " is not supported");
  }
}
项目:hadoop-TCP    文件:DatanodeWebHdfsMethods.java   
private void init(final UserGroupInformation ugi,
    final DelegationParam delegation, final InetSocketAddress nnRpcAddr,
    final UriFsPathParam path, final HttpOpParam<?> op,
    final Param<?, ?>... parameters) throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path
        + ", ugi=" + ugi + Param.toSortedString(", ", parameters));
  }
  if (nnRpcAddr == null) {
    throw new IllegalArgumentException(NamenodeRpcAddressParam.NAME
        + " is not specified.");
  }

  //clear content type
  response.setContentType(null);

  if (UserGroupInformation.isSecurityEnabled()) {
    //add a token for RPC.
    final Token<DelegationTokenIdentifier> token = 
        new Token<DelegationTokenIdentifier>();
    token.decodeFromUrlString(delegation.getValue());
    SecurityUtil.setTokenService(token, nnRpcAddr);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
    ugi.addToken(token);
  }
}
项目:hadoop-TCP    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    final InputStream in,
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
        final NamenodeRpcAddressParam namenodeRpcAddress,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(in, ugi, delegation, namenodeRpcAddress, ROOT, op, bufferSize);
}
项目:hadoop-TCP    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
        final NamenodeRpcAddressParam namenodeRpcAddress,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return get(ugi, delegation, namenodeRpcAddress, ROOT, op, offset, length,
      bufferSize);
}
项目:hadoop-on-lustre    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(ugi, delegation, username, doAsUser, ROOT, op, bufferSize);
}
项目:hadoop-on-lustre    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(RenewerParam.NAME) @DefaultValue(RenewerParam.DEFAULT)
        final RenewerParam renewer,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, URISyntaxException, InterruptedException {
  return get(ugi, delegation, username, doAsUser, ROOT, op,
      offset, length, renewer, bufferSize);
}
项目:hadoop-on-lustre    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP DELETE request for the root. */
@DELETE
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT)
        final DeleteOpParam op,
    @QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT)
        final RecursiveParam recursive
    ) throws IOException, InterruptedException {
  return delete(ugi, delegation, username, doAsUser, ROOT, op, recursive);
}
项目:hadoop-on-lustre    文件:DatanodeWebHdfsMethods.java   
private void init(final UserGroupInformation ugi, final DelegationParam delegation,
    final UriFsPathParam path, final HttpOpParam<?> op,
    final Param<?, ?>... parameters) throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path
        + ", ugi=" + ugi + Param.toSortedString(", ", parameters));
  }

  //clear content type
  response.setContentType(null);

  if (UserGroupInformation.isSecurityEnabled()) {
    //add a token for RPC.
    final DataNode datanode = (DataNode)context.getAttribute("datanode");
    final InetSocketAddress nnRpcAddr = NameNode.getAddress(datanode.getConf());
    final Token<DelegationTokenIdentifier> token = new Token<DelegationTokenIdentifier>();
    token.decodeFromUrlString(delegation.getValue());
    SecurityUtil.setTokenService(token, nnRpcAddr);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
    ugi.addToken(token);
  }
}
项目:hadoop-on-lustre    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP PUT request for the root. */
@PUT
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response putRoot(
    final InputStream in,
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(PutOpParam.NAME) @DefaultValue(PutOpParam.DEFAULT)
        final PutOpParam op,
    @QueryParam(PermissionParam.NAME) @DefaultValue(PermissionParam.DEFAULT)
        final PermissionParam permission,
    @QueryParam(OverwriteParam.NAME) @DefaultValue(OverwriteParam.DEFAULT)
        final OverwriteParam overwrite,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize,
    @QueryParam(ReplicationParam.NAME) @DefaultValue(ReplicationParam.DEFAULT)
        final ReplicationParam replication,
    @QueryParam(BlockSizeParam.NAME) @DefaultValue(BlockSizeParam.DEFAULT)
        final BlockSizeParam blockSize
    ) throws IOException, InterruptedException {
  return put(in, ugi, delegation, ROOT, op, permission, overwrite, bufferSize,
      replication, blockSize);
}
项目:hadoop-on-lustre    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    final InputStream in,
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(in, ugi, delegation, ROOT, op, bufferSize);
}
项目:hadoop-on-lustre    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return get(ugi, delegation, ROOT, op, offset, length, bufferSize); 
}
项目:hardfs    文件:WebHdfsFileSystem.java   
Param<?,?>[] getAuthParameters(final HttpOpParam.Op op) throws IOException {
  List<Param<?,?>> authParams = Lists.newArrayList();    
  // Skip adding delegation token for token operations because these
  // operations require authentication.
  Token<?> token = null;
  if (UserGroupInformation.isSecurityEnabled() && !op.getRequireAuth()) {
    token = getDelegationToken();
  }
  if (token != null) {
    authParams.add(new DelegationParam(token.encodeToUrlString()));
  } else {
    UserGroupInformation userUgi = ugi;
    UserGroupInformation realUgi = userUgi.getRealUser();
    if (realUgi != null) { // proxy user
      authParams.add(new DoAsParam(userUgi.getShortUserName()));
      userUgi = realUgi;
    }
    authParams.add(new UserParam(userUgi.getShortUserName()));
  }
  return authParams.toArray(new Param<?,?>[0]);
}
项目:hardfs    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP POST request for the root. */
@POST
@Path("/")
@Consumes({"*/*"})
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response postRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(PostOpParam.NAME) @DefaultValue(PostOpParam.DEFAULT)
        final PostOpParam op,
    @QueryParam(ConcatSourcesParam.NAME) @DefaultValue(ConcatSourcesParam.DEFAULT)
        final ConcatSourcesParam concatSrcs,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return post(ugi, delegation, username, doAsUser, ROOT, op, concatSrcs, bufferSize);
}
项目:hardfs    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP GET request for the root. */
@GET
@Path("/")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response getRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(GetOpParam.NAME) @DefaultValue(GetOpParam.DEFAULT)
        final GetOpParam op,
    @QueryParam(OffsetParam.NAME) @DefaultValue(OffsetParam.DEFAULT)
        final OffsetParam offset,
    @QueryParam(LengthParam.NAME) @DefaultValue(LengthParam.DEFAULT)
        final LengthParam length,
    @QueryParam(RenewerParam.NAME) @DefaultValue(RenewerParam.DEFAULT)
        final RenewerParam renewer,
    @QueryParam(BufferSizeParam.NAME) @DefaultValue(BufferSizeParam.DEFAULT)
        final BufferSizeParam bufferSize
    ) throws IOException, InterruptedException {
  return get(ugi, delegation, username, doAsUser, ROOT, op,
      offset, length, renewer, bufferSize);
}
项目:hardfs    文件:NamenodeWebHdfsMethods.java   
/** Handle HTTP DELETE request for the root. */
@DELETE
@Path("/")
@Produces(MediaType.APPLICATION_JSON)
public Response deleteRoot(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(UserParam.NAME) @DefaultValue(UserParam.DEFAULT)
        final UserParam username,
    @QueryParam(DoAsParam.NAME) @DefaultValue(DoAsParam.DEFAULT)
        final DoAsParam doAsUser,
    @QueryParam(DeleteOpParam.NAME) @DefaultValue(DeleteOpParam.DEFAULT)
        final DeleteOpParam op,
    @QueryParam(RecursiveParam.NAME) @DefaultValue(RecursiveParam.DEFAULT)
        final RecursiveParam recursive
    ) throws IOException, InterruptedException {
  return delete(ugi, delegation, username, doAsUser, ROOT, op, recursive);
}
项目:hardfs    文件:NamenodeWebHdfsMethods.java   
private Response delete(
    final UserGroupInformation ugi,
    final DelegationParam delegation,
    final UserParam username,
    final DoAsParam doAsUser,
    final String fullpath,
    final DeleteOpParam op,
    final RecursiveParam recursive
    ) throws IOException {
  final NameNode namenode = (NameNode)context.getAttribute("name.node");

  switch(op.getValue()) {
  case DELETE:
  {
    final boolean b = namenode.getRpcServer().delete(fullpath, recursive.getValue());
    final String js = JsonUtil.toJsonString("boolean", b);
    return Response.ok(js).type(MediaType.APPLICATION_JSON).build();
  }
  default:
    throw new UnsupportedOperationException(op + " is not supported");
  }
}
项目:hardfs    文件:DatanodeWebHdfsMethods.java   
private void init(final UserGroupInformation ugi,
    final DelegationParam delegation, final InetSocketAddress nnRpcAddr,
    final UriFsPathParam path, final HttpOpParam<?> op,
    final Param<?, ?>... parameters) throws IOException {
  if (LOG.isTraceEnabled()) {
    LOG.trace("HTTP " + op.getValue().getType() + ": " + op + ", " + path
        + ", ugi=" + ugi + Param.toSortedString(", ", parameters));
  }
  if (nnRpcAddr == null) {
    throw new IllegalArgumentException(NamenodeRpcAddressParam.NAME
        + " is not specified.");
  }

  //clear content type
  response.setContentType(null);

  if (UserGroupInformation.isSecurityEnabled()) {
    //add a token for RPC.
    final Token<DelegationTokenIdentifier> token = 
        new Token<DelegationTokenIdentifier>();
    token.decodeFromUrlString(delegation.getValue());
    SecurityUtil.setTokenService(token, nnRpcAddr);
    token.setKind(DelegationTokenIdentifier.HDFS_DELEGATION_KIND);
    ugi.addToken(token);
  }
}