long offset() { return new OffsetParam(param(OffsetParam.NAME)).getOffset(); }
/** 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 URLRunner(GetOpParam.Op.OPEN, offsetUrl, resolved).run(); } }
/** 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 URLRunner(GetOpParam.Op.OPEN, offsetUrl, resolved, true).run(); } }
/** 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 URLRunner(GetOpParam.Op.OPEN, offsetUrl, resolved).run(); } }
long offset() { return new OffsetParam(param(OffsetParam.NAME)).getOffset(); }
long offset() { return new OffsetParam(param(OffsetParam.NAME)).getOffset(); }
@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; return new FsPathResponseRunner<BlockLocation[]>(op, p, new OffsetParam(offset), new LengthParam(length)) { @Override BlockLocation[] decodeResponse(Map<?,?> json) throws IOException { return DFSUtil.locatedBlocks2Locations( JsonUtil.toLocatedBlocks(json)); } }.run(); }
@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; return new FsPathResponseRunner<BlockLocation[]>(op, p, new OffsetParam(offset), new LengthParam(length)) { @Override BlockLocation[] decodeResponse(Map<?,?> json) throws IOException { return DFSUtil.locatedBlocks2Locations( JsonUtil.toLocatedBlocks(json)); } }.run(); }
@Override public BlockLocation[] getFileBlockLocations(final Path p, final long offset, final long length) throws IOException { statistics.incrementReadOps(1); storageStatistics.incrementOpCounter(OpType.GET_FILE_BLOCK_LOCATIONS); final HttpOpParam.Op op = GetOpParam.Op.GET_BLOCK_LOCATIONS; return new FsPathResponseRunner<BlockLocation[]>(op, p, new OffsetParam(offset), new LengthParam(length)) { @Override BlockLocation[] decodeResponse(Map<?,?> json) throws IOException { return DFSUtilClient.locatedBlocks2Locations( JsonUtilClient.toLocatedBlocks(json)); } }.run(); }
@Override protected URL getUrl() throws IOException { // This method is called every time either a read is executed. // The check for connection == null is to ensure that a new URL is only // created upon a new connection and not for every read. if (cachedConnection == null) { // Update URL with current offset. BufferSize doesn't change, but it // still must be included when creating the new URL. updateURLParameters(new BufferSizeParam(bufferSize), new OffsetParam(pos)); originalUrl = super.getUrl(); } return originalUrl; }
@Override protected URL getUrl() throws IOException { // This method is called every time either a read is executed. // The check for connection == null is to ensure that a new URL is only // created upon a new connection and not for every read. if (cachedConnection == null) { // Update URL with current offset. BufferSize doesn't change, but it // still must be included when creating the new URL. updateURLParameters(new BufferSizeParam(bufferSize), new OffsetParam(pos)); originalUrl = super.getUrl(); } return originalUrl; }
@Override protected URL getUrl() throws IOException { // This method is called every time either a read is executed. // The check for connection == null is to ensure that a new URL is only // created upon a new connection and not for every read. if (cachedConnection == null) { // Update URL with current offset. BufferSize doesn't change, but it // still must be included when creating the new URL. updateURLParameters(new BufferSizeParam(bufferSize), new OffsetParam(pos)); originalUrl = super.getUrl(); } return originalUrl; }
final URL rurl = new URL(resolvedUrl + "&" + new OffsetParam(pos)); cachedConnection = new URLRunner(GetOpParam.Op.OPEN, rurl, true).run(); } catch (IOException ioe) {
final URL rurl = new URL(resolvedUrl + "&" + new OffsetParam(pos)); cachedConnection = new URLRunner(GetOpParam.Op.OPEN, rurl, true).run(); } catch (IOException ioe) {
final URL rurl = new URL(resolvedUrl + "&" + new OffsetParam(pos)); cachedConnection = new URLRunner(GetOpParam.Op.OPEN, rurl, true, false).run();
@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 } } }
content.length())), new OffsetParam(1L)); HttpURLConnection conn = null; InputStream is = null;
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)) );