Skip to content

Commit

Permalink
Use DruidLeaderSelector in CliCoordinator.HearbeatSupplier (apache#16215
Browse files Browse the repository at this point in the history
)
  • Loading branch information
findingrish authored Mar 28, 2024
1 parent 524842a commit 3471352
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import org.apache.druid.client.HttpServerInventoryViewResource;
import org.apache.druid.client.InternalQueryConfig;
import org.apache.druid.client.coordinator.Coordinator;
import org.apache.druid.discovery.DruidLeaderSelector;
import org.apache.druid.discovery.NodeRole;
import org.apache.druid.error.DruidException;
import org.apache.druid.guice.ConfigProvider;
Expand Down Expand Up @@ -465,20 +466,20 @@ public CoordinatorCustomDutyGroups get()

private static class HeartbeatSupplier implements Provider<Supplier<Map<String, Object>>>
{
private final DruidCoordinator coordinator;
private final DruidLeaderSelector leaderSelector;

@Inject
public HeartbeatSupplier(DruidCoordinator coordinator)
public HeartbeatSupplier(@Coordinator DruidLeaderSelector leaderSelector)
{
this.coordinator = coordinator;
this.leaderSelector = leaderSelector;
}

@Override
public Supplier<Map<String, Object>> get()
{
return () -> {
Map<String, Object> heartbeatTags = new HashMap<>();
heartbeatTags.put("leader", coordinator.isLeader() ? 1 : 0);
heartbeatTags.put("leader", leaderSelector.isLeader() ? 1 : 0);

return heartbeatTags;
};
Expand Down

0 comments on commit 3471352

Please sign in to comment.