jihoonson commented on a change in pull request #6676: Handoff should ignore
segments that are dropped by drop rules
URL: https://github.com/apache/incubator-druid/pull/6676#discussion_r244858477
##########
File path:
server/src/main/java/org/apache/druid/server/http/DatasourcesResource.java
##########
@@ -647,4 +655,80 @@ public Response getSegmentDataSourceSpecificInterval(
);
return Response.ok(retval).build();
}
+
+ @GET
+ @Path("/{dataSourceName}/handoffComplete")
+ @Produces(MediaType.APPLICATION_JSON)
+ @ResourceFilters(DatasourceResourceFilter.class)
+ public Response isHandOffComplete(
+ @PathParam("dataSourceName") String dataSourceName,
+ @QueryParam("interval") final String interval,
+ @QueryParam("partitionNumber") final int partitionNumber,
+ @QueryParam("version") final String version
+ )
+ {
+ try {
+ final List<Rule> rules =
databaseRuleManager.getRulesWithDefault(dataSourceName);
+ final Interval theInterval = Intervals.of(interval);
+ final SegmentDescriptor descriptor = new SegmentDescriptor(theInterval,
version, partitionNumber);
+ final DateTime now = DateTimes.nowUtc();
+ // dropped means a segment will never be handed off, i.e it completed
hand off
+ // init to true, reset to false only if this segment can be loaded by
rules
+ boolean dropped = true;
+ for (Rule rule : rules) {
+ if (rule.appliesTo(theInterval, now)) {
+ if (rule instanceof LoadRule) {
+ dropped = false;
+ }
+ break;
+ }
+ }
+ if (dropped) {
+ return Response.ok(true).build();
+ }
+
+ TimelineLookup<String, SegmentLoadInfo> timeline =
serverInventoryView.getTimeline(
+ new TableDataSource(dataSourceName)
+ );
+ if (timeline == null) {
+ log.debug("No timeline found for datasource[%s]", dataSourceName);
+ return Response.ok(false).build();
+ }
+
+ Iterable<TimelineObjectHolder<String, SegmentLoadInfo>> lookup =
timeline.lookupWithIncompletePartitions(
+ theInterval);
+ FunctionalIterable<ImmutableSegmentLoadInfo> loadInfoIterable =
FunctionalIterable
+ .create(lookup).transformCat(
+ (TimelineObjectHolder<String, SegmentLoadInfo> input) ->
+ Iterables.transform(
+ input.getObject(),
+ (PartitionChunk<SegmentLoadInfo> chunk) ->
+ chunk.getObject().toImmutableSegmentLoadInfo()
+ )
+ );
+ if (isSegmentLoaded(loadInfoIterable, descriptor)) {
+ return Response.ok(true).build();
+ }
+
+ return Response.ok(false).build();
+ }
+ catch (Exception e) {
+ return Response.serverError().entity(ImmutableMap.of("error",
e.toString())).build();
Review comment:
Probably logging the full stack trace of exception would help as well?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]