/// <exception cref="System.Exception"/> public override FSDataInputStream Load(DFSClientCache.DFSInputStreamCaheKey key) { DFSClient client = this._enclosing.GetDfsClient(key.userId); DFSInputStream dis = client.Open(key.inodePath); return(client.CreateWrappedInputStream(dis)); }
/// <exception cref="System.IO.IOException"/> private void OnOpen(ChannelHandlerContext ctx) { string nnId = @params.NamenodeId(); int bufferSize = @params.BufferSize(); long offset = @params.Offset(); long length = @params.Length(); DefaultHttpResponse response = new DefaultHttpResponse(HttpVersion.Http11, HttpResponseStatus .Ok); HttpHeaders headers = response.Headers(); // Allow the UI to access the file headers.Set(HttpHeaders.Names.AccessControlAllowMethods, HttpMethod.Get); headers.Set(HttpHeaders.Names.AccessControlAllowOrigin, "*"); headers.Set(HttpHeaders.Names.ContentType, ApplicationOctetStream); headers.Set(HttpHeaders.Names.Connection, HttpHeaders.Values.Close); DFSClient dfsclient = NewDfsClient(nnId, conf); HdfsDataInputStream @in = dfsclient.CreateWrappedInputStream(dfsclient.Open(path, bufferSize, true)); @in.Seek(offset); long contentLength = @in.GetVisibleLength() - offset; if (length >= 0) { contentLength = Math.Min(contentLength, length); } InputStream data; if (contentLength >= 0) { headers.Set(HttpHeaders.Names.ContentLength, contentLength); data = new LimitInputStream(@in, contentLength); } else { data = @in; } ctx.Write(response); ctx.WriteAndFlush(new _ChunkedStream_221(dfsclient, data)).AddListener(ChannelFutureListener .Close); }
/// <exception cref="System.IO.IOException"/> /// <exception cref="Org.Apache.Hadoop.FS.UnresolvedLinkException"/> public override FSDataInputStream Open(Path f, int bufferSize) { DFSInputStream dfsis = dfs.Open(GetUriPath(f), bufferSize, verifyChecksum); return(dfs.CreateWrappedInputStream(dfsis)); }