use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class DistributedApplicationStore method activateExistingApplications.
/**
* Activates applications that should be activated according to the distributed store.
*/
private void activateExistingApplications() {
log.info("Going to activate existing applications");
getApplicationNames().forEach(appName -> {
// Only update the application version if the application has already been installed.
ApplicationId appId = getId(appName);
if (appId != null) {
ApplicationDescription appDesc = getApplicationDescription(appName);
InternalApplicationHolder appHolder = Versioned.valueOrNull(apps.get(appId));
if (appHolder != null && appHolder.state == ACTIVATED) {
log.debug("App name and version from local system : {}, {}", appDesc.name(), appDesc.version());
log.debug("App name and version from app store : {}, {}", appHolder.app.id(), appHolder.app().version());
}
// If the application has already been activated, set the local state to active.
if (appHolder != null && appDesc.version().equals(appHolder.app().version()) && appHolder.state == ACTIVATED) {
log.info("Going to activate app : {}", appHolder.app.id());
setActive(appName);
updateTime(appName);
}
}
});
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class MeterRequestProtoTranslator method translate.
/**
* Translates gRPC MeterRequest to {@link MeterRequest}.
*
* @param meterRequest gRPC message
* @return {@link MeterRequest}
*/
public static MeterRequest translate(MeterRequestProtoOuterClass.MeterRequestProto meterRequest) {
DeviceId deviceid = DeviceId.deviceId(meterRequest.getDeviceId());
ApplicationId appId = ApplicationIdProtoTranslator.translate(meterRequest.getApplicationId());
Meter.Unit unit = MeterEnumsProtoTranslator.translate(meterRequest.getUnit()).get();
boolean burst = meterRequest.getIsBurst();
Collection<Band> bands = BandProtoTranslator.translate(meterRequest.getBandsList());
MeterRequest.Type type = (MeterRequest.Type) translate(meterRequest.getType()).get();
if (type == MeterRequest.Type.ADD) {
return DefaultMeterRequest.builder().forDevice(deviceid).fromApp(appId).withUnit(unit).withBands(bands).add();
} else {
return DefaultMeterRequest.builder().forDevice(deviceid).fromApp(appId).withUnit(unit).withBands(bands).remove();
}
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class DistributedApplicationIdStore method registerApplication.
@Override
public ApplicationId registerApplication(String name) {
ApplicationId exisitingAppId = registeredIds.asJavaMap().get(name);
if (exisitingAppId == null) {
ApplicationId newAppId = new DefaultApplicationId((int) appIdCounter.incrementAndGet(), name);
exisitingAppId = registeredIds.asJavaMap().putIfAbsent(name, newAppId);
return exisitingAppId == null ? newAppId : exisitingAppId;
} else {
return exisitingAppId;
}
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class MockCoreService method registerApplication.
@Override
public ApplicationId registerApplication(String name) {
// Check if the app already exists
ApplicationId appId = getAppId(name);
if (appId == null) {
appId = new DefaultApplicationId(nextAppId, name);
nextAppId += 1;
appIds.add(appId);
}
return appId;
}
use of org.onosproject.core.ApplicationId in project onos by opennetworkinglab.
the class ImrWebResource method getMonitoredIntents.
/**
* Get the list of monitored intents of a specific application.
* Shows for each intent key the related end points (as inElements and OutElements).
*
* @onos.rsModel monitoredIntentsGet
* @param id Application ID
* @param name Application Name
* @return 200 OK
*/
@GET
@Path("monitoredIntents/{id}/{name}")
@Produces(MediaType.APPLICATION_JSON)
public Response getMonitoredIntents(@PathParam("id") short id, @PathParam("name") String name) {
imrService = get(IntentMonitorAndRerouteService.class);
ApplicationId appId = new DefaultApplicationId(id, name);
ArrayNode jsonMonitoredIntents = getJsonMonitoredIntents(imrService.getMonitoredIntents(appId));
ObjectNode result = mapper.createObjectNode();
result.putArray(ROOT_FIELD_MONITORED_INTENTS).addAll(jsonMonitoredIntents);
return ok(result).build();
}
Aggregations