Example #1
0
 protected void doIntentUpdate() {
   updateScheduled.set(false);
   if (intentService == null) {
     log.warn("Intent service is not bound yet");
     return;
   }
   try {
     // FIXME very inefficient
     for (IntentData intentData : intentService.getIntentData()) {
       try {
         trackIntent(intentData);
       } catch (NullPointerException npe) {
         log.warn("intent error {}", intentData.key(), npe);
       }
     }
   } catch (Exception e) {
     log.warn("Exception caught during update task", e);
   }
 }
Example #2
0
  @Override
  public void trackIntent(IntentData intentData) {

    // NOTE: This will be called for intents that are being added to the store
    //      locally (i.e. every intent update)

    Key key = intentData.key();
    Intent intent = intentData.intent();
    boolean isLocal = intentService.isLocal(key);
    boolean isInstalled = intentData.state() == INSTALLING || intentData.state() == INSTALLED;
    List<Intent> installables = intentData.installables();

    if (log.isTraceEnabled()) {
      log.trace(
          "intent {}, old: {}, new: {}, installableCount: {}, resourceCount: {}",
          key,
          intentsByDevice.values().contains(key),
          isLocal && isInstalled,
          installables.size(),
          intent.resources().size()
              + installables.stream().mapToLong(i -> i.resources().size()).sum());
    }

    if (isNullOrEmpty(installables) && intentData.state() == INSTALLED) {
      log.warn("Intent {} is INSTALLED with no installables", key);
    }

    // FIXME Intents will be added 3 times (once directly using addTracked,
    //       then when installing and when installed)
    if (isLocal && isInstalled) {
      addTrackedResources(key, intent.resources());
      for (Intent installable : installables) {
        addTrackedResources(key, installable.resources());
      }
      // FIXME check all resources against current topo service(s); recompile if necessary
    } else {
      removeTrackedResources(key, intent.resources());
      for (Intent installable : installables) {
        removeTrackedResources(key, installable.resources());
      }
    }
  }