Search in sources :

Example 1 with KernelTransactionImplementation

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

the class TxStateTransactionDataViewTest method shouldAccessExampleMetaData.

@Test
public void shouldAccessExampleMetaData() {
    NodeProxy.NodeActions nodeActions = mock(NodeProxy.NodeActions.class);
    final RelationshipProxy.RelationshipActions relActions = mock(RelationshipProxy.RelationshipActions.class);
    final KernelTransactionImplementation transaction = mock(KernelTransactionImplementation.class);
    when(transaction.getMetaData()).thenReturn(genericMap("username", "Igor"));
    TxStateTransactionDataSnapshot transactionDataSnapshot = new TxStateTransactionDataSnapshot(state, nodeActions, relActions, ops, storeStatement, transaction);
    assertEquals(1, transactionDataSnapshot.metaData().size());
    assertThat("Expected metadata map to contain defined username", transactionDataSnapshot.metaData(), equalTo(genericMap("username", "Igor")));
}
Also used : RelationshipProxy(org.neo4j.kernel.impl.core.RelationshipProxy) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) NodeProxy(org.neo4j.kernel.impl.core.NodeProxy) Test(org.junit.Test)

Example 2 with KernelTransactionImplementation

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

the class TimeoutGuardTest method getKernelStatement.

private KernelStatement getKernelStatement(long transactionTimeout) {
    KernelTransactionImplementation transaction = newNotInitializedTransaction();
    StatementLocks statementLocks = mock(StatementLocks.class);
    transaction.initialize(1L, 2L, statementLocks, KernelTransaction.Type.implicit, AUTH_DISABLED, transactionTimeout);
    return transaction.acquireStatement();
}
Also used : KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) StatementLocks(org.neo4j.kernel.impl.locking.StatementLocks)

Example 3 with KernelTransactionImplementation

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

the class LuceneFulltextIndexTest method completeConfigurationMustInjectMissingConfigurations.

@Test
void completeConfigurationMustInjectMissingConfigurations() throws Exception {
    int label;
    int propertyKey;
    try (Transaction tx = db.beginTx()) {
        createNodeIndexableByPropertyValue(tx, LABEL, "bla");
        tx.commit();
    }
    try (KernelTransactionImplementation tx = getKernelTransaction()) {
        label = tx.tokenRead().nodeLabel(LABEL.name());
        propertyKey = tx.tokenRead().propertyKey(PROP);
        tx.success();
    }
    IndexConfig indexConfig = IndexConfig.with(EVENTUALLY_CONSISTENT, Values.booleanValue(true));
    FulltextSchemaDescriptor schema = SchemaDescriptor.fulltext(NODE, new int[] { label }, new int[] { propertyKey });
    IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
    IndexDescriptor descriptor = indexProvider.completeConfiguration(IndexPrototype.forSchema(schema, providerDescriptor).withName("index_1").withIndexConfig(indexConfig).materialise(1));
    assertThat((Value) descriptor.getIndexConfig().get(ANALYZER)).isEqualTo(Values.stringValue("standard-no-stop-words"));
    assertThat((Value) descriptor.getIndexConfig().get(EVENTUALLY_CONSISTENT)).isEqualTo(Values.booleanValue(true));
    assertThat(asList(descriptor.getCapability().behaviours())).containsExactlyInAnyOrder(IndexBehaviour.EVENTUALLY_CONSISTENT, IndexBehaviour.SKIP_AND_LIMIT);
}
Also used : IndexConfig(org.neo4j.internal.schema.IndexConfig) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) Value(org.neo4j.values.storable.Value) FulltextSchemaDescriptor(org.neo4j.internal.schema.FulltextSchemaDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 4 with KernelTransactionImplementation

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

the class FulltextIndexProviderTest method createFulltextIndex.

@Test
void createFulltextIndex() throws Exception {
    IndexDescriptor fulltextIndex = createIndex(new int[] { labelIdHej, labelIdHa, labelIdHe }, new int[] { propIdHej, propIdHa, propIdHe });
    try (KernelTransactionImplementation transaction = getKernelTransaction()) {
        IndexDescriptor descriptor = transaction.schemaRead().indexGetForName(NAME);
        assertEquals(descriptor.schema(), fulltextIndex.schema());
        transaction.success();
    }
}
Also used : KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 5 with KernelTransactionImplementation

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

the class FulltextIndexProviderTest method shouldHaveAReasonableDirectoryStructure.

@Test
void shouldHaveAReasonableDirectoryStructure() throws Exception {
    createIndex(new int[] { labelIdHej, labelIdHa, labelIdHe }, new int[] { propIdHej, propIdHa, propIdHe });
    try (Transaction tx = db.beginTx()) {
        tx.schema().awaitIndexesOnline(1, TimeUnit.HOURS);
        tx.commit();
    }
    try (KernelTransactionImplementation transaction = getKernelTransaction()) {
        IndexDescriptor descriptor = transaction.schemaRead().indexGetForName(NAME);
        Path indexDir = Path.of(db.databaseLayout().databaseDirectory().toAbsolutePath().toString(), "schema", "index", descriptor.getIndexProvider().name(), "" + descriptor.getId());
        List<Path> listFiles = List.of(requireNonNull(FileUtils.listPaths(indexDir)));
        assertTrue(listFiles.contains(indexDir.resolve("failure-message")));
        assertTrue(listFiles.contains(indexDir.resolve("1")));
        assertTrue(listFiles.contains(indexDir.resolve(indexDir.getFileName() + ".tx")));
    }
}
Also used : Path(java.nio.file.Path) InternalTransaction(org.neo4j.kernel.impl.coreapi.InternalTransaction) Transaction(org.neo4j.graphdb.Transaction) KernelTransaction(org.neo4j.kernel.api.KernelTransaction) KernelTransactionImplementation(org.neo4j.kernel.impl.api.KernelTransactionImplementation) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

KernelTransactionImplementation (org.neo4j.kernel.impl.api.KernelTransactionImplementation)35 Test (org.junit.jupiter.api.Test)20 ConstraintIndexCreator (org.neo4j.kernel.impl.api.state.ConstraintIndexCreator)13 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)12 IndexingService (org.neo4j.kernel.impl.api.index.IndexingService)8 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)7 StorageReader (org.neo4j.storageengine.api.StorageReader)7 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)6 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)6 DbmsRuntimeRepository (org.neo4j.dbms.database.DbmsRuntimeRepository)5 Transaction (org.neo4j.graphdb.Transaction)5 SchemaDescriptor (org.neo4j.internal.schema.SchemaDescriptor)5 TransactionState (org.neo4j.kernel.api.txstate.TransactionState)5 CommandCreationContext (org.neo4j.storageengine.api.CommandCreationContext)5 InOrder (org.mockito.InOrder)4 InternalTransaction (org.neo4j.kernel.impl.coreapi.InternalTransaction)4 Test (org.junit.Test)3 SecurityAuthorizationHandler (org.neo4j.internal.kernel.api.security.SecurityAuthorizationHandler)3 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)3 IndexingProvidersService (org.neo4j.kernel.impl.api.index.IndexingProvidersService)3