@Test public void testAddPeerToSpeaker() throws Exception { int initialSize = bgpConfig.getSpeakerWithName("bgp1").peers().size(); bgpConfig.addPeerToSpeaker("bgp1", IP4); assertEquals(initialSize + 1, bgpConfig.getSpeakerWithName("bgp1").peers().size()); }
public void addPeerToSpeaker(String speakerName, IpAddress peerAddress) { JsonNode speakersNode = object.get(SPEAKERS); speakersNode.forEach(jsonNode -> { if (jsonNode.hasNonNull(NAME) && jsonNode.get(NAME).asText().equals(speakerName)) { ArrayNode peersNode = (ArrayNode) jsonNode.get(PEERS); for (int i = 0; i < peersNode.size(); i++) { if (peersNode.get(i).asText().equals(peerAddress.toString())) { return; } } peersNode.add(peerAddress.toString()); } }); }
BgpConfig extends Config<ApplicationId> { public void addPeerToSpeaker(String speakerName, IpAddress peerAddress) { JsonNode speakersNode = object.get(SPEAKERS); speakersNode.forEach(jsonNode -> { if (jsonNode.hasNonNull(NAME) && jsonNode.get(NAME).asText().equals(speakerName)) { ArrayNode peersNode = (ArrayNode) jsonNode.get(PEERS); for (int i = 0; i < peersNode.size(); i++) { if (peersNode.get(i).asText().equals(peerAddress.toString())) { return; } } peersNode.add(peerAddress.toString()); } }); } }
BgpConfig extends Config<ApplicationId> { public void addPeerToSpeaker(String speakerName, IpAddress peerAddress) { JsonNode speakersNode = object.get(SPEAKERS); speakersNode.forEach(jsonNode -> { if (jsonNode.hasNonNull(NAME) && jsonNode.get(NAME).asText().equals(speakerName)) { ArrayNode peersNode = (ArrayNode) jsonNode.get(PEERS); for (int i = 0; i < peersNode.size(); i++) { if (peersNode.get(i).asText().equals(peerAddress.toString())) { return; } } peersNode.add(peerAddress.toString()); } }); }  }
BgpConfig extends Config<ApplicationId> { public void addPeerToSpeaker(String speakerName, IpAddress peerAddress) { JsonNode speakersNode = object.get(SPEAKERS); speakersNode.forEach(jsonNode -> { if (jsonNode.hasNonNull(NAME) && jsonNode.get(NAME).asText().equals(speakerName)) { ArrayNode peersNode = (ArrayNode) jsonNode.get(PEERS); for (int i = 0; i < peersNode.size(); i++) { if (peersNode.get(i).asText().equals(peerAddress.toString())) { return; } } peersNode.add(peerAddress.toString()); } }); }  Set<BgpSpeakerConfig> bgpSpeakers(); BgpSpeakerConfig getSpeakerWithName(String name); void addSpeaker(BgpSpeakerConfig speaker); void removeSpeaker(String speakerName); void addPeerToSpeaker(String speakerName, IpAddress peerAddress); BgpSpeakerConfig getSpeakerFromPeer(IpAddress peerAddress); void removePeerFromSpeaker(BgpSpeakerConfig speaker, IpAddress peerAddress); }
BgpConfig extends Config<ApplicationId> { public void addPeerToSpeaker(String speakerName, IpAddress peerAddress) { JsonNode speakersNode = object.get(SPEAKERS); speakersNode.forEach(jsonNode -> { if (jsonNode.hasNonNull(NAME) && jsonNode.get(NAME).asText().equals(speakerName)) { ArrayNode peersNode = (ArrayNode) jsonNode.get(PEERS); for (int i = 0; i < peersNode.size(); i++) { if (peersNode.get(i).asText().equals(peerAddress.toString())) { return; } } peersNode.add(peerAddress.toString()); } }); }  Set<BgpSpeakerConfig> bgpSpeakers(); BgpSpeakerConfig getSpeakerWithName(String name); void addSpeaker(BgpSpeakerConfig speaker); void removeSpeaker(String speakerName); void addPeerToSpeaker(String speakerName, IpAddress peerAddress); BgpSpeakerConfig getSpeakerFromPeer(IpAddress peerAddress); void removePeerFromSpeaker(BgpSpeakerConfig speaker, IpAddress peerAddress); static final String SPEAKERS; static final String CONNECT_POINT; static final String NAME; static final String PEERS; static final String VLAN; }