Ejemplo n.º 1
0
 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;
 }
Ejemplo n.º 2
0
 public override void Close()
 {
     if (reader != null)
     {
         reader.Dispose();
         reader = null;
     }
 }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
        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);
            }
        }