@Override public RandomAccessContent getRandomAccessContent( final RandomAccessMode randomAccessMode ) throws FileSystemException { return fileContent.getRandomAccessContent( randomAccessMode ); }
/** * Creates access to the file for random i/o. * * @since 2.0 */ @Override protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception { return file.getContent().getRandomAccessContent(mode); } }
/** * Creates access to the file for random i/o. * @since 2.0 */ @Override protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception { return file.getContent().getRandomAccessContent(mode); } }
/** * Creates access to the file for random i/o. * * @since 2.0 */ @Override protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception { return file.getContent().getRandomAccessContent(mode); } }
/** * @param rac * @throws FileSystemException */ public RandomAccessContentAccess(FileObject file) throws FileSystemException { this(file.getContent().getRandomAccessContent(RandomAccessMode.READ)); }
public RandomAccessContentAccess(FileObject file) throws FileSystemException { this(file.getContent().getRandomAccessContent(RandomAccessMode.READ)); }
/** * Creates access to the file for random i/o. * * @since 2.0 */ @Override protected RandomAccessContent doGetRandomAccessContent(final RandomAccessMode mode) throws Exception { return file.getContent().getRandomAccessContent(mode); } }
public InputStream newStream(final long start, final long end) { try { final long newFileStart = this.fileStart + start; final long newFileEnd = end < 0 ? this.fileEnd : this.fileStart + end; final RandomAccessContent rac = fo.getContent().getRandomAccessContent(RandomAccessMode.READ); rac.seek(newFileStart); return new SharedRandomContentInputStream(createdStreams, fo, newFileStart, newFileEnd, rac.getInputStream()); } catch (final IOException e) { throw new RuntimeException(e); } }
public InputStream newStream(long start, long end) { try { long newFileStart = this.fileStart+start; long newFileEnd = end<0?this.fileEnd:this.fileStart+end; RandomAccessContent rac = fo.getContent().getRandomAccessContent(RandomAccessMode.READ); rac.seek(newFileStart); return new SharedRandomContentInputStream( createdStreams, fo, newFileStart, newFileEnd, rac.getInputStream()); } catch (IOException e) { throw new RuntimeException(e); } }
@Test public void testGetRandomAccessContent() throws Exception { decorated.getRandomAccessContent( RandomAccessMode.READ ); verify( fileContent ).getRandomAccessContent( RandomAccessMode.READ ); }
@Override public IReadOnlyAccess getReadOnlyAccess() throws IOException { IReadOnlyAccess input = null; try { final RandomAccessContent rac = this.file.getContent().getRandomAccessContent(RandomAccessMode.READ); input = new RandomAccessContentAccess(rac); } catch (final Exception e) { input = new InputStreamReadOnlyAccessFile(this.file.getContent().getInputStream()); } return input; }
@Override public IReadOnlyAccess getReadOnlyAccess() throws IOException { IReadOnlyAccess input = null; try { RandomAccessContent rac = file.getContent().getRandomAccessContent( RandomAccessMode.READ); input = new RandomAccessContentAccess(rac); } catch (Exception e) { input = new InputStreamReadOnlyAccessFile(file.getContent() .getInputStream()); } return input; }
public LoadingInfo(FileObject fileObject, boolean tailing, OpenMode openMode) throws IOException { this.fileObject = fileObject; this.tailing = tailing; friendlyUrl = fileObject.getName().getFriendlyURI(); fileObject.refresh(); InputStream inputStream = fileObject.getContent().getInputStream(); byte[] probe = loadProbe(inputStream, 10000); gzipped = checkIfIsGzipped(probe, probe.length); inputStreamBufferedStart = gzipped ? ungzip(probe) : probe; if (openMode == FROM_START || gzipped) { PushbackInputStream pushBackInputStream = new PushbackInputStream(inputStream, probe.length + 1); // +1 to support empty files pushBackInputStream.unread(probe); observableInputStreamImpl = new ObservableInputStreamImpl(pushBackInputStream); contentInputStream = gzipped ? new GZIPInputStream(observableInputStreamImpl) : observableInputStreamImpl; } else { RandomAccessContent randomAccessContent = fileObject.getContent().getRandomAccessContent(READ); randomAccessContent.seek(randomAccessContent.length()); observableInputStreamImpl = new ObservableInputStreamImpl(randomAccessContent.getInputStream()); contentInputStream = observableInputStreamImpl; } if (fileObject.getType().hasContent()) { lastFileSize = fileObject.getContent().getSize(); } }
reader = fileObject.getContent().getRandomAccessContent(RandomAccessMode.READ); position = this.startPosition == -1 ? this.fileObject.getContent().getSize() : startPosition; currentTime = System.currentTimeMillis();
public void reloadIfFileSizeChanged() throws IOException { fileObject.refresh(); long lastFileSize = this.lastFileSize; long currentSize = fileObject.getContent().getSize(); if (currentSize > lastFileSize) { observableInputStreamImpl.close(); RandomAccessContent randomAccessContent = fileObject.getContent().getRandomAccessContent(READ); randomAccessContent.seek(lastFileSize); this.lastFileSize = currentSize; observableInputStreamImpl = new ObservableInputStreamImpl(randomAccessContent.getInputStream(), lastFileSize); if (gzipped) { contentInputStream = new GZIPInputStream(observableInputStreamImpl); } else { contentInputStream = observableInputStreamImpl; } } else if (currentSize < lastFileSize) { observableInputStreamImpl.close(); InputStream inputStream = fileObject.getContent().getInputStream(); observableInputStreamImpl = new ObservableInputStreamImpl(inputStream, 0); if (gzipped) { contentInputStream = new GZIPInputStream(observableInputStreamImpl); } else { contentInputStream = observableInputStreamImpl; } this.lastFileSize = fileObject.getContent().getSize(); } }
file = createScratchFolder().resolveFile("random_write.txt"); file.createFile(); final RandomAccessContent ra = file.getContent().getRandomAccessContent(RandomAccessMode.READWRITE);
@Test public void testRandomAccessContent2() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); file.getContent().getRandomAccessContent(RandomAccessMode.READ).close(); }
@Test public void testRandomAccessContent2() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); file.getContent().getRandomAccessContent(RandomAccessMode.READ).close(); }
@Test(expected = FileSystemException.class) public void testRandomAccessContent() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); file.getContent().getRandomAccessContent(RandomAccessMode.READWRITE).close(); }
@Test(expected = FileSystemException.class) public void testRandomAccessContent() throws Exception { final FileObject fo = manager.resolveFile(TEST_DIR1); Assert.assertNotNull(fo); Assert.assertFalse(fo.exists()); // Create the test file final FileObject file = createTestFile(hdfs); Assert.assertTrue(fo.exists()); file.getContent().getRandomAccessContent(RandomAccessMode.READWRITE).close(); }