mirror of https://github.com/apache/druid.git
Handle nulls in DruidCoordinator.getReplicationFactor (#14447)
This commit is contained in:
parent
09d6c5a45e
commit
f5cc823d0f
|
@ -302,11 +302,11 @@ public class DruidCoordinator
|
|||
@Nullable
|
||||
public Integer getReplicationFactor(SegmentId segmentId)
|
||||
{
|
||||
if (segmentReplicationStatus != null) {
|
||||
return segmentReplicationStatus.getReplicaCountsInCluster(segmentId).required();
|
||||
} else {
|
||||
if (segmentReplicationStatus == null) {
|
||||
return null;
|
||||
}
|
||||
SegmentReplicaCount replicaCountsInCluster = segmentReplicationStatus.getReplicaCountsInCluster(segmentId);
|
||||
return replicaCountsInCluster == null ? null : replicaCountsInCluster.required();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
|
|
@ -249,6 +249,9 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
|||
EasyMock.replay(serverInventoryView, loadQueueTaskMaster);
|
||||
|
||||
coordinator.start();
|
||||
|
||||
Assert.assertNull(coordinator.getReplicationFactor(dataSegment.getId()));
|
||||
|
||||
// Wait for this coordinator to become leader
|
||||
leaderAnnouncerLatch.await();
|
||||
|
||||
|
@ -306,6 +309,7 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
|||
// the segments are replicated as many times as they can be given state of cluster, therefore should not be
|
||||
// under-replicated.
|
||||
Assert.assertEquals(0L, underRepliicationCountsPerDataSourceUsingClusterView.getLong(dataSource));
|
||||
Assert.assertEquals(Integer.valueOf(2), coordinator.getReplicationFactor(dataSegment.getId()));
|
||||
|
||||
coordinator.stop();
|
||||
leaderUnannouncerLatch.await();
|
||||
|
@ -398,6 +402,8 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
|||
Assert.assertEquals(0L, underReplicationCountsPerDataSourcePerTierUsingClusterView.get(hotTierName).getLong(dataSource));
|
||||
Assert.assertEquals(0L, underReplicationCountsPerDataSourcePerTierUsingClusterView.get(coldTierName).getLong(dataSource));
|
||||
|
||||
dataSegments.values().forEach(dataSegment -> Assert.assertEquals(Integer.valueOf(1), coordinator.getReplicationFactor(dataSegment.getId())));
|
||||
|
||||
coordinator.stop();
|
||||
leaderUnannouncerLatch.await();
|
||||
|
||||
|
|
Loading…
Reference in New Issue