org.neo4j.kernel.configuration.Config.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(13.3k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.neo4j.kernel.configuration.Config.<init>()方法的一些代码示例,展示了Config.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Config.<init>()方法的具体详情如下:
包路径:org.neo4j.kernel.configuration.Config
类名称:Config
方法名:<init>

Config.<init>介绍

暂无

代码示例

代码示例来源:origin: neo4j/neo4j

/**
   * @return The config reflecting the state of the builder.
   * @throws InvalidSettingException is thrown if an invalid setting is encountered and {@link
   * GraphDatabaseSettings#strict_config_validation} is true.
   */
  @Nonnull
  public Config build() throws InvalidSettingException
  {
    List<LoadableConfig> loadableConfigs =
        Optional.ofNullable( settingsClasses ).orElseGet( LoadableConfig::allConfigClasses );
    // If reading from a file, make sure we always have a neo4j_home
    if ( configFile != null && !initialSettings.containsKey( GraphDatabaseSettings.neo4j_home.name() ) )
    {
      initialSettings.put( GraphDatabaseSettings.neo4j_home.name(), System.getProperty( "user.dir" ) );
    }
    Config config = new Config( configFile, throwOnFileLoadFailure, initialSettings, overriddenDefaults, validators, loadableConfigs );
    if ( connectorsDisabled )
    {
      config.augment( config.allConnectorIdentifiers().stream().collect(
          Collectors.toMap( id -> new Connector( id ).enabled.name(), id -> Settings.FALSE ) ) );
    }
    return config;
  }
}

代码示例来源:origin: org.neo4j/neo4j-kernel

/**
   * @return The config reflecting the state of the builder.
   * @throws InvalidSettingException is thrown if an invalid setting is encountered and {@link
   * GraphDatabaseSettings#strict_config_validation} is true.
   */
  @Nonnull
  public Config build() throws InvalidSettingException
  {
    List<LoadableConfig> loadableConfigs =
        Optional.ofNullable( settingsClasses ).orElseGet( LoadableConfig::allConfigClasses );
    // If reading from a file, make sure we always have a neo4j_home
    if ( configFile != null && !initialSettings.containsKey( GraphDatabaseSettings.neo4j_home.name() ) )
    {
      initialSettings.put( GraphDatabaseSettings.neo4j_home.name(), System.getProperty( "user.dir" ) );
    }
    Config config = new Config( configFile, throwOnFileLoadFailure, initialSettings, overriddenDefaults, validators, loadableConfigs );
    if ( connectorsDisabled )
    {
      config.augment( config.allConnectorIdentifiers().stream().collect(
          Collectors.toMap( id -> new Connector( id ).enabled.name(), id -> Settings.FALSE ) ) );
    }
    return config;
  }
}

代码示例来源:origin: org.neo4j/neo4j-core-edge

public CoreGraphDatabase( File storeDir, Map<String,String> params,
    GraphDatabaseFacadeFactory.Dependencies dependencies, DiscoveryServiceFactory discoveryServiceFactory )
{
  CustomIOConfigValidator.assertCustomIOConfigNotUsed( new Config( params ), CUSTOM_IO_EXCEPTION_MESSAGE );
  Function<PlatformModule,EditionModule> factory =
      ( platformModule ) -> new EnterpriseCoreEditionModule( platformModule, discoveryServiceFactory );
  new GraphDatabaseFacadeFactory( DatabaseInfo.CORE, factory ).initFacade( storeDir, params, dependencies, this );
}

代码示例来源:origin: com.buschmais.jqassistant.neo4jserver/neo4jv2

@Override
public void start() {
  tempDirectory = createTempDirectory();
  Map<String, String> opts = new HashMap<>();
  // Neo4j 2.x
  opts.put(DBMS_SECURITY_AUTH_ENABLED, Boolean.FALSE.toString());
  opts.put(ORG_NEO_4J_SERVER_WEBSERVER_ADDRESS, embeddedNeo4jConfiguration.getListenAddress());
  opts.put(ORG_NEO_4J_SERVER_WEBSERVER_PORT, Integer.toString(embeddedNeo4jConfiguration.getHttpPort()));
  // Neo4j 2.x/3.x
  String sslDir = tempDirectory.toFile().getAbsolutePath() + "neo4j-home/";
  opts.put(ServerSettings.tls_key_file.name(), sslDir + "/ssl/snakeoil.key");
  opts.put(ServerSettings.tls_certificate_file.name(), sslDir + "/ssl/snakeoil.cert");
  Config defaults = new Config(opts); // Config.empty().with(opts);
  FormattedLogProvider logProvider = FormattedLogProvider.withDefaultLogLevel(Level.INFO).toOutputStream(System.out);
  GraphDatabaseDependencies graphDatabaseDependencies = GraphDatabaseDependencies.newDependencies().userLogProvider(logProvider);
  Database.Factory factory = new Database.Factory() {
    @Override
    public Database newDatabase(Config config, GraphDatabaseFacadeFactory.Dependencies dependencies) {
      return new WrappedDatabase((GraphDatabaseAPI) graphDatabaseService);
    }
  };
  communityNeoServer = new CommunityNeoServer(defaults, factory, graphDatabaseDependencies, logProvider);
  communityNeoServer.start();
}

代码示例来源:origin: org.neo4j/neo4j-core-edge

public EdgeGraphDatabase( File storeDir, Map<String,String> params, Dependencies dependencies,
      DiscoveryServiceFactory discoveryServiceFactory )
  {
    CustomIOConfigValidator.assertCustomIOConfigNotUsed( new Config( params ), CUSTOM_IO_EXCEPTION_MESSAGE );
    Function<PlatformModule,EditionModule> factory =
        ( platformModule ) -> new EnterpriseEdgeEditionModule( platformModule, discoveryServiceFactory );
    new GraphDatabaseFacadeFactory( DatabaseInfo.EDGE, factory ).initFacade( storeDir, params, dependencies, this );
  }
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

static Config config( TaskExecutionOrder executionOrder )
{
  Map<String,String> params = stringMap(
      ConsistencyCheckSettings.consistency_check_execution_order.name(), executionOrder.name(),
      // Enable property owners check by default in tests:
      ConsistencyCheckSettings.consistency_check_property_owners.name(), "true" );
  return new Config( params, GraphDatabaseSettings.class, ConsistencyCheckSettings.class );
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

@Test
public void shouldFailIfTheStoreInNotConsistent() throws Exception
{
  // given
  breakNodeStore();
  Date timestamp = new Date();
  ConsistencyCheckService service = new ConsistencyCheckService( timestamp );
  Config configuration = new Config( settings(), GraphDatabaseSettings.class, ConsistencyCheckSettings.class );
  // when
  ConsistencyCheckService.Result result = service.runFullConsistencyCheck( fixture.directory(),
      configuration, ProgressMonitorFactory.NONE, NullLogProvider.getInstance(),
      new DefaultFileSystemAbstraction() );
  // then
  assertEquals( ConsistencyCheckService.Result.FAILURE, result );
  File reportFile = new File( fixture.directory(), defaultLogFileName( timestamp ) );
  assertTrue( "Inconsistency report file " + reportFile + " not generated", reportFile.exists() );
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

@Test
public void shouldSucceedIfStoreIsConsistent() throws Exception
{
  // given
  Date timestamp = new Date();
  ConsistencyCheckService service = new ConsistencyCheckService( timestamp );
  Config configuration = new Config( settings(), GraphDatabaseSettings.class, ConsistencyCheckSettings.class );
  // when
  ConsistencyCheckService.Result result = service.runFullConsistencyCheck( fixture.directory(),
      configuration, ProgressMonitorFactory.NONE, NullLogProvider.getInstance(),
      new DefaultFileSystemAbstraction() );
  // then
  assertEquals( ConsistencyCheckService.Result.SUCCESS, result );
  File reportFile = new File( fixture.directory(), defaultLogFileName( timestamp ) );
  assertFalse( "Unexpected generation of consistency check report file: " + reportFile, reportFile.exists() );
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

@Test
public void shouldWriteInconsistenciesToLogFileAtSpecifiedLocation() throws Exception
{
  // given
  breakNodeStore();
  ConsistencyCheckService service = new ConsistencyCheckService();
  File specificLogFile = new File( testDirectory.directory(), "specific_logfile.txt" );
  Config configuration = new Config(
      settings( ConsistencyCheckSettings.consistency_check_report_file.name(), specificLogFile.getPath() ),
      GraphDatabaseSettings.class, ConsistencyCheckSettings.class
  );
  // when
  service.runFullConsistencyCheck( fixture.directory(), configuration,
      ProgressMonitorFactory.NONE, NullLogProvider.getInstance(), new DefaultFileSystemAbstraction() );
  // then
  assertTrue( "Inconsistency report file " + specificLogFile + " not generated", specificLogFile.exists() );
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

private void assertConsistent( File storeDir ) throws ConsistencyCheckIncompleteException, IOException
{
  ConsistencyCheckService consistencyChecker = new ConsistencyCheckService();
  Result result = consistencyChecker.runFullConsistencyCheck( storeDir,
      new Config( stringMap( GraphDatabaseSettings.pagecache_memory.name(), "8m" ) ),
      ProgressMonitorFactory.NONE,
      NullLogProvider.getInstance(), new DefaultFileSystemAbstraction() );
  assertTrue( "Database contains inconsistencies, there should be a report in " + storeDir,
      result.isSuccessful() );
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

public static void assertConsistentStore( File dir ) throws ConsistencyCheckIncompleteException, IOException
  {
    final Config configuration =
        new Config(
            stringMap( GraphDatabaseSettings.pagecache_memory.name(), "8m" ),
            GraphDatabaseSettings.class,
            ConsistencyCheckSettings.class
        );

    final ConsistencyCheckService.Result result =
        new ConsistencyCheckService().runFullConsistencyCheck(
            dir,
            configuration,
            ProgressMonitorFactory.NONE,
            NullLogProvider.getInstance(),
            new DefaultFileSystemAbstraction()
        );

    assertTrue( result.isSuccessful() );
  }
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

final BatchImporter inserter = new ParallelBatchImporter( directory.graphDbDir(),
    new DefaultFileSystemAbstraction(), config, NullLogService.getInstance(),
    processorAssigner, EMPTY, new Config() );

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

@Test
public void shouldReportNodesThatAreNotIndexed() throws Exception
{
  // given
  IndexSamplingConfig samplingConfig = new IndexSamplingConfig( new Config() );
  for ( IndexRule indexRule : loadAllIndexRules( fixture.directStoreAccess().nativeStores().getSchemaStore() ) )
  {
    IndexAccessor accessor = fixture.directStoreAccess().indexes().getOnlineAccessor(
        indexRule.getId(), new IndexConfiguration( indexRule.isConstraintIndex() ), samplingConfig );
    IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE );
    updater.remove( asPrimitiveLongSet( indexedNodes ) );
    updater.close();
    accessor.close();
  }
  // when
  ConsistencySummaryStatistics stats = check();
  // then
  on( stats ).verify( RecordType.NODE, 1 )
        .andThatsAllFolks();
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

IndexDescriptor descriptor = new IndexDescriptor( rule.getLabel(), rule.getPropertyKey() );
IndexConfiguration indexConfig = new IndexConfiguration( false );
IndexSamplingConfig samplingConfig = new IndexSamplingConfig( new Config() );
IndexPopulator populator =
  storeAccess.indexes().getPopulator( rule.getId(), descriptor, indexConfig, samplingConfig );

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

@Test
public void shouldReportNodesWithDuplicatePropertyValueInUniqueIndex() throws Exception
{
  // given
  IndexConfiguration indexConfig = new IndexConfiguration( false );
  IndexSamplingConfig samplingConfig = new IndexSamplingConfig( new Config() );
  for ( IndexRule indexRule : loadAllIndexRules( fixture.directStoreAccess().nativeStores().getSchemaStore() ) )
  {
    IndexAccessor accessor = fixture.directStoreAccess()
                    .indexes()
                    .getOnlineAccessor( indexRule.getId(), indexConfig, samplingConfig );
    IndexUpdater updater = accessor.newUpdater( IndexUpdateMode.ONLINE );
    updater.process( NodePropertyUpdate.add( 42, 0, "value", new long[]{3} ) );
    updater.close();
    accessor.close();
  }
  // when
  ConsistencySummaryStatistics stats = check();
  // then
  on( stats ).verify( RecordType.NODE, 1 )
        .verify( RecordType.INDEX, 2 )
        .andThatsAllFolks();
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

public DirectStoreAccess directStoreAccess()
{
  if ( directStoreAccess == null )
  {
    DefaultFileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction();
    PageCache pageCache = getPageCache( fileSystem );
    StoreAccess nativeStores = new StoreAccess( fileSystem, pageCache, directory ).initialize();
    Config config = new Config();
    OperationalMode operationalMode = OperationalMode.single;
    directStoreAccess = new DirectStoreAccess(
        nativeStores,
        new LuceneLabelScanStoreBuilder(
            directory,
            nativeStores.getRawNeoStores(),
            fileSystem,
            config,
            operationalMode,
            FormattedLogProvider.toOutputStream( System.out )
        ).build(),
        createIndexes( fileSystem, config, operationalMode )
    );
  }
  return directStoreAccess;
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

@Test
public void shouldAllowGraphCheckDisabled() throws IOException, ConsistencyCheckIncompleteException
{
  GraphDatabaseService gds = new GraphDatabaseFactory().newEmbeddedDatabase( testDirectory.absolutePath() );
  try ( Transaction tx = gds.beginTx() )
  {
    gds.createNode();
    tx.success();
  }
  gds.shutdown();
  ConsistencyCheckService service = new ConsistencyCheckService();
  Config configuration = new Config( settings(), GraphDatabaseSettings.class, ConsistencyCheckSettings.class );
  configuration.applyChanges( MapUtil.stringMap( ConsistencyCheckSettings.consistency_check_graph.name(),
      Settings.FALSE ) );
  // when
  Result result = service.runFullConsistencyCheck( testDirectory.graphDbDir(), configuration,
      ProgressMonitorFactory.NONE, NullLogProvider.getInstance(), new DefaultFileSystemAbstraction() );
  // then
  assertEquals( ConsistencyCheckService.Result.SUCCESS, result );
}

代码示例来源:origin: org.neo4j/neo4j-consistency-check-legacy

@Test
public void shouldNotReportDuplicateForHugeLongValues() throws Exception
{
  // given
  ConsistencyCheckService service = new ConsistencyCheckService();
  Config configuration = new Config( settings(), GraphDatabaseSettings.class, ConsistencyCheckSettings.class );
  GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( testDirectory.graphDbDir() );
  String propertyKey = "itemId";
  Label label = DynamicLabel.label( "Item" );
  try ( Transaction tx = db.beginTx() )
  {
    db.schema().constraintFor( label ).assertPropertyIsUnique( propertyKey ).create();
    tx.success();
  }
  try ( Transaction tx = db.beginTx() )
  {
    set( db.createNode( label ), property( propertyKey, 973305894188596880L ) );
    set( db.createNode( label ), property( propertyKey, 973305894188596864L ) );
    tx.success();
  }
  db.shutdown();
  // when
  Result result = service.runFullConsistencyCheck( testDirectory.graphDbDir(), configuration,
      ProgressMonitorFactory.NONE, NullLogProvider.getInstance(), new DefaultFileSystemAbstraction() );
  // then
  assertEquals( ConsistencyCheckService.Result.SUCCESS, result );
}

相关文章