use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class TransitionalTxManagementKernelTransaction method rollback.
public void rollback() {
try {
KernelTransaction kernelTransactionBoundToThisThread = bridge.getKernelTransactionBoundToThisThread(false);
kernelTransactionBoundToThisThread.failure();
kernelTransactionBoundToThisThread.close();
} catch (TransactionFailureException e) {
throw new RuntimeException(e);
} finally {
bridge.unbindTransactionFromCurrentThread();
}
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class IndexProceduresTest method closeStatementOnClose.
@Test
public void closeStatementOnClose() throws Exception {
KernelTransaction kernelTransaction = mock(KernelTransaction.class);
Statement statement = mock(Statement.class);
when(kernelTransaction.acquireStatement()).thenReturn(statement);
//noinspection EmptyTryBlock
try (IndexProcedures ignored = new IndexProcedures(kernelTransaction, null)) {
}
verify(statement).close();
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class ConstraintIndexCreator method dropUniquenessConstraintIndex.
/**
* You MUST hold a schema write lock before you call this method.
*/
public void dropUniquenessConstraintIndex(NewIndexDescriptor descriptor) throws TransactionFailureException, DropIndexFailureException {
try (KernelTransaction transaction = kernelSupplier.get().newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
Statement statement = transaction.acquireStatement()) {
// NOTE: This creates the index (obviously) but it DOES NOT grab a schema
// write lock. It is assumed that the transaction that invoked this "inner" transaction
// holds a schema write lock, and that it will wait for this inner transaction to do its
// work.
// TODO (Ben+Jake): The Transactor is really part of the kernel internals, so it needs access to the
// internal implementation of Statement. However it is currently used by the external
// RemoveOrphanConstraintIndexesOnStartup job. This needs revisiting.
((KernelStatement) statement).txState().indexDoDrop(descriptor);
transaction.success();
}
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class ConstraintIndexCreator method createConstraintIndex.
public NewIndexDescriptor createConstraintIndex(final LabelSchemaDescriptor schema) {
try (KernelTransaction transaction = kernelSupplier.get().newTransaction(KernelTransaction.Type.implicit, AUTH_DISABLED);
Statement statement = transaction.acquireStatement()) {
// NOTE: This creates the index (obviously) but it DOES NOT grab a schema
// write lock. It is assumed that the transaction that invoked this "inner" transaction
// holds a schema write lock, and that it will wait for this inner transaction to do its
// work.
// TODO (Ben+Jake): The Transactor is really part of the kernel internals, so it needs access to the
// internal implementation of Statement. However it is currently used by the external
// RemoveOrphanConstraintIndexesOnStartup job. This needs revisiting.
NewIndexDescriptor index = NewIndexDescriptorFactory.uniqueForSchema(schema);
((KernelStatement) statement).txState().indexRuleDoAdd(index);
transaction.success();
return index;
} catch (TransactionFailureException e) {
throw new RuntimeException(e);
}
}
use of org.neo4j.kernel.api.KernelTransaction in project neo4j by neo4j.
the class IsolatedTransactionTokenCreator method getOrCreate.
@Override
public synchronized int getOrCreate(String name) throws org.neo4j.kernel.api.exceptions.KernelException {
KernelAPI kernel = kernelSupplier.get();
try (KernelTransaction transaction = kernel.newTransaction(Type.implicit, AUTH_DISABLED)) {
try (Statement statement = transaction.acquireStatement()) {
int id = createKey(statement, name);
transaction.success();
return id;
}
}
}
Aggregations