use of io.confluent.kafkarest.Errors in project kafka-rest by confluentinc.
the class PartitionsResource method getOffsets.
/**
* Returns a summary with beginning and end offsets for the given {@code topic} and {@code
* partition}.
*
* @throws io.confluent.rest.exceptions.RestNotFoundException if either {@code topic} or {@code
* partition} don't exist.
*/
@GET
@Path("/{partition}/offsets")
@ResourceName("api.v2.partitions.get-offsets")
public void getOffsets(@Suspended AsyncResponse asyncResponse, @PathParam("topic") String topic, @PathParam("partition") int partitionId) {
CompletableFuture<TopicPartitionOffsetResponse> response = partitionManager.get().getLocalPartition(topic, partitionId).thenApply(partition -> partition.orElseThrow(Errors::partitionNotFoundException)).thenApply(partition -> new TopicPartitionOffsetResponse(partition.getEarliestOffset(), partition.getLatestOffset()));
AsyncResponses.asyncResume(asyncResponse, response);
}
use of io.confluent.kafkarest.Errors in project kafka-rest by confluentinc.
the class TopicsResource method getTopic.
@GET
@Path("/{topic}")
@PerformanceMetric("topic.get+v2")
@ResourceName("api.v2.topics.get")
public void getTopic(@Suspended AsyncResponse asyncResponse, @PathParam("topic") String topicName) {
TopicManager topicManager = topicManagerProvider.get();
TopicConfigManager topicConfigManager = topicConfigManagerProvider.get();
CompletableFuture<Topic> topicFuture = topicManager.getLocalTopic(topicName).thenApply(topic -> topic.orElseThrow(Errors::topicNotFoundException));
CompletableFuture<GetTopicResponse> response = topicFuture.thenCompose(topic -> topicConfigManager.listTopicConfigs(topic.getClusterId(), topicName)).thenCombine(topicFuture, (configs, topic) -> GetTopicResponse.fromTopic(topic, configs));
AsyncResponses.asyncResume(asyncResponse, response);
}
Aggregations