use of org.onosproject.lisp.ctl.LispRouter in project onos by opennetworkinglab.
the class LispMapServer method sendSmrMessage.
/**
* Sends SMR (Solicit Map Request) to their subscribers.
*
* @param eidRecord the updated EID
*/
private void sendSmrMessage(LispEidRecord eidRecord) {
RequestBuilder builder = new DefaultRequestBuilder();
LispAfiAddress msAddress = null;
try {
msAddress = new LispIpv4Address(IpAddress.valueOf(InetAddress.getLocalHost()));
} catch (UnknownHostException e) {
log.warn("Source EID is not found, {}", e.getMessage());
}
LispMapRequest msg = builder.withIsSmr(true).withIsSmrInvoked(true).withIsProbe(false).withIsPitr(false).withIsAuthoritative(false).withIsMapDataPresent(false).withSourceEid(msAddress).withEidRecords(ImmutableList.of(eidRecord)).build();
LispRouterFactory routerFactory = LispRouterFactory.getInstance();
Collection<LispRouter> routers = routerFactory.getRouters();
routers.forEach(router -> {
if (isInEidRecordRange(eidRecord, router.getEidRecords())) {
router.sendMessage(msg);
}
});
}
use of org.onosproject.lisp.ctl.LispRouter in project onos by opennetworkinglab.
the class LispControllerImplTest method testAddRemoveConnectedRouter.
/**
* Tests adding and removing connected routers.
*/
@Test
public void testAddRemoveConnectedRouter() {
// Test adding connected routers into agent
boolean addRouter1 = agent.addConnectedRouter(routerId1, router1);
assertThat(addRouter1, is(true));
boolean addRouter2 = agent.addConnectedRouter(routerId2, router2);
assertThat(addRouter2, is(true));
boolean addRouter3 = agent.addConnectedRouter(routerId3, router3);
assertThat(addRouter3, is(true));
// Test the callback methods that contained in router listener is fired
assertThat(routerListener.addedIds, hasSize(3));
assertThat(routerListener.addedIds, hasItems(routerId1, routerId2, routerId3));
// Test adding a router twice (duplicated router)
// this should return false to indicate that there is already a router
// has been added previously
boolean addBadRouter1 = agent.addConnectedRouter(routerId1, router1);
assertThat(addBadRouter1, is(false));
// Also make sure that the duplicated router will never increase the counter
assertThat(controller.connectedRouters.size(), is(3));
// Test querying the router list
Stream<LispRouter> queriedRouters = makeIntoStream(controller.getRouters());
long routerCount = queriedRouters.count();
assertThat(routerCount, is(3L));
// Test querying the individual router
LispRouter queriedRouter = controller.getRouter(routerId1);
assertThat(queriedRouter, is(router1));
// Test removing a router from connected router collection
agent.removeConnectedRouter(routerId2);
Stream<LispRouter> queriedRoutersAfterRemoval = makeIntoStream(controller.getRouters());
long routerCountAfterRemoval = queriedRoutersAfterRemoval.count();
assertThat(routerCountAfterRemoval, is(2L));
// Test the callback methods that contained in router listener is fired
assertThat(routerListener.removedIds, hasSize(1));
assertThat(routerListener.removedIds, hasItems(routerId2));
// Test querying the removed switch
LispRouter queriedRouterAfterRemoval = controller.getRouter(routerId2);
assertThat(queriedRouterAfterRemoval, nullValue());
}
Aggregations