@Override public long read( ByteBuffer[] byteBuffers, int i, int i1 ) throws IOException { return inner.read( byteBuffers, i, i1 ); }
private void copyFile( File from, FileSystemAbstraction fromFs, File to, ByteBuffer buffer ) throws IOException { try ( StoreChannel source = fromFs.open( from, OpenMode.READ ); StoreChannel sink = this.open( to, OpenMode.READ_WRITE ) ) { sink.truncate( 0 ); for ( int available; (available = (int) (source.size() - source.position())) > 0; ) { buffer.clear(); buffer.limit( min( available, buffer.capacity() ) ); source.read( buffer ); buffer.flip(); sink.write( buffer ); } } }
public static void writeLogHeader( StoreChannel channel, long logVersion, long previousLastCommittedTxId ) throws IOException { ByteBuffer buffer = ByteBuffer.allocate( LOG_HEADER_SIZE ); writeLogHeader( buffer, logVersion, previousLastCommittedTxId ); channel.writeAll( buffer ); }
private void releaseChannel() throws IOException { storeLockFileChannel.close(); storeLockFileChannel = null; }
@Test void absoluteVersusRelative() throws Exception { // GIVEN File file = new File( "myfile" ); StoreChannel channel = fileSystem.open( file, OpenMode.READ_WRITE ); byte[] bytes = "test".getBytes(); channel.write( ByteBuffer.wrap( bytes ) ); channel.close(); // WHEN channel = fileSystem.open( new File( file.getAbsolutePath() ), OpenMode.READ ); byte[] readBytes = new byte[bytes.length]; channel.readAll( ByteBuffer.wrap( readBytes ) ); // THEN assertTrue( Arrays.equals( bytes, readBytes ) ); }
public PhysicalLogVersionedStoreChannel( StoreChannel delegateChannel, long version, byte formatVersion ) throws IOException { this.delegateChannel = delegateChannel; this.version = version; this.formatVersion = formatVersion; this.position = delegateChannel.position(); }
@After public void verifyInterruptionAndChannelState() throws IOException { assertTrue( Thread.interrupted() ); assertThat( "channelShouldBeClosed? " + channelShouldBeClosed, channel.isOpen(), is( !channelShouldBeClosed ) ); if ( channelShouldBeClosed ) { try { channel.force( true ); fail( "Operating on a closed channel should fail" ); } catch ( ClosedChannelException expected ) { // This is good. What we expect to see. } } channel.close(); fs.close(); }
@Override public long size() throws IOException { return delegateChannel.size(); }
private void write( StoreChannel channel, long time, long identifier, long version, long lastCommittedTxId, long indexVersion ) throws IOException { buf.clear(); buf.putLong( time ).putLong( identifier ).putLong( version ).putLong( lastCommittedTxId ).putLong( indexVersion ); buf.flip(); channel.writeAll( buf, 0 ); channel.force( true ); }
@Override public void force( boolean metaData ) throws IOException { delegateChannel.force( metaData ); }
@Override public void readAll( ByteBuffer dst ) throws IOException { delegate.readAll( dst ); }
@Override public StoreChannel truncate( long size ) throws IOException { return delegateChannel.truncate( size ); }
@Override public int write( ByteBuffer src ) throws IOException { return delegate.write( src ); }