use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.
the class StoreMigration method run.
public void run(final FileSystemAbstraction fs, final File storeDirectory, Config config, LogProvider userLogProvider) throws IOException {
StoreLogService logService = StoreLogService.withUserLogProvider(userLogProvider).inLogsDirectory(fs, storeDirectory);
VisibleMigrationProgressMonitor progressMonitor = new VisibleMigrationProgressMonitor(logService.getUserLog(StoreMigration.class));
LifeSupport life = new LifeSupport();
life.add(logService);
// Add participants from kernel extensions...
LegacyIndexProvider legacyIndexProvider = new LegacyIndexProvider();
Log log = userLogProvider.getLog(StoreMigration.class);
try (PageCache pageCache = createPageCache(fs, config)) {
Dependencies deps = new Dependencies();
deps.satisfyDependencies(fs, config, legacyIndexProvider, pageCache, logService);
KernelContext kernelContext = new SimpleKernelContext(storeDirectory, DatabaseInfo.UNKNOWN, deps);
KernelExtensions kernelExtensions = life.add(new KernelExtensions(kernelContext, GraphDatabaseDependencies.newDependencies().kernelExtensions(), deps, ignore()));
// Add the kernel store migrator
life.start();
SchemaIndexProvider schemaIndexProvider = kernelExtensions.resolveDependency(SchemaIndexProvider.class, HighestSelectionStrategy.getInstance());
LabelScanStoreProvider labelScanStoreProvider = kernelExtensions.resolveDependency(LabelScanStoreProvider.class, new NamedLabelScanStoreSelectionStrategy(config));
long startTime = System.currentTimeMillis();
DatabaseMigrator migrator = new DatabaseMigrator(progressMonitor, fs, config, logService, schemaIndexProvider, labelScanStoreProvider, legacyIndexProvider.getIndexProviders(), pageCache, RecordFormatSelector.selectForConfig(config, userLogProvider));
migrator.migrate(storeDirectory);
long duration = System.currentTimeMillis() - startTime;
log.info(format("Migration completed in %d s%n", duration / 1000));
} catch (Exception e) {
throw new StoreUpgrader.UnableToUpgradeException("Failure during upgrade", e);
} finally {
life.shutdown();
}
}
use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.
the class NamedLabelScanStoreSelectionStrategyTest method shouldSelectSpecificallyConfiguredProviderAmongMultiple.
@Test
public void shouldSelectSpecificallyConfiguredProviderAmongMultiple() throws Exception {
// GIVEN
NamedLabelScanStoreSelectionStrategy strategy = strategy(LabelIndex.LUCENE);
LabelScanStoreProvider nativeProvider = provider(LabelIndex.NATIVE, store(false));
LabelScanStoreProvider luceneProvider = provider(LabelIndex.LUCENE, store(false));
// WHEN
LabelScanStoreProvider selected = select(strategy, nativeProvider, luceneProvider);
// THEN
assertSame(luceneProvider, selected);
}
use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.
the class NamedLabelScanStoreSelectionStrategyTest method shouldFailAutoSelectIfMultipleProvidersWithPresentStore.
@Test
public void shouldFailAutoSelectIfMultipleProvidersWithPresentStore() throws Exception {
// GIVEN
NamedLabelScanStoreSelectionStrategy strategy = strategy(LabelIndex.AUTO);
LabelScanStoreProvider nativeProvider = provider(LabelIndex.NATIVE, store(true));
LabelScanStoreProvider luceneProvider = provider(LabelIndex.LUCENE, store(true));
// WHEN
try {
select(strategy, nativeProvider, luceneProvider);
fail("Should've failed");
} catch (IllegalArgumentException e) {
// THEN good
}
}
use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.
the class NamedLabelScanStoreSelectionStrategyTest method shouldFailAutoSelectIfNoProviderWithPresentStoreAndSomeReportedIOException.
@Test
public void shouldFailAutoSelectIfNoProviderWithPresentStoreAndSomeReportedIOException() throws Exception {
// GIVEN
NamedLabelScanStoreSelectionStrategy strategy = strategy(LabelIndex.AUTO);
LabelScanStoreProvider nativeProvider = provider(LabelIndex.NATIVE, store(false));
LabelScanStoreProvider luceneProvider = provider(LabelIndex.LUCENE, store(null));
// WHEN
try {
select(strategy, nativeProvider, luceneProvider);
fail("Should've failed");
} catch (IllegalArgumentException e) {
// THEN good
assertTrue(e.getCause() instanceof IOException);
}
}
use of org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider in project neo4j by neo4j.
the class NeoStoreDataSourceRule method getDataSource.
public NeoStoreDataSource getDataSource(File storeDir, FileSystemAbstraction fs, IdGeneratorFactory idGeneratorFactory, IdTypeConfigurationProvider idConfigurationProvider, PageCache pageCache, Config config, DatabaseHealth databaseHealth, LogService logService) {
if (dataSource != null) {
dataSource.stop();
dataSource.shutdown();
}
StatementLocksFactory locksFactory = mock(StatementLocksFactory.class);
StatementLocks statementLocks = mock(StatementLocks.class);
Locks.Client locks = mock(Locks.Client.class);
when(statementLocks.optimistic()).thenReturn(locks);
when(statementLocks.pessimistic()).thenReturn(locks);
when(locksFactory.newInstance()).thenReturn(statementLocks);
JobScheduler jobScheduler = mock(JobScheduler.class, RETURNS_MOCKS);
Monitors monitors = new Monitors();
LabelScanStoreProvider labelScanStoreProvider = nativeLabelScanStoreProvider(storeDir, fs, pageCache, config, logService);
SystemNanoClock clock = Clocks.nanoClock();
dataSource = new NeoStoreDataSource(storeDir, config, idGeneratorFactory, IdReuseEligibility.ALWAYS, idConfigurationProvider, logService, mock(JobScheduler.class, RETURNS_MOCKS), mock(TokenNameLookup.class), dependencyResolverForNoIndexProvider(labelScanStoreProvider), mock(PropertyKeyTokenHolder.class), mock(LabelTokenHolder.class), mock(RelationshipTypeTokenHolder.class), locksFactory, mock(SchemaWriteGuard.class), mock(TransactionEventHandlers.class), IndexingService.NO_MONITOR, fs, mock(TransactionMonitor.class), databaseHealth, mock(PhysicalLogFile.Monitor.class), TransactionHeaderInformationFactory.DEFAULT, new StartupStatisticsProvider(), null, new CommunityCommitProcessFactory(), mock(InternalAutoIndexing.class), pageCache, new StandardConstraintSemantics(), monitors, new Tracers("null", NullLog.getInstance(), monitors, jobScheduler), mock(Procedures.class), IOLimiter.unlimited(), new AvailabilityGuard(clock, NullLog.getInstance()), clock, new CanWrite(), new StoreCopyCheckPointMutex());
return dataSource;
}
Aggregations