@Override public void close() throws IOException { channel.close(); }
@Test public void shouldThrowIllegalStateExceptionAfterClosed() throws Exception { // GIVEN final File file = new File( directory.directory(), "file" ); StoreChannel storeChannel = fileSystemRule.get().open( file, OpenMode.READ_WRITE ); PhysicalLogVersionedStoreChannel versionedStoreChannel = new PhysicalLogVersionedStoreChannel( storeChannel, 1, (byte) -1 /* ignored */ ); PhysicalFlushableChannel channel = new PhysicalFlushableChannel( versionedStoreChannel ); // closing the WritableLogChannel, then the underlying channel is what PhysicalLogFile does channel.close(); storeChannel.close(); // WHEN just appending something to the buffer channel.put( (byte) 0 ); // and wanting to empty that into the channel try { channel.prepareForFlush(); fail( "Should have thrown exception" ); } catch ( IllegalStateException e ) { // THEN we should get an IllegalStateException, not a ClosedChannelException } }
@Override public synchronized void shutdown() throws IOException { currentStoreChannel.close(); currentStoreChannel = null; }
@Override public void close() throws IOException { channel.close(); }
@Override public synchronized void shutdown() throws IOException { currentStoreChannel.close(); currentStoreChannel = null; }
void switchStoreFile() throws IOException { currentStoreChannel.close(); if ( currentStoreFile.equals( fileA ) ) { currentStoreChannel = resetStoreFile( fileB ); currentStoreFile = fileB; } else { currentStoreChannel = resetStoreFile( fileA ); currentStoreFile = fileA; } }
void switchStoreFile() throws IOException { currentStoreChannel.close(); if ( currentStoreFile.equals( fileA ) ) { currentStoreChannel = resetStoreFile( fileB ); currentStoreFile = fileB; } else { currentStoreChannel = resetStoreFile( fileA ); currentStoreFile = fileA; } }
/** * Idempotently closes the writer. */ synchronized void closeWriter() { if ( bufferedWriter != null ) { try { flush(); bufferedWriter.close(); } catch ( IOException e ) { log.error( "Failed to close writer for: " + file, e ); } bufferedWriter = null; refCount.decrease(); } }
/** * Idempotently closes the writer. */ synchronized void closeWriter() { if ( bufferedWriter != null ) { try { flush(); bufferedWriter.close(); } catch ( IOException e ) { log.error( "Failed to close writer for: " + file, e ); } bufferedWriter = null; refCount.decrease(); } }