public void reduceNumberOfDiscoveryServices() { synchronized (this) { numberOfDiscoveryServices--; if (!errorOccurred && finishedDiscoveryServices == numberOfDiscoveryServices) { if (listener != null) { listener.onFinished(); } } } } }
@Override public synchronized void abortScan() { synchronized (this) { if (scheduledStop != null) { scheduledStop.cancel(false); scheduledStop = null; } final ScanListener scanListener = this.scanListener; if (scanListener != null) { Exception e = new CancellationException("Scan has been aborted."); scanListener.onErrorOccurred(e); this.scanListener = null; } } }
@Override public synchronized void abortScan() { synchronized (this) { if (scheduledStop != null) { scheduledStop.cancel(false); scheduledStop = null; } final ScanListener scanListener = this.scanListener; if (scanListener != null) { Exception e = new CancellationException("Scan has been aborted."); scanListener.onErrorOccurred(e); this.scanListener = 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; } }
@Override public void onErrorOccurred(@Nullable Exception exception) { synchronized (this) { if (!errorOccurred) { if (listener != null) { listener.onErrorOccurred(exception); } errorOccurred = true; } else { // Skip error logging for aborted scans if (!(exception instanceof CancellationException)) { if (exception != null) { logger.warn("Error occurred while executing discovery service: {}", exception.getMessage(), exception); } } } } }
/** * 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; } }
@Override public void onErrorOccurred(@Nullable Exception exception) { synchronized (this) { if (!errorOccurred) { if (listener != null) { listener.onErrorOccurred(exception); } errorOccurred = true; } else { // Skip error logging for aborted scans if (!(exception instanceof CancellationException)) { if (exception != null) { logger.warn("Error occurred while executing discovery service: {}", exception.getMessage(), exception); } } } } }
public void reduceNumberOfDiscoveryServices() { synchronized (this) { numberOfDiscoveryServices--; if (!errorOccurred && finishedDiscoveryServices == numberOfDiscoveryServices) { if (listener != null) { listener.onFinished(); } } } } }
@Override public synchronized void onFinished() { synchronized (this) { finishedDiscoveryServices++; logger.debug("Finished {} of {} discovery services.", finishedDiscoveryServices, numberOfDiscoveryServices); if (!errorOccurred && finishedDiscoveryServices == numberOfDiscoveryServices) { if (listener != null) { listener.onFinished(); } } } }
@Override public synchronized void onFinished() { synchronized (this) { finishedDiscoveryServices++; logger.debug("Finished {} of {} discovery services.", finishedDiscoveryServices, numberOfDiscoveryServices); if (!errorOccurred && finishedDiscoveryServices == numberOfDiscoveryServices) { if (listener != null) { listener.onFinished(); } } } }