Esempio n. 1
0
  @Test
  public void shouldKillTransactionsOnShutdown() throws Throwable {
    // Given
    assumeThat(kernel, instanceOf(Kernel.class));
    KernelTransaction tx = kernel.newTransaction();

    // When
    ((Kernel) kernel).stop();

    // Then
    try {
      tx.acquireStatement().readOperations().nodeExists(0l);
      fail("Should have been terminated.");
    } catch (TransactionTerminatedException e) {
      // Success
    } finally {
      tx.close();
    }
  }
Esempio n. 2
0
  private KernelModule buildKernel(
      IntegrityValidator integrityValidator,
      LogicalTransactionStore logicalTransactionStore,
      NeoStore neoStore,
      TransactionRepresentationStoreApplier storeApplier,
      IndexingService indexingService,
      StoreReadLayer storeLayer,
      UpdateableSchemaState updateableSchemaState,
      LabelScanStore labelScanStore,
      PersistenceCache persistenceCache,
      SchemaIndexProviderMap schemaIndexProviderMap) {
    final TransactionCommitProcess transactionCommitProcess =
        commitProcessFactory.create(
            logicalTransactionStore,
            kernelHealth,
            neoStore,
            storeApplier,
            new NeoStoreInjectedTransactionValidator(integrityValidator),
            TransactionApplicationMode.INTERNAL,
            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.
     */
    Provider<KernelAPI> kernelProvider =
        new Provider<KernelAPI>() {
          @Override
          public KernelAPI instance() {
            return kernelModule.kernelAPI();
          }
        };

    ConstraintIndexCreator constraintIndexCreator =
        new ConstraintIndexCreator(kernelProvider, indexingService);

    LegacyIndexStore legacyIndexStore =
        new LegacyIndexStore(config, indexConfigStore, kernelProvider, legacyIndexProviderLookup);

    LegacyPropertyTrackers legacyPropertyTrackers =
        new LegacyPropertyTrackers(
            propertyKeyTokenHolder,
            nodeManager.getNodePropertyTrackers(),
            nodeManager.getRelationshipPropertyTrackers(),
            nodeManager);
    final NeoStoreTransactionContextSupplier neoStoreTransactionContextSupplier =
        new NeoStoreTransactionContextSupplier(neoStore);

    StatementOperationParts statementOperations =
        buildStatementOperations(
            storeLayer,
            legacyPropertyTrackers,
            constraintIndexCreator,
            updateableSchemaState,
            guard,
            legacyIndexStore);

    final TransactionHooks hooks = new TransactionHooks();
    final KernelTransactions kernelTransactions =
        life.add(
            new KernelTransactions(
                neoStoreTransactionContextSupplier,
                neoStore,
                locks,
                integrityValidator,
                constraintIndexCreator,
                indexingService,
                labelScanStore,
                statementOperations,
                updateableSchemaState,
                schemaWriteGuard,
                schemaIndexProviderMap,
                transactionHeaderInformationFactory,
                persistenceCache,
                storeLayer,
                transactionCommitProcess,
                indexConfigStore,
                legacyIndexProviderLookup,
                hooks,
                transactionMonitor,
                life));

    final Kernel kernel = new Kernel(kernelTransactions, hooks, kernelHealth, transactionMonitor);

    kernel.registerTransactionHook(transactionEventHandlers);

    final NeoStoreFileListing fileListing =
        new NeoStoreFileListing(
            storeDir, labelScanStore, indexingService, legacyIndexProviderLookup);

    return new KernelModule() {
      @Override
      public TransactionCommitProcess transactionCommitProcess() {
        return transactionCommitProcess;
      }

      @Override
      public KernelAPI kernelAPI() {
        return kernel;
      }

      @Override
      public KernelTransactions kernelTransactions() {
        return kernelTransactions;
      }

      @Override
      public NeoStoreFileListing fileListing() {
        return fileListing;
      }
    };
  }