use of org.neo4j.kernel.impl.coreapi.CoreAPIAvailabilityGuard in project neo4j by neo4j.
the class EnterpriseCoreEditionModule method editionInvariants.
private void editionInvariants(PlatformModule platformModule, Dependencies dependencies, Config config, LogService logging, LifeSupport life) {
statementLocksFactory = new StatementLocksFactorySelector(lockManager, config, logging).select();
dependencies.satisfyDependency(createKernelData(platformModule.fileSystem, platformModule.pageCache, platformModule.storeDir, config, platformModule.graphDatabaseFacade, life));
ioLimiter = new ConfigurableIOLimiter(platformModule.config);
headerInformationFactory = createHeaderInformationFactory();
schemaWriteGuard = createSchemaWriteGuard();
transactionStartTimeout = config.get(GraphDatabaseSettings.transaction_start_timeout);
constraintSemantics = new EnterpriseConstraintSemantics();
coreAPIAvailabilityGuard = new CoreAPIAvailabilityGuard(platformModule.availabilityGuard, transactionStartTimeout);
registerRecovery(platformModule.databaseInfo, life, dependencies);
publishEditionInfo(dependencies.resolveDependency(UsageData.class), platformModule.databaseInfo, config);
dependencies.satisfyDependency(createSessionTracker());
}
use of org.neo4j.kernel.impl.coreapi.CoreAPIAvailabilityGuard in project neo4j by neo4j.
the class GraphDatabaseFacadeFactory method initFacade.
/**
* Instantiate a graph database given configuration, dependencies, and a custom implementation of {@link org
* .neo4j.kernel.impl.factory.GraphDatabaseFacade}.
*
* @param storeDir the directory where the Neo4j data store is located
* @param config configuration
* @param dependencies the dependencies required to construct the {@link GraphDatabaseFacade}
* @param graphDatabaseFacade the already created facade which needs initialisation
* @return the initialised {@link GraphDatabaseFacade}
*/
public GraphDatabaseFacade initFacade(File storeDir, Config config, final Dependencies dependencies, final GraphDatabaseFacade graphDatabaseFacade) {
PlatformModule platform = createPlatform(storeDir, config, dependencies, graphDatabaseFacade);
EditionModule edition = editionFactory.apply(platform);
AtomicReference<QueryExecutionEngine> queryEngine = new AtomicReference<>(noEngine());
final DataSourceModule dataSource = createDataSource(platform, edition, queryEngine::get);
Logger msgLog = platform.logging.getInternalLog(getClass()).infoLogger();
CoreAPIAvailabilityGuard coreAPIAvailabilityGuard = edition.coreAPIAvailabilityGuard;
ClassicCoreSPI spi = new ClassicCoreSPI(platform, dataSource, msgLog, coreAPIAvailabilityGuard);
graphDatabaseFacade.init(spi, dataSource.guard, dataSource.threadToTransactionBridge, platform.config);
// Start it
platform.dataSourceManager.addListener(new DataSourceManager.Listener() {
private QueryExecutionEngine engine;
@Override
public void registered(NeoStoreDataSource dataSource) {
if (engine == null) {
engine = QueryEngineProvider.initialize(platform.dependencies, platform.graphDatabaseFacade, dependencies.executionEngines());
}
queryEngine.set(engine);
}
@Override
public void unregistered(NeoStoreDataSource dataSource) {
queryEngine.set(noEngine());
}
});
Throwable error = null;
try {
// Done after create to avoid a redundant
// "database is now unavailable"
enableAvailabilityLogging(platform.availabilityGuard, msgLog);
platform.life.start();
} catch (final Throwable throwable) {
error = new RuntimeException("Error starting " + getClass().getName() + ", " + platform.storeDir, throwable);
} finally {
if (error != null) {
try {
graphDatabaseFacade.shutdown();
} catch (Throwable shutdownError) {
error = Exceptions.withSuppressed(shutdownError, error);
}
}
}
if (error != null) {
msgLog.log("Failed to start database", error);
throw Exceptions.launderedException(error);
}
return graphDatabaseFacade;
}
Aggregations