Search in sources :

Example 11 with PingableLeader

use of com.palantir.leader.PingableLeader in project atlasdb by palantir.

the class LeaderPingHealthCheckTest method getMockOfPingableLeaderWherePingThrows.

private PingableLeader getMockOfPingableLeaderWherePingThrows() {
    PingableLeader mockLeader = mock(PingableLeader.class);
    when(mockLeader.ping()).thenThrow(mock(AtlasDbRemoteException.class));
    return mockLeader;
}
Also used : PingableLeader(com.palantir.leader.PingableLeader) AtlasDbRemoteException(com.palantir.atlasdb.http.errors.AtlasDbRemoteException)

Example 12 with PingableLeader

use of com.palantir.leader.PingableLeader in project atlasdb by palantir.

the class LeaderPingHealthCheckTest method shouldBeUnhealthyIfQuorumNodesAreNotUpAndOnePingedSuccessfully.

@Test
public void shouldBeUnhealthyIfQuorumNodesAreNotUpAndOnePingedSuccessfully() throws Exception {
    PingableLeader leader1 = getMockOfPingableLeaderWherePingReturns(true);
    PingableLeader leader2 = getMockOfPingableLeaderWherePingThrows();
    PingableLeader leader3 = getMockOfPingableLeaderWherePingThrows();
    ImmutableSet<PingableLeader> leaders = ImmutableSet.of(leader1, leader2, leader3);
    assertEquals(TimeLockStatus.NO_QUORUM, new LeaderPingHealthCheck(leaders).getStatus());
}
Also used : PingableLeader(com.palantir.leader.PingableLeader) Test(org.junit.Test)

Example 13 with PingableLeader

use of com.palantir.leader.PingableLeader in project atlasdb by palantir.

the class PaxosTimeLockServerIntegrationTest method waitForClusterToStabilize.

@BeforeClass
public static void waitForClusterToStabilize() {
    PingableLeader leader = AtlasDbHttpClients.createProxy(Optional.of(TestProxies.SSL_SOCKET_FACTORY), "https://localhost:" + TIMELOCK_SERVER_HOLDER.getTimelockPort(), PingableLeader.class);
    Awaitility.await().atMost(30, TimeUnit.SECONDS).pollInterval(1, TimeUnit.SECONDS).until(() -> {
        try {
            // Returns true only if this node is ready to serve timestamps and locks on all clients.
            CLIENTS.forEach(client -> getTimelockService(client).getFreshTimestamp());
            CLIENTS.forEach(client -> getTimelockService(client).currentTimeMillis());
            CLIENTS.forEach(client -> getLockService(client).currentTimeMillis());
            return leader.ping();
        } catch (Throwable t) {
            return false;
        }
    });
}
Also used : PingableLeader(com.palantir.leader.PingableLeader) BeforeClass(org.junit.BeforeClass)

Aggregations

PingableLeader (com.palantir.leader.PingableLeader)13 Test (org.junit.Test)5 HostAndPort (com.google.common.net.HostAndPort)2 LeaderRuntimeConfig (com.palantir.atlasdb.config.LeaderRuntimeConfig)2 LeaderElectionService (com.palantir.leader.LeaderElectionService)2 InstrumentedExecutorService (com.codahale.metrics.InstrumentedExecutorService)1 ThreadFactoryBuilder (com.google.common.util.concurrent.ThreadFactoryBuilder)1 ImmutableLeaderRuntimeConfig (com.palantir.atlasdb.config.ImmutableLeaderRuntimeConfig)1 ImmutableServerListConfig (com.palantir.atlasdb.config.ImmutableServerListConfig)1 LocalPaxosServices (com.palantir.atlasdb.factory.Leaders.LocalPaxosServices)1 AtlasDbRemoteException (com.palantir.atlasdb.http.errors.AtlasDbRemoteException)1 KvsBackedPersistentLockService (com.palantir.atlasdb.persistentlock.KvsBackedPersistentLockService)1 NoOpPersistentLockService (com.palantir.atlasdb.persistentlock.NoOpPersistentLockService)1 PersistentLockService (com.palantir.atlasdb.persistentlock.PersistentLockService)1 PaxosLeaderElectionService (com.palantir.leader.PaxosLeaderElectionService)1 PaxosLeaderElectionServiceBuilder (com.palantir.leader.PaxosLeaderElectionServiceBuilder)1 PaxosLeadershipEventRecorder (com.palantir.leader.PaxosLeadershipEventRecorder)1 LockService (com.palantir.lock.LockService)1 LockRefreshingLockService (com.palantir.lock.client.LockRefreshingLockService)1 LegacyTimelockService (com.palantir.lock.impl.LegacyTimelockService)1