Search in sources :

Example 1 with GetFlowHistoryRequest

use of org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest in project open-kilda by telstra.

the class HistoryOperationsBolt method getFlowHistory.

@TimedExecution("get_flow_history")
private List<InfoData> getFlowHistory(GetFlowHistoryRequest request) {
    Instant timeFrom = Instant.ofEpochSecond(request.getTimestampFrom());
    Instant timeTo = Instant.ofEpochSecond(request.getTimestampTo() + 1).minusMillis(1);
    return historyService.listFlowEvents(request.getFlowId(), timeFrom, timeTo, request.getMaxCount()).stream().map(entry -> {
        List<FlowHistoryPayload> payload = listFlowHistories(entry);
        List<FlowDumpPayload> dumps = listFlowDumps(entry);
        return HistoryMapper.INSTANCE.map(entry, payload, dumps);
    }).collect(Collectors.toList());
}
Also used : BaseRequest(org.openkilda.messaging.nbtopology.request.BaseRequest) FlowDumpPayload(org.openkilda.messaging.payload.history.FlowDumpPayload) FlowEvent(org.openkilda.model.history.FlowEvent) GetFlowStatusTimestampsRequest(org.openkilda.messaging.nbtopology.request.GetFlowStatusTimestampsRequest) PortHistoryRequest(org.openkilda.messaging.nbtopology.request.PortHistoryRequest) HistoryMapper(org.openkilda.wfm.share.mappers.HistoryMapper) InfoData(org.openkilda.messaging.info.InfoData) StreamType(org.openkilda.wfm.topology.nbworker.StreamType) Instant(java.time.Instant) HistoryService(org.openkilda.wfm.share.history.service.HistoryService) Collectors(java.util.stream.Collectors) List(java.util.List) Tuple(org.apache.storm.tuple.Tuple) FlowHistoryPayload(org.openkilda.messaging.payload.history.FlowHistoryPayload) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution) GetFlowHistoryRequest(org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest) PersistenceManager(org.openkilda.persistence.PersistenceManager) Instant(java.time.Instant) List(java.util.List) TimedExecution(org.openkilda.wfm.share.metrics.TimedExecution)

Example 2 with GetFlowHistoryRequest

use of org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest in project open-kilda by telstra.

the class FlowServiceImpl method listFlowEvents.

@Override
public CompletableFuture<List<FlowHistoryEntry>> listFlowEvents(String flowId, long timestampFrom, long timestampTo, int maxCount) {
    if (maxCount < 1) {
        throw new MessageException(RequestCorrelationId.getId(), System.currentTimeMillis(), ErrorType.PARAMETERS_INVALID, format("Invalid `max_count` argument '%s'.", maxCount), "`max_count` argument must be positive.");
    }
    String correlationId = RequestCorrelationId.getId();
    GetFlowHistoryRequest request = GetFlowHistoryRequest.builder().flowId(flowId).timestampFrom(timestampFrom).timestampTo(timestampTo).maxCount(maxCount).build();
    CommandMessage command = new CommandMessage(request, System.currentTimeMillis(), correlationId);
    return messagingChannel.sendAndGetChunked(nbworkerTopic, command).thenApply(result -> result.stream().map(FlowHistoryEntry.class::cast).collect(Collectors.toList()));
}
Also used : FlowHistoryEntry(org.openkilda.messaging.payload.history.FlowHistoryEntry) MessageException(org.openkilda.messaging.error.MessageException) GetFlowHistoryRequest(org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest) CommandMessage(org.openkilda.messaging.command.CommandMessage)

Aggregations

GetFlowHistoryRequest (org.openkilda.messaging.nbtopology.request.GetFlowHistoryRequest)2 Instant (java.time.Instant)1 List (java.util.List)1 Collectors (java.util.stream.Collectors)1 Tuple (org.apache.storm.tuple.Tuple)1 CommandMessage (org.openkilda.messaging.command.CommandMessage)1 MessageException (org.openkilda.messaging.error.MessageException)1 InfoData (org.openkilda.messaging.info.InfoData)1 BaseRequest (org.openkilda.messaging.nbtopology.request.BaseRequest)1 GetFlowStatusTimestampsRequest (org.openkilda.messaging.nbtopology.request.GetFlowStatusTimestampsRequest)1 PortHistoryRequest (org.openkilda.messaging.nbtopology.request.PortHistoryRequest)1 FlowDumpPayload (org.openkilda.messaging.payload.history.FlowDumpPayload)1 FlowHistoryEntry (org.openkilda.messaging.payload.history.FlowHistoryEntry)1 FlowHistoryPayload (org.openkilda.messaging.payload.history.FlowHistoryPayload)1 FlowEvent (org.openkilda.model.history.FlowEvent)1 PersistenceManager (org.openkilda.persistence.PersistenceManager)1 HistoryService (org.openkilda.wfm.share.history.service.HistoryService)1 HistoryMapper (org.openkilda.wfm.share.mappers.HistoryMapper)1 TimedExecution (org.openkilda.wfm.share.metrics.TimedExecution)1 StreamType (org.openkilda.wfm.topology.nbworker.StreamType)1