use of org.onosproject.app.ApplicationEvent in project onos by opennetworkinglab.
the class DistributedApplicationStore method fetchBits.
/**
* Fetches the bits from the cluster peers.
*/
private void fetchBits(Application app, boolean delegateInstallation) {
ControllerNode localNode = clusterService.getLocalNode();
CountDownLatch latch = new CountDownLatch(1);
// FIXME: send message with name & version to make sure we don't get served old bits
log.info("Downloading bits for application {} for version : {}", app.id().name(), app.version());
for (ControllerNode node : clusterService.getNodes()) {
if (latch.getCount() == 0) {
break;
}
if (node.equals(localNode)) {
continue;
}
clusterCommunicator.sendAndReceive(app.id().name(), APP_BITS_REQUEST, s -> s.getBytes(Charsets.UTF_8), Function.identity(), node.id()).whenCompleteAsync((bits, error) -> {
if (error == null && latch.getCount() > 0) {
saveApplication(new ByteArrayInputStream(bits));
log.info("Downloaded bits for application {} from node {}", app.id().name(), node.id());
latch.countDown();
if (delegateInstallation) {
if (log.isTraceEnabled()) {
log.trace("Delegate installation for {}", app.id());
}
notifyDelegate(new ApplicationEvent(APP_INSTALLED, app));
}
} else if (error != null) {
log.warn("Unable to fetch bits for application {} from node {}", app.id().name(), node.id());
}
}, messageHandlingExecutor);
}
try {
if (!latch.await(FETCH_TIMEOUT_MS, MILLISECONDS)) {
log.warn("Unable to fetch bits for application {}", app.id().name());
}
} catch (InterruptedException e) {
log.warn("Interrupted while fetching bits for application {}", app.id().name());
Thread.currentThread().interrupt();
}
}
use of org.onosproject.app.ApplicationEvent in project onos by opennetworkinglab.
the class SimpleApplicationStore method remove.
@Override
public void remove(ApplicationId appId) {
Application app = apps.remove(appId);
if (app != null) {
states.remove(appId);
delegate.notify(new ApplicationEvent(APP_UNINSTALLED, app));
purgeApplication(app.id().name());
}
}
use of org.onosproject.app.ApplicationEvent in project onos by opennetworkinglab.
the class SimpleApplicationStore method create.
@Override
public Application create(InputStream appDescStream) {
ApplicationDescription appDesc = saveApplication(appDescStream);
ApplicationId appId = idStore.registerApplication(appDesc.name());
DefaultApplication app = DefaultApplication.builder(appDesc).withAppId(appId).build();
apps.put(appId, app);
states.put(appId, INSTALLED);
delegate.notify(new ApplicationEvent(APP_INSTALLED, app));
return app;
}
Aggregations