Search in sources :

Example 1 with ImmutableSegmentLoadInfo

use of org.apache.druid.client.ImmutableSegmentLoadInfo in project druid by druid-io.

the class DataSourcesResource method getServedSegmentsInInterval.

/**
 * Provides serverView for a datasource and Interval which gives details about servers hosting segments for an
 * interval. Used by the realtime tasks to fetch a view of the interval they are interested in.
 */
@GET
@Path("/{dataSourceName}/intervals/{interval}/serverview")
@Produces(MediaType.APPLICATION_JSON)
@ResourceFilters(DatasourceResourceFilter.class)
public Response getServedSegmentsInInterval(@PathParam("dataSourceName") String dataSourceName, @PathParam("interval") String interval, @QueryParam("partial") final boolean partial) {
    TimelineLookup<String, SegmentLoadInfo> timeline = serverInventoryView.getTimeline(new TableDataSource(dataSourceName));
    final Interval theInterval = Intervals.of(interval.replace('_', '/'));
    if (timeline == null) {
        log.debug("No timeline found for datasource[%s]", dataSourceName);
        return Response.ok(new ArrayList<ImmutableSegmentLoadInfo>()).build();
    }
    return Response.ok(prepareServedSegmentsInInterval(timeline, theInterval)).build();
}
Also used : TableDataSource(org.apache.druid.query.TableDataSource) SegmentLoadInfo(org.apache.druid.client.SegmentLoadInfo) ImmutableSegmentLoadInfo(org.apache.druid.client.ImmutableSegmentLoadInfo) ArrayList(java.util.ArrayList) Interval(org.joda.time.Interval) Path(javax.ws.rs.Path) ResourceFilters(com.sun.jersey.spi.container.ResourceFilters) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 2 with ImmutableSegmentLoadInfo

use of org.apache.druid.client.ImmutableSegmentLoadInfo in project druid by druid-io.

the class DataSourcesResourceTest method testSegmentLoadChecksForVersion.

@Test
public void testSegmentLoadChecksForVersion() {
    Interval interval = Intervals.of("2011-04-01/2011-04-02");
    Assert.assertFalse(DataSourcesResource.isSegmentLoaded(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(interval, "v1", 2), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(interval, "v2", 2)));
    Assert.assertTrue(DataSourcesResource.isSegmentLoaded(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(interval, "v2", 2), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(interval, "v1", 2)));
    Assert.assertTrue(DataSourcesResource.isSegmentLoaded(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(interval, "v1", 2), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(interval, "v1", 2)));
}
Also used : SegmentDescriptor(org.apache.druid.query.SegmentDescriptor) ImmutableSegmentLoadInfo(org.apache.druid.client.ImmutableSegmentLoadInfo) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 3 with ImmutableSegmentLoadInfo

use of org.apache.druid.client.ImmutableSegmentLoadInfo in project druid by druid-io.

the class CoordinatorBasedSegmentHandoffNotifierTest method testHandoffChecksForAssignableServer.

@Test
public void testHandoffChecksForAssignableServer() {
    Interval interval = Intervals.of("2011-04-01/2011-04-02");
    Assert.assertTrue(CoordinatorBasedSegmentHandoffNotifier.isHandOffComplete(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(interval, "v1", 2), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(interval, "v1", 2)));
    Assert.assertTrue(CoordinatorBasedSegmentHandoffNotifier.isHandOffComplete(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(interval, "v1", 2), Sets.newHashSet(createRealtimeServerMetadata("a")))), new SegmentDescriptor(interval, "v1", 2)));
}
Also used : SegmentDescriptor(org.apache.druid.query.SegmentDescriptor) ImmutableSegmentLoadInfo(org.apache.druid.client.ImmutableSegmentLoadInfo) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 4 with ImmutableSegmentLoadInfo

use of org.apache.druid.client.ImmutableSegmentLoadInfo in project druid by druid-io.

the class CoordinatorBasedSegmentHandoffNotifierTest method testHandoffChecksForVersion.

@Test
public void testHandoffChecksForVersion() {
    Interval interval = Intervals.of("2011-04-01/2011-04-02");
    Assert.assertFalse(CoordinatorBasedSegmentHandoffNotifier.isHandOffComplete(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(interval, "v1", 2), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(interval, "v2", 2)));
    Assert.assertTrue(CoordinatorBasedSegmentHandoffNotifier.isHandOffComplete(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(interval, "v2", 2), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(interval, "v1", 2)));
    Assert.assertTrue(CoordinatorBasedSegmentHandoffNotifier.isHandOffComplete(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(interval, "v1", 2), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(interval, "v1", 2)));
}
Also used : SegmentDescriptor(org.apache.druid.query.SegmentDescriptor) ImmutableSegmentLoadInfo(org.apache.druid.client.ImmutableSegmentLoadInfo) Interval(org.joda.time.Interval) Test(org.junit.Test)

Example 5 with ImmutableSegmentLoadInfo

use of org.apache.druid.client.ImmutableSegmentLoadInfo in project druid by druid-io.

the class CoordinatorBasedSegmentHandoffNotifierTest method testHandoffChecksForInterval.

@Test
public void testHandoffChecksForInterval() {
    Assert.assertFalse(CoordinatorBasedSegmentHandoffNotifier.isHandOffComplete(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(Intervals.of("2011-04-01/2011-04-02"), "v1", 1), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(Intervals.of("2011-04-01/2011-04-03"), "v1", 1)));
    Assert.assertTrue(CoordinatorBasedSegmentHandoffNotifier.isHandOffComplete(Collections.singletonList(new ImmutableSegmentLoadInfo(createSegment(Intervals.of("2011-04-01/2011-04-04"), "v1", 1), Sets.newHashSet(createHistoricalServerMetadata("a")))), new SegmentDescriptor(Intervals.of("2011-04-02/2011-04-03"), "v1", 1)));
}
Also used : SegmentDescriptor(org.apache.druid.query.SegmentDescriptor) ImmutableSegmentLoadInfo(org.apache.druid.client.ImmutableSegmentLoadInfo) Test(org.junit.Test)

Aggregations

ImmutableSegmentLoadInfo (org.apache.druid.client.ImmutableSegmentLoadInfo)12 SegmentDescriptor (org.apache.druid.query.SegmentDescriptor)10 Test (org.junit.Test)9 Interval (org.joda.time.Interval)8 ResourceFilters (com.sun.jersey.spi.container.ResourceFilters)2 GET (javax.ws.rs.GET)2 Path (javax.ws.rs.Path)2 Produces (javax.ws.rs.Produces)2 SegmentLoadInfo (org.apache.druid.client.SegmentLoadInfo)2 TableDataSource (org.apache.druid.query.TableDataSource)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Executor (java.util.concurrent.Executor)1 Pair (org.apache.druid.java.util.common.Pair)1 UnknownSegmentIdsException (org.apache.druid.metadata.UnknownSegmentIdsException)1 DruidServerMetadata (org.apache.druid.server.coordination.DruidServerMetadata)1 LoadRule (org.apache.druid.server.coordinator.rules.LoadRule)1 Rule (org.apache.druid.server.coordinator.rules.Rule)1