@GET
@Path("/topologies/{id}/components/{topologyComponentId}/kafka_topic_offsets")
@Timed
public Response getKafkaTopicOffsets(@PathParam("id") Long id,
@PathParam("topologyComponentId") Long topologyComponentId,
@QueryParam("from") Long from,
@QueryParam("to") Long to,
@Context SecurityContext securityContext) throws IOException {
SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER,
Topology.NAMESPACE, id, READ);
assertTimeRange(from, to);
Topology topology = catalogService.getTopology(id);
TopologyComponent topologyComponent = catalogService.getTopologyComponent(id, topologyComponentId);
if (topology != null && topologyComponent != null) {
String asUser = WSUtils.getUserFromSecurityContext(securityContext);
Map<String, Map<Long, Double>> metrics = metricsService.getKafkaTopicOffsets(topology, topologyComponent, from, to, asUser);
return WSUtils.respondEntity(metrics, OK);
} else if (topology == null) {
throw EntityNotFoundException.byId("Topology: " + id.toString());
} else {
throw EntityNotFoundException.byId("TopologyComponent: " + id.toString());
}
}