예제 #1
0
  @Override
  public void interfaceRemoved(Query operation, DOFObjectID objectID, DOFInterfaceID interfaceID) {
    if (!objectID.equals(providerId) || !interfaceID.equals(HubRequestInterface.IID)) return;
    log.trace("Hub Request Provider Removed {}:{}", objectID, interfaceID);

    //        requestProvided.set(false);
    GracePeriodExpiredTask gracePeriodExpiredTask = new GracePeriodExpiredTask(this);
    synchronized (this) {
      if (gracePeriodFuture != null) {
        gracePeriodFuture.cancel(true);
        gracePeriodFuture = null;
      }
      gracePeriodExpiredFuture =
          hubProvideFactory.timerExecutor.schedule(
              gracePeriodExpiredTask, requestorGracePeriodMinutes.get(), TimeUnit.MINUTES);
      if (provider != null) provider.requestProvideStopped(-1);
    }
  }
예제 #2
0
  void handleInterfaceAdded(DOFObjectID objectId, DOFInterfaceID interfaceId) {
    DOFObject requestor;
    int requestorGracePeriodMinutes = -1;
    // this is the flag that other domainManagers started this sequence, MAX_VALUE == started by
    // activate, not broadcast get
    boolean broadcastGetActivated =
        (hubProvideFactory.coreDomainGracePeriodMinutes.get() != Integer.MAX_VALUE);

    try {
      requestor =
          systemData.system.waitProvider(objectId, interfaceId, hubProvideFactory.commTimeout);
      requestorGracePeriodMinutes =
          HubRequestInterface.getGracePeriod(requestor, hubProvideFactory.commTimeout);

      synchronized (this) {
        if (gracePeriodExpiredFuture != null) {
          gracePeriodExpiredFuture.cancel(true);
          gracePeriodExpiredFuture = null;
          return;
        }
        hubRequestRequestor = requestor;
      }
    } catch (Exception e) {
      /*
       * Interesting point in time here ... the coredomain broadcast's get may have initiated the startup sequence instead of
       * a requestor's activate.  The coredomain's get handler will be capturing the smallest value seen from the broadcast
       * and we are going to go with the lowest that has been seen at this time. (comm timeout on get from the requestor).
       * If the requestor's provide and getGracePeriod do not fail, then the state of the other cr/domain managers no longer matters
       * to this manager as we have a know live requestor.
       */

      // this is the flag that other domainManagers started this sequence, MAX_VALUE == started by
      // activate, not broadcast get
      if (!broadcastGetActivated) {
        // this is a fatal timeout, clean up the monitor;
        log.warn(
            "Failed to obtain hubRequestRequestor for getting grace period on {}: " + e,
            providerId);
        hubProvideFactory.removeHubRequestMonitor(providerId);
        return;
      }
    }
    synchronized (this) {
      provider =
          new HubProvider(hubProvideFactory.coreSystem, providerId, requestorGracePeriodMinutes);
      provider.init();
      provider.requestProvideStarted();
    }
    setHubConfig();
    if (broadcastGetActivated && requestorGracePeriodMinutes == -1) {
      GracePeriodExpiredTask gracePeriodExpiredTask = new GracePeriodExpiredTask(this);
      synchronized (this) {
        if (gracePeriodFuture != null) {
          gracePeriodFuture.cancel(true);
          gracePeriodFuture = null;
        }
        int remaining = hubProvideFactory.coreDomainGracePeriodMinutes.get();
        gracePeriodExpiredFuture =
            hubProvideFactory.timerExecutor.schedule(
                gracePeriodExpiredTask, remaining, TimeUnit.MINUTES);
        provider.requestProvideStopped(remaining);
      }
    }
  }