Skip to content

Commit

Permalink
Revert "Merge pull request #9804 from tinwelint/3.3-nsni-combined-ind…
Browse files Browse the repository at this point in the history
…ex-provider--migration"

This reverts commit 7d0e62c, reversing
changes made to 16b8e4a.
  • Loading branch information
burqen committed Aug 25, 2017
1 parent b2d52bf commit b40416c
Show file tree
Hide file tree
Showing 88 changed files with 917 additions and 1,600 deletions.
Expand Up @@ -44,13 +44,14 @@
import org.neo4j.io.pagecache.tracing.PageCacheTracer;
import org.neo4j.io.pagecache.tracing.cursor.PageCursorTracerSupplier;
import org.neo4j.kernel.api.direct.DirectStoreAccess;
import org.neo4j.kernel.api.impl.index.storage.DirectoryFactory;
import org.neo4j.kernel.api.impl.schema.LuceneSchemaIndexProvider;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.api.labelscan.LabelScanStore;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.extension.KernelExtensions;
import org.neo4j.kernel.impl.api.index.SchemaIndexProviderMap;
import org.neo4j.kernel.impl.api.scan.FullStoreChangeStream;
import org.neo4j.kernel.impl.factory.OperationalMode;
import org.neo4j.kernel.impl.index.labelscan.NativeLabelScanStore;
import org.neo4j.kernel.impl.logging.SimpleLogService;
import org.neo4j.kernel.impl.pagecache.ConfiguringPageCacheFactory;
import org.neo4j.kernel.impl.store.NeoStores;
import org.neo4j.kernel.impl.store.StoreAccess;
Expand All @@ -63,12 +64,8 @@
import org.neo4j.logging.LogProvider;

import static java.lang.String.format;
import static org.neo4j.consistency.internal.SchemaIndexExtensionLoader.RECOVERY_PREVENTING_COLLECTOR;
import static org.neo4j.consistency.internal.SchemaIndexExtensionLoader.instantiateKernelExtensions;
import static org.neo4j.consistency.internal.SchemaIndexExtensionLoader.loadSchemaIndexProviders;
import static org.neo4j.io.file.Files.createOrOpenAsOuputStream;
import static org.neo4j.kernel.configuration.Settings.TRUE;
import static org.neo4j.kernel.impl.factory.DatabaseInfo.COMMUNITY;

public class ConsistencyCheckService
{
Expand Down Expand Up @@ -207,6 +204,7 @@ public Result runFullConsistencyCheck( final File storeDir, Config config, Progr
{
Log log = logProvider.getLog( getClass() );
config.augment( GraphDatabaseSettings.read_only, TRUE );
OperationalMode operationalMode = OperationalMode.single;

StoreFactory factory = new StoreFactory( storeDir, config,
new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, logProvider );
Expand All @@ -227,17 +225,11 @@ public Result runFullConsistencyCheck( final File storeDir, Config config, Progr

// Bootstrap kernel extensions
LifeSupport life = new LifeSupport();
KernelExtensions extensions = life.add( instantiateKernelExtensions( storeDir,
fileSystem, config, new SimpleLogService( logProvider, logProvider ), pageCache,
RECOVERY_PREVENTING_COLLECTOR,
// May be enterprise edition, but in consistency checker we only care about the operational mode
COMMUNITY ) );

try ( NeoStores neoStores = factory.openAllNeoStores() )
{
life.start();

SchemaIndexProviderMap indexes = loadSchemaIndexProviders( extensions );
SchemaIndexProvider indexes = life.add( new LuceneSchemaIndexProvider( fileSystem, DirectoryFactory.PERSISTENT,
storeDir, logProvider, config, operationalMode ) );

LabelScanStore labelScanStore =
new NativeLabelScanStore( pageCache, storeDir, FullStoreChangeStream.EMPTY, true, new Monitors(),
Expand Down
Expand Up @@ -244,7 +244,7 @@ private PrimitiveLongIterator queryIndexOrEmpty( IndexReader reader, IndexQuery[
Arrays.toString( query ) ), e );
}

return reader.hasFullNumberPrecision( query )
return reader.hasFullNumberPrecision()
? indexedNodeIds : LookupFilter.exactIndexMatches( propertyReader, indexedNodeIds, query );
}

Expand Down
Expand Up @@ -31,7 +31,6 @@
import org.neo4j.kernel.api.index.IndexAccessor;
import org.neo4j.kernel.api.index.InternalIndexState;
import org.neo4j.kernel.api.index.SchemaIndexProvider;
import org.neo4j.kernel.impl.api.index.SchemaIndexProviderMap;
import org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig;
import org.neo4j.kernel.impl.store.RecordStore;
import org.neo4j.kernel.impl.store.SchemaStorage;
Expand All @@ -44,7 +43,7 @@ public class IndexAccessors implements Closeable
private final List<IndexRule> onlineIndexRules = new ArrayList<>();
private final List<IndexRule> notOnlineIndexRules = new ArrayList<>();

public IndexAccessors( SchemaIndexProviderMap providers,
public IndexAccessors( SchemaIndexProvider provider,
RecordStore<DynamicRecord> schemaStore,
IndexSamplingConfig samplingConfig ) throws IOException
{
Expand All @@ -59,8 +58,7 @@ public IndexAccessors( SchemaIndexProviderMap providers,
// - populating indexes will be rebuilt on next startup
// - failed indexes have to be dropped by the user anyways
IndexRule indexRule = rules.next();
if ( InternalIndexState.ONLINE == provider( providers, indexRule )
.getInitialState( indexRule.getId(), indexRule.getIndexDescriptor() ) )
if ( InternalIndexState.ONLINE == provider.getInitialState( indexRule.getId(), indexRule.getIndexDescriptor() ) )
{
onlineIndexRules.add( indexRule );
}
Expand All @@ -83,16 +81,10 @@ public IndexAccessors( SchemaIndexProviderMap providers,
for ( IndexRule indexRule : onlineIndexRules )
{
long indexId = indexRule.getId();
accessors.put( indexId, provider( providers, indexRule )
.getOnlineAccessor( indexId, indexRule.getIndexDescriptor(), samplingConfig ) );
accessors.put( indexId, provider.getOnlineAccessor( indexId, indexRule.getIndexDescriptor(), samplingConfig ) );
}
}

private SchemaIndexProvider provider( SchemaIndexProviderMap providers, IndexRule indexRule )
{
return providers.apply( indexRule.getProviderDescriptor() );
}

public Collection<IndexRule> notOnlineRules()
{
return notOnlineIndexRules;
Expand Down

This file was deleted.

Expand Up @@ -216,9 +216,19 @@ public void shouldReportMissingSchemaIndex() throws Exception
File storeDir = testDirectory.absolutePath();
GraphDatabaseService gds = getGraphDatabaseService( storeDir );

Label label = Label.label( "label" );
String propKey = "propKey";
createIndex( gds, label, propKey );
IndexDefinition indexDefinition;

try ( Transaction tx = gds.beginTx() )
{
indexDefinition = gds.schema().indexFor( Label.label( "label" ) ).on( "propKey" ).create();
tx.success();
}

try ( Transaction tx = gds.beginTx() )
{
gds.schema().awaitIndexOnline( indexDefinition, 1, TimeUnit.MINUTES );
tx.success();
}

gds.shutdown();

Expand All @@ -241,49 +251,6 @@ public void shouldReportMissingSchemaIndex() throws Exception
) );
}

@Test
public void oldLuceneSchemaIndexShouldBeConsideredConsistentWithFusionProvider() throws Exception
{
File storeDir = testDirectory.graphDbDir();
String enableNativeIndex = GraphDatabaseSettings.enable_native_schema_index.name();
Label label = Label.label( "label" );
String propKey = "propKey";

// Given a lucene index
GraphDatabaseService db = getGraphDatabaseService( storeDir, enableNativeIndex, Settings.FALSE );
createIndex( db, label, propKey );
try ( Transaction tx = db.beginTx() )
{
db.createNode( label ).setProperty( propKey, 1 );
db.createNode( label ).setProperty( propKey, "string" );
tx.success();
}
db.shutdown();

ConsistencyCheckService service = new ConsistencyCheckService();
Config configuration =
Config.defaults( settings( enableNativeIndex, Settings.TRUE ) );
Result result = runFullConsistencyCheck( service, configuration, storeDir );
assertTrue( result.isSuccessful() );
}

private void createIndex( GraphDatabaseService gds, Label label, String propKey )
{
IndexDefinition indexDefinition;

try ( Transaction tx = gds.beginTx() )
{
indexDefinition = gds.schema().indexFor( label ).on( propKey ).create();
tx.success();
}

try ( Transaction tx = gds.beginTx() )
{
gds.schema().awaitIndexOnline( indexDefinition, 1, TimeUnit.MINUTES );
tx.success();
}
}

private File findFile( String targetFile, File directory )
{
File file = new File( directory, targetFile );
Expand All @@ -300,14 +267,9 @@ private GraphDatabaseService getGraphDatabaseService()
}

private GraphDatabaseService getGraphDatabaseService( File storeDir )
{
return getGraphDatabaseService( storeDir, new String[0] );
}

private GraphDatabaseService getGraphDatabaseService( File storeDir, String... settings )
{
GraphDatabaseBuilder builder = new TestGraphDatabaseFactory().newEmbeddedDatabaseBuilder( storeDir );
builder.setConfig( settings( settings ) );
builder.setConfig( settings() );

return builder.newGraphDatabase();
}
Expand Down

0 comments on commit b40416c

Please sign in to comment.