Search in sources :

Example 1 with NodeId

use of org.onosproject.cluster.NodeId in project onos by opennetworkinglab.

the class ControlMetricsStatsListCommand method doExecute.

@Override
protected void doExecute() {
    ControlPlaneMonitorService service = get(ControlPlaneMonitorService.class);
    NodeId nodeId = NodeId.nodeId(node);
    switch(type) {
        case "cpu":
            printMetricsStats(service, nodeId, CPU_METRICS);
            break;
        case "memory":
            printMetricsStats(service, nodeId, MEMORY_METRICS);
            break;
        case "disk":
            printMetricsStats(service, nodeId, DISK_METRICS, name);
            break;
        case "network":
            printMetricsStats(service, nodeId, NETWORK_METRICS, name);
            break;
        case "control_message":
            if (name != null) {
                printMetricsStats(service, nodeId, CONTROL_MESSAGE_METRICS, DeviceId.deviceId(name));
            }
            break;
        default:
            print(INVALID_TYPE);
            break;
    }
}
Also used : ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId)

Example 2 with NodeId

use of org.onosproject.cluster.NodeId 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();
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with NodeId

use of org.onosproject.cluster.NodeId 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();
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 4 with NodeId

use of org.onosproject.cluster.NodeId 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();
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 5 with NodeId

use of org.onosproject.cluster.NodeId in project onos by opennetworkinglab.

the class ControlMetricsWebResource method memoryMetrics.

/**
 * Returns memory metrics.
 *
 * @return memory metrics
 * @onos.rsModel MemoryMetrics
 */
@GET
@Path("memory_metrics")
@Produces(MediaType.APPLICATION_JSON)
public Response memoryMetrics() {
    ObjectNode root = mapper().createObjectNode();
    ControlPlaneMonitorService monitorService = get(ControlPlaneMonitorService.class);
    ClusterService clusterService = get(ClusterService.class);
    NodeId localNodeId = clusterService.getLocalNode().id();
    metricsStats(monitorService, localNodeId, MEMORY_METRICS, root);
    return ok(root).build();
}
Also used : ClusterService(org.onosproject.cluster.ClusterService) ObjectNode(com.fasterxml.jackson.databind.node.ObjectNode) ControlPlaneMonitorService(org.onosproject.cpman.ControlPlaneMonitorService) NodeId(org.onosproject.cluster.NodeId) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Aggregations

NodeId (org.onosproject.cluster.NodeId)145 ClusterService (org.onosproject.cluster.ClusterService)36 DeviceId (org.onosproject.net.DeviceId)36 Set (java.util.Set)26 MastershipRole (org.onosproject.net.MastershipRole)23 ControllerNode (org.onosproject.cluster.ControllerNode)22 Test (org.junit.Test)18 Activate (org.osgi.service.component.annotations.Activate)18 List (java.util.List)16 MastershipService (org.onosproject.mastership.MastershipService)15 ObjectNode (com.fasterxml.jackson.databind.node.ObjectNode)13 Map (java.util.Map)12 ImmutableSet (com.google.common.collect.ImmutableSet)11 ArrayList (java.util.ArrayList)11 Collectors (java.util.stream.Collectors)11 HashSet (java.util.HashSet)10 Optional (java.util.Optional)10 ClusterCommunicationService (org.onosproject.store.cluster.messaging.ClusterCommunicationService)10 Component (org.osgi.service.component.annotations.Component)9 Deactivate (org.osgi.service.component.annotations.Deactivate)9