@Test public void shouldNotConsumeVlansForSingleSwitchFlows() throws ResourceAllocationException { transactionManager.doInTransaction(() -> { final int attemps = (flowResourcesConfig.getMaxFlowTransitVlan() - flowResourcesConfig.getMinFlowTransitVlan()) / 2 + 1; for (int i = 0; i < attemps; i++) { thirdFlow.setFlowId(format("third-flow-%d", i)); Flow flow3 = convertFlow(thirdFlow); resourcesManager.allocateFlowResources(flow3); } }); }
public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } }
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } }
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); }
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
                                                                      PathId oppositePathId,
                                                                      FlowEncapsulationType encapsulationType); }
FlowResourcesManager { public FlowResources allocateFlowResources(Flow flow) throws ResourceAllocationException { log.debug("Allocate flow resources for {}.", flow); PathId forwardPathId = generatePathId(flow.getFlowId()); PathId reversePathId = generatePathId(flow.getFlowId()); try { return allocateResources(flow, forwardPathId, reversePathId); } catch (ConstraintViolationException | ResourceNotAvailableException ex) { throw new ResourceAllocationException("Unable to allocate resources", ex); } } FlowResourcesManager(PersistenceManager persistenceManager, FlowResourcesConfig config); FlowResources allocateFlowResources(Flow flow); void deallocatePathResources(PathId pathId, long unmaskedCookie, FlowEncapsulationType encapsulationType); void deallocatePathResources(FlowResources resources); Optional<EncapsulationResources> getEncapsulationResources(PathId pathId,
                                                                      PathId oppositePathId,
                                                                      FlowEncapsulationType encapsulationType);  }