org.neo4j.kernel.configuration.Config类的使用及代码示例

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

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

Config介绍

[英]This class holds the overall configuration of a Neo4j database instance. Use the accessors to convert the internal key-value settings to other types.

Users can assume that old settings have been migrated to their new counterparts, and that defaults have been applied.
[中]此类保存Neo4j数据库实例的总体配置。使用访问器将内部键值设置转换为其他类型。
用户可以假定旧设置已迁移到新设置,并且已应用默认设置。

代码示例

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

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;
  }
}

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

Kernel( String desiredId )
{
  super( fileSystemRule.get(), pageCacheRule.getPageCache( fileSystemRule.get() ),
      new File( GraphDatabaseSettings.DEFAULT_DATABASE_NAME ), Config.defaults( forced_kernel_id, desiredId), mock( DataSourceManager.class ) );
  kernels.add( this );
}

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

@Test
public void augmentAnotherConfig()
{
  Config config = Config();
  config.augment( MySettingsWithDefaults.hello, "Hi" );
  Config anotherConfig = Config();
  anotherConfig.augment( stringMap( MySettingsWithDefaults.boolSetting.name(),
      Settings.FALSE, MySettingsWithDefaults.hello.name(), "Bye" ) );
  config.augment( anotherConfig );
  assertThat( config.get( MySettingsWithDefaults.boolSetting ), equalTo( false ) );
  assertThat( config.get( MySettingsWithDefaults.hello ), equalTo( "Bye" ) );
}

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

@Override
public int denseNodeThreshold()
{
  return config.getRaw().containsKey( dense_node_threshold.name() )
      ? config.get( dense_node_threshold )
      : defaults.denseNodeThreshold();
}

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

private static Config loadNeo4jConfig( Path homeDir, Path configDir, String databaseName, Config additionalConfig )
  {
    Config config = Config.fromFile( configDir.resolve( Config.DEFAULT_CONFIG_FILE_NAME ) )
        .withHome( homeDir )
        .withConnectorsDisabled()
        .withNoThrowOnFileLoadFailure()
        .build();
    config.augment( additionalConfig );
    config.augment( GraphDatabaseSettings.active_database, databaseName );
    return config;
  }
}

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

@Test
public void testPluginInitialization()
{
  Config config = Config.defaults( ServerSettings.transaction_idle_timeout, "600" );
  NeoServer neoServer = Mockito.mock( NeoServer.class, Mockito.RETURNS_DEEP_STUBS );
  Mockito.when( neoServer.getConfig() ).thenReturn( config );
  ExtensionInitializer extensionInitializer = new ExtensionInitializer( neoServer );
  Collection<Injectable<?>> injectableProperties =
      extensionInitializer.initializePackages( Collections.singletonList( "org.neo4j.server.modules" ) );
  assertTrue(
      injectableProperties.stream()
          .anyMatch( i -> ServerSettings
              .transaction_idle_timeout.name().equals( i.getValue() ) ) );
}

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

@Test
  public void shouldReportThirdPartyPackagesAtSpecifiedMount() throws Exception
  {
    // Given
    WebServer webServer = mock( WebServer.class );

    CommunityNeoServer neoServer = mock( CommunityNeoServer.class );
    when( neoServer.baseUri() ).thenReturn( new URI( "http://localhost:7575" ) );
    when( neoServer.getWebServer() ).thenReturn( webServer );
    Database database = mock( Database.class );
    when( neoServer.getDatabase() ).thenReturn( database );

    Config config = mock( Config.class );
    List<ThirdPartyJaxRsPackage> jaxRsPackages = new ArrayList<>();
    String path = "/third/party/package";
    jaxRsPackages.add( new ThirdPartyJaxRsPackage( "org.example.neo4j", path ) );
    when( config.get( ServerSettings.third_party_packages ) ).thenReturn( jaxRsPackages );

    // When
    ThirdPartyJAXRSModule module =
        new ThirdPartyJAXRSModule( webServer, config, NullLogProvider.getInstance(), neoServer );
    module.start();

    // Then
    verify( webServer ).addJAXRSPackages( any( List.class ), anyString(), anyCollection() );
  }
}

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

@Test
  void executeQueryStartDefaultTransaction()
  {
    KernelTransaction kernelTransaction = mock( KernelTransaction.class );
    InternalTransaction transaction = new TopLevelTransaction( kernelTransaction );

    when( queryService.beginTransaction( KernelTransaction.Type.implicit, AUTH_DISABLED ) )
      .thenReturn( transaction );

    graphDatabaseFacade.execute( "create (n)" );
    graphDatabaseFacade.execute( "create (n)", new HashMap<>() );

    long timeout = Config.defaults().get( GraphDatabaseSettings.transaction_timeout ).toMillis();
    verify( spi, times( 2 ) ).beginTransaction( KernelTransaction.Type.implicit, AUTH_DISABLED, timeout );
  }
}

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

private RecordStorageEngine get( FileSystemAbstraction fs, PageCache pageCache,
                 IndexProvider indexProvider, DatabaseHealth databaseHealth, DatabaseLayout databaseLayout,
                 Function<BatchTransactionApplierFacade, BatchTransactionApplierFacade> transactionApplierTransformer,
                 Monitors monitors, LockService lockService )
{
  IdGeneratorFactory idGeneratorFactory = new EphemeralIdGenerator.Factory();
  ExplicitIndexProvider explicitIndexProviderLookup = mock( ExplicitIndexProvider.class );
  when( explicitIndexProviderLookup.allIndexProviders() ).thenReturn( Iterables.empty() );
  IndexConfigStore indexConfigStore = new IndexConfigStore( databaseLayout, fs );
  JobScheduler scheduler = life.add( createScheduler() );
  Config config = Config.defaults( GraphDatabaseSettings.default_schema_provider, indexProvider.getProviderDescriptor().name() );
  Dependencies dependencies = new Dependencies();
  dependencies.satisfyDependency( indexProvider );
  BufferingIdGeneratorFactory bufferingIdGeneratorFactory =
      new BufferingIdGeneratorFactory( idGeneratorFactory, IdReuseEligibility.ALWAYS,
          new CommunityIdTypeConfigurationProvider() );
  DefaultIndexProviderMap indexProviderMap = new DefaultIndexProviderMap( dependencies, config );
  NullLogProvider nullLogProvider = NullLogProvider.getInstance();
  life.add( indexProviderMap );
  return life.add( new ExtendedRecordStorageEngine( databaseLayout, config, pageCache, fs,
      nullLogProvider, nullLogProvider, mockedTokenHolders(),
      mock( SchemaState.class ), new StandardConstraintSemantics(),
      scheduler, mock( TokenNameLookup.class ), lockService, indexProviderMap,
      IndexingService.NO_MONITOR, databaseHealth, explicitIndexProviderLookup, indexConfigStore,
      new SynchronizedArrayIdOrderingQueue(), idGeneratorFactory,
      new BufferedIdController( bufferingIdGeneratorFactory, scheduler ), transactionApplierTransformer, monitors,
      RecoveryCleanupWorkCollector.immediate(), OperationalMode.single ) );
}

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

@Test
public void noThrowWhenLatestVersionAndUpgradeIsNotAllowed()
{
  when( tailScanner.getTailInformation() ).thenReturn( new OnlyVersionTailInformation( LogEntryVersion.CURRENT ) );
  LogVersionUpgradeChecker.check( tailScanner, Config.defaults( GraphDatabaseSettings.allow_upgrade, "false") );
}

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

@Test
  public void shouldAdvertiseServicesWhenAsked() throws Exception
  {
    UriInfo uriInfo = mock( UriInfo.class );
    URI uri = new URI( "http://example.org:7474/" );
    when( uriInfo.getBaseUri() ).thenReturn( uri );
    RootService svc = new RootService( new CommunityNeoServer( Config.defaults( stringMap(
        new HttpConnector( "http", Encryption.NONE ).type.name(), "HTTP",
        new HttpConnector( "http", Encryption.NONE ).enabled.name(), "true"
    ) ),
        GraphDatabaseDependencies.newDependencies().userLogProvider( NullLogProvider.getInstance() )
            .monitors( new Monitors() )
    ) );
    EntityOutputFormat output = new EntityOutputFormat( new JsonFormat(), null, null );
    Response serviceDefinition = svc.getServiceDefinition( uriInfo, output );
    assertEquals( 200, serviceDefinition.getStatus() );
    Map<String, Object> result = (Map<String, Object>) output.getResultAsMap().get( "services" );
    assertThat( result.get( "console" )
        .toString(), containsString( String.format( "%sserver/console", uri.toString() ) ) );
    assertThat( result.get( "jmx" )
        .toString(), containsString( String.format( "%sserver/jmx", uri.toString() ) ) );
  }
}

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

@Test
public void shouldLogIfConfigFileCouldNotBeFound()
{
  Log log = mock( Log.class );
  File confFile = testDirectory.file( "test.conf" ); // Note: we don't create the file.
  Config config = Config.fromFile( confFile ).withNoThrowOnFileLoadFailure().build();
  config.setLogger( log );
  verify( log ).warn( "Config file [%s] does not exist.", confFile );
}

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

@Test
void shouldReportStoreSizes() throws Throwable
{
  UdcInformationCollector collector = new DefaultUdcInformationCollector( Config.defaults(), dataSourceManager, usageData );
  when( fileSystem.getFileSize( Mockito.any() ) ).thenReturn( 152L );
  Map<String, String> udcParams = collector.getUdcParams();
  assertThat( udcParams.get( "storesize" ), is( "152" ) );
}

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

final GraphDatabaseFacade mockDb = mock( GraphDatabaseFacade.class );
Config config = Config.defaults();
GraphDatabaseFacadeFactory.Dependencies deps =
    GraphDatabaseDependencies.newDependencies().userLogProvider( NullLogProvider.getInstance() );
GraphFactory factory = new SimpleGraphFactory( mockDb );
LifecycleManagingDatabase db = new LifecycleManagingDatabase( config, factory, deps )
when( mockDb.execute( LifecycleManagingDatabase.CYPHER_WARMUP_QUERY ) ).thenThrow(
    new TransactionFailureException( "Boo" ) );

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

PageCache pageCache = pageCacheRule.getPageCache( fileSystemAbstraction );
Config config = Config.defaults( GraphDatabaseSettings.rebuild_idgenerators_fast, "true" );
DynamicStringStore stringPropertyStore = mock( DynamicStringStore.class );
        NullLogProvider.getInstance(), stringPropertyStore, mock( PropertyKeyTokenStore.class ), mock( DynamicArrayStore.class ),
        RecordFormatSelector.defaultFormat() );
store.initialise( true );

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

@Test
public void shouldAcquireSchemaWriteLockBeforeCreatingUniquenessConstraint() throws Exception
{
  // given
  String defaultProvider = Config.defaults().get( default_schema_provider );
  when( constraintIndexCreator.createUniquenessConstraintIndex( transaction, descriptor, defaultProvider ) ).thenReturn( 42L );
  when( storageReader.constraintsGetForSchema(  descriptor.schema() ) ).thenReturn( Collections.emptyIterator() );
  // when
  operations.uniquePropertyConstraintCreate( descriptor );
  // then
  order.verify( locks ).acquireExclusive( LockTracer.NONE, ResourceTypes.LABEL, descriptor.getLabelId() );
  order.verify( txState ).constraintDoAdd( ConstraintDescriptorFactory.uniqueForSchema( descriptor ), 42L );
}

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

@Test
  public void shouldRegisterASingleUri()
  {
    // Given
    WebServer webServer = mock( WebServer.class );

    Map<String, String> params = new HashMap<>();
    String path = "/db/data";
    params.put( ServerSettings.rest_api_path.name(), path );
    Config config = Config.defaults( params );

    // When
    RESTApiModule module = new RESTApiModule( webServer, config, () -> new UsageData( mock( JobScheduler.class ) ), NullLogProvider.getInstance() );
    module.start();

    // Then
    verify( webServer ).addJAXRSClasses( anyListOf( String.class ), anyString(), any() );
  }
}

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

Config config = Config.defaults( GraphDatabaseSettings.rebuild_idgenerators_fast, "false" );
File storeFile = testDirectory.file( "nodes" );
File idFile = testDirectory.file( "idNodes" );
DynamicArrayStore labelStore = mock( DynamicArrayStore.class );
NodeStore store = new NodeStore( storeFile, idFile, config, new DefaultIdGeneratorFactory( fs ),
    pageCacheRule.getPageCache( fs ), NullLogProvider.getInstance(), labelStore,
    RecordFormatSelector.defaultFormat() );
store.initialise( true );

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

@Test
public void shouldNotLoadNoneWhiteListedFunction() throws Throwable
{
  // Given
  Log log = spy(Log.class);
  procedureCompiler = new ReflectiveProcedureCompiler( new TypeMappers(), components, new ComponentRegistry(),
      log, new ProcedureConfig( Config.defaults( GraphDatabaseSettings.procedure_whitelist, "WrongName" ) ) );
  List<CallableUserFunction> method = compile( SingleReadOnlyFunction.class );
  verify( log ).warn( "The function 'org.neo4j.kernel.impl.proc.listCoolPeople' is not on the whitelist and won't be loaded." );
  assertThat( method.size(), equalTo( 0 ) );
}

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

@Before
public void setup() throws Throwable
{
  config = Config.defaults();
  users = CommunitySecurityModule.getUserRepository( config, NullLogProvider.getInstance(), fsRule.get() );
  UserRepository initUserRepository =
      CommunitySecurityModule.getInitialUserRepository( config, NullLogProvider.getInstance(), fsRule.get() );
  manager = new BasicAuthManager( users, mock( PasswordPolicy.class ), authStrategy, initUserRepository );
  manager.init();
}

相关文章