/** * Call to remove all results of all {@link #supportedThingTypes} that are * older than the given timestamp. To remove all left over results after a * full scan, this method could be called {@link #getTimestampOfLastScan()} * as timestamp. * * @param timestamp timestamp, older results will be removed */ protected void removeOlderResults(long timestamp) { removeOlderResults(timestamp, null, null); }
/** * Called on component deactivation, if the implementation of this class is * an OSGi declarative service and does not override the method. The method * implementation calls {@link AbstractDiscoveryService#stopBackgroundDiscovery()} if background * discovery is enabled at the time of component deactivation. */ protected void deactivate() { if (this.backgroundDiscoveryEnabled) { stopBackgroundDiscovery(); } }
private int getMaxScanTimeout(Set<DiscoveryService> discoveryServices) { int result = 0; for (DiscoveryService discoveryService : discoveryServices) { if (discoveryService.getScanTimeout() > result) { result = discoveryService.getScanTimeout(); } } return result; }
private boolean isResultExpired(DiscoveryResult result, long now) { if (result.getTimeToLive() == DiscoveryResult.TTL_UNLIMITED) { return false; } return (result.getTimestamp() + result.getTimeToLive() * 1000 < now); } }
private void runDiscoveryForThingType(Console console, ThingTypeUID thingTypeUID) { discoveryServiceRegistry.startScan(thingTypeUID, null); }
/** * This method cleans up after a scan, i.e. it removes listeners and other required operations. */ protected synchronized void stopScan() { if (scanListener != null) { scanListener.onFinished(); scanListener = null; } }
/** * Creates a new builder for a given thing UID. * * @param thingUID the thing UID for which the builder should be created- * * @return a new instance of a {@link DiscoveryResultBuilder} */ public static DiscoveryResultBuilder create(ThingUID thingUID) { return new DiscoveryResultBuilder(thingUID); }
public static Predicate<DiscoveryResult> withFlag(DiscoveryResultFlag flag) { return r -> flag == r.getFlag(); }
private boolean isResultExpired(DiscoveryResult result, long now) { if (result.getTimeToLive() == DiscoveryResult.TTL_UNLIMITED) { return false; } return (result.getTimestamp() + result.getTimeToLive() * 1000 < now); } }
private void runDiscoveryForBinding(Console console, String bindingId) { discoveryServiceRegistry.startScan(bindingId, null); }
public void reduceNumberOfDiscoveryServices() { synchronized (this) { numberOfDiscoveryServices--; if (!errorOccurred && finishedDiscoveryServices == numberOfDiscoveryServices) { if (listener != null) { listener.onFinished(); } } } } }
/** * Call to remove all results of all {@link #supportedThingTypes} that are * older than the given timestamp. To remove all left over results after a * full scan, this method could be called {@link #getTimestampOfLastScan()} * as timestamp. * * @param timestamp * timestamp, older results will be removed */ protected void removeOlderResults(long timestamp) { removeOlderResults(timestamp, null); }
/** * Called on component deactivation, if the implementation of this class is * an OSGi declarative service and does not override the method. The method * implementation calls {@link AbstractDiscoveryService#stopBackgroundDiscovery()} if background * discovery is enabled at the time of component deactivation. */ protected void deactivate() { if (this.backgroundDiscoveryEnabled) { stopBackgroundDiscovery(); } }
private int getMaxScanTimeout(Set<DiscoveryService> discoveryServices) { int result = 0; for (DiscoveryService discoveryService : discoveryServices) { if (discoveryService.getScanTimeout() > result) { result = discoveryService.getScanTimeout(); } } return result; }
/** * Creates a new builder for a given thing UID. * * @param thingUID the thing UID for which the builder should be created- * @return a new instance of a {@link DiscoveryResultBuilder} */ public static DiscoveryResultBuilder create(ThingUID thingUID) { return new DiscoveryResultBuilder(thingUID); }
public static Predicate<DiscoveryResult> withFlag(DiscoveryResultFlag flag) { return r -> flag == r.getFlag(); }
private void runDiscoveryForThingType(Console console, ThingTypeUID thingTypeUID) { discoveryServiceRegistry.startScan(thingTypeUID, null); }
public void reduceNumberOfDiscoveryServices() { synchronized (this) { numberOfDiscoveryServices--; if (!errorOccurred && finishedDiscoveryServices == numberOfDiscoveryServices) { if (listener != null) { listener.onFinished(); } } } } }
/** * This method cleans up after a scan, i.e. it removes listeners and other required operations. */ protected synchronized void stopScan() { if (scanListener != null) { scanListener.onFinished(); scanListener = null; } }