// 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; } }
void getSystemAndStartQuery() { try { Authentication groupId = DOFObjectID.Authentication.create(providerId.getBase()); DOFObjectID.Attribute attr = providerId.getAttribute(DOFObjectID.Attribute.GROUP); Domain domainId = DOFObjectID.Domain.create(attr.getValueObjectID()); DOFCredentials domainCredentials = DOFCredentials.create(hubProvideFactory.coreCredentials, domainId); // // @formatter:off DOFSystem.Config domainSystemConfig = new DOFSystem.Config.Builder() .setName(groupId.getDataString() + "." + domainId.getDataString() + "-DOFSystem") .setCredentials(domainCredentials) .setPermissionsExtendAllowed(true) .setTunnelDomains(true) .build(); // @formatter:on DOFDomain.Config domainConfig = new DOFDomain.Config.Builder(domainCredentials).build(); DOFDomain serviceDomain = hubProvideFactory.dof.createDomain(domainConfig); serviceDomain.addStateListener(this); long t0 = System.currentTimeMillis(); long to = hubProvideFactory.commTimeout; synchronized (domainFound) { while (!domainFound.get()) { try { domainFound.wait(to); if (domainFound.get()) break; long delta = System.currentTimeMillis() - t0; if (delta >= hubProvideFactory.commTimeout) throw new TimeoutException( "timed out: " + to + " waiting for Domain listener to report completed"); to = hubProvideFactory.commTimeout - delta; // spurious wakeup, or wait(to) slightly off System.currentTimeMillis } finally { serviceDomain.removeStateListener(this); } } } DOFSystem system = hubProvideFactory.dof.createSystem(domainSystemConfig, hubProvideFactory.commTimeout); systemData = new CreateSystemTask.SystemData(groupId, domainId, domainCredentials, system); } catch (InterruptedException e) { hubProvideFactory.removeHubRequestMonitor(providerId); log.debug("Create system task interrupted."); return; } catch (Exception e) { hubProvideFactory.removeHubRequestMonitor(providerId); log.debug("Create system failed {} - " + e.getCause(), providerId); return; } synchronized (this) { if (activateInterestOperation == null || activateInterestOperation.isComplete()) activateInterestOperation = systemData.system.beginInterest( systemData.groupId, HubRequestInterface.IID, DOFInterestLevel.ACTIVATE, DOF.TIMEOUT_NEVER, null, null); if (queryOperation == null || queryOperation.isComplete()) { DOFQuery query = new DOFQuery.Builder() .addFilter(providerId) .addRestriction(HubRequestInterface.IID) .build(); queryOperation = systemData.system.beginQuery(query, DOF.TIMEOUT_NEVER, this, null); } createSystemFuture = null; log.debug( "HubManager dof: " + hubProvideFactory.dof.getState().getName() + " beginQuery for: " + providerId.toStandardString() + ":" + HubRequestInterface.IID); } }