Skip to content

Commit

Permalink
Change method name tryMappedPagedFile to getExistingMapping
Browse files Browse the repository at this point in the history
  • Loading branch information
burqen committed Aug 19, 2016
1 parent a58e93a commit b6d1cc2
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 12 deletions.
Expand Up @@ -54,8 +54,7 @@ public interface PageCache extends AutoCloseable
* All other options are either silently ignored, or will cause an exception to be thrown. * All other options are either silently ignored, or will cause an exception to be thrown.
* @throws java.nio.file.NoSuchFileException if the given file does not exist, and the * @throws java.nio.file.NoSuchFileException if the given file does not exist, and the
* {@link StandardOpenOption#CREATE} option was not specified. * {@link StandardOpenOption#CREATE} option was not specified.
* @throws IOException if the file could otherwise not be mapped. Causes include the file being locked, or exclusive * @throws IOException if the file could otherwise not be mapped. Causes include the file being locked.
* mapping conflicts.
*/ */
PagedFile map( File file, int pageSize, OpenOption... openOptions ) throws IOException; PagedFile map( File file, int pageSize, OpenOption... openOptions ) throws IOException;


Expand All @@ -75,7 +74,7 @@ public interface PageCache extends AutoCloseable
* empty {@link Optional} if no mapping exist. * empty {@link Optional} if no mapping exist.
* @throws IOException if page cache has been closed or page eviction problems occur. * @throws IOException if page cache has been closed or page eviction problems occur.
*/ */
Optional<PagedFile> tryMappedPagedFile( File file ) throws IOException; Optional<PagedFile> getExistingMapping( File file ) throws IOException;


/** Flush all dirty pages */ /** Flush all dirty pages */
void flushAndForce() throws IOException; void flushAndForce() throws IOException;
Expand Down
Expand Up @@ -364,7 +364,7 @@ else if ( !ignoredOpenOptions.contains( option ) )
} }


@Override @Override
public synchronized Optional<PagedFile> tryMappedPagedFile( File file ) throws IOException public synchronized Optional<PagedFile> getExistingMapping( File file ) throws IOException
{ {
assertHealthy(); assertHealthy();
ensureThreadsInitialised(); ensureThreadsInitialised();
Expand Down
Expand Up @@ -69,10 +69,10 @@ public PagedFile map( File file, int pageSize, OpenOption... openOptions ) throw
} }


@Override @Override
public Optional<PagedFile> tryMappedPagedFile( File file ) throws IOException public Optional<PagedFile> getExistingMapping( File file ) throws IOException
{ {
adversary.injectFailure( IOException.class, SecurityException.class ); adversary.injectFailure( IOException.class, SecurityException.class );
final Optional<PagedFile> optional = delegate.tryMappedPagedFile( file ); final Optional<PagedFile> optional = delegate.getExistingMapping( file );
if ( optional.isPresent() ) if ( optional.isPresent() )
{ {
return Optional.of( new AdversarialPagedFile( optional.get(), adversary ) ); return Optional.of( new AdversarialPagedFile( optional.get(), adversary ) );
Expand Down
Expand Up @@ -39,9 +39,9 @@ public PagedFile map( File file, int pageSize, OpenOption... openOptions ) throw
} }


@Override @Override
public Optional<PagedFile> tryMappedPagedFile( File file ) throws IOException public Optional<PagedFile> getExistingMapping( File file ) throws IOException
{ {
return delegate.tryMappedPagedFile( file ); return delegate.getExistingMapping( file );
} }


public int pageSize() public int pageSize()
Expand Down
Expand Up @@ -1044,7 +1044,7 @@ public void tryMappedPagedFileShouldReportMappedFilePresent() throws Exception
final File file = file( "a" ); final File file = file( "a" );
try ( PagedFile pf = cache.map( file, filePageSize ) ) try ( PagedFile pf = cache.map( file, filePageSize ) )
{ {
final Optional<PagedFile> optional = cache.tryMappedPagedFile( file ); final Optional<PagedFile> optional = cache.getExistingMapping( file );
assertTrue( optional.isPresent() ); assertTrue( optional.isPresent() );
final PagedFile actual = optional.get(); final PagedFile actual = optional.get();
assertThat( actual, sameInstance( pf ) ); assertThat( actual, sameInstance( pf ) );
Expand All @@ -1056,7 +1056,7 @@ public void tryMappedPagedFileShouldReportMappedFilePresent() throws Exception
public void tryMappedPagedFileShouldReportNonMappedFileNotPresent() throws Exception public void tryMappedPagedFileShouldReportNonMappedFileNotPresent() throws Exception
{ {
PageCache cache = getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL ); PageCache cache = getPageCache( fs, maxPages, pageCachePageSize, PageCacheTracer.NULL );
final Optional<PagedFile> dont_exist = cache.tryMappedPagedFile( new File( "dont_exist" ) ); final Optional<PagedFile> dont_exist = cache.getExistingMapping( new File( "dont_exist" ) );
assertFalse( dont_exist.isPresent() ); assertFalse( dont_exist.isPresent() );
} }


Expand Down
Expand Up @@ -69,9 +69,9 @@ public PagedFile map( File file, int pageSize, OpenOption... openOptions ) throw
} }


@Override @Override
public Optional<PagedFile> tryMappedPagedFile( File file ) throws IOException public Optional<PagedFile> getExistingMapping( File file ) throws IOException
{ {
return delegate.tryMappedPagedFile( file ); return delegate.getExistingMapping( file );
} }


@Override @Override
Expand Down

0 comments on commit b6d1cc2

Please sign in to comment.