private void removeProvidersFromIndexDbFile( DatabaseLayout databaseLayout ) { IndexConfigStore indexStore = new IndexConfigStore( databaseLayout, fileSystemRule.get() ); for ( Class<? extends PropertyContainer> cls : new Class[] {Node.class, Relationship.class} ) { for ( String name : indexStore.getNames( cls ) ) { Map<String, String> config = indexStore.get( cls, name ); config = new HashMap<>( config ); config.remove( IndexManager.PROVIDER ); indexStore.set( Node.class, name, config ); } } } }
void deleteIndex( IndexIdentifier identifier, boolean recovery ) throws IOException { if ( readOnly ) { throw new IllegalStateException( "Index deletion in read only mode is not supported." ); } closeIndex( identifier ); FileUtils.deleteRecursively( getFileDirectory( baseStorePath, identifier ) ); indexTypeMap.remove( identifier ); boolean removeFromIndexStore = !recovery || (indexStore.has( identifier.entityType.entityClass(), identifier.indexName )); if ( removeFromIndexStore ) { indexStore.remove( identifier.entityType.entityClass(), identifier.indexName ); } typeCache.invalidate( identifier ); }
private Map<String, String> config( Class<? extends PropertyContainer> cls, String indexName, Map<String, String> config ) { // TODO Doesn't look right if ( config != null ) { config = MapUtil.stringMap( new HashMap<>( config ), IndexManager.PROVIDER, LuceneIndexImplementation.SERVICE_NAME ); indexStore.setIfNecessary( cls, indexName, config ); return config; } else { return indexStore.get( cls, indexName ); } }
private void makeSureAllIndexesAreInstantiated() { for ( String name : indexStore.getNames( Node.class ) ) { Map<String, String> config = indexStore.get( Node.class, name ); if ( config.get( IndexManager.PROVIDER ).equals( LuceneIndexImplementation.SERVICE_NAME ) ) { ensureInstantiated( new IndexIdentifier( IndexEntityType.Node, name ) ); } } for ( String name : indexStore.getNames( Relationship.class ) ) { Map<String, String> config = indexStore.get( Relationship.class, name ); if ( config.get( IndexManager.PROVIDER ).equals( LuceneIndexImplementation.SERVICE_NAME ) ) { ensureInstantiated( new IndexIdentifier( IndexEntityType.Relationship, name ) ); } } }
private void setupIndexInfrastructure() { indexStore = new IndexConfigStore( testDirectory.databaseLayout(), fileSystemRule.get() ); indexStore.set( Node.class, INDEX_NAME, MapUtil.stringMap( IndexManager.PROVIDER, "lucene", "type", "fulltext" ) ); } }
public Map<String, String> getNodeIndexConfiguration( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> config = indexStore.get( Node.class, indexName ); if ( config == null ) { throw new ExplicitIndexNotFoundKernelException( "No node index '" + indexName + "' found" ); } return config; }
@Before public void setUp() { indexStore = new IndexConfigStore( directory.databaseLayout(), fileSystemRule.get() ); addIndex( "foo" ); }
public String removeNodeIndexConfiguration( String indexName, String key ) throws ExplicitIndexNotFoundKernelException { assertLegalConfigKey( key ); Map<String, String> config = new HashMap<>( getNodeIndexConfiguration( indexName ) ); String value = config.remove( key ); if ( value != null ) { indexStore.set( Node.class, indexName, config ); } return value; }
public String[] getAllRelationshipIndexNames() { return indexStore.getNames( Relationship.class ); } }
@Test public void failureToCreateAnIndexShouldNotLeaveConfigurationBehind() { // WHEN try { // PerFieldAnalyzerWrapper is invalid since it has no public no-arg constructor nodeIndex( stringMap( "analyzer", PerFieldAnalyzerWrapper.class.getName() ) ); fail( "Should have failed" ); } catch ( RuntimeException e ) { assertThat( e.getMessage(), CoreMatchers.containsString( PerFieldAnalyzerWrapper.class.getName() ) ); } // THEN - assert that there's no index config about this index left behind assertFalse( "There should be no index config for index '" + currentIndexName() + "' left behind", ((GraphDatabaseAPI)graphDb).getDependencyResolver().resolveDependency( IndexConfigStore.class ).has( Node.class, currentIndexName() ) ); }
@Override public boolean visitIndexCreateCommand( IndexCommand.CreateCommand command ) throws IOException { indexConfigStore.setIfNecessary( IndexEntityType.byId( command.getEntityType() ).entityClass(), defineCommand.getIndexName( command.getIndexNameId() ), command.getConfig() ); return applier( command ).visitIndexCreateCommand( command ); }
private IndexConfigStore newIndexConfigStore( MutableObjectIntMap<String> names, String providerName ) { EphemeralFileSystemAbstraction fileSystem = fs.get(); IndexConfigStore store = life.add( new IndexConfigStore( testDirectory.databaseLayout(), fileSystem ) ); names.forEachKey( name -> { store.set( Node.class, name, stringMap( IndexManager.PROVIDER, providerName ) ); store.set( Relationship.class, name, stringMap( IndexManager.PROVIDER, providerName ) ); } ); return store; } }
public Map<String, String> getRelationshipIndexConfiguration( String indexName ) throws ExplicitIndexNotFoundKernelException { Map<String, String> config = indexStore.get( Relationship.class, indexName ); if ( config == null ) { throw new ExplicitIndexNotFoundKernelException( "No relationship index '" + indexName + "' found" ); } return config; }
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 ) ); }
public String setNodeIndexConfiguration( String indexName, String key, String value ) throws ExplicitIndexNotFoundKernelException { assertLegalConfigKey( key ); Map<String, String> config = new HashMap<>( getNodeIndexConfiguration( indexName ) ); String oldValue = config.put( key, value ); indexStore.set( Node.class, indexName, config ); return oldValue; }
public String[] getAllNodeIndexNames() { return indexStore.getNames( Node.class ); }