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

项目:hadoop    文件:TestParameterParser.java   
@Test
public void testOffset() throws IOException {
  final long X = 42;

  long offset = new OffsetParam(Long.toString(X)).getOffset();
  Assert.assertEquals("OffsetParam: ", X, offset);

  offset = new OffsetParam((String) null).getOffset();
  Assert.assertEquals("OffsetParam with null should have defaulted to 0", 0, offset);

  try {
    offset = new OffsetParam("abc").getValue();
    Assert.fail("OffsetParam with nondigit value should have thrown IllegalArgumentException");
  } catch (IllegalArgumentException iae) {
    // Ignore
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestParameterParser.java   
@Test
public void testOffset() throws IOException {
  final long X = 42;

  long offset = new OffsetParam(Long.toString(X)).getOffset();
  Assert.assertEquals("OffsetParam: ", X, offset);

  offset = new OffsetParam((String) null).getOffset();
  Assert.assertEquals("OffsetParam with null should have defaulted to 0", 0, offset);

  try {
    offset = new OffsetParam("abc").getValue();
    Assert.fail("OffsetParam with nondigit value should have thrown IllegalArgumentException");
  } catch (IllegalArgumentException iae) {
    // Ignore
  }
}
项目:big-c    文件:TestParameterParser.java   
@Test
public void testOffset() throws IOException {
  final long X = 42;

  long offset = new OffsetParam(Long.toString(X)).getOffset();
  Assert.assertEquals("OffsetParam: ", X, offset);

  offset = new OffsetParam((String) null).getOffset();
  Assert.assertEquals("OffsetParam with null should have defaulted to 0", 0, offset);

  try {
    offset = new OffsetParam("abc").getValue();
    Assert.fail("OffsetParam with nondigit value should have thrown IllegalArgumentException");
  } catch (IllegalArgumentException iae) {
    // Ignore
  }
}
项目: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    文件: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    文件: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   
/** 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-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    文件: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 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    文件: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    文件: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    文件: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-lustre2    文件: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-on-lustre2    文件: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);
}
项目:hortonworks-extension    文件: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);
}
项目:hortonworks-extension    文件: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); 
}
项目:hortonworks-extension    文件: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);
}
项目:hortonworks-extension    文件: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); 
}
项目:hadoop    文件:TestWebHDFS.java   
@Test
public void testWebHdfsOffsetAndLength() throws Exception{
  MiniDFSCluster cluster = null;
  final Configuration conf = WebHdfsTestUtil.createConf();
  final int OFFSET = 42;
  final int LENGTH = 512;
  final String PATH = "/foo";
  byte[] CONTENTS = new byte[1024];
  RANDOM.nextBytes(CONTENTS);
  try {
    cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
    final WebHdfsFileSystem fs =
        WebHdfsTestUtil.getWebHdfsFileSystem(conf, WebHdfsFileSystem.SCHEME);
    try (OutputStream os = fs.create(new Path(PATH))) {
      os.write(CONTENTS);
    }
    InetSocketAddress addr = cluster.getNameNode().getHttpAddress();
    URL url = new URL("http", addr.getHostString(), addr
        .getPort(), WebHdfsFileSystem.PATH_PREFIX + PATH + "?op=OPEN" +
        Param.toSortedString("&", new OffsetParam((long) OFFSET),
                             new LengthParam((long) LENGTH))
    );
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setInstanceFollowRedirects(true);
    Assert.assertEquals(LENGTH, conn.getContentLength());
    byte[] subContents = new byte[LENGTH];
    byte[] realContents = new byte[LENGTH];
    System.arraycopy(CONTENTS, OFFSET, subContents, 0, LENGTH);
    IOUtils.readFully(conn.getInputStream(), realContents);
    Assert.assertArrayEquals(subContents, realContents);
  } finally {
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestWebHDFS.java   
@Test
public void testWebHdfsOffsetAndLength() throws Exception{
  MiniDFSCluster cluster = null;
  final Configuration conf = WebHdfsTestUtil.createConf();
  final int OFFSET = 42;
  final int LENGTH = 512;
  final String PATH = "/foo";
  byte[] CONTENTS = new byte[1024];
  RANDOM.nextBytes(CONTENTS);
  try {
    cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
    final WebHdfsFileSystem fs =
        WebHdfsTestUtil.getWebHdfsFileSystem(conf, WebHdfsConstants.WEBHDFS_SCHEME);
    try (OutputStream os = fs.create(new Path(PATH))) {
      os.write(CONTENTS);
    }
    InetSocketAddress addr = cluster.getNameNode().getHttpAddress();
    URL url = new URL("http", addr.getHostString(), addr
        .getPort(), WebHdfsFileSystem.PATH_PREFIX + PATH + "?op=OPEN" +
        Param.toSortedString("&", new OffsetParam((long) OFFSET),
                             new LengthParam((long) LENGTH))
    );
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setInstanceFollowRedirects(true);
    Assert.assertEquals(LENGTH, conn.getContentLength());
    byte[] subContents = new byte[LENGTH];
    byte[] realContents = new byte[LENGTH];
    System.arraycopy(CONTENTS, OFFSET, subContents, 0, LENGTH);
    IOUtils.readFully(conn.getInputStream(), realContents);
    Assert.assertArrayEquals(subContents, realContents);
  } finally {
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}
项目:big-c    文件:TestWebHDFS.java   
@Test
public void testWebHdfsOffsetAndLength() throws Exception{
  MiniDFSCluster cluster = null;
  final Configuration conf = WebHdfsTestUtil.createConf();
  final int OFFSET = 42;
  final int LENGTH = 512;
  final String PATH = "/foo";
  byte[] CONTENTS = new byte[1024];
  RANDOM.nextBytes(CONTENTS);
  try {
    cluster = new MiniDFSCluster.Builder(conf).numDataNodes(1).build();
    final WebHdfsFileSystem fs =
        WebHdfsTestUtil.getWebHdfsFileSystem(conf, WebHdfsFileSystem.SCHEME);
    try (OutputStream os = fs.create(new Path(PATH))) {
      os.write(CONTENTS);
    }
    InetSocketAddress addr = cluster.getNameNode().getHttpAddress();
    URL url = new URL("http", addr.getHostString(), addr
        .getPort(), WebHdfsFileSystem.PATH_PREFIX + PATH + "?op=OPEN" +
        Param.toSortedString("&", new OffsetParam((long) OFFSET),
                             new LengthParam((long) LENGTH))
    );
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setInstanceFollowRedirects(true);
    Assert.assertEquals(LENGTH, conn.getContentLength());
    byte[] subContents = new byte[LENGTH];
    byte[] realContents = new byte[LENGTH];
    System.arraycopy(CONTENTS, OFFSET, subContents, 0, LENGTH);
    IOUtils.readFully(conn.getInputStream(), realContents);
    Assert.assertArrayEquals(subContents, realContents);
  } finally {
    if (cluster != null) {
      cluster.shutdown();
    }
  }
}
项目:hadoop-2.6.0-cdh5.4.3    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request. */
@GET
@Path("{" + UriFsPathParam.NAME + ":.*}")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response get(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeAddressParam.NAME)
    @DefaultValue(NamenodeAddressParam.DEFAULT)
        final NamenodeAddressParam namenode,
    @PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
    @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 {

  final String nnId = namenode.getValue();
  init(ugi, delegation, nnId, path, op, offset, length, bufferSize);

  return ugi.doAs(new PrivilegedExceptionAction<Response>() {
    @Override
    public Response run() throws IOException {
      return get(nnId, path.getAbsolutePath(), op, offset,
              length, bufferSize);
    }
  });
}
项目:hadoop-plus    文件:WebHdfsFileSystem.java   
/** Setup offset url and connect. */
@Override
protected HttpURLConnection connect(final long offset,
    final boolean resolved) throws IOException {
  final URL offsetUrl = offset == 0L? url
      : new URL(url + "&" + new OffsetParam(offset));
  return new Runner(GetOpParam.Op.OPEN, offsetUrl, resolved).run().conn;
}
项目:hadoop-plus    文件:WebHdfsFileSystem.java   
@Override
public BlockLocation[] getFileBlockLocations(final Path p, 
    final long offset, final long length) throws IOException {
  statistics.incrementReadOps(1);

  final HttpOpParam.Op op = GetOpParam.Op.GET_BLOCK_LOCATIONS;
  final Map<?, ?> m = run(op, p, new OffsetParam(offset),
      new LengthParam(length));
  return DFSUtil.locatedBlocks2Locations(JsonUtil.toLocatedBlocks(m));
}
项目:hadoop-plus    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request. */
@GET
@Path("{" + UriFsPathParam.NAME + ":.*}")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response get(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
        final NamenodeRpcAddressParam namenodeRpcAddress,
    @PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
    @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 {

  final InetSocketAddress nnRpcAddr = namenodeRpcAddress.getValue();
  init(ugi, delegation, nnRpcAddr, path, op, offset, length, bufferSize);

  return ugi.doAs(new PrivilegedExceptionAction<Response>() {
    @Override
    public Response run() throws IOException {
      return get(ugi, delegation, nnRpcAddr, path.getAbsolutePath(), op,
          offset, length, bufferSize);
    }
  });
}
项目:FlexMap    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request. */
@GET
@Path("{" + UriFsPathParam.NAME + ":.*}")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response get(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeAddressParam.NAME)
    @DefaultValue(NamenodeAddressParam.DEFAULT)
        final NamenodeAddressParam namenode,
    @PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
    @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 {

  final String nnId = namenode.getValue();
  init(ugi, delegation, nnId, path, op, offset, length, bufferSize);

  return ugi.doAs(new PrivilegedExceptionAction<Response>() {
    @Override
    public Response run() throws IOException {
      return get(nnId, path.getAbsolutePath(), op, offset,
              length, bufferSize);
    }
  });
}
项目:hops    文件:WebHdfsFileSystem.java   
/**
 * Setup offset url and connect.
 */
@Override
protected HttpURLConnection connect(final long offset,
    final boolean resolved) throws IOException {
  final URL offsetUrl =
      offset == 0L ? url : new URL(url + "&" + new OffsetParam(offset));
  return new Runner(GetOpParam.Op.OPEN, offsetUrl, resolved).run().conn;
}
项目:hops    文件:WebHdfsFileSystem.java   
@Override
public BlockLocation[] getFileBlockLocations(final Path p, final long offset,
    final long length) throws IOException {
  statistics.incrementReadOps(1);

  final HttpOpParam.Op op = GetOpParam.Op.GET_BLOCK_LOCATIONS;
  final Map<?, ?> m =
      run(op, p, new OffsetParam(offset), new LengthParam(length));
  return DFSUtil.locatedBlocks2Locations(JsonUtil.toLocatedBlocks(m));
}
项目:hops    文件: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,
    @QueryParam(FsActionParam.NAME)
    @DefaultValue(FsActionParam.DEFAULT)
    final FsActionParam fsAction)
    throws IOException, InterruptedException {
  return get(ugi, delegation, username, doAsUser, ROOT, op, offset, length,
      renewer, bufferSize, fsAction);
}
项目:hops    文件: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);
}
项目:hops    文件:DatanodeWebHdfsMethods.java   
/**
 * Handle HTTP GET request.
 */
@GET
@Path("{" + UriFsPathParam.NAME + ":.*}")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response get(
    @Context
    final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME)
    @DefaultValue(DelegationParam.DEFAULT)
    final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
    final NamenodeRpcAddressParam namenodeRpcAddress,
    @PathParam(UriFsPathParam.NAME)
    final UriFsPathParam path,
    @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 {

  final InetSocketAddress nnRpcAddr = namenodeRpcAddress.getValue();
  init(ugi, delegation, nnRpcAddr, path, op, offset, length, bufferSize);

  return ugi.doAs(new PrivilegedExceptionAction<Response>() {
    @Override
    public Response run() throws IOException {
      return get(ugi, delegation, nnRpcAddr, path.getAbsolutePath(), op,
          offset, length, bufferSize);
    }
  });
}
项目:hadoop-TCP    文件:WebHdfsFileSystem.java   
/** Setup offset url and connect. */
@Override
protected HttpURLConnection connect(final long offset,
    final boolean resolved) throws IOException {
  final URL offsetUrl = offset == 0L? url
      : new URL(url + "&" + new OffsetParam(offset));
  return new Runner(GetOpParam.Op.OPEN, offsetUrl, resolved).run().conn;
}
项目:hadoop-TCP    文件:WebHdfsFileSystem.java   
@Override
public BlockLocation[] getFileBlockLocations(final Path p, 
    final long offset, final long length) throws IOException {
  statistics.incrementReadOps(1);

  final HttpOpParam.Op op = GetOpParam.Op.GET_BLOCK_LOCATIONS;
  final Map<?, ?> m = run(op, p, new OffsetParam(offset),
      new LengthParam(length));
  return DFSUtil.locatedBlocks2Locations(JsonUtil.toLocatedBlocks(m));
}
项目:hadoop-TCP    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request. */
@GET
@Path("{" + UriFsPathParam.NAME + ":.*}")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response get(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
        final NamenodeRpcAddressParam namenodeRpcAddress,
    @PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
    @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 {

  final InetSocketAddress nnRpcAddr = namenodeRpcAddress.getValue();
  init(ugi, delegation, nnRpcAddr, path, op, offset, length, bufferSize);

  return ugi.doAs(new PrivilegedExceptionAction<Response>() {
    @Override
    public Response run() throws IOException {
      return get(ugi, delegation, nnRpcAddr, path.getAbsolutePath(), op,
          offset, length, bufferSize);
    }
  });
}
项目:hadoop-on-lustre    文件:WebHdfsFileSystem.java   
/** Setup offset url and connect. */
@Override
protected HttpURLConnection connect(final long offset,
    final boolean resolved) throws IOException {
  final URL offsetUrl = offset == 0L? url
      : new URL(url + "&" + new OffsetParam(offset));
  return new Runner(GetOpParam.Op.OPEN, offsetUrl, resolved).run().conn;
}
项目:hadoop-on-lustre    文件:WebHdfsFileSystem.java   
@Override
public BlockLocation[] getFileBlockLocations(final FileStatus status,
    final long offset, final long length) throws IOException {
  if (status == null) {
    return null;
  }
  statistics.incrementReadOps(1);

  final Path p = status.getPath();
  final HttpOpParam.Op op = GetOpParam.Op.GET_BLOCK_LOCATIONS;
  final Map<?, ?> m = run(op, p, new OffsetParam(offset),
      new LengthParam(length));
  return DFSUtil.locatedBlocks2Locations(JsonUtil.toLocatedBlocks(m));
}
项目:hardfs    文件:WebHdfsFileSystem.java   
/** Setup offset url and connect. */
@Override
protected HttpURLConnection connect(final long offset,
    final boolean resolved) throws IOException {
  final URL offsetUrl = offset == 0L? url
      : new URL(url + "&" + new OffsetParam(offset));
  return new Runner(GetOpParam.Op.OPEN, offsetUrl, resolved).run().conn;
}
项目:hardfs    文件:WebHdfsFileSystem.java   
@Override
public BlockLocation[] getFileBlockLocations(final Path p, 
    final long offset, final long length) throws IOException {
  statistics.incrementReadOps(1);

  final HttpOpParam.Op op = GetOpParam.Op.GET_BLOCK_LOCATIONS;
  final Map<?, ?> m = run(op, p, new OffsetParam(offset),
      new LengthParam(length));
  return DFSUtil.locatedBlocks2Locations(JsonUtil.toLocatedBlocks(m));
}
项目:hardfs    文件:DatanodeWebHdfsMethods.java   
/** Handle HTTP GET request. */
@GET
@Path("{" + UriFsPathParam.NAME + ":.*}")
@Produces({MediaType.APPLICATION_OCTET_STREAM, MediaType.APPLICATION_JSON})
public Response get(
    @Context final UserGroupInformation ugi,
    @QueryParam(DelegationParam.NAME) @DefaultValue(DelegationParam.DEFAULT)
        final DelegationParam delegation,
    @QueryParam(NamenodeRpcAddressParam.NAME)
    @DefaultValue(NamenodeRpcAddressParam.DEFAULT)
        final NamenodeRpcAddressParam namenodeRpcAddress,
    @PathParam(UriFsPathParam.NAME) final UriFsPathParam path,
    @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 {

  final InetSocketAddress nnRpcAddr = namenodeRpcAddress.getValue();
  init(ugi, delegation, nnRpcAddr, path, op, offset, length, bufferSize);

  return ugi.doAs(new PrivilegedExceptionAction<Response>() {
    @Override
    public Response run() throws IOException {
      return get(ugi, delegation, nnRpcAddr, path.getAbsolutePath(), op,
          offset, length, bufferSize);
    }
  });
}