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
|
@Nullable
|
||||||
public Integer getReplicationFactor(SegmentId segmentId)
|
public Integer getReplicationFactor(SegmentId segmentId)
|
||||||
{
|
{
|
||||||
if (segmentReplicationStatus != null) {
|
if (segmentReplicationStatus == null) {
|
||||||
return segmentReplicationStatus.getReplicaCountsInCluster(segmentId).required();
|
|
||||||
} else {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
SegmentReplicaCount replicaCountsInCluster = segmentReplicationStatus.getReplicaCountsInCluster(segmentId);
|
||||||
|
return replicaCountsInCluster == null ? null : replicaCountsInCluster.required();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
|
|
@ -249,6 +249,9 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
||||||
EasyMock.replay(serverInventoryView, loadQueueTaskMaster);
|
EasyMock.replay(serverInventoryView, loadQueueTaskMaster);
|
||||||
|
|
||||||
coordinator.start();
|
coordinator.start();
|
||||||
|
|
||||||
|
Assert.assertNull(coordinator.getReplicationFactor(dataSegment.getId()));
|
||||||
|
|
||||||
// Wait for this coordinator to become leader
|
// Wait for this coordinator to become leader
|
||||||
leaderAnnouncerLatch.await();
|
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
|
// the segments are replicated as many times as they can be given state of cluster, therefore should not be
|
||||||
// under-replicated.
|
// under-replicated.
|
||||||
Assert.assertEquals(0L, underRepliicationCountsPerDataSourceUsingClusterView.getLong(dataSource));
|
Assert.assertEquals(0L, underRepliicationCountsPerDataSourceUsingClusterView.getLong(dataSource));
|
||||||
|
Assert.assertEquals(Integer.valueOf(2), coordinator.getReplicationFactor(dataSegment.getId()));
|
||||||
|
|
||||||
coordinator.stop();
|
coordinator.stop();
|
||||||
leaderUnannouncerLatch.await();
|
leaderUnannouncerLatch.await();
|
||||||
|
@ -398,6 +402,8 @@ public class DruidCoordinatorTest extends CuratorTestBase
|
||||||
Assert.assertEquals(0L, underReplicationCountsPerDataSourcePerTierUsingClusterView.get(hotTierName).getLong(dataSource));
|
Assert.assertEquals(0L, underReplicationCountsPerDataSourcePerTierUsingClusterView.get(hotTierName).getLong(dataSource));
|
||||||
Assert.assertEquals(0L, underReplicationCountsPerDataSourcePerTierUsingClusterView.get(coldTierName).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();
|
coordinator.stop();
|
||||||
leaderUnannouncerLatch.await();
|
leaderUnannouncerLatch.await();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue