use of org.apache.druid.server.coordinator.ServerHolder in project druid by druid-io.
the class MarkAsUnusedOvershadowedSegments method run.
@Override
public DruidCoordinatorRuntimeParams run(DruidCoordinatorRuntimeParams params) {
// Mark as unused overshadowed segments only if we've had enough time to make sure we aren't flapping with old data.
if (!params.coordinatorIsLeadingEnoughTimeToMarkAsUnusedOvershadowedSegements()) {
return params;
}
CoordinatorStats stats = new CoordinatorStats();
DruidCluster cluster = params.getDruidCluster();
Map<String, VersionedIntervalTimeline<String, DataSegment>> timelines = new HashMap<>();
for (SortedSet<ServerHolder> serverHolders : cluster.getSortedHistoricalsByTier()) {
for (ServerHolder serverHolder : serverHolders) {
addSegmentsFromServer(serverHolder, timelines);
}
}
for (ServerHolder serverHolder : cluster.getBrokers()) {
addSegmentsFromServer(serverHolder, timelines);
}
// Mark all segments as unused in db that are overshadowed by served segments
for (DataSegment dataSegment : params.getUsedSegments()) {
VersionedIntervalTimeline<String, DataSegment> timeline = timelines.get(dataSegment.getDataSource());
if (timeline != null && timeline.isOvershadowed(dataSegment.getInterval(), dataSegment.getVersion(), dataSegment)) {
coordinator.markSegmentAsUnused(dataSegment);
stats.addToGlobalStat("overShadowedCount", 1);
}
}
return params.buildFromExisting().withCoordinatorStats(stats).build();
}
use of org.apache.druid.server.coordinator.ServerHolder in project druid by druid-io.
the class BroadcastDistributionRule method assign.
private CoordinatorStats assign(final Set<ServerHolder> serverHolders, final DataSegment segment) {
final CoordinatorStats stats = new CoordinatorStats();
stats.addToGlobalStat(LoadRule.ASSIGNED_COUNT, 0);
for (ServerHolder holder : serverHolders) {
if (segment.getSize() > holder.getAvailableSize()) {
log.makeAlert("Failed to broadcast segment for [%s]", segment.getDataSource()).addData("segmentId", segment.getId()).addData("segmentSize", segment.getSize()).addData("hostName", holder.getServer().getHost()).addData("availableSize", holder.getAvailableSize()).emit();
} else {
if (!holder.isLoadingSegment(segment)) {
holder.getPeon().loadSegment(segment, null);
stats.addToGlobalStat(LoadRule.ASSIGNED_COUNT, 1);
}
}
}
return stats;
}
use of org.apache.druid.server.coordinator.ServerHolder in project druid by druid-io.
the class BroadcastDistributionRule method drop.
private CoordinatorStats drop(final Set<ServerHolder> serverHolders, final DataSegment segment) {
CoordinatorStats stats = new CoordinatorStats();
for (ServerHolder holder : serverHolders) {
holder.getPeon().dropSegment(segment, null);
stats.addToGlobalStat(LoadRule.DROPPED_COUNT, 1);
}
return stats;
}
use of org.apache.druid.server.coordinator.ServerHolder in project druid by druid-io.
the class BroadcastDistributionRule method run.
@Override
public CoordinatorStats run(DruidCoordinator coordinator, DruidCoordinatorRuntimeParams params, DataSegment segment) {
final Set<ServerHolder> dropServerHolders = new HashSet<>();
// Find servers where we need to load the broadcast segments
final Set<ServerHolder> loadServerHolders = params.getDruidCluster().getAllServers().stream().filter((serverHolder) -> {
ServerType serverType = serverHolder.getServer().getType();
if (!serverType.isSegmentBroadcastTarget()) {
return false;
}
final boolean isServingSegment = serverHolder.isServingSegment(segment);
if (serverHolder.isDecommissioning()) {
if (isServingSegment && !serverHolder.isDroppingSegment(segment)) {
dropServerHolders.add(serverHolder);
}
return false;
}
return !isServingSegment && !serverHolder.isLoadingSegment(segment);
}).collect(Collectors.toSet());
final CoordinatorStats stats = new CoordinatorStats();
return stats.accumulate(assign(loadServerHolders, segment)).accumulate(drop(dropServerHolders, segment));
}
use of org.apache.druid.server.coordinator.ServerHolder in project druid by druid-io.
the class LoadRule method dropSegmentFromServers.
private static int dropSegmentFromServers(BalancerStrategy balancerStrategy, DataSegment segment, NavigableSet<ServerHolder> holders, int numToDrop) {
final Iterator<ServerHolder> iterator = balancerStrategy.pickServersToDrop(segment, holders);
while (numToDrop > 0) {
if (!iterator.hasNext()) {
break;
}
final ServerHolder holder = iterator.next();
if (holder.isServingSegment(segment)) {
log.info("Dropping segment [%s] on server [%s] in tier [%s]", segment.getId(), holder.getServer().getName(), holder.getServer().getTier());
holder.getPeon().dropSegment(segment, null);
numToDrop--;
} else {
log.warn("Server [%s] is no longer serving segment [%s], skipping drop.", holder.getServer().getName(), segment.getId());
}
}
return numToDrop;
}
Aggregations