Search in sources :

Example 1 with DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY

use of org.apache.hadoop.ozone.OzoneConfigKeys.DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY in project ozone by apache.

the class TestRatisPipelineLeader method testLeaderIdAfterLeaderChange.

@Test(timeout = 120000)
public void testLeaderIdAfterLeaderChange() throws Exception {
    List<Pipeline> pipelines = cluster.getStorageContainerManager().getPipelineManager().getPipelines(RatisReplicationConfig.getInstance(ReplicationFactor.THREE));
    Assert.assertFalse(pipelines.isEmpty());
    Pipeline ratisPipeline = pipelines.iterator().next();
    Assert.assertTrue(ratisPipeline.isHealthy());
    Optional<HddsDatanodeService> dnToStop = cluster.getHddsDatanodes().stream().filter(s -> !s.getDatanodeStateMachine().getDatanodeDetails().getUuid().equals(ratisPipeline.getLeaderId())).findAny();
    Assert.assertTrue(dnToStop.isPresent());
    dnToStop.get().stop();
    // wait long enough based on leader election min timeout
    Thread.sleep(4000 * conf.getTimeDuration(DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY, 5, TimeUnit.SECONDS));
    GenericTestUtils.waitFor(() -> {
        try {
            return verifyLeaderInfo(ratisPipeline);
        } catch (Exception e) {
            LOG.error("Failed verifying the leader info.", e);
            Assert.fail("Failed getting leader info.");
            return false;
        }
    }, 200, 20000);
}
Also used : OzoneConfiguration(org.apache.hadoop.hdds.conf.OzoneConfiguration) GroupInfoReply(org.apache.ratis.protocol.GroupInfoReply) BeforeClass(org.junit.BeforeClass) HddsDatanodeService(org.apache.hadoop.ozone.HddsDatanodeService) GroupInfoRequest(org.apache.ratis.protocol.GroupInfoRequest) LoggerFactory(org.slf4j.LoggerFactory) ContainerProtocolCalls(org.apache.hadoop.hdds.scm.storage.ContainerProtocolCalls) MiniOzoneCluster(org.apache.hadoop.ozone.MiniOzoneCluster) RaftGroupId(org.apache.ratis.protocol.RaftGroupId) Logger(org.apache.log4j.Logger) GrpcClientProtocolService(org.apache.ratis.grpc.client.GrpcClientProtocolService) Level(org.apache.log4j.Level) DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY(org.apache.hadoop.ozone.OzoneConfigKeys.DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY) HddsConfigKeys(org.apache.hadoop.hdds.HddsConfigKeys) XceiverServerRatis(org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis) AfterClass(org.junit.AfterClass) RatisReplicationConfig(org.apache.hadoop.hdds.client.RatisReplicationConfig) ReplicationFactor(org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) Test(org.junit.Test) TimeUnit(java.util.concurrent.TimeUnit) List(java.util.List) Ignore(org.junit.Ignore) ClientId(org.apache.ratis.protocol.ClientId) Optional(java.util.Optional) Assert(org.junit.Assert) GenericTestUtils(org.apache.ozone.test.GenericTestUtils) HddsDatanodeService(org.apache.hadoop.ozone.HddsDatanodeService) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline) Test(org.junit.Test)

Aggregations

List (java.util.List)1 Optional (java.util.Optional)1 TimeUnit (java.util.concurrent.TimeUnit)1 HddsConfigKeys (org.apache.hadoop.hdds.HddsConfigKeys)1 RatisReplicationConfig (org.apache.hadoop.hdds.client.RatisReplicationConfig)1 OzoneConfiguration (org.apache.hadoop.hdds.conf.OzoneConfiguration)1 ReplicationFactor (org.apache.hadoop.hdds.protocol.proto.HddsProtos.ReplicationFactor)1 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)1 ContainerProtocolCalls (org.apache.hadoop.hdds.scm.storage.ContainerProtocolCalls)1 HddsDatanodeService (org.apache.hadoop.ozone.HddsDatanodeService)1 MiniOzoneCluster (org.apache.hadoop.ozone.MiniOzoneCluster)1 DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY (org.apache.hadoop.ozone.OzoneConfigKeys.DFS_RATIS_LEADER_ELECTION_MINIMUM_TIMEOUT_DURATION_KEY)1 XceiverServerRatis (org.apache.hadoop.ozone.container.common.transport.server.ratis.XceiverServerRatis)1 Level (org.apache.log4j.Level)1 Logger (org.apache.log4j.Logger)1 GenericTestUtils (org.apache.ozone.test.GenericTestUtils)1 GrpcClientProtocolService (org.apache.ratis.grpc.client.GrpcClientProtocolService)1 ClientId (org.apache.ratis.protocol.ClientId)1 GroupInfoReply (org.apache.ratis.protocol.GroupInfoReply)1 GroupInfoRequest (org.apache.ratis.protocol.GroupInfoRequest)1