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());
}
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()));
}
Aggregations