Search in sources :

Example 6 with OpenOption

use of java.nio.file.OpenOption in project neo4j by neo4j.

the class PageCacheTest method mustThrowOnUnsupportedOpenOptions.

@Test(timeout = SEMI_LONG_TIMEOUT_MILLIS)
public void mustThrowOnUnsupportedOpenOptions() throws Exception {
    configureStandardPageCache();
    verifyMappingWithOpenOptionThrows(StandardOpenOption.CREATE_NEW);
    verifyMappingWithOpenOptionThrows(StandardOpenOption.SYNC);
    verifyMappingWithOpenOptionThrows(StandardOpenOption.DSYNC);
    verifyMappingWithOpenOptionThrows(new OpenOption() {

        @Override
        public String toString() {
            return "NonStandardOpenOption";
        }
    });
}
Also used : StandardOpenOption(java.nio.file.StandardOpenOption) OpenOption(java.nio.file.OpenOption) Long.toHexString(java.lang.Long.toHexString) Matchers.containsString(org.hamcrest.Matchers.containsString) Test(org.junit.Test)

Example 7 with OpenOption

use of java.nio.file.OpenOption in project neo4j by neo4j.

the class MetaDataStoreTest method setUp.

@Before
public void setUp() {
    fs = fsRule.get();
    pageCache = pageCacheRule.getPageCache(fs);
    fakePageCursorOverflow = false;
    pageCacheWithFakeOverflow = new DelegatingPageCache(pageCache) {

        @Override
        public PagedFile map(File file, int pageSize, OpenOption... openOptions) throws IOException {
            return new DelegatingPagedFile(super.map(file, pageSize, openOptions)) {

                @Override
                public PageCursor io(long pageId, int pf_flags) throws IOException {
                    return new DelegatingPageCursor(super.io(pageId, pf_flags)) {

                        @Override
                        public boolean checkAndClearBoundsFlag() {
                            return fakePageCursorOverflow | super.checkAndClearBoundsFlag();
                        }
                    };
                }
            };
        }
    };
}
Also used : OpenOption(java.nio.file.OpenOption) DelegatingPageCache(org.neo4j.io.pagecache.DelegatingPageCache) PagedFile(org.neo4j.io.pagecache.PagedFile) DelegatingPagedFile(org.neo4j.io.pagecache.DelegatingPagedFile) DelegatingPagedFile(org.neo4j.io.pagecache.DelegatingPagedFile) IOException(java.io.IOException) PagedFile(org.neo4j.io.pagecache.PagedFile) File(java.io.File) DelegatingPagedFile(org.neo4j.io.pagecache.DelegatingPagedFile) DelegatingPageCursor(org.neo4j.io.pagecache.impl.DelegatingPageCursor) PageCursor(org.neo4j.io.pagecache.PageCursor) DelegatingPageCursor(org.neo4j.io.pagecache.impl.DelegatingPageCursor) Before(org.junit.Before)

Example 8 with OpenOption

use of java.nio.file.OpenOption in project google-cloud-java by GoogleCloudPlatform.

the class CloudStorageFileSystemProvider method newInputStream.

@Override
public InputStream newInputStream(Path path, OpenOption... options) throws IOException {
    initStorage();
    InputStream result = super.newInputStream(path, options);
    CloudStoragePath cloudPath = CloudStorageUtil.checkPath(path);
    int blockSize = cloudPath.getFileSystem().config().blockSize();
    for (OpenOption option : options) {
        if (option instanceof OptionBlockSize) {
            blockSize = ((OptionBlockSize) option).size();
        }
    }
    return new BufferedInputStream(result, blockSize);
}
Also used : StandardOpenOption(java.nio.file.StandardOpenOption) OpenOption(java.nio.file.OpenOption) BufferedInputStream(java.io.BufferedInputStream) BufferedInputStream(java.io.BufferedInputStream) InputStream(java.io.InputStream)

Aggregations

OpenOption (java.nio.file.OpenOption)8 StandardOpenOption (java.nio.file.StandardOpenOption)7 File (java.io.File)2 ArrayList (java.util.ArrayList)2 Acl (com.google.cloud.storage.Acl)1 BlobId (com.google.cloud.storage.BlobId)1 BlobInfo (com.google.cloud.storage.BlobInfo)1 Storage (com.google.cloud.storage.Storage)1 StorageException (com.google.cloud.storage.StorageException)1 BufferedInputStream (java.io.BufferedInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 Long.toHexString (java.lang.Long.toHexString)1 ByteBuffer (java.nio.ByteBuffer)1 SeekableByteChannel (java.nio.channels.SeekableByteChannel)1 Charset (java.nio.charset.Charset)1 Path (java.nio.file.Path)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 List (java.util.List)1