// This method generally should only be called by HubProvideFactory.removeHubRequestMonitor() public void destroy() { if (systemData != null) systemData.system.destroy(); synchronized (this) { if (createSystemFuture != null) createSystemFuture.cancel(true); if (queryOperation != null) queryOperation.cancel(); queryOperation = null; if (gracePeriodFuture != null) gracePeriodFuture.cancel(true); gracePeriodFuture = null; if (gracePeriodExpiredFuture != null) gracePeriodExpiredFuture.cancel(true); gracePeriodExpiredFuture = null; if (activateInterestOperation != null) activateInterestOperation.cancel(); activateInterestOperation = null; if (provider != null) provider.destroy(); provider = null; if (hubConfig != null) hubProvideFactory.removeHubConfig(hubConfig); hubConfig = null; if (hubRequestRequestor != null) hubRequestRequestor.destroy(); hubRequestRequestor = null; } }
public void handleGracePeriodExpired() { synchronized (this) { gracePeriodExpiredFuture = null; // if (requestProvided.get()) // return; // gracePeriodExpired.set(true); if (provider != null) { provider.destroy(); provider = null; } } hubProvideFactory.removeHubConfig(hubConfig); }
@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); } }
/** * ************************************************************************ * DOFSystem.QueryOperationListener implementation * ************************************************************************ */ @Override public void interfaceAdded(Query operation, DOFObjectID objectId, DOFInterfaceID interfaceId) { if (!objectId.equals(providerId) || !interfaceId.equals(HubRequestInterface.IID)) return; // if (gracePeriodExpired.get()) // return; // requestProvided.set(true); log.trace("Hub Request Provider Added {}:{}", objectId, interfaceId); synchronized (this) { if (gracePeriodExpiredFuture != null) { gracePeriodExpiredFuture.cancel(true); gracePeriodExpiredFuture = null; provider.requestProvideStarted(); } if (provider != null) return; // existing state is fine, we are done here. // first time, or first time after a hubProvideFactory.remove(monitor) gracePeriodFuture = hubProvideFactory.executor.submit(new GetGracePeriodTask(this, objectId, interfaceId)); } }
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); } } }