public List<EventInformation> loadEventLogFile(File eventLogFile) throws IOException { return loadEventLogFileAsStream(eventLogFile).collect(toList()); }
public TopologyTestRunResource(StreamlineAuthorizer authorizer, StreamCatalogService catalogService, TopologyActionsService actionsService) { this.authorizer = authorizer; this.catalogService = catalogService; this.actionsService = actionsService; this.eventLogFileReader = new EventLogFileReader(); this.objectMapper = new ObjectMapper(); }
@GET @Path("/topologies/{topologyId}/testhistories/{historyId}/events/root") public Response getRootEventsOfTestRunTopologyHistory(@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, @PathParam("historyId") Long historyId, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); File eventLogFile = getEventLogFile(topologyId, historyId); List<EventInformation> events = eventLogFileReader.loadEventLogFile(eventLogFile); List<com.hortonworks.registries.common.QueryParam> qps = com.hortonworks.registries.common.QueryParam.params( TopologySource.TOPOLOGYID, topologyId.toString(), TopologySource.VERSIONID, catalogService.getCurrentVersionId(topologyId).toString()); Set<String> sourceNames = catalogService.listTopologySources(qps).stream() .map(TopologyComponent::getName) .collect(Collectors.toSet()); return WSUtils.respondEntities(new CorrelatedEventsGrouper(events).groupByRelatedSourceEvents(sourceNames), OK); }
@GET @Path("/topologies/{topologyId}/testhistories/{historyId}/events/correlated/{rootEventId}") public Response getGroupedCorrelatedEventsOfTestRunTopologyHistory(@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, @PathParam("historyId") Long historyId, @PathParam("rootEventId") String rootEventId, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); File eventLogFile = getEventLogFile(topologyId, historyId); List<EventInformation> events = eventLogFileReader.loadEventLogFile(eventLogFile); GroupedCorrelationEvents groupedEvents = new CorrelatedEventsGrouper(events).groupByComponent(rootEventId); if (!groupedEvents.getAllEvents().containsKey(rootEventId)) { throw BadRequestException.message("Can't find provided root event " + rootEventId + " from events."); } return WSUtils.respondEntity(groupedEvents, OK); }
private Response getEventsOfTestRunTopologyHistory(Long topologyId, Long historyId, String componentName, SecurityContext securityContext) throws IOException { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); File eventLogFile = getEventLogFile(topologyId, historyId); Stream<EventInformation> eventsStream = eventLogFileReader.loadEventLogFileAsStream(eventLogFile); if (!StringUtils.isEmpty(componentName)) { eventsStream = eventsStream.filter(event -> { String eventComponentName = event.getComponentName(); return eventComponentName != null && eventComponentName.equals(componentName); }); } return WSUtils.respondEntities(eventsStream.collect(toList()), OK); }
@GET @Path("/topologies/{topologyId}/testhistories/{historyId}/events/tree/{rootEventId}") public Response getEventTreeOfTestRunTopologyHistory(@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, @PathParam("historyId") Long historyId, @PathParam("rootEventId") String rootEventId, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); File eventLogFile = getEventLogFile(topologyId, historyId); List<EventInformation> events = eventLogFileReader.loadEventLogFile(eventLogFile); EventInformationTreeNode rootEventNode = new EventInformationTreeBuilder(events).constructEventTree(rootEventId); if (rootEventNode == null) { throw BadRequestException.message("Can't find provided root event " + rootEventId + " from events."); } return WSUtils.respondEntity(rootEventNode, OK); }
@GET @Path("/topologies/{topologyId}/testhistories/{historyId}/events/tree/{rootEventId}/subtree/{subRootEventId}") public Response getEventSubTreeOfTestRunTopologyHistory(@Context UriInfo urlInfo, @PathParam("topologyId") Long topologyId, @PathParam("historyId") Long historyId, @PathParam("rootEventId") String rootEventId, @PathParam("subRootEventId") String subRootEventId, @Context SecurityContext securityContext) throws Exception { SecurityUtil.checkRoleOrPermissions(authorizer, securityContext, Roles.ROLE_TOPOLOGY_USER, Topology.NAMESPACE, topologyId, READ); File eventLogFile = getEventLogFile(topologyId, historyId); List<EventInformation> events = eventLogFileReader.loadEventLogFile(eventLogFile); EventInformationTreeNode subRootEventNode = new EventInformationTreeBuilder(events).constructEventTree(rootEventId, subRootEventId); if (subRootEventNode == null) { throw BadRequestException.message("Can't find provided root event " + rootEventId + " from events."); } return WSUtils.respondEntity(subRootEventNode, OK); }