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));
}
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;
}
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;
}
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;
}
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;
}
Aggregations