Search in sources :

Example 1 with Kernel

use of org.neo4j.kernel.impl.api.Kernel in project neo4j by neo4j.

the class NeoStoreDataSource method buildKernel.

private NeoStoreKernelModule buildKernel(TransactionAppender appender, IndexingService indexingService, StoreReadLayer storeLayer, UpdateableSchemaState updateableSchemaState, LabelScanStore labelScanStore, StorageEngine storageEngine, IndexConfigStore indexConfigStore, TransactionIdStore transactionIdStore, AvailabilityGuard availabilityGuard, Clock clock, PropertyAccessor propertyAccessor) throws KernelException, IOException {
    TransactionCommitProcess transactionCommitProcess = commitProcessFactory.create(appender, storageEngine, config);
    /*
         * This is used by legacy indexes and constraint indexes whenever a transaction is to be spawned
         * from within an existing transaction. It smells, and we should look over alternatives when time permits.
         */
    Supplier<KernelAPI> kernelProvider = () -> kernelModule.kernelAPI();
    boolean releaseSchemaLockWhenBuildingConstratinIndexes = config.get(GraphDatabaseSettings.release_schema_lock_while_building_constraint);
    ConstraintIndexCreator constraintIndexCreator = new ConstraintIndexCreator(kernelProvider, indexingService, propertyAccessor, releaseSchemaLockWhenBuildingConstratinIndexes);
    LegacyIndexStore legacyIndexStore = new LegacyIndexStore(config, indexConfigStore, kernelProvider, legacyIndexProviderLookup);
    StatementOperationContainer statementOperationContainer = dependencies.satisfyDependency(buildStatementOperations(storeLayer, autoIndexing, constraintIndexCreator, updateableSchemaState, guard, legacyIndexStore));
    TransactionHooks hooks = new TransactionHooks();
    KernelTransactions kernelTransactions = life.add(new KernelTransactions(statementLocksFactory, constraintIndexCreator, statementOperationContainer, schemaWriteGuard, transactionHeaderInformationFactory, transactionCommitProcess, indexConfigStore, legacyIndexProviderLookup, hooks, transactionMonitor, availabilityGuard, tracers, storageEngine, procedures, transactionIdStore, clock, accessCapability));
    final Kernel kernel = new Kernel(kernelTransactions, hooks, databaseHealth, transactionMonitor, procedures, config);
    kernel.registerTransactionHook(transactionEventHandlers);
    final NeoStoreFileListing fileListing = new NeoStoreFileListing(storeDir, labelScanStore, indexingService, legacyIndexProviderLookup, storageEngine);
    return new NeoStoreKernelModule(transactionCommitProcess, kernel, kernelTransactions, fileListing);
}
Also used : NeoStoreFileListing(org.neo4j.kernel.impl.transaction.state.NeoStoreFileListing) ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) LegacyIndexStore(org.neo4j.kernel.impl.index.LegacyIndexStore) TransactionCommitProcess(org.neo4j.kernel.impl.api.TransactionCommitProcess) TransactionHooks(org.neo4j.kernel.impl.api.TransactionHooks) KernelTransactions(org.neo4j.kernel.impl.api.KernelTransactions) StatementOperationContainer(org.neo4j.kernel.impl.api.StatementOperationContainer) KernelAPI(org.neo4j.kernel.api.KernelAPI) Kernel(org.neo4j.kernel.impl.api.Kernel)

Example 2 with Kernel

use of org.neo4j.kernel.impl.api.Kernel in project neo4j by neo4j.

the class KernelIT method shouldKillTransactionsOnShutdown.

@Test
public void shouldKillTransactionsOnShutdown() throws Throwable {
    // Given
    assumeThat(kernel, instanceOf(Kernel.class));
    // Then
    try (KernelTransaction tx = kernel.newTransaction(KernelTransaction.Type.implicit, AnonymousContext.read())) {
        ((Kernel) kernel).stop();
        tx.acquireStatement().readOperations().nodeExists(0L);
        fail("Should have been terminated.");
    } catch (TransactionTerminatedException e) {
    // Success
    }
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) TransactionTerminatedException(org.neo4j.graphdb.TransactionTerminatedException) Kernel(org.neo4j.kernel.impl.api.Kernel) Test(org.junit.Test)

Aggregations

Kernel (org.neo4j.kernel.impl.api.Kernel)2 Test (org.junit.Test)1 TransactionTerminatedException (org.neo4j.graphdb.TransactionTerminatedException)1 KernelAPI (org.neo4j.kernel.api.KernelAPI)1 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)1 KernelTransactions (org.neo4j.kernel.impl.api.KernelTransactions)1 StatementOperationContainer (org.neo4j.kernel.impl.api.StatementOperationContainer)1 TransactionCommitProcess (org.neo4j.kernel.impl.api.TransactionCommitProcess)1 TransactionHooks (org.neo4j.kernel.impl.api.TransactionHooks)1 ConstraintIndexCreator (org.neo4j.kernel.impl.api.state.ConstraintIndexCreator)1 LegacyIndexStore (org.neo4j.kernel.impl.index.LegacyIndexStore)1 NeoStoreFileListing (org.neo4j.kernel.impl.transaction.state.NeoStoreFileListing)1