Search in sources :

Example 1 with CoreAPIAvailabilityGuard

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());
}
Also used : UsageData(org.neo4j.udc.UsageData) StatementLocksFactorySelector(org.neo4j.kernel.impl.factory.StatementLocksFactorySelector) EnterpriseConstraintSemantics(org.neo4j.kernel.impl.enterprise.EnterpriseConstraintSemantics) ConfigurableIOLimiter(org.neo4j.kernel.impl.enterprise.transaction.log.checkpoint.ConfigurableIOLimiter) CoreAPIAvailabilityGuard(org.neo4j.kernel.impl.coreapi.CoreAPIAvailabilityGuard)

Example 2 with CoreAPIAvailabilityGuard

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;
}
Also used : NeoStoreDataSource(org.neo4j.kernel.NeoStoreDataSource) AtomicReference(java.util.concurrent.atomic.AtomicReference) Logger(org.neo4j.logging.Logger) DataSourceManager(org.neo4j.kernel.impl.transaction.state.DataSourceManager) CoreAPIAvailabilityGuard(org.neo4j.kernel.impl.coreapi.CoreAPIAvailabilityGuard) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine)

Aggregations

CoreAPIAvailabilityGuard (org.neo4j.kernel.impl.coreapi.CoreAPIAvailabilityGuard)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 NeoStoreDataSource (org.neo4j.kernel.NeoStoreDataSource)1 EnterpriseConstraintSemantics (org.neo4j.kernel.impl.enterprise.EnterpriseConstraintSemantics)1 ConfigurableIOLimiter (org.neo4j.kernel.impl.enterprise.transaction.log.checkpoint.ConfigurableIOLimiter)1 StatementLocksFactorySelector (org.neo4j.kernel.impl.factory.StatementLocksFactorySelector)1 QueryExecutionEngine (org.neo4j.kernel.impl.query.QueryExecutionEngine)1 DataSourceManager (org.neo4j.kernel.impl.transaction.state.DataSourceManager)1 Logger (org.neo4j.logging.Logger)1 UsageData (org.neo4j.udc.UsageData)1