Search in sources :

Example 1 with FlowEvent

use of org.openkilda.model.history.FlowEvent in project open-kilda by telstra.

the class FermaFlowEventRepositoryTest method findByFlowIdAndTimeFrameOrderTest.

@Test
public void findByFlowIdAndTimeFrameOrderTest() {
    List<FlowEvent> expected = new ArrayList<>();
    expected.add(buildFlowEvent(FLOW_1, TASK_1, ACTION_1, TIME_1));
    expected.add(buildFlowEvent(FLOW_1, TASK_2, ACTION_2, TIME_2));
    expected.add(buildFlowEvent(FLOW_1, TASK_3, ACTION_3, TIME_3));
    for (FlowEvent flowHistory : expected) {
        flowEventRepository.add(flowHistory);
    }
    List<FlowEvent> actual = new ArrayList<>(flowEventRepository.findByFlowIdAndTimeFrame(FLOW_1, TIME_1.minusSeconds(1), TIME_3.plusSeconds(1), 100));
    assertEquals(expected, actual);
    // result must be sorted by time
    assertTrue(actual.get(0).getTimestamp().isBefore(actual.get(1).getTimestamp()));
    assertTrue(actual.get(1).getTimestamp().isBefore(actual.get(2).getTimestamp()));
}
Also used : FlowEvent(org.openkilda.model.history.FlowEvent) ArrayList(java.util.ArrayList) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 2 with FlowEvent

use of org.openkilda.model.history.FlowEvent in project open-kilda by telstra.

the class HistoryService method store.

/**
 * Save history data into data storage.
 *
 * @param historyHolder holder of history information.
 */
public void store(FlowHistoryHolder historyHolder) {
    transactionManager.doInTransaction(() -> {
        String taskId = historyHolder.getTaskId();
        if (historyHolder.getFlowEventData() != null) {
            FlowEvent event = HistoryMapper.INSTANCE.map(historyHolder.getFlowEventData());
            event.setTaskId(taskId);
            flowEventRepository.add(event);
        }
        if (historyHolder.getFlowHistoryData() != null) {
            FlowEventAction history = HistoryMapper.INSTANCE.map(historyHolder.getFlowHistoryData());
            history.setTaskId(taskId);
            flowEventActionRepository.add(history);
        }
        if (historyHolder.getFlowDumpData() != null) {
            FlowEventDump dump = HistoryMapper.INSTANCE.map(historyHolder.getFlowDumpData());
            dump.setTaskId(taskId);
            flowEventDumpRepository.add(dump);
        }
    });
}
Also used : FlowEvent(org.openkilda.model.history.FlowEvent) FlowEventAction(org.openkilda.model.history.FlowEventAction) FlowEventDump(org.openkilda.model.history.FlowEventDump)

Aggregations

FlowEvent (org.openkilda.model.history.FlowEvent)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 FlowEventAction (org.openkilda.model.history.FlowEventAction)1 FlowEventDump (org.openkilda.model.history.FlowEventDump)1 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)1