use of org.neo4j.kernel.impl.api.TestKernelTransactionHandle in project neo4j by neo4j.
the class TransactionDependenciesResolverTest method blockingChainDescriptionForDirectlyBlockedTransaction.
@Test
void blockingChainDescriptionForDirectlyBlockedTransaction() {
HashMap<KernelTransactionHandle, Optional<QuerySnapshot>> map = new HashMap<>();
TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 3, singletonList(new ActiveLock(ResourceTypes.NODE, EXCLUSIVE, 1, 1)));
TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction());
map.put(handle1, Optional.of(createQuerySnapshot(1)));
map.put(handle2, Optional.of(createQuerySnapshotWaitingForLock(2, SHARED, ResourceTypes.NODE, 1, 1)));
TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map);
assertThat(resolver.describeBlockingTransactions(handle1)).isEmpty();
assertEquals("[transaction-3]", resolver.describeBlockingTransactions(handle2));
}
use of org.neo4j.kernel.impl.api.TestKernelTransactionHandle in project neo4j by neo4j.
the class TransactionDependenciesResolverTest method detectBlockedTransactionsByExclusiveLock.
@Test
void detectBlockedTransactionsByExclusiveLock() {
HashMap<KernelTransactionHandle, Optional<QuerySnapshot>> map = new HashMap<>();
TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 0, singletonList(new ActiveLock(ResourceTypes.NODE, EXCLUSIVE, 1, 1)));
TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction());
map.put(handle1, Optional.of(createQuerySnapshot(1)));
map.put(handle2, Optional.of(createQuerySnapshotWaitingForLock(2, SHARED, ResourceTypes.NODE, 1, 1)));
TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map);
assertFalse(resolver.isBlocked(handle1));
assertTrue(resolver.isBlocked(handle2));
}
use of org.neo4j.kernel.impl.api.TestKernelTransactionHandle in project neo4j by neo4j.
the class TransactionDependenciesResolverTest method blockingChainDescriptionForIndependentTransactionsIsEmpty.
@Test
void blockingChainDescriptionForIndependentTransactionsIsEmpty() {
HashMap<KernelTransactionHandle, Optional<QuerySnapshot>> map = new HashMap<>();
TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction());
TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction());
map.put(handle1, Optional.of(createQuerySnapshot(1)));
map.put(handle2, Optional.of(createQuerySnapshot(2)));
TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map);
assertThat(resolver.describeBlockingTransactions(handle1)).isEmpty();
assertThat(resolver.describeBlockingTransactions(handle2)).isEmpty();
}
use of org.neo4j.kernel.impl.api.TestKernelTransactionHandle in project neo4j by neo4j.
the class TransactionDependenciesResolverTest method detectIndependentTransactionsAsNotBlocked.
@Test
void detectIndependentTransactionsAsNotBlocked() {
HashMap<KernelTransactionHandle, Optional<QuerySnapshot>> map = new HashMap<>();
TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction());
TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction());
map.put(handle1, Optional.of(createQuerySnapshot(1)));
map.put(handle2, Optional.of(createQuerySnapshot(2)));
TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map);
assertFalse(resolver.isBlocked(handle1));
assertFalse(resolver.isBlocked(handle2));
}
use of org.neo4j.kernel.impl.api.TestKernelTransactionHandle in project neo4j by neo4j.
the class TransactionDependenciesResolverTest method blockingChainDescriptionForChainedBlockedTransaction.
@Test
void blockingChainDescriptionForChainedBlockedTransaction() {
HashMap<KernelTransactionHandle, Optional<QuerySnapshot>> map = new HashMap<>();
TestKernelTransactionHandle handle1 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 4, singletonList(new ActiveLock(ResourceTypes.NODE, EXCLUSIVE, 4, 1)));
TestKernelTransactionHandle handle2 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 5, singletonList(new ActiveLock(ResourceTypes.NODE, SHARED, 5, 2)));
TestKernelTransactionHandle handle3 = new TestKernelTransactionHandleWithLocks(new StubKernelTransaction(), 6);
map.put(handle1, Optional.of(createQuerySnapshot(1)));
map.put(handle2, Optional.of(createQuerySnapshotWaitingForLock(2, EXCLUSIVE, ResourceTypes.NODE, 5, 1)));
map.put(handle3, Optional.of(createQuerySnapshotWaitingForLock(3, EXCLUSIVE, ResourceTypes.NODE, 6, 2)));
TransactionDependenciesResolver resolver = new TransactionDependenciesResolver(map);
assertThat(resolver.describeBlockingTransactions(handle1)).isEmpty();
assertEquals("[transaction-4]", resolver.describeBlockingTransactions(handle2));
assertEquals("[transaction-4, transaction-5]", resolver.describeBlockingTransactions(handle3));
}
Aggregations