use of io.druid.indexing.common.actions.ResetDataSourceMetadataAction in project druid by druid-io.
the class KafkaIndexTask method sendResetRequestAndWait.
private void sendResetRequestAndWait(Map<TopicPartition, Long> outOfRangePartitions, TaskToolbox taskToolbox) throws IOException {
Map<Integer, Long> partitionOffsetMap = Maps.newHashMap();
for (Map.Entry<TopicPartition, Long> outOfRangePartition : outOfRangePartitions.entrySet()) {
partitionOffsetMap.put(outOfRangePartition.getKey().partition(), outOfRangePartition.getValue());
}
boolean result = taskToolbox.getTaskActionClient().submit(new ResetDataSourceMetadataAction(getDataSource(), new KafkaDataSourceMetadata(new KafkaPartitions(ioConfig.getStartPartitions().getTopic(), partitionOffsetMap))));
if (result) {
log.makeAlert("Resetting Kafka offsets for datasource [%s]", getDataSource()).addData("partitions", partitionOffsetMap.keySet()).emit();
// wait for being killed by supervisor
try {
Thread.sleep(Long.MAX_VALUE);
} catch (InterruptedException e) {
throw new RuntimeException("Got interrupted while waiting to be killed");
}
} else {
log.makeAlert("Failed to send reset request for partitions [%s]", partitionOffsetMap.keySet()).emit();
}
}
Aggregations