LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public LBPool createPool(LBPool pool) { if (pool == null) pool = new LBPool(); pools.put(pool.id, pool); if (pool.vipId != null && vips.containsKey(pool.vipId)) vips.get(pool.vipId).pools.add(pool.id); else { log.error("specified vip-id must exist"); pool.vipId = null; pools.put(pool.id, pool); } return pool; }  @Override String getName(); @Override boolean isCallbackOrderingPrereq(OFType type, String name); @Override boolean isCallbackOrderingPostreq(OFType type, String name); @Override net.floodlightcontroller.core.IListener.Command receive(IOFSwitch sw, OFMessage msg, FloodlightContext cntx); void pushPacket(IPacket packet, 
                           IOFSwitch sw,
                           OFBufferId bufferId,
                           OFPort inPort,
                           OFPort outPort, 
                           FloodlightContext cntx,
                           boolean flush); void pushStaticVipRoute(boolean inBound, Route route, IPClient client, LBMember member, IOFSwitch pinSwitch); @Override Collection<LBVip> listVips(); @Override Collection<LBVip> listVip(String vipId); @Override LBVip createVip(LBVip vip); @Override LBVip updateVip(LBVip vip); @Override int removeVip(String vipId); @Override Collection<LBPool> listPools(); @Override Collection<LBPool> listPool(String poolId); @Override LBPool createPool(LBPool pool); @Override LBPool updatePool(LBPool pool); @Override int removePool(String poolId); @Override Collection<LBMember> listMembers(); @Override Collection<LBMember> listMember(String memberId); @Override Collection<LBMember> listMembersByPool(String poolId); @Override LBMember createMember(LBMember member); @Override LBMember updateMember(LBMember member); @Override int removeMember(String memberId); @Override Collection<LBMonitor> listMonitors(); @Override Collection<LBMonitor> listMonitor(String monitorId); @Override LBMonitor createMonitor(LBMonitor monitor); @Override LBMonitor updateMonitor(LBMonitor monitor); @Override int removeMonitor(String monitorId); @Override Collection<Class<? extends IFloodlightService>> getModuleServices(); @Override Map<Class<? extends IFloodlightService>, IFloodlightService> getServiceImpls(); @Override Collection<Class<? extends IFloodlightService>> getModuleDependencies(); @Override void init(FloodlightModuleContext context); @Override void startUp(FloodlightModuleContext context); public Comparator<SwitchPort> clusterIdComparator; }
@Test public void testCreatePool() { String postData1, postData2, postData3; IOException error = null; testCreateVip(); postData1 = "{\"id\":\"1\",\"name\":\"pool1\",\"protocol\":\"icmp\",\"vip_id\":\"1\"}"; postData2 = "{\"id\":\"2\",\"name\":\"pool2\",\"protocol\":\"tcp\",\"vip_id\":\"2\"}"; postData3 = "{\"id\":\"3\",\"name\":\"pool3\",\"protocol\":\"udp\",\"vip_id\":\"3\"}"; try { pool1 = poolsResource.jsonToPool(postData1); } catch (IOException e) { error = e; } try { pool2 = poolsResource.jsonToPool(postData2); } catch (IOException e) { error = e; } try { pool3 = poolsResource.jsonToPool(postData3); } catch (IOException e) { error = e; } assertFalse(pool1==null); assertFalse(pool2==null); assertFalse(pool3==null); assertTrue(error==null); lb.createPool(pool1); lb.createPool(pool2); lb.createPool(pool3); assertTrue(lb.pools.containsKey(pool1.id)); assertTrue(lb.vips.get(pool1.vipId).pools.contains(pool1.id)); assertTrue(lb.pools.containsKey(pool2.id)); assertTrue(lb.vips.get(pool2.vipId).pools.contains(pool2.id)); assertTrue(lb.pools.containsKey(pool3.id)); assertFalse(lb.vips.containsKey(pool3.vipId)); }