public HdfsStreamReader(HdfsInstance instance, string dfsPath, long offset, long length, int byteBufferSize) : base(byteBufferSize) { this.reader = instance.OpenReader(dfsPath); this.offset = offset; this.bytesToRead = length; }
public override int Read(byte[] buffer, int offset, int count) { int numBytesRead = _cachedReader.ReadBlock(_readPosition, buffer, offset, count); if (numBytesRead == 0 && offset < Length) { // the reader has a stale idea of the file length; reopen it and try again _cachedReader.Dispose(); string logPath = _logUri.AbsolutePath; _cachedReader = _hdfs.OpenReader(logPath); numBytesRead = _cachedReader.ReadBlock(_readPosition, buffer, offset, count); } _readPosition += numBytesRead; return(numBytesRead); }
public HdfsLogReaderStream(Uri logUri) { _logUri = logUri; _readPosition = 0; // this is the current read position try { _hdfs = new HdfsInstance(_logUri); string logPath = _logUri.AbsolutePath; _cachedReader = _hdfs.OpenReader(logPath); } catch (Exception e) { throw new ApplicationException("HdfsLogReaderStream failed to open reader", e); } }