@Test public void shouldFindIsByEndpointWithMultiTableSupport() { createTestFlow(TEST_FLOW_ID, switchA, PORT_1, VLAN_1, switchB, PORT_2, VLAN_2, true); createTestFlow(TEST_FLOW_ID_2, switchA, PORT_1, VLAN_2, switchB, PORT_2, 0, true); createTestFlow(TEST_FLOW_ID_3, switchA, PORT_1, VLAN_3, switchB, PORT_2, 0, false); createTestFlow(TEST_FLOW_ID_4, switchB, PORT_1, VLAN_1, switchB, PORT_3, VLAN_1, true); Collection<String> flowIds = flowRepository.findFlowsIdsByEndpointWithMultiTableSupport(switchA.getSwitchId(), PORT_1); assertEquals(2, flowIds.size()); assertTrue(flowIds.contains(TEST_FLOW_ID)); assertTrue(flowIds.contains(TEST_FLOW_ID_2)); }
@Override public Collection<String> findFlowsIdsByEndpointWithMultiTableSupport(SwitchId switchId, int port) { Set<String> result = new HashSet<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.SRC_PORT_PROPERTY, port) .has(FlowFrame.SRC_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.DST_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.DST_PORT_PROPERTY, port) .has(FlowFrame.DST_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); return result; }
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<String> findFlowsIdsByEndpointWithMultiTableSupport(SwitchId switchId, int port) { Set<String> result = new HashSet<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.SRC_PORT_PROPERTY, port) .has(FlowFrame.SRC_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.DST_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.DST_PORT_PROPERTY, port) .has(FlowFrame.DST_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); return result; } }
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<String> findFlowsIdsByEndpointWithMultiTableSupport(SwitchId switchId, int port) { Set<String> result = new HashSet<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.SRC_PORT_PROPERTY, port) .has(FlowFrame.SRC_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.DST_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.DST_PORT_PROPERTY, port) .has(FlowFrame.DST_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); return result; } FermaFlowRepository(FramedGraphFactory<?> graphFactory, FlowPathRepository flowPathRepository,
                               TransactionManager transactionManager); }
FermaFlowRepository extends FermaGenericRepository<Flow, FlowData, FlowFrame> implements FlowRepository { @Override public Collection<String> findFlowsIdsByEndpointWithMultiTableSupport(SwitchId switchId, int port) { Set<String> result = new HashSet<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.SRC_PORT_PROPERTY, port) .has(FlowFrame.SRC_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.DST_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.DST_PORT_PROPERTY, port) .has(FlowFrame.DST_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); return result; } 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<String> findFlowsIdsByEndpointWithMultiTableSupport(SwitchId switchId, int port) { Set<String> result = new HashSet<>(); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.SRC_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.SRC_PORT_PROPERTY, port) .has(FlowFrame.SRC_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); framedGraph().traverse(g -> g.V() .hasLabel(FlowFrame.FRAME_LABEL) .has(FlowFrame.DST_SWITCH_ID_PROPERTY, SwitchIdConverter.INSTANCE.toGraphProperty(switchId)) .has(FlowFrame.DST_PORT_PROPERTY, port) .has(FlowFrame.DST_MULTI_TABLE_PROPERTY, true) .values(FlowFrame.FLOW_ID_PROPERTY)) .getRawTraversal().toStream() .forEach(i -> result.add((String) i)); return result; } 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);  }