@Override public long position() throws IOException { return delegate.position() - offset; }
@Override public long position() throws IOException { return inner.position(); }
@Override public StoreChannel position( long newPosition ) throws IOException { this.position = newPosition; return delegateChannel.position( newPosition ); }
/** * @return the position of the channel, also taking into account buffer position. * @throws IOException if underlying channel throws {@link IOException}. */ public long position() throws IOException { return channel.position() + buffer.position(); }
/** * This is the position within the buffered stream (and not the * underlying channel, which will generally be further ahead). * * @return The position within the buffered stream. * @throws IOException on I/O error. */ public long position() throws IOException { return channel.position() - aheadBuffer.remaining(); }
@Override public LimitedFileChannel position( long l ) throws IOException { return new LimitedFileChannel( inner.position( l ), fs ); }
@Override public StoreChannel position( long newPosition ) throws IOException { return delegate.position( offset( newPosition ) ); }
private void markAsCleanlyClosed( ) throws IOException { // remove sticky ByteBuffer buffer = ByteBuffer.allocate( Byte.BYTES ); buffer.put( CLEAN_GENERATOR ).flip(); fileChannel.position( 0 ); fileChannel.writeAll( buffer ); }
private void writeHeader( long highId ) throws IOException { ByteBuffer buffer = ByteBuffer.allocate( HEADER_SIZE ); buffer.put( STICKY_GENERATOR ).putLong( highId ).flip(); fileChannel.position( 0 ); fileChannel.writeAll( buffer ); }
@Override public long position() throws IOException { return delegate.position(); }
@Override public StoreChannel position( long newPosition ) throws IOException { delegate.position( newPosition ); return this; }
private void markAsSticky() throws IOException { ByteBuffer buffer = ByteBuffer.allocate( Byte.BYTES ); buffer.put( STICKY_GENERATOR ).flip(); fileChannel.position( 0 ); fileChannel.writeAll( buffer ); fileChannel.force( false ); }
public ChannelOutputStream( StoreChannel channel, boolean append ) throws IOException { this.channel = channel; if ( append ) { this.channel.position( this.channel.size() ); } }
@Override public StoreFileChannel position( long newPosition ) throws IOException { adversary.injectFailure( IOException.class ); return (StoreFileChannel) delegate.position( newPosition ); }
@Test void positionWithPosition() throws Exception { long position = 500; channel.position( position ); verify( actual ).position( 500 + offset ); }
@Test( expected = ClosedByInterruptException.class ) public void ch_getPosition() throws IOException { chan( true ).position(); }
@Test( expected = ClosedByInterruptException.class ) public void ch_setPosition() throws IOException { chan( true ).position( 0 ); }
static void changeVersionNumber( FileSystemAbstraction fileSystem, File storeFile, String versionString ) throws IOException { byte[] versionBytes = UTF8.encode( versionString ); try ( StoreChannel fileChannel = fileSystem.open( storeFile, OpenMode.READ_WRITE ) ) { fileChannel.position( fileSystem.getFileSize( storeFile ) - versionBytes.length ); fileChannel.write( ByteBuffer.wrap( versionBytes ) ); } }
private void appendDropTransactionToTransactionLog( File databaseDirectory, CommittedTransactionRepresentation dropTransaction ) throws IOException { LogFiles logFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( databaseDirectory, fs ).build(); File logFile = logFiles.getLogFileForVersion( logFiles.getHighestLogVersion() ); StoreChannel writeStoreChannel = fs.open( logFile, OpenMode.READ_WRITE ); writeStoreChannel.position( writeStoreChannel.size() ); try ( PhysicalFlushableChannel writeChannel = new PhysicalFlushableChannel( writeStoreChannel ) ) { new LogEntryWriter( writeChannel ).serialize( dropTransaction ); } }