@Test public void testCreateMember() { String postData1, postData2, postData3, postData4; IOException error = null; testCreateVip(); testCreatePool(); postData1 = "{\"id\":\"1\",\"address\":\"10.0.0.3\",\"port\":\"8\",\"pool_id\":\"1\"}"; postData2 = "{\"id\":\"2\",\"address\":\"10.0.0.4\",\"port\":\"8\",\"pool_id\":\"1\"}"; postData3 = "{\"id\":\"3\",\"address\":\"10.0.0.5\",\"port\":\"100\",\"pool_id\":\"2\"}"; postData4 = "{\"id\":\"4\",\"address\":\"10.0.0.6\",\"port\":\"100\",\"pool_id\":\"2\"}"; try { member1 = membersResource.jsonToMember(postData1); } catch (IOException e) { error = e; } try { member2 = membersResource.jsonToMember(postData2); } catch (IOException e) { error = e; } try { member3 = membersResource.jsonToMember(postData3); } catch (IOException e) { error = e; } try { member4 = membersResource.jsonToMember(postData4); } catch (IOException e) { error = e; } assertFalse(member1==null); assertFalse(member2==null); assertFalse(member3==null); assertFalse(member4==null); assertTrue(error==null); lb.createMember(member1); lb.createMember(member2); lb.createMember(member3); lb.createMember(member4); lb.createMember(member1); assertTrue(lb.members.containsKey(member1.id)); assertTrue(lb.members.containsKey(member2.id)); assertTrue(lb.members.containsKey(member3.id)); assertTrue(lb.members.containsKey(member4.id)); assertTrue(lb.pools.get(member1.poolId).members.size()==2); assertTrue(lb.pools.get(member3.poolId).members.size()==2); assertTrue(lb.vips.get(member1.vipId)!=null); }
@Override public LBMember createMember(LBMember member) { if (member == null) member = new LBMember(); members.put(member.id, member); memberIpToId.put(member.address, member.id); if (member.poolId != null && pools.get(member.poolId) != null) { member.vipId = pools.get(member.poolId).vipId; if (!pools.get(member.poolId).members.contains(member.id)) pools.get(member.poolId).members.add(member.id); } else log.error("member must be specified with non-null pool_id"); return member; }
LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public LBMember createMember(LBMember member) { if (member == null) member = new LBMember(); members.put(member.id, member); memberIpToId.put(member.address, member.id); if (member.poolId != null && pools.get(member.poolId) != null) { member.vipId = pools.get(member.poolId).vipId; if (!pools.get(member.poolId).members.contains(member.id)) pools.get(member.poolId).members.add(member.id); } else log.error("member must be specified with non-null pool_id"); return member; } }
LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public LBMember createMember(LBMember member) { if (member == null) member = new LBMember(); members.put(member.id, member); memberIpToId.put(member.address, member.id); if (member.poolId != null && pools.get(member.poolId) != null) { member.vipId = pools.get(member.poolId).vipId; if (!pools.get(member.poolId).members.contains(member.id)) pools.get(member.poolId).members.add(member.id); } else log.error("member must be specified with non-null pool_id"); return member; }  }
LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public LBMember createMember(LBMember member) { if (member == null) member = new LBMember(); members.put(member.id, member); memberIpToId.put(member.address, member.id); if (member.poolId != null && pools.get(member.poolId) != null) { member.vipId = pools.get(member.poolId).vipId; if (!pools.get(member.poolId).members.contains(member.id)) pools.get(member.poolId).members.add(member.id); } else log.error("member must be specified with non-null pool_id"); return member; }  @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,
                           int bufferId,
                           short inPort,
                           short outPort, 
                           FloodlightContext cntx,
                           boolean flush); void pushStaticVipRoute(boolean inBound, Route route, IPClient client, LBMember member, long 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); static void parseActionString(OFFlowMod flowMod, String actionstr, Logger log); }
LoadBalancer implements IFloodlightModule,
    ILoadBalancerService, IOFMessageListener { @Override public LBMember createMember(LBMember member) { if (member == null) member = new LBMember(); members.put(member.id, member); memberIpToId.put(member.address, member.id); if (member.poolId != null && pools.get(member.poolId) != null) { member.vipId = pools.get(member.poolId).vipId; if (!pools.get(member.poolId).members.contains(member.id)) pools.get(member.poolId).members.add(member.id); } else log.error("member must be specified with non-null pool_id"); return member; }  @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,
                           int bufferId,
                           short inPort,
                           short outPort, 
                           FloodlightContext cntx,
                           boolean flush); void pushStaticVipRoute(boolean inBound, Route route, IPClient client, LBMember member, long 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); static void parseActionString(OFFlowMod flowMod, String actionstr, Logger log); public Comparator<SwitchPort> clusterIdComparator; }