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 Iterable<QueryEngineProvider> engineProviders;
private final boolean failOnCorruptedLogFiles; private final boolean failOnCorruptedLogFiles;


public NeoStoreDataSource( String databaseName, File databaseDirectory, Config config, IdGeneratorFactory idGeneratorFactory, LogService logService, public NeoStoreDataSource( DatabaseCreationContext context )
JobScheduler scheduler, TokenNameLookup tokenNameLookup, DependencyResolver dependencyResolver, TokenHolders tokenHolders, {
StatementLocksFactory statementLocksFactory, SchemaWriteGuard schemaWriteGuard, TransactionEventHandlers transactionEventHandlers, this.databaseName = context.getDatabaseName();
IndexingService.Monitor indexingServiceMonitor, FileSystemAbstraction fs, TransactionMonitor transactionMonitor, DatabaseHealth databaseHealth, this.databaseDirectory = context.getDatabaseDirectory();
LogFileCreationMonitor physicalLogMonitor, TransactionHeaderInformationFactory transactionHeaderInformationFactory, this.config = context.getConfig();
CommitProcessFactory commitProcessFactory, AutoIndexing autoIndexing, IndexConfigStore indexConfigStore, this.idGeneratorFactory = context.getIdGeneratorFactory();
ExplicitIndexProvider explicitIndexProvider, PageCache pageCache, ConstraintSemantics constraintSemantics, Monitors monitors, Tracers tracers, this.tokenNameLookup = context.getTokenNameLookup();
Procedures procedures, IOLimiter ioLimiter, AvailabilityGuard availabilityGuard, SystemNanoClock clock, AccessCapability accessCapability, this.dependencyResolver = context.getGlobalDependencies();
StoreCopyCheckPointMutex storeCopyCheckPointMutex, RecoveryCleanupWorkCollector recoveryCleanupWorkCollector, IdController idController, this.scheduler = context.getScheduler();
DatabaseInfo databaseInfo, VersionContextSupplier versionContextSupplier, CollectionsFactorySupplier collectionsFactorySupplier, this.logService = context.getLogService();
Iterable<KernelExtensionFactory<?>> kernelExtensionFactories, Function<File,FileSystemWatcherService> watcherServiceFactory, this.autoIndexing = context.getAutoIndexing();
GraphDatabaseFacade facade, Iterable<QueryEngineProvider> engineProviders ) this.indexConfigStore = context.getIndexConfigStore();
{ this.explicitIndexProvider = context.getExplicitIndexProvider();
this.databaseName = databaseName; this.storeCopyCheckPointMutex = context.getStoreCopyCheckPointMutex();
this.databaseDirectory = databaseDirectory; this.logProvider = context.getLogService().getInternalLogProvider();
this.config = config; this.tokenHolders = context.getTokenHolders();
this.idGeneratorFactory = idGeneratorFactory; this.statementLocksFactory = context.getStatementLocksFactory();
this.tokenNameLookup = tokenNameLookup; this.schemaWriteGuard = context.getSchemaWriteGuard();
this.dependencyResolver = dependencyResolver; this.transactionEventHandlers = context.getTransactionEventHandlers();
this.scheduler = scheduler; this.indexingServiceMonitor = context.getIndexingServiceMonitor();
this.logService = logService; this.fs = context.getFs();
this.autoIndexing = autoIndexing; this.transactionMonitor = context.getTransactionMonitor();
this.indexConfigStore = indexConfigStore; this.databaseHealth = context.getDatabaseHealth();
this.explicitIndexProvider = explicitIndexProvider; this.physicalLogMonitor = context.getPhysicalLogMonitor();
this.storeCopyCheckPointMutex = storeCopyCheckPointMutex; this.transactionHeaderInformationFactory = context.getTransactionHeaderInformationFactory();
this.logProvider = logService.getInternalLogProvider(); this.constraintSemantics = context.getConstraintSemantics();
this.tokenHolders = tokenHolders; this.monitors = context.getMonitors();
this.statementLocksFactory = statementLocksFactory; this.tracers = context.getTracers();
this.schemaWriteGuard = schemaWriteGuard; this.procedures = context.getProcedures();
this.transactionEventHandlers = transactionEventHandlers; this.ioLimiter = context.getIoLimiter();
this.indexingServiceMonitor = indexingServiceMonitor; this.availabilityGuard = context.getAvailabilityGuard();
this.fs = fs; this.clock = context.getClock();
this.transactionMonitor = transactionMonitor; this.accessCapability = context.getAccessCapability();
this.databaseHealth = databaseHealth; this.recoveryCleanupWorkCollector = context.getRecoveryCleanupWorkCollector();
this.physicalLogMonitor = physicalLogMonitor;
this.transactionHeaderInformationFactory = transactionHeaderInformationFactory; readOnly = context.getConfig().get( GraphDatabaseSettings.read_only );
this.constraintSemantics = constraintSemantics; this.idController = context.getIdController();
this.monitors = monitors; this.databaseInfo = context.getDatabaseInfo();
this.tracers = tracers; this.versionContextSupplier = context.getVersionContextSupplier();
this.procedures = procedures; this.kernelExtensionFactories = context.getKernelExtensionFactories();
this.ioLimiter = ioLimiter; this.watcherServiceFactory = context.getWatcherServiceFactory();
this.availabilityGuard = availabilityGuard; this.facade = context.getFacade();
this.clock = clock; this.engineProviders = context.getEngineProviders();
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;
this.msgLog = logProvider.getLog( getClass() ); this.msgLog = logProvider.getLog( getClass() );
this.lockService = new ReentrantLockService(); this.lockService = new ReentrantLockService();
this.commitProcessFactory = commitProcessFactory; this.commitProcessFactory = context.getCommitProcessFactory();
this.pageCache = pageCache; this.pageCache = context.getPageCache();
this.monitors.addMonitorListener( new LoggingLogFileMonitor( msgLog ) ); this.monitors.addMonitorListener( new LoggingLogFileMonitor( msgLog ) );
this.collectionsFactorySupplier = collectionsFactorySupplier; this.collectionsFactorySupplier = context.getCollectionsFactorySupplier();
this.failOnCorruptedLogFiles = config.get( GraphDatabaseSettings.fail_on_corrupted_log_files ); this.failOnCorruptedLogFiles = context.getConfig().get( GraphDatabaseSettings.fail_on_corrupted_log_files );
} }


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

public AutoIndexing getAutoIndexing()
{
return autoIndexing;
}

public TransactionEventHandlers getTransactionEventHandlers()
{
return transactionEventHandlers;
}
} }

0 comments on commit dc47173

Please sign in to comment.