use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class RouteManager method activate.
@Activate
protected void activate() {
routeMonitor = new RouteMonitor(this, clusterService, storageService);
routeResolver = new RouteResolver(this, hostService);
threadFactory = groupedThreads("onos/route", "listener-%d", log);
hostEventExecutors = new PredictableExecutor(DEFAULT_BUCKETS, groupedThreads("onos/route-manager", "event-host-%d", log));
resolvedRouteStore = new DefaultResolvedRouteStore();
routeStore.setDelegate(delegate);
hostService.addListener(hostListener);
routeStore.getRouteTables().stream().flatMap(id -> routeStore.getRoutes(id).stream()).forEach(routeSet -> routeResolver.resolve(routeSet));
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class BgpSessionManagerTest method setUp.
@Before
public void setUp() throws Exception {
peer1 = new TestBgpPeer(BGP_PEER1_ID);
peer2 = new TestBgpPeer(BGP_PEER2_ID);
peer3 = new TestBgpPeer(BGP_PEER3_ID);
peers.clear();
peers.add(peer1);
peers.add(peer2);
peers.add(peer3);
//
// Setup the BGP Session Manager to test, and start listening for BGP
// connections.
//
bgpSessionManager = new BgpSessionManager();
routeService = createNiceMock(RouteAdminService.class);
replay(routeService);
bgpSessionManager.routeService = routeService;
ClusterService clusterService = createMock(ClusterService.class);
expect(clusterService.getLocalNode()).andReturn(new DefaultControllerNode(NODE_ID, LOCAL)).anyTimes();
replay(clusterService);
bgpSessionManager.clusterService = clusterService;
// NOTE: We use port 0 to bind on any available port
ComponentContext componentContext = createMock(ComponentContext.class);
getDictionaryMock(componentContext);
replay(componentContext);
bgpSessionManager.activate(componentContext);
// Get the port number the BGP Session Manager is listening on
Channel serverChannel = TestUtils.getField(bgpSessionManager, "serverChannel");
SocketAddress socketAddress = serverChannel.getLocalAddress();
InetSocketAddress inetSocketAddress = (InetSocketAddress) socketAddress;
InetAddress connectToAddress = InetAddresses.forString("127.0.0.1");
connectToSocket = new InetSocketAddress(connectToAddress, inetSocketAddress.getPort());
//
// Setup the AS Paths
//
ArrayList<BgpRouteEntry.PathSegment> pathSegments = new ArrayList<>();
byte pathSegmentType1 = (byte) BgpConstants.Update.AsPath.AS_SEQUENCE;
ArrayList<Long> segmentAsNumbers1 = new ArrayList<>();
segmentAsNumbers1.add(65010L);
segmentAsNumbers1.add(65020L);
segmentAsNumbers1.add(65030L);
BgpRouteEntry.PathSegment pathSegment1 = new BgpRouteEntry.PathSegment(pathSegmentType1, segmentAsNumbers1);
pathSegments.add(pathSegment1);
asPathShort = new BgpRouteEntry.AsPath(new ArrayList<>(pathSegments));
//
byte pathSegmentType2 = (byte) BgpConstants.Update.AsPath.AS_SET;
ArrayList<Long> segmentAsNumbers2 = new ArrayList<>();
segmentAsNumbers2.add(65041L);
segmentAsNumbers2.add(65042L);
segmentAsNumbers2.add(65043L);
BgpRouteEntry.PathSegment pathSegment2 = new BgpRouteEntry.PathSegment(pathSegmentType2, segmentAsNumbers2);
pathSegments.add(pathSegment2);
//
asPathLong = new BgpRouteEntry.AsPath(pathSegments);
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class ControlMetricsWebResource method cpuMetrics.
/**
* Returns cpu metrics.
*
* @return cpu metrics
* @onos.rsModel CpuMetrics
*/
@GET
@Path("cpu_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response cpuMetrics() {
ObjectNode root = mapper().createObjectNode();
ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
ClusterService clusterService = get(ClusterService.class);
NodeId localNodeId = clusterService.getLocalNode().id();
metricsStats(monitorService, localNodeId, CPU_METRICS, root);
return ok(root).build();
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class ControlMetricsWebResource method diskMetrics.
/**
* Returns disk metrics of all resources.
*
* @return disk metrics of all resources
* @onos.rsModel DiskMetrics
*/
@GET
@Path("disk_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response diskMetrics() {
ObjectNode root = mapper().createObjectNode();
ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
ClusterService clusterService = get(ClusterService.class);
NodeId localNodeId = clusterService.getLocalNode().id();
ArrayNode diskNodes = root.putArray("disks");
monitorService.availableResourcesSync(localNodeId, DISK).forEach(name -> {
ObjectNode diskNode = mapper().createObjectNode();
ObjectNode valueNode = mapper().createObjectNode();
metricsStats(monitorService, localNodeId, DISK_METRICS, name, valueNode);
diskNode.put("name", name);
diskNode.set("value", valueNode);
diskNodes.add(diskNode);
});
return ok(root).build();
}
use of org.onosproject.cluster.ClusterService in project onos by opennetworkinglab.
the class ControlMetricsWebResource method networkMetrics.
/**
* Returns network metrics of all resources.
*
* @return network metrics of all resources
* @onos.rsModel NetworkMetrics
*/
@GET
@Path("network_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response networkMetrics() {
ObjectNode root = mapper().createObjectNode();
ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
ClusterService clusterService = get(ClusterService.class);
NodeId localNodeId = clusterService.getLocalNode().id();
ArrayNode networkNodes = root.putArray("networks");
monitorService.availableResourcesSync(localNodeId, NETWORK).forEach(name -> {
ObjectNode networkNode = mapper().createObjectNode();
ObjectNode valueNode = mapper().createObjectNode();
metricsStats(monitorService, localNodeId, NETWORK_METRICS, name, valueNode);
networkNode.put("name", name);
networkNode.set("value", valueNode);
networkNodes.add(networkNode);
});
return ok(root).build();
}
Aggregations