Search in sources :

Example 16 with DataSegment

use of io.druid.timeline.DataSegment in project druid by druid-io.

the class IndexingServiceClient method mergeSegments.

public void mergeSegments(List<DataSegment> segments) {
    final Iterator<DataSegment> segmentsIter = segments.iterator();
    if (!segmentsIter.hasNext()) {
        return;
    }
    final String dataSource = segmentsIter.next().getDataSource();
    while (segmentsIter.hasNext()) {
        DataSegment next = segmentsIter.next();
        if (!dataSource.equals(next.getDataSource())) {
            throw new IAE("Cannot merge segments of different dataSources[%s] and [%s]", dataSource, next.getDataSource());
        }
    }
    runQuery(new ClientAppendQuery(dataSource, segments));
}
Also used : IAE(io.druid.java.util.common.IAE) DataSegment(io.druid.timeline.DataSegment)

Example 17 with DataSegment

use of io.druid.timeline.DataSegment in project druid by druid-io.

the class ServerSelector method getCandidates.

public List<DruidServerMetadata> getCandidates(final int numCandidates) {
    List<DruidServerMetadata> result = Lists.newArrayList();
    synchronized (this) {
        final DataSegment target = segment.get();
        for (Map.Entry<Integer, Set<QueryableDruidServer>> entry : toPrioritizedServers().entrySet()) {
            Set<QueryableDruidServer> servers = entry.getValue();
            TreeMap<Integer, Set<QueryableDruidServer>> tieredMap = Maps.newTreeMap();
            while (!servers.isEmpty()) {
                // strategy.pick() removes entry
                tieredMap.put(entry.getKey(), servers);
                QueryableDruidServer server = strategy.pick(tieredMap, target);
                if (server == null) {
                    // regard this as any server in tieredMap is not appropriate
                    break;
                }
                result.add(server.getServer().getMetadata());
                if (numCandidates > 0 && result.size() >= numCandidates) {
                    return result;
                }
                servers.remove(server);
            }
        }
    }
    return result;
}
Also used : Set(java.util.Set) DruidServerMetadata(io.druid.server.coordination.DruidServerMetadata) DataSegment(io.druid.timeline.DataSegment) TreeMap(java.util.TreeMap) Map(java.util.Map)

Example 18 with DataSegment

use of io.druid.timeline.DataSegment in project druid by druid-io.

the class LocalDataSegmentFinder method findSegments.

@Override
public Set<DataSegment> findSegments(String workingDirPath, boolean updateDescriptor) throws SegmentLoadingException {
    final Set<DataSegment> segments = Sets.newHashSet();
    final File workingDir = new File(workingDirPath);
    if (!workingDir.isDirectory()) {
        throw new SegmentLoadingException("Working directory [%s] didn't exist !?", workingDir);
    }
    recursiveSearchSegments(segments, workingDir, updateDescriptor);
    return segments;
}
Also used : DataSegment(io.druid.timeline.DataSegment) File(java.io.File)

Example 19 with DataSegment

use of io.druid.timeline.DataSegment in project druid by druid-io.

the class DruidDataSource method removePartition.

public DruidDataSource removePartition(String partitionName) {
    synchronized (lock) {
        DataSegment dataPart = partitionNames.remove(partitionName);
        if (dataPart == null) {
            return this;
        }
        segmentsHolder.remove(dataPart);
    }
    return this;
}
Also used : DataSegment(io.druid.timeline.DataSegment)

Example 20 with DataSegment

use of io.druid.timeline.DataSegment in project druid by druid-io.

the class ClientInfoResource method getDatasourceMetrics.

@GET
@Path("/{dataSourceName}/metrics")
@Produces(MediaType.APPLICATION_JSON)
@ResourceFilters(DatasourceResourceFilter.class)
public Iterable<String> getDatasourceMetrics(@PathParam("dataSourceName") String dataSourceName, @QueryParam("interval") String interval) {
    final List<DataSegment> segments = getSegmentsForDatasources().get(dataSourceName);
    final Set<String> metrics = Sets.newHashSet();
    if (segments == null || segments.isEmpty()) {
        return metrics;
    }
    Interval theInterval;
    if (interval == null || interval.isEmpty()) {
        DateTime now = getCurrentTime();
        theInterval = new Interval(segmentMetadataQueryConfig.getDefaultHistory(), now);
    } else {
        theInterval = new Interval(interval);
    }
    for (DataSegment segment : segments) {
        if (theInterval.overlaps(segment.getInterval())) {
            metrics.addAll(segment.getMetrics());
        }
    }
    return metrics;
}
Also used : DataSegment(io.druid.timeline.DataSegment) DateTime(org.joda.time.DateTime) 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)

Aggregations

DataSegment (io.druid.timeline.DataSegment)296 Test (org.junit.Test)154 Interval (org.joda.time.Interval)136 File (java.io.File)56 DateTime (org.joda.time.DateTime)53 IOException (java.io.IOException)37 DruidServer (io.druid.client.DruidServer)36 Map (java.util.Map)35 ImmutableMap (com.google.common.collect.ImmutableMap)20 DruidDataSource (io.druid.client.DruidDataSource)19 ListeningExecutorService (com.google.common.util.concurrent.ListeningExecutorService)18 List (java.util.List)18 DefaultObjectMapper (io.druid.jackson.DefaultObjectMapper)16 Rule (io.druid.server.coordinator.rules.Rule)16 ForeverLoadRule (io.druid.server.coordinator.rules.ForeverLoadRule)14 IntervalDropRule (io.druid.server.coordinator.rules.IntervalDropRule)13 IntervalLoadRule (io.druid.server.coordinator.rules.IntervalLoadRule)13 GET (javax.ws.rs.GET)13 Produces (javax.ws.rs.Produces)13 Path (org.apache.hadoop.fs.Path)13