src-java/flowhs-topology/flowhs-storm-topology/src/main/java/org/openkilda/wfm/topology/flowhs/validation/FlowValidator.java
/**
     * Checks a flow for endpoints' conflicts.
     *
     * @throws InvalidFlowException is thrown in a case when flow endpoints conflict with existing flows.
     */
Checks a flow for endpoints' conflicts.
@throws InvalidFlowException is thrown in a case when flow endpoints conflict with existing flows.
Checks a flow for endpoints ' conflicts . @throws InvalidFlowException is thrown in a case when flow endpoints conflict with existing flows .
private void checkFlowForFlowConflicts(String flowId, EndpointDescriptor descriptor, Set<String> bulkUpdateFlowIds)
            throws InvalidFlowException {
        final FlowEndpoint endpoint = descriptor.getEndpoint();
        for (Flow entry : flowRepository.findByEndpoint(endpoint.getSwitchId(), endpoint.getPortNumber())) {
            if (flowId.equals(entry.getFlowId()) || bulkUpdateFlowIds.contains(entry.getFlowId())) {
                continue;
            }
            FlowEndpoint source = new FlowSourceAdapter(entry).getEndpoint();
            FlowEndpoint destination = new FlowDestAdapter(entry).getEndpoint();
            EndpointDescriptor conflict = null;
            if (endpoint.isSwitchPortVlanEquals(source)) {
                conflict = EndpointDescriptor.makeSource(source);
            } else if (endpoint.isSwitchPortVlanEquals(destination)) {
                conflict = EndpointDescriptor.makeDestination(destination);
            }
            if (conflict != null) {
                String errorMessage = format("Requested flow '%s' conflicts with existing flow '%s'. "
                                + "Details: requested flow '%s' %s: %s, "
                                + "existing flow '%s' %s: %s",
                        flowId, entry.getFlowId(),
                        flowId, descriptor.getName(), endpoint,
                        entry.getFlowId(), conflict.getName(), conflict.getEndpoint());
                throw new InvalidFlowException(errorMessage, ErrorType.ALREADY_EXISTS);
            }
        }
    }
private void checkFlowForFlowConflicts ( String flowId , EndpointDescriptor descriptor , Set < String > bulkUpdateFlowIds ) throws InvalidFlowException { final FlowEndpoint endpoint = descriptor . getEndpoint ( ) ; for ( Flow entry : flowRepository . findByEndpoint ( endpoint . getSwitchId ( ) , endpoint . getPortNumber ( ) ) ) { if ( flowId . equals ( entry . getFlowId ( ) ) || bulkUpdateFlowIds . contains ( entry . getFlowId ( ) ) ) { continue ; } FlowEndpoint source = new FlowSourceAdapter ( entry ) . getEndpoint ( ) ; FlowEndpoint destination = new FlowDestAdapter ( entry ) . getEndpoint ( ) ; EndpointDescriptor conflict = null ; if ( endpoint . isSwitchPortVlanEquals ( source ) ) { conflict = EndpointDescriptor . makeSource ( source ) ; } else if ( endpoint . isSwitchPortVlanEquals ( destination ) ) { conflict = EndpointDescriptor . makeDestination ( destination ) ; } if ( conflict != null ) { String errorMessage = format ( "Requested flow '%s' conflicts with existing flow '%s'. " + "Details: requested flow '%s' %s: %s, " + "existing flow '%s' %s: %s" , flowId , entry . getFlowId ( ) , flowId , descriptor . getName ( ) , endpoint , entry . getFlowId ( ) , conflict . getName ( ) , conflict . getEndpoint ( ) ) ; throw new InvalidFlowException ( errorMessage , ErrorType . ALREADY_EXISTS ) ; } } }
Checks a flow for endpoints' conflicts.
Checks a flow for endpoints ' conflicts .