/** * @param config initial configuration for the database. * @return an instance of {@link GraphDatabaseService}. */ default GraphDatabaseService newDatabase( @Nonnull Config config ) { return newDatabase( config.getRaw() ); } }
@Override public int denseNodeThreshold() { return config.getRaw().containsKey( dense_node_threshold.name() ) ? config.get( dense_node_threshold ) : defaults.denseNodeThreshold(); }
private Config mockConfig( Map<String,String> rawConfig ) { Config config = Mockito.mock( Config.class ); when( config.getRaw() ).thenReturn( rawConfig ); when( config.get( strict_config_validation ) ) .thenReturn( Boolean.valueOf( rawConfig.get( strict_config_validation.name() ) ) ); return config; } }
@Override public Map<String,String> validate( @Nonnull Config config, @Nonnull Log log ) throws InvalidSettingException Map<String,String> rawConfig = config.getRaw(); Map<String,String> validConfig = stringMap(); for ( SettingValidator validator : settingValidators )
public static DbRepresentation of( File storeDir, boolean includeIndexes, Config config ) { GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir ); builder.setConfig( config.getRaw() ); GraphDatabaseService db = builder.newGraphDatabase(); try { return of( db, includeIndexes ); } finally { db.shutdown(); } }
private BatchInserter newBatchInserter( Config config ) throws Exception { return BatchInserters.inserter( storeDir.databaseDir(), fileSystemRule.get(), config.getRaw() ); }
@Test( expected = ToolFailureException.class ) public void failOnNotCleanlyShutdownStoreWithLogsInCustomAbsoluteLocation() throws Exception { File customConfigFile = testDirectory.file( "customConfig" ); File otherLocation = testDirectory.directory( "otherLocation" ); Config customConfig = Config.defaults( logical_logs_location, otherLocation.getAbsolutePath() ); createGraphDbAndKillIt( customConfig ); MapUtil.store( customConfig.getRaw(), customConfigFile ); String[] args = {testDirectory.databaseDir().getPath(), "-config", customConfigFile.getPath()}; runConsistencyCheckToolWith( fs.get(), args ); }
@Test( expected = ToolFailureException.class ) public void failOnNotCleanlyShutdownStoreWithLogsInCustomRelativeLocation() throws Exception { File customConfigFile = testDirectory.file( "customConfig" ); Config customConfig = Config.defaults( logical_logs_location, "otherLocation" ); createGraphDbAndKillIt( customConfig ); MapUtil.store( customConfig.getRaw(), fs.openAsOutputStream( customConfigFile, false ) ); String[] args = {testDirectory.databaseDir().getPath(), "-config", customConfigFile.getPath()}; runConsistencyCheckToolWith( fs.get(), args ); }
private GraphDatabaseService graphDatabaseService( Config config ) { TestGraphDatabaseFactory factory = new TestGraphDatabaseFactory(); factory.setFileSystem( fileSystemRule.get() ); return factory.newImpermanentDatabaseBuilder( storeDir.databaseDir() ) // Shouldn't be necessary to set dense node threshold since it's a stick config .setConfig( config.getRaw() ) .newGraphDatabase(); }
private void recoverBrokenStoreWithConfig( Config config ) throws IOException { try ( FileSystemAbstraction fileSystemAbstraction = createSomeDataAndCrash( storeDir, fileSystem, config ) ) { PageCache pageCache = pageCacheRule.getPageCache( fileSystemAbstraction ); RecoveryRequiredChecker recoverer = getRecoveryChecker( fileSystemAbstraction, pageCache, config ); assertThat( recoverer.isRecoveryRequiredAt( databaseLayout ), is( true ) ); new TestGraphDatabaseFactory() .setFileSystem( fileSystemAbstraction ) .newEmbeddedDatabaseBuilder( storeDir ) .setConfig( config.getRaw() ) .newGraphDatabase() .shutdown(); assertThat( recoverer.isRecoveryRequiredAt( databaseLayout ), is( false ) ); } }
private static FileSystemAbstraction createSomeDataAndCrash( File store, EphemeralFileSystemAbstraction fileSystem, Config config ) { final GraphDatabaseService db = new TestGraphDatabaseFactory() .setFileSystem( fileSystem ) .newImpermanentDatabaseBuilder( store ) .setConfig( config.getRaw() ) .newGraphDatabase(); try ( Transaction tx = db.beginTx() ) { db.createNode(); tx.success(); } EphemeralFileSystemAbstraction snapshot = fileSystem.snapshot(); db.shutdown(); return snapshot; } }
private void createGraphDbAndKillIt( Config config ) throws Exception { final GraphDatabaseService db = new TestGraphDatabaseFactory() .setFileSystem( fs.get() ) .newImpermanentDatabaseBuilder( testDirectory.databaseDir() ) .setConfig( config.getRaw() ) .newGraphDatabase(); try ( Transaction tx = db.beginTx() ) { db.createNode( label( "FOO" ) ); db.createNode( label( "BAR" ) ); tx.success(); } fs.snapshot( db::shutdown ); }
public static void initialize(GraphDatabaseAPI db) { Static.clear(); Config neo4jConfig = db.getDependencyResolver().resolveDependency(Config.class); Map<String, String> params = neo4jConfig.getRaw(); apocConfig.clear(); apocConfig.putAll(Util.subMap(params, PREFIX)); PARAM_WHITELIST.forEach((k, v) -> { Optional<Object> configValue = neo4jConfig.getValue(k); if (configValue.isPresent()) { apocConfig.put(v, configValue.get().toString()); } }); config.clear(); params.forEach((k, v) -> { if (!SKIP.matcher(k).find()) {config.put(k, v);} }); }
private Map<String, String> findModuleConfig(String moduleId) { Map<String, String> moduleConfig = new HashMap<>(); String moduleConfigKeyPrefix = MODULE_CONFIG_KEY + "." + moduleId + "."; for (String paramKey : config.getRaw().keySet()) { if (paramKey.startsWith(moduleConfigKeyPrefix) || !MODULE_ENABLED_KEY.matcher(paramKey).find()) { moduleConfig.put(paramKey.replace(moduleConfigKeyPrefix, ""), config.getRaw(paramKey).get()); } } return moduleConfig; }
/** * @param config initial configuration for the database. * @return an instance of {@link GraphDatabaseService}. */ default GraphDatabaseService newDatabase( @Nonnull Config config ) { return newDatabase( config.getRaw() ); } }
public void recoverWithDatabase( Path targetDirectory, PageCache pageCache, Config config ) { Map<String,String> configParams = config.getRaw(); configParams.put( GraphDatabaseSettings.logical_logs_location.name(), targetDirectory.toString() ); configParams.put( GraphDatabaseSettings.pagecache_warmup_enabled.name(), Settings.FALSE ); GraphDatabaseAPI targetDb = startTemporaryDb( targetDirectory, pageCache, configParams ); targetDb.shutdown(); } }
@Override public int denseNodeThreshold() { return config.getRaw().containsKey( dense_node_threshold.name() ) ? config.get( dense_node_threshold ) : defaults.denseNodeThreshold(); }
private StatsCollector createStatsCollector() { String disable = neoServer.getConfig().getRaw().get("com.graphaware.runtime.stats.disable"); String disabled = neoServer.getConfig().getRaw().get("com.graphaware.runtime.stats.disabled"); if (Boolean.parseBoolean(disable) || Boolean.parseBoolean(disabled)) { LOG.info("Google Analytics disabled"); return NullStatsCollector.getInstance(); } else { LOG.info("Google Analytics enabled"); } return new GoogleAnalyticsStatsCollector(neoServer.getDatabase().getGraph()); }