Search in sources :

Example 1 with RatisReplicationConfig

use of org.apache.hadoop.hdds.client.RatisReplicationConfig in project ozone by apache.

the class TestSCMNodeManager method assertPipelines.

private void assertPipelines(HddsProtos.ReplicationFactor factor, Predicate<Integer> countCheck, Collection<DatanodeDetails> allowedDNs) throws Exception {
    Set<String> allowedDnIds = allowedDNs.stream().map(DatanodeDetails::getUuidString).collect(Collectors.toSet());
    RatisReplicationConfig replConfig = RatisReplicationConfig.getInstance(factor);
    // Wait for the expected number of pipelines using allowed DNs.
    GenericTestUtils.waitFor(() -> {
        List<Pipeline> pipelines = scm.getPipelineManager().getPipelines(replConfig);
        LOG.info("Found {} pipelines of type {} and factor {}.", pipelines.size(), replConfig.getReplicationType(), replConfig.getReplicationFactor());
        boolean success = countCheck.test(pipelines.size());
        // these pipelines use nodes outside of allowedDNs.
        if (success) {
            for (Pipeline pipeline : pipelines) {
                for (DatanodeDetails pipelineDN : pipeline.getNodes()) {
                    // never be used once we have the expected number of pipelines.
                    if (!allowedDnIds.contains(pipelineDN.getUuidString())) {
                        String message = String.format("Pipeline %s used datanode %s " + "which is not in the set of allowed datanodes: %s", pipeline.getId().toString(), pipelineDN.getUuidString(), allowedDnIds.toString());
                        Assert.fail(message);
                    }
                }
            }
        }
        return success;
    }, 1000, 10000);
}
Also used : MockDatanodeDetails.randomDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails) MockDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails) MockDatanodeDetails.createDatanodeDetails(org.apache.hadoop.hdds.protocol.MockDatanodeDetails.createDatanodeDetails) DatanodeDetails(org.apache.hadoop.hdds.protocol.DatanodeDetails) RatisReplicationConfig(org.apache.hadoop.hdds.client.RatisReplicationConfig) Pipeline(org.apache.hadoop.hdds.scm.pipeline.Pipeline)

Aggregations

RatisReplicationConfig (org.apache.hadoop.hdds.client.RatisReplicationConfig)1 DatanodeDetails (org.apache.hadoop.hdds.protocol.DatanodeDetails)1 MockDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails)1 MockDatanodeDetails.createDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.createDatanodeDetails)1 MockDatanodeDetails.randomDatanodeDetails (org.apache.hadoop.hdds.protocol.MockDatanodeDetails.randomDatanodeDetails)1 Pipeline (org.apache.hadoop.hdds.scm.pipeline.Pipeline)1