use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class ImrWebResource method getJsonNodesIntentStats.
/**
* Build the Json Nodes from the intent stats retrieved from {@link IntentMonitorAndRerouteService}.
*
* @param mapKeyToStats Intent statistics
* @return {@link ArrayNode} built from the statistics
*/
private ArrayNode getJsonNodesIntentStats(Map<ApplicationId, Map<Key, List<FlowEntry>>> mapKeyToStats) {
final ArrayNode rootArrayNode = mapper.createArrayNode();
mapKeyToStats.forEach((appId, mapIntentKeyStats) -> {
ObjectNode appObjNode = codec(ApplicationId.class).encode(appId, this);
ArrayNode intentArrayNode = appObjNode.putArray("intents");
mapIntentKeyStats.forEach((intentKey, lstStats) -> {
ObjectNode intentKeyObjNode = mapper.createObjectNode();
ArrayNode statsArrayNode = intentKeyObjNode.putArray(intentKey.toString());
lstStats.forEach(stat -> {
statsArrayNode.add(codec(FlowEntry.class).encode(stat, this));
});
intentArrayNode.add(intentKeyObjNode);
});
rootArrayNode.add(appObjNode);
});
return rootArrayNode;
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class IntentMonitorAndRerouteManager method applyPath.
@Override
public boolean applyPath(Route route) {
checkNotNull(route, "Route to apply must be not null");
checkNotNull(route.appId(), "Application id must be not null");
checkNotNull(route.key(), "Intent key to apply must be not null");
checkNotNull(route.paths(), "New path must be not null");
checkArgument(route.paths().size() >= 1);
ApplicationId appId = route.appId();
Key key = route.key();
// check if the app and the intent key are monitored
if (!monitoredIntents.containsKey(appId)) {
return false;
}
if (!monitoredIntents.get(appId).containsKey(key)) {
return false;
}
// TODO: now we manage only the unsplittable routing
Path currentPath = route.paths().stream().max(Comparator.comparing(Path::weight)).get();
// in this case remove them from the list
if (currentPath.path().get(0) instanceof HostId) {
currentPath.path().remove(0);
}
if (currentPath.path().get(currentPath.path().size() - 1) instanceof HostId) {
currentPath.path().remove(currentPath.path().size() - 1);
}
List<Link> links = createPathFromDeviceList(currentPath.path());
// Generate the new Link collection intent, if not possible it will return the old intent
ConnectivityIntent intent = generateLinkCollectionIntent(links, key, appId);
storeMonitoredIntent(intent);
intentService.submit(intent);
return true;
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class DistributedK8sIpamStore method activate.
@Activate
protected void activate() {
ApplicationId appId = coreService.registerApplication(APP_ID);
allocatedStore = storageService.<String, K8sIpam>consistentMapBuilder().withSerializer(Serializer.using(SERIALIZER_K8S_IPAM)).withName("k8s-ipam-allocated-store").withApplicationId(appId).build();
availableStore = storageService.<String, K8sIpam>consistentMapBuilder().withSerializer(Serializer.using(SERIALIZER_K8S_IPAM)).withName("k8s-ipam-available-store").withApplicationId(appId).build();
log.info("Started");
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class OpticalIntentsWebResource method deleteIntent.
/**
* Delete the specified optical intent.
*
* @param appId application identifier
* @param keyString intent key
* @return 204 NO CONTENT
*/
@DELETE
@Consumes(MediaType.APPLICATION_JSON)
@Path("{appId}/{key}")
public Response deleteIntent(@PathParam("appId") String appId, @PathParam("key") String keyString) {
final ApplicationId app = get(CoreService.class).getAppId(appId);
nullIsNotFound(app, "Application Id not found");
IntentService intentService = get(IntentService.class);
Intent intent = intentService.getIntent(Key.of(keyString, app));
if (intent == null) {
intent = intentService.getIntent(Key.of(Long.decode(keyString), app));
}
nullIsNotFound(intent, "Intent Id is not found");
if ((intent instanceof OpticalConnectivityIntent) || (intent instanceof OpticalCircuitIntent)) {
intentService.withdraw(intent);
} else {
throw new IllegalArgumentException("Specified intent is not of type OpticalConnectivityIntent");
}
return Response.noContent().build();
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class PortLoadBalancerListCommand method doExecute.
@Override
public void doExecute() {
PortLoadBalancerService service = get(PortLoadBalancerService.class);
// Get port load balancers and reservations
Map<PortLoadBalancerId, PortLoadBalancer> portLoadBalancerStore = service.getPortLoadBalancers();
Map<PortLoadBalancerId, ApplicationId> portLoadBalancerResStore = service.getReservations();
// Print id -> ports, mode, reservation
portLoadBalancerStore.forEach((portLoadBalancerId, portLoadBalancer) -> print("%s -> %s, %s, %s", portLoadBalancerId, portLoadBalancer.ports(), portLoadBalancer.mode(), portLoadBalancerResStore.get(portLoadBalancerId) == null ? AVAILABLE : portLoadBalancerResStore.get(portLoadBalancerId).name()));
}
Aggregations