@Test(expected = ResourceNotAvailableException.class) public void vxlanPoolFullTest() { transactionManager.doInTransaction(() -> { for (int i = MIN_VXLAN; i <= MAX_VXLAN + 1; i++) { Flow flow = Flow.builder() .flowId(format("flow_%d", i)).srcSwitch(SWITCH_A).destSwitch(SWITCH_B).build(); assertTrue(vxlanPool.allocate(flow, new PathId(format("path_%d", i)), new PathId(format("op_path_%d", i))).getVxlan().getVni() > 0); } }); }
@Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); }
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } }
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); }
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); @Override VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<VxlanEncapsulation> get(PathId pathId, PathId oppositePathId); }
VxlanPool implements EncapsulationResourcesProvider<VxlanEncapsulation> { @Override public VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId) { return get(oppositePathId, null) .orElseGet(() -> allocate(flow, pathId)); } VxlanPool(PersistenceManager persistenceManager, int minVxlan, int maxVxlan, int poolSize); @Override VxlanEncapsulation allocate(Flow flow, PathId pathId, PathId oppositePathId); @Override void deallocate(PathId pathId); @Override Optional<VxlanEncapsulation> get(PathId pathId, PathId oppositePathId);  }