@Override public void seek(long pos) throws IOException { if (pos == mCurrentPosition) { return; } if (pos < 0) { throw new IOException("Seek position is negative: " + pos); } if (pos > mTachyonFile.length()) { throw new IOException("Seek position is past EOF: " + pos + ", fileSize = " + mTachyonFile.length()); } if (mTachyonFileInputStream != null) { mTachyonFileInputStream.seek(pos); } else { getHdfsInputStream(pos); // TODO(calvin): Optimize for the case when the data is still valid in the buffer // Invalidate buffer mBufferLimit = -1; } mCurrentPosition = pos; }
@Override public FSDataOutputStream append(Path cPath, int bufferSize, Progressable progress) throws IOException { LOG.info("append(" + cPath + ", " + bufferSize + ", " + progress + ")"); if (mStatistics != null) { mStatistics.incrementWriteOps(1); } TachyonURI path = new TachyonURI(Utils.getPathWithoutScheme(cPath)); long fileId = mTFS.getFileId(path); TachyonFile file = mTFS.getFile(fileId); if (file.length() > 0) { LOG.warn("This maybe an error."); } return new FSDataOutputStream(file.getOutStream(), mStatistics); }
/** * {@inheritDoc} * * If the file does not exist in Tachyon, query it from HDFS. */ @Override public FileStatus getFileStatus(Path path) throws IOException { TachyonURI tPath = new TachyonURI(Utils.getPathWithoutScheme(path)); Path hdfsPath = Utils.getHDFSPath(tPath, mUnderFSAddress); LOG.info("getFileStatus(" + path + "): HDFS Path: " + hdfsPath + " TPath: " + mTachyonHeader + tPath); if (mStatistics != null) { mStatistics.incrementReadOps(1); } TachyonFile file; try { file = mTFS.getFile(tPath); } catch (IOException ioe) { LOG.info("File does not exist: " + path); throw new FileNotFoundException("File does not exist: " + path); } FileStatus ret = new FileStatus(file.length(), file.isDirectory(), file.getDiskReplication(), file.getBlockSizeByte(), file.getCreationTimeMs(), file.getCreationTimeMs(), null, null, null, new Path(mTachyonHeader + tPath)); return ret; }
if ((position < 0) || (position >= mTachyonFile.length())) { return ret;