use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class ConfigurableStandalonePageCacheFactory method createPageCache.
/**
* Create page cache
* @param fileSystem file system that page cache will be based on
* @param pageCacheTracer global page cache tracer
* @param pageCursorTracerSupplier supplier of thread local (transaction local) page cursor tracer that will provide
* thread local page cache statistics
* @param config page cache configuration
* @return created page cache instance
*/
public static PageCache createPageCache(FileSystemAbstraction fileSystem, PageCacheTracer pageCacheTracer, PageCursorTracerSupplier pageCursorTracerSupplier, Config config) {
Config finalConfig = config.withDefaults(MapUtil.stringMap(GraphDatabaseSettings.pagecache_memory.name(), "8M"));
FormattedLogProvider logProvider = FormattedLogProvider.toOutputStream(System.err);
ConfiguringPageCacheFactory pageCacheFactory = new ConfiguringPageCacheFactory(fileSystem, finalConfig, pageCacheTracer, pageCursorTracerSupplier, logProvider.getLog(PageCache.class));
return pageCacheFactory.getOrCreatePageCache();
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class FileURLAccessRuleTest method shouldThrowWhenRelativePathIsOutsideImportDirectory.
@Test
public void shouldThrowWhenRelativePathIsOutsideImportDirectory() throws Exception {
File importDir = new File("/tmp/neo4jtest").getAbsoluteFile();
final Config config = Config.embeddedDefaults(MapUtil.stringMap(GraphDatabaseSettings.load_csv_file_url_root.name(), importDir.toString()));
try {
URLAccessRules.fileAccess().validate(config, new URL("file:///../baz.csv"));
fail("expected exception not thrown ");
} catch (URLAccessValidationError error) {
assertThat(error.getMessage(), equalTo("file URL points outside configured import directory"));
}
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class FileURLAccessRuleTest method shouldThrowWhenFileAccessIsDisabled.
@Test
public void shouldThrowWhenFileAccessIsDisabled() throws Exception {
final URL url = new URL("file:///bar/baz.csv");
final Config config = Config.embeddedDefaults(MapUtil.stringMap(GraphDatabaseSettings.allow_file_urls.name(), "false"));
try {
URLAccessRules.fileAccess().validate(config, url);
fail("expected exception not thrown ");
} catch (URLAccessValidationError error) {
assertThat(error.getMessage(), equalTo("configuration property 'dbms.security.allow_csv_import_from_file_urls' is false"));
}
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class FileURLAccessRuleTest method shouldAdjustURLToWithinImportDirectory.
@Test
public void shouldAdjustURLToWithinImportDirectory() throws Exception {
final URL url = new File("/bar/baz.csv").toURI().toURL();
final Config config = Config.embeddedDefaults(MapUtil.stringMap(GraphDatabaseSettings.load_csv_file_url_root.name(), "/var/lib/neo4j/import"));
URL accessURL = URLAccessRules.fileAccess().validate(config, url);
URL expected = new File("/var/lib/neo4j/import/bar/baz.csv").toURI().toURL();
assertEquals(expected, accessURL);
}
use of org.neo4j.kernel.configuration.Config in project neo4j by neo4j.
the class ConfiguringPageCacheFactoryTest method mustIgnoreExplicitlySpecifiedCachePageSizeIfPageSwapperHintIsStrict.
@Test
public void mustIgnoreExplicitlySpecifiedCachePageSizeIfPageSwapperHintIsStrict() throws Exception {
// Given
int cachePageSizeHint = 16 * 1024;
PageSwapperFactoryForTesting.cachePageSizeHint.set(cachePageSizeHint);
PageSwapperFactoryForTesting.cachePageSizeHintIsStrict.set(true);
Config config = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.pagecache_swapper.name(), TEST_PAGESWAPPER_NAME));
// When
ConfiguringPageCacheFactory factory = new ConfiguringPageCacheFactory(fsRule.get(), config, PageCacheTracer.NULL, PageCursorTracerSupplier.NULL, NullLog.getInstance());
// Then
try (PageCache cache = factory.getOrCreatePageCache()) {
assertThat(cache.pageSize(), is(cachePageSizeHint));
}
}
Aggregations