Search in sources :

Example 1 with TopicPartitionOffsetResponse

use of io.confluent.kafkarest.entities.v2.TopicPartitionOffsetResponse 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);
}
Also used : TopicPartitionOffsetResponse(io.confluent.kafkarest.entities.v2.TopicPartitionOffsetResponse) PathParam(javax.ws.rs.PathParam) PartitionManager(io.confluent.kafkarest.controllers.PartitionManager) AsyncResponses(io.confluent.kafkarest.resources.AsyncResponses) Provider(javax.inject.Provider) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) AsyncResponse(javax.ws.rs.container.AsyncResponse) Path(javax.ws.rs.Path) Versions(io.confluent.kafkarest.Versions) ResourceName(io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName) CompletableFuture(java.util.concurrent.CompletableFuture) PerformanceMetric(io.confluent.rest.annotations.PerformanceMetric) Collectors(java.util.stream.Collectors) Suspended(javax.ws.rs.container.Suspended) Inject(javax.inject.Inject) List(java.util.List) Consumes(javax.ws.rs.Consumes) Errors(io.confluent.kafkarest.Errors) TopicPartitionOffsetResponse(io.confluent.kafkarest.entities.v2.TopicPartitionOffsetResponse) Objects.requireNonNull(java.util.Objects.requireNonNull) GetPartitionResponse(io.confluent.kafkarest.entities.v2.GetPartitionResponse) Errors(io.confluent.kafkarest.Errors) Path(javax.ws.rs.Path) ResourceName(io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName) GET(javax.ws.rs.GET)

Aggregations

Errors (io.confluent.kafkarest.Errors)1 Versions (io.confluent.kafkarest.Versions)1 PartitionManager (io.confluent.kafkarest.controllers.PartitionManager)1 GetPartitionResponse (io.confluent.kafkarest.entities.v2.GetPartitionResponse)1 TopicPartitionOffsetResponse (io.confluent.kafkarest.entities.v2.TopicPartitionOffsetResponse)1 ResourceName (io.confluent.kafkarest.extension.ResourceAccesslistFeature.ResourceName)1 AsyncResponses (io.confluent.kafkarest.resources.AsyncResponses)1 PerformanceMetric (io.confluent.rest.annotations.PerformanceMetric)1 List (java.util.List)1 Objects.requireNonNull (java.util.Objects.requireNonNull)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 Collectors (java.util.stream.Collectors)1 Inject (javax.inject.Inject)1 Provider (javax.inject.Provider)1 Consumes (javax.ws.rs.Consumes)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 PathParam (javax.ws.rs.PathParam)1 Produces (javax.ws.rs.Produces)1 AsyncResponse (javax.ws.rs.container.AsyncResponse)1