use of org.apache.druid.indexing.overlord.supervisor.SupervisorReport in project druid by druid-io.
the class SeekableStreamSupervisor method generateReport.
private SupervisorReport<? extends SeekableStreamSupervisorReportPayload<PartitionIdType, SequenceOffsetType>> generateReport(boolean includeOffsets) {
int numPartitions = partitionGroups.values().stream().mapToInt(Set::size).sum();
final SeekableStreamSupervisorReportPayload<PartitionIdType, SequenceOffsetType> payload = createReportPayload(numPartitions, includeOffsets);
SupervisorReport<SeekableStreamSupervisorReportPayload<PartitionIdType, SequenceOffsetType>> report = new SupervisorReport<>(dataSource, DateTimes.nowUtc(), payload);
List<TaskReportData<PartitionIdType, SequenceOffsetType>> taskReports = new ArrayList<>();
try {
for (TaskGroup taskGroup : activelyReadingTaskGroups.values()) {
for (Entry<String, TaskData> entry : taskGroup.tasks.entrySet()) {
String taskId = entry.getKey();
@Nullable DateTime startTime = entry.getValue().startTime;
Map<PartitionIdType, SequenceOffsetType> currentOffsets = entry.getValue().currentSequences;
Long remainingSeconds = null;
if (startTime != null) {
long elapsedMillis = System.currentTimeMillis() - startTime.getMillis();
long remainingMillis = Math.max(0, ioConfig.getTaskDuration().getMillis() - elapsedMillis);
remainingSeconds = TimeUnit.MILLISECONDS.toSeconds(remainingMillis);
}
taskReports.add(new TaskReportData<>(taskId, includeOffsets ? taskGroup.startingSequences : null, includeOffsets ? currentOffsets : null, startTime, remainingSeconds, TaskReportData.TaskType.ACTIVE, includeOffsets ? getRecordLagPerPartition(currentOffsets) : null, includeOffsets ? getTimeLagPerPartition(currentOffsets) : null));
}
}
for (List<TaskGroup> taskGroups : pendingCompletionTaskGroups.values()) {
for (TaskGroup taskGroup : taskGroups) {
for (Entry<String, TaskData> entry : taskGroup.tasks.entrySet()) {
String taskId = entry.getKey();
@Nullable DateTime startTime = entry.getValue().startTime;
Map<PartitionIdType, SequenceOffsetType> currentOffsets = entry.getValue().currentSequences;
Long remainingSeconds = null;
if (taskGroup.completionTimeout != null) {
remainingSeconds = Math.max(0, taskGroup.completionTimeout.getMillis() - System.currentTimeMillis()) / 1000;
}
taskReports.add(new TaskReportData<>(taskId, includeOffsets ? taskGroup.startingSequences : null, includeOffsets ? currentOffsets : null, startTime, remainingSeconds, TaskReportData.TaskType.PUBLISHING, null, null));
}
}
}
taskReports.forEach(payload::addTask);
} catch (Exception e) {
log.warn(e, "Failed to generate status report");
}
return report;
}
Aggregations