Search in sources :

Example 1 with CommunityLockManger

use of org.neo4j.kernel.impl.locking.community.CommunityLockManger in project neo4j by neo4j.

the class SlaveLockManagerTest method doesNotCreateClientsAfterShutdown.

@Test
public void doesNotCreateClientsAfterShutdown() throws Throwable {
    SlaveLockManager slaveLockManager = newSlaveLockManager(new CommunityLockManger(Config.defaults(), Clocks.systemClock()));
    assertNotNull(slaveLockManager.newClient());
    slaveLockManager.close();
    try {
        slaveLockManager.newClient();
        fail("Exception expected");
    } catch (Exception e) {
        assertThat(e, instanceOf(IllegalStateException.class));
    }
}
Also used : CommunityLockManger(org.neo4j.kernel.impl.locking.community.CommunityLockManger) Test(org.junit.Test)

Example 2 with CommunityLockManger

use of org.neo4j.kernel.impl.locking.community.CommunityLockManger in project neo4j by neo4j.

the class SlaveLocksClientTest method setUp.

@Before
public void setUp() throws Exception {
    master = mock(Master.class);
    availabilityGuard = new AvailabilityGuard(Clocks.fakeClock(), getInstance());
    lockManager = new CommunityLockManger(Config.defaults(), Clocks.systemClock());
    local = spy(lockManager.newClient());
    logProvider = new AssertableLogProvider();
    LockResult lockResultOk = new LockResult(LockStatus.OK_LOCKED);
    TransactionStreamResponse<LockResult> responseOk = new TransactionStreamResponse<>(lockResultOk, null, TransactionStream.EMPTY, ResourceReleaser.NO_OP);
    whenMasterAcquireShared().thenReturn(responseOk);
    whenMasterAcquireExclusive().thenReturn(responseOk);
    client = new SlaveLocksClient(master, local, lockManager, mock(RequestContextFactory.class), availabilityGuard, logProvider);
}
Also used : Master(org.neo4j.kernel.ha.com.master.Master) TransactionStreamResponse(org.neo4j.com.TransactionStreamResponse) CommunityLockManger(org.neo4j.kernel.impl.locking.community.CommunityLockManger) AvailabilityGuard(org.neo4j.kernel.AvailabilityGuard) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Before(org.junit.Before)

Aggregations

CommunityLockManger (org.neo4j.kernel.impl.locking.community.CommunityLockManger)2 Before (org.junit.Before)1 Test (org.junit.Test)1 TransactionStreamResponse (org.neo4j.com.TransactionStreamResponse)1 AvailabilityGuard (org.neo4j.kernel.AvailabilityGuard)1 Master (org.neo4j.kernel.ha.com.master.Master)1 AssertableLogProvider (org.neo4j.logging.AssertableLogProvider)1