@Override public FileLock tryLock() throws IOException { return inner.tryLock(); }
@Override public FileLock tryLock() throws IOException { return delegate.tryLock(); }
@Override public FileLock tryLock() throws IOException { return delegateChannel.tryLock(); }
@Override public FileLock tryLock() throws IOException { return delegate.tryLock(); }
@Override public FileLock tryLock() throws IOException { adversary.injectFailure( IOException.class ); return delegate.tryLock(); }
private void acquireLock() throws IOException { if ( SystemUtils.IS_OS_WINDOWS ) { // We don't take file locks on the individual store files on Windows, because once you've taking // a file lock on a channel, you can only do IO on that file through that channel. This would // mean that we can't stripe our FileChannels on Windows, which is the platform that needs striped // channels the most because of lack of pwrite and pread support. // This is generally fine, because the StoreLocker and the lock file will protect the store from // being opened by multiple instances at the same time anyway. return; } try { fileLock = channels[tokenChannelStripe].tryLock(); if ( fileLock == null ) { throw new FileLockException( file ); } } catch ( OverlappingFileLockException e ) { throw new FileLockException( file, e ); } }
@Test void tryLock() throws Exception { channel.tryLock(); verify( actual ).tryLock(); }
@Test public void ch_tryLock() throws IOException { chan( false ).tryLock().release(); }
@Test void mustDisableStripingIfToldTo() throws IOException { // given int bytesPerPage = 32; PageSwapperFactory factory = createSwapperFactory(); FileSystemAbstraction fs = mock( FileSystemAbstraction.class ); StoreChannel channel = mock( StoreChannel.class ); when( channel.tryLock() ).thenReturn( mock( FileLock.class ) ); when( fs.create( any( File.class ) ) ).thenReturn( channel ); when( fs.open( any( File.class ), any() ) ).thenReturn( channel ); // when factory.open( fs, Configuration.EMPTY ); PageSwapper swapper = createSwapper( factory, file, bytesPerPage, NO_CALLBACK, true, true ); try { // then verify( fs, times( 1 ) ).open( eq( file ), any( OpenMode.class ) ); } finally { swapper.close(); } }
storeLockFileLock = storeLockFileChannel.tryLock(); if ( storeLockFileLock == null )
File file = testDir.file( "file" ); try ( StoreChannel ch = fileSystem.create( file ); FileLock ignore = ch.tryLock() )
@Override public FileLock tryLock() throws IOException { return delegateChannel.tryLock(); }
@Override public FileLock tryLock() throws IOException { return delegate.tryLock(); }
@Override public FileLock tryLock() throws IOException { return inner.tryLock(); }
private void acquireLock() throws IOException { if ( SystemUtils.IS_OS_WINDOWS ) { // We don't take file locks on the individual store files on Windows, because once you've taking // a file lock on a channel, you can only do IO on that file through that channel. This would // mean that we can't stripe our FileChannels on Windows, which is the platform that needs striped // channels the most because of lack of pwrite and pread support. // This is generally fine, because the StoreLocker and the lock file will protect the store from // being opened by multiple instances at the same time anyway. return; } try { fileLock = channels[tokenChannelStripe].tryLock(); if ( fileLock == null ) { throw new FileLockException( file ); } } catch ( OverlappingFileLockException e ) { throw new FileLockException( file, e ); } }
storeLockFileLock = storeLockFileChannel.tryLock(); if ( storeLockFileLock == null )