@Test public void shouldGetAllDownFlows() { Flow flowA = createTestFlow(TEST_FLOW_ID, switchA, switchB); flowA.setStatus(FlowStatus.DOWN); Flow flowB = createTestFlow(TEST_FLOW_ID_2, switchA, switchB); flowB.setStatus(FlowStatus.DOWN); createTestFlow(TEST_FLOW_ID_3, switchA, switchB); Collection<String> foundDownFlows = flowRepository.findByFlowFilter(FlowFilter.builder().flowStatus(FlowStatus.DOWN).build()).stream() .map(Flow::getFlowId) .collect(Collectors.toList()); assertEquals(2, foundDownFlows.size()); assertTrue(foundDownFlows.contains(TEST_FLOW_ID)); assertTrue(foundDownFlows.contains(TEST_FLOW_ID_2)); Collection<String> foundFlows = flowRepository.findByFlowFilter(FlowFilter.builder().build()).stream() .map(Flow::getFlowId) .collect(Collectors.toList()); assertEquals(3, foundFlows.size()); }
@Override public Collection<Flow> findByFlowFilter(FlowFilter flowFilter) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(FlowFrame.FRAME_LABEL); if (flowFilter.getFlowStatus() != null) { traversal = traversal.has(FlowFrame.STATUS_PROPERTY, FlowStatusConverter.INSTANCE.toGraphProperty(flowFilter.getFlowStatus())); } return traversal; }).toListExplicit(FlowFrame.class).stream() .map(Flow::new) .collect(Collectors.toList()); }
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByFlowFilter(FlowFilter flowFilter) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(FlowFrame.FRAME_LABEL); if (flowFilter.getFlowStatus() != null) { traversal = traversal.has(FlowFrame.STATUS_PROPERTY, FlowStatusConverter.INSTANCE.toGraphProperty(flowFilter.getFlowStatus())); } return traversal; }).toListExplicit(FlowFrame.class).stream() .map(Flow::new) .collect(Collectors.toList()); } }
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByFlowFilter(FlowFilter flowFilter) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(FlowFrame.FRAME_LABEL); if (flowFilter.getFlowStatus() != null) { traversal = traversal.has(FlowFrame.STATUS_PROPERTY, FlowStatusConverter.INSTANCE.toGraphProperty(flowFilter.getFlowStatus())); } return traversal; }).toListExplicit(FlowFrame.class).stream() .map(Flow::new) .collect(Collectors.toList()); } FermaFlowRepository(FramedGraphFactory<?> graphFactory, FlowPathRepository flowPathRepository,
                               TransactionManager transactionManager); }
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByFlowFilter(FlowFilter flowFilter) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(FlowFrame.FRAME_LABEL); if (flowFilter.getFlowStatus() != null) { traversal = traversal.has(FlowFrame.STATUS_PROPERTY, FlowStatusConverter.INSTANCE.toGraphProperty(flowFilter.getFlowStatus())); } return traversal; }).toListExplicit(FlowFrame.class).stream() .map(Flow::new) .collect(Collectors.toList()); } FermaFlowRepository(FramedGraphFactory<?> graphFactory, FlowPathRepository flowPathRepository,
                               TransactionManager transactionManager); @Override long countFlows(); @Override Collection<Flow> findAll(); @Override boolean exists(String flowId); @Override Optional<Flow> findById(String flowId); @Override Collection<Flow> findByGroupId(String flowGroupId); @Override Collection<String> findFlowsIdByGroupId(String flowGroupId); @Override Collection<Flow> findWithPeriodicPingsEnabled(); @Override Collection<Flow> findByEndpoint(SwitchId switchId, int port); @Override Optional<Flow> findByEndpointAndVlan(SwitchId switchId, int port, int vlan); @Override Optional<Flow> findOneSwitchFlowBySwitchIdInPortAndOutVlan(SwitchId switchId, int inPort, int outVlan); @Override Collection<Flow> findOneSwitchFlows(SwitchId switchId); @Override Collection<Flow> findByEndpointWithMultiTableSupport(SwitchId switchId, int port); @Override Collection<String> findFlowsIdsByEndpointWithMultiTableSupport(SwitchId switchId, int port); @Override Collection<String> findFlowIdsForMultiSwitchFlowsByEndpointWithMultiTableSupport(SwitchId switchId,
                                                                                            int port); @Override Collection<Flow> findByEndpointSwitch(SwitchId switchId); @Override Collection<Flow> findByEndpointSwitchWithMultiTableSupport(SwitchId switchId); @Override Collection<Flow> findByEndpointSwitchWithEnabledLldp(SwitchId switchId); @Override Collection<Flow> findByEndpointSwitchWithEnabledArp(SwitchId switchId); @Override Collection<Flow> findInactiveFlows(); @Override Collection<Flow> findByFlowFilter(FlowFilter flowFilter); @Override Optional<String> getOrCreateFlowGroupId(String flowId); @Override void updateStatus(@NonNull String flowId, @NonNull FlowStatus flowStatus); @Override void updateStatus(String flowId, FlowStatus flowStatus, String flowStatusInfo); @Override void updateStatusInfo(String flowId, String flowStatusInfo); @Override @TransactionRequired void updateStatusSafe(Flow flow, FlowStatus flowStatus, String flowStatusInfo); @Override long computeFlowsBandwidthSum(Set<String> flowIds); @Override Optional<Flow> remove(String flowId); }
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<Flow> findByFlowFilter(FlowFilter flowFilter) { return framedGraph().traverse(g -> { GraphTraversal<Vertex, Vertex> traversal = g.V() .hasLabel(FlowFrame.FRAME_LABEL); if (flowFilter.getFlowStatus() != null) { traversal = traversal.has(FlowFrame.STATUS_PROPERTY, FlowStatusConverter.INSTANCE.toGraphProperty(flowFilter.getFlowStatus())); } return traversal; }).toListExplicit(FlowFrame.class).stream() .map(Flow::new) .collect(Collectors.toList()); } FermaFlowRepository(FramedGraphFactory<?> graphFactory, FlowPathRepository flowPathRepository,
                               TransactionManager transactionManager); @Override long countFlows(); @Override Collection<Flow> findAll(); @Override boolean exists(String flowId); @Override Optional<Flow> findById(String flowId); @Override Collection<Flow> findByGroupId(String flowGroupId); @Override Collection<String> findFlowsIdByGroupId(String flowGroupId); @Override Collection<Flow> findWithPeriodicPingsEnabled(); @Override Collection<Flow> findByEndpoint(SwitchId switchId, int port); @Override Optional<Flow> findByEndpointAndVlan(SwitchId switchId, int port, int vlan); @Override Optional<Flow> findOneSwitchFlowBySwitchIdInPortAndOutVlan(SwitchId switchId, int inPort, int outVlan); @Override Collection<Flow> findOneSwitchFlows(SwitchId switchId); @Override Collection<Flow> findByEndpointWithMultiTableSupport(SwitchId switchId, int port); @Override Collection<String> findFlowsIdsByEndpointWithMultiTableSupport(SwitchId switchId, int port); @Override Collection<String> findFlowIdsForMultiSwitchFlowsByEndpointWithMultiTableSupport(SwitchId switchId,
                                                                                            int port); @Override Collection<Flow> findByEndpointSwitch(SwitchId switchId); @Override Collection<Flow> findByEndpointSwitchWithMultiTableSupport(SwitchId switchId); @Override Collection<Flow> findByEndpointSwitchWithEnabledLldp(SwitchId switchId); @Override Collection<Flow> findByEndpointSwitchWithEnabledArp(SwitchId switchId); @Override Collection<Flow> findInactiveFlows(); @Override Collection<Flow> findByFlowFilter(FlowFilter flowFilter); @Override Optional<String> getOrCreateFlowGroupId(String flowId); @Override void updateStatus(@NonNull String flowId, @NonNull FlowStatus flowStatus); @Override void updateStatus(String flowId, FlowStatus flowStatus, String flowStatusInfo); @Override void updateStatusInfo(String flowId, String flowStatusInfo); @Override @TransactionRequired void updateStatusSafe(Flow flow, FlowStatus flowStatus, String flowStatusInfo); @Override long computeFlowsBandwidthSum(Set<String> flowIds); @Override Optional<Flow> remove(String flowId);  }