/** {@inheritDoc} */ @Override public void supplyAsyncThenAccept(final Callback<Boolean> cb) { try { LOG.info("Attemping to detect service {} on address {} at location {}", m_detectorConfig.getName(), getHostAddress(), getLocationName()); // Launch the detector m_service.getLocationAwareDetectorClient().detect().withClassName(m_detectorConfig.getPluginClass()) .withAddress(m_address).withNodeId(m_nodeId).withLocation(getLocationName()) .withAttributes(m_detectorConfig.getParameters().stream() .collect(Collectors.toMap(PluginParameter::getKey, PluginParameter::getValue))) .execute() // After completion, run the callback .whenComplete((res, ex) -> { LOG.info("Completed detector execution for service {} on address {} at location {}", m_detectorConfig.getName(), getHostAddress(), getLocationName()); if (ex != null) { cb.handleException(ex); } else { cb.accept(res); } }); } catch (Throwable e) { cb.handleException(e); } }
/** {@inheritDoc} */ @Override public void supplyAsyncThenAccept(final Callback<Boolean> cb) { try { LOG.info("Attemping to detect service {} on address {} at location {}", m_detectorConfig.getName(), getHostAddress(), getLocationName()); // Launch the detector m_service.getLocationAwareDetectorClient().detect().withClassName(m_detectorConfig.getPluginClass()) .withAddress(m_address).withNodeId(m_nodeId).withLocation(getLocationName()) .withAttributes(m_detectorConfig.getParameters().stream() .collect(Collectors.toMap(PluginParameter::getKey, PluginParameter::getValue))) .execute() // After completion, run the callback .whenComplete((res, ex) -> { LOG.info("Completed detector execution for service {} on address {} at location {}", m_detectorConfig.getName(), getHostAddress(), getLocationName()); if (ex != null) { cb.handleException(ex); } else { cb.accept(res); } }); } catch (Throwable e) { cb.handleException(e); } }