Search in sources :

Example 11 with QueryExecutionEngine

use of org.neo4j.kernel.impl.query.QueryExecutionEngine in project neo4j by neo4j.

the class BoltFactoryImpl method start.

@Override
public void start() throws Throwable {
    DependencyResolver dependencyResolver = gds.getDependencyResolver();
    queryExecutionEngine = dependencyResolver.resolveDependency(QueryExecutionEngine.class);
    queryService = dependencyResolver.resolveDependency(GraphDatabaseQueryService.class);
    transactionIdStore = dependencyResolver.resolveDependency(TransactionIdStore.class);
    availabilityGuard = dependencyResolver.resolveDependency(AvailabilityGuard.class);
}
Also used : QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) TransactionIdStore(org.neo4j.kernel.impl.transaction.log.TransactionIdStore) GraphDatabaseQueryService(org.neo4j.kernel.GraphDatabaseQueryService) AvailabilityGuard(org.neo4j.kernel.AvailabilityGuard) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 12 with QueryExecutionEngine

use of org.neo4j.kernel.impl.query.QueryExecutionEngine in project neo4j by neo4j.

the class ServerExecutionEngineTest method shouldNotDetectInvalidQueriesAsPeriodicCommitQueries.

@Test
public void shouldNotDetectInvalidQueriesAsPeriodicCommitQueries() throws Exception {
    // GIVEN
    QueryExecutionEngine engine = rule.getGraphDatabaseAPI().getDependencyResolver().resolveDependency(QueryExecutionEngine.class);
    // WHEN
    boolean result = engine.isPeriodicCommit("MATCH n RETURN m");
    // THEN
    assertFalse("Did detect an invalid query as periodic commit query", result);
}
Also used : QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) Test(org.junit.Test)

Example 13 with QueryExecutionEngine

use of org.neo4j.kernel.impl.query.QueryExecutionEngine in project neo4j by neo4j.

the class CommunityCypherEngineProvider method createEngine.

@Override
protected QueryExecutionEngine createEngine(Dependencies deps, GraphDatabaseAPI graphAPI) {
    GraphDatabaseCypherService queryService = new GraphDatabaseCypherService(graphAPI);
    deps.satisfyDependency(queryService);
    DependencyResolver resolver = graphAPI.getDependencyResolver();
    LogService logService = resolver.resolveDependency(LogService.class);
    KernelAPI kernelAPI = resolver.resolveDependency(KernelAPI.class);
    Monitors monitors = resolver.resolveDependency(Monitors.class);
    LogProvider logProvider = logService.getInternalLogProvider();
    CommunityCompatibilityFactory compatibilityFactory = new CommunityCompatibilityFactory(queryService, kernelAPI, monitors, logProvider);
    deps.satisfyDependencies(compatibilityFactory);
    return new ExecutionEngine(queryService, logProvider, compatibilityFactory);
}
Also used : LogProvider(org.neo4j.logging.LogProvider) QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) Monitors(org.neo4j.kernel.monitoring.Monitors) CommunityCompatibilityFactory(org.neo4j.cypher.internal.CommunityCompatibilityFactory) GraphDatabaseCypherService(org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService) KernelAPI(org.neo4j.kernel.api.KernelAPI) LogService(org.neo4j.kernel.impl.logging.LogService) DependencyResolver(org.neo4j.graphdb.DependencyResolver)

Example 14 with QueryExecutionEngine

use of org.neo4j.kernel.impl.query.QueryExecutionEngine 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)

Example 15 with QueryExecutionEngine

use of org.neo4j.kernel.impl.query.QueryExecutionEngine in project neo4j by neo4j.

the class ServerExecutionEngineTest method shouldNotDetectNonPeriodicCommitQueriesAsPeriodicCommitQueries.

@Test
public void shouldNotDetectNonPeriodicCommitQueriesAsPeriodicCommitQueries() throws Exception {
    // GIVEN
    QueryExecutionEngine engine = rule.getGraphDatabaseAPI().getDependencyResolver().resolveDependency(QueryExecutionEngine.class);
    // WHEN
    boolean result = engine.isPeriodicCommit("CREATE ()");
    // THEN
    assertFalse("Did detect non-periodic commit query as periodic commit query", result);
}
Also used : QueryExecutionEngine(org.neo4j.kernel.impl.query.QueryExecutionEngine) Test(org.junit.Test)

Aggregations

QueryExecutionEngine (org.neo4j.kernel.impl.query.QueryExecutionEngine)21 Test (org.junit.Test)16 HttpServletRequest (javax.servlet.http.HttpServletRequest)13 TransactionalContext (org.neo4j.kernel.impl.query.TransactionalContext)12 InOrder (org.mockito.InOrder)10 Result (org.neo4j.graphdb.Result)8 GraphDatabaseQueryService (org.neo4j.kernel.GraphDatabaseQueryService)8 Notification (org.neo4j.graphdb.Notification)7 DependencyResolver (org.neo4j.graphdb.DependencyResolver)3 LogProvider (org.neo4j.logging.LogProvider)3 SyntaxException (org.neo4j.cypher.SyntaxException)2 CommunityCompatibilityFactory (org.neo4j.cypher.internal.CommunityCompatibilityFactory)2 GraphDatabaseCypherService (org.neo4j.cypher.javacompat.internal.GraphDatabaseCypherService)2 DeadlockDetectedException (org.neo4j.kernel.DeadlockDetectedException)2 KernelAPI (org.neo4j.kernel.api.KernelAPI)2 Type (org.neo4j.kernel.api.KernelTransaction.Type)2 SecurityContext (org.neo4j.kernel.api.security.SecurityContext)2 LogService (org.neo4j.kernel.impl.logging.LogService)2 QueryExecutionKernelException (org.neo4j.kernel.impl.query.QueryExecutionKernelException)2 Monitors (org.neo4j.kernel.monitoring.Monitors)2