Skip to content

Commit

Permalink
Use parameter object to create current NeoStoreDataSource.
Browse files Browse the repository at this point in the history
Simplify datasource construction.
  • Loading branch information
MishaDemianenko committed Aug 3, 2018
1 parent f68abaf commit dc47173
Show file tree
Hide file tree
Showing 7 changed files with 911 additions and 174 deletions.
@@ -0,0 +1,147 @@
/*
* Copyright (c) 2002-2018 "Neo4j,"
* Neo4j Sweden AB [http://neo4j.com]
*
* This file is part of Neo4j.
*
* Neo4j is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.neo4j.kernel;

import java.io.File;
import java.util.function.Function;

import org.neo4j.graphdb.DependencyResolver;
import org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector;
import org.neo4j.internal.kernel.api.TokenNameLookup;
import org.neo4j.io.fs.FileSystemAbstraction;
import org.neo4j.io.pagecache.IOLimiter;
import org.neo4j.io.pagecache.PageCache;
import org.neo4j.io.pagecache.tracing.cursor.context.VersionContextSupplier;
import org.neo4j.kernel.api.explicitindex.AutoIndexing;
import org.neo4j.kernel.configuration.Config;
import org.neo4j.kernel.extension.KernelExtensionFactory;
import org.neo4j.kernel.impl.api.CommitProcessFactory;
import org.neo4j.kernel.impl.api.ExplicitIndexProvider;
import org.neo4j.kernel.impl.api.SchemaWriteGuard;
import org.neo4j.kernel.impl.api.index.IndexingService;
import org.neo4j.kernel.impl.constraints.ConstraintSemantics;
import org.neo4j.kernel.impl.core.TokenHolders;
import org.neo4j.kernel.impl.factory.AccessCapability;
import org.neo4j.kernel.impl.factory.DatabaseInfo;
import org.neo4j.kernel.impl.factory.GraphDatabaseFacade;
import org.neo4j.kernel.impl.index.IndexConfigStore;
import org.neo4j.kernel.impl.locking.StatementLocksFactory;
import org.neo4j.kernel.impl.logging.LogService;
import org.neo4j.kernel.impl.proc.Procedures;
import org.neo4j.kernel.impl.query.QueryEngineProvider;
import org.neo4j.kernel.impl.storageengine.impl.recordstorage.id.IdController;
import org.neo4j.kernel.impl.store.id.IdGeneratorFactory;
import org.neo4j.kernel.impl.transaction.TransactionHeaderInformationFactory;
import org.neo4j.kernel.impl.transaction.TransactionMonitor;
import org.neo4j.kernel.impl.transaction.log.checkpoint.StoreCopyCheckPointMutex;
import org.neo4j.kernel.impl.transaction.log.files.LogFileCreationMonitor;
import org.neo4j.kernel.impl.util.collection.CollectionsFactorySupplier;
import org.neo4j.kernel.impl.util.watcher.FileSystemWatcherService;
import org.neo4j.kernel.internal.DatabaseHealth;
import org.neo4j.kernel.internal.TransactionEventHandlers;
import org.neo4j.kernel.monitoring.Monitors;
import org.neo4j.kernel.monitoring.tracing.Tracers;
import org.neo4j.scheduler.JobScheduler;
import org.neo4j.time.SystemNanoClock;

public interface DatabaseCreationContext
{
String getDatabaseName();

File getDatabaseDirectory();

Config getConfig();

IdGeneratorFactory getIdGeneratorFactory();

LogService getLogService();

JobScheduler getScheduler();

TokenNameLookup getTokenNameLookup();

DependencyResolver getGlobalDependencies();

TokenHolders getTokenHolders();

StatementLocksFactory getStatementLocksFactory();

SchemaWriteGuard getSchemaWriteGuard();

TransactionEventHandlers getTransactionEventHandlers();

IndexingService.Monitor getIndexingServiceMonitor();

FileSystemAbstraction getFs();

TransactionMonitor getTransactionMonitor();

DatabaseHealth getDatabaseHealth();

LogFileCreationMonitor getPhysicalLogMonitor();

TransactionHeaderInformationFactory getTransactionHeaderInformationFactory();

CommitProcessFactory getCommitProcessFactory();

AutoIndexing getAutoIndexing();

IndexConfigStore getIndexConfigStore();

ExplicitIndexProvider getExplicitIndexProvider();

PageCache getPageCache();

ConstraintSemantics getConstraintSemantics();

Monitors getMonitors();

Tracers getTracers();

Procedures getProcedures();

IOLimiter getIoLimiter();

AvailabilityGuard getAvailabilityGuard();

SystemNanoClock getClock();

AccessCapability getAccessCapability();

StoreCopyCheckPointMutex getStoreCopyCheckPointMutex();

RecoveryCleanupWorkCollector getRecoveryCleanupWorkCollector();

IdController getIdController();

DatabaseInfo getDatabaseInfo();

VersionContextSupplier getVersionContextSupplier();

CollectionsFactorySupplier getCollectionsFactorySupplier();

Iterable<KernelExtensionFactory<?>> getKernelExtensionFactories();

Function<File,FileSystemWatcherService> getWatcherServiceFactory();

GraphDatabaseFacade getFacade();

Iterable<QueryEngineProvider> getEngineProviders();
}
Expand Up @@ -279,67 +279,56 @@ boolean applicable( DiagnosticsPhase phase )
private final Iterable<QueryEngineProvider> engineProviders;
private final boolean failOnCorruptedLogFiles;

public NeoStoreDataSource( String databaseName, File databaseDirectory, Config config, IdGeneratorFactory idGeneratorFactory, LogService logService,
JobScheduler scheduler, TokenNameLookup tokenNameLookup, DependencyResolver dependencyResolver, TokenHolders tokenHolders,
StatementLocksFactory statementLocksFactory, SchemaWriteGuard schemaWriteGuard, TransactionEventHandlers transactionEventHandlers,
IndexingService.Monitor indexingServiceMonitor, FileSystemAbstraction fs, TransactionMonitor transactionMonitor, DatabaseHealth databaseHealth,
LogFileCreationMonitor physicalLogMonitor, TransactionHeaderInformationFactory transactionHeaderInformationFactory,
CommitProcessFactory commitProcessFactory, AutoIndexing autoIndexing, IndexConfigStore indexConfigStore,
ExplicitIndexProvider explicitIndexProvider, PageCache pageCache, ConstraintSemantics constraintSemantics, Monitors monitors, Tracers tracers,
Procedures procedures, IOLimiter ioLimiter, AvailabilityGuard availabilityGuard, SystemNanoClock clock, AccessCapability accessCapability,
StoreCopyCheckPointMutex storeCopyCheckPointMutex, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, IdController idController,
DatabaseInfo databaseInfo, VersionContextSupplier versionContextSupplier, CollectionsFactorySupplier collectionsFactorySupplier,
Iterable<KernelExtensionFactory<?>> kernelExtensionFactories, Function<File,FileSystemWatcherService> watcherServiceFactory,
GraphDatabaseFacade facade, Iterable<QueryEngineProvider> engineProviders )
{
this.databaseName = databaseName;
this.databaseDirectory = databaseDirectory;
this.config = config;
this.idGeneratorFactory = idGeneratorFactory;
this.tokenNameLookup = tokenNameLookup;
this.dependencyResolver = dependencyResolver;
this.scheduler = scheduler;
this.logService = logService;
this.autoIndexing = autoIndexing;
this.indexConfigStore = indexConfigStore;
this.explicitIndexProvider = explicitIndexProvider;
this.storeCopyCheckPointMutex = storeCopyCheckPointMutex;
this.logProvider = logService.getInternalLogProvider();
this.tokenHolders = tokenHolders;
this.statementLocksFactory = statementLocksFactory;
this.schemaWriteGuard = schemaWriteGuard;
this.transactionEventHandlers = transactionEventHandlers;
this.indexingServiceMonitor = indexingServiceMonitor;
this.fs = fs;
this.transactionMonitor = transactionMonitor;
this.databaseHealth = databaseHealth;
this.physicalLogMonitor = physicalLogMonitor;
this.transactionHeaderInformationFactory = transactionHeaderInformationFactory;
this.constraintSemantics = constraintSemantics;
this.monitors = monitors;
this.tracers = tracers;
this.procedures = procedures;
this.ioLimiter = ioLimiter;
this.availabilityGuard = availabilityGuard;
this.clock = clock;
this.accessCapability = accessCapability;
this.recoveryCleanupWorkCollector = recoveryCleanupWorkCollector;

readOnly = config.get( GraphDatabaseSettings.read_only );
this.idController = idController;
this.databaseInfo = databaseInfo;
this.versionContextSupplier = versionContextSupplier;
this.kernelExtensionFactories = kernelExtensionFactories;
this.watcherServiceFactory = watcherServiceFactory;
this.facade = facade;
this.engineProviders = engineProviders;
public NeoStoreDataSource( DatabaseCreationContext context )
{
this.databaseName = context.getDatabaseName();
this.databaseDirectory = context.getDatabaseDirectory();
this.config = context.getConfig();
this.idGeneratorFactory = context.getIdGeneratorFactory();
this.tokenNameLookup = context.getTokenNameLookup();
this.dependencyResolver = context.getGlobalDependencies();
this.scheduler = context.getScheduler();
this.logService = context.getLogService();
this.autoIndexing = context.getAutoIndexing();
this.indexConfigStore = context.getIndexConfigStore();
this.explicitIndexProvider = context.getExplicitIndexProvider();
this.storeCopyCheckPointMutex = context.getStoreCopyCheckPointMutex();
this.logProvider = context.getLogService().getInternalLogProvider();
this.tokenHolders = context.getTokenHolders();
this.statementLocksFactory = context.getStatementLocksFactory();
this.schemaWriteGuard = context.getSchemaWriteGuard();
this.transactionEventHandlers = context.getTransactionEventHandlers();
this.indexingServiceMonitor = context.getIndexingServiceMonitor();
this.fs = context.getFs();
this.transactionMonitor = context.getTransactionMonitor();
this.databaseHealth = context.getDatabaseHealth();
this.physicalLogMonitor = context.getPhysicalLogMonitor();
this.transactionHeaderInformationFactory = context.getTransactionHeaderInformationFactory();
this.constraintSemantics = context.getConstraintSemantics();
this.monitors = context.getMonitors();
this.tracers = context.getTracers();
this.procedures = context.getProcedures();
this.ioLimiter = context.getIoLimiter();
this.availabilityGuard = context.getAvailabilityGuard();
this.clock = context.getClock();
this.accessCapability = context.getAccessCapability();
this.recoveryCleanupWorkCollector = context.getRecoveryCleanupWorkCollector();

readOnly = context.getConfig().get( GraphDatabaseSettings.read_only );
this.idController = context.getIdController();
this.databaseInfo = context.getDatabaseInfo();
this.versionContextSupplier = context.getVersionContextSupplier();
this.kernelExtensionFactories = context.getKernelExtensionFactories();
this.watcherServiceFactory = context.getWatcherServiceFactory();
this.facade = context.getFacade();
this.engineProviders = context.getEngineProviders();
this.msgLog = logProvider.getLog( getClass() );
this.lockService = new ReentrantLockService();
this.commitProcessFactory = commitProcessFactory;
this.pageCache = pageCache;
this.commitProcessFactory = context.getCommitProcessFactory();
this.pageCache = context.getPageCache();
this.monitors.addMonitorListener( new LoggingLogFileMonitor( msgLog ) );
this.collectionsFactorySupplier = collectionsFactorySupplier;
this.failOnCorruptedLogFiles = config.get( GraphDatabaseSettings.fail_on_corrupted_log_files );
this.collectionsFactorySupplier = context.getCollectionsFactorySupplier();
this.failOnCorruptedLogFiles = context.getConfig().get( GraphDatabaseSettings.fail_on_corrupted_log_files );
}

// We do our own internal life management:
Expand Down Expand Up @@ -872,4 +861,14 @@ public LifeSupport getLife()
{
return life;
}

public AutoIndexing getAutoIndexing()
{
return autoIndexing;
}

public TransactionEventHandlers getTransactionEventHandlers()
{
return transactionEventHandlers;
}
}

0 comments on commit dc47173

Please sign in to comment.