.withService(m_service) .withMonitor(m_serviceMonitor) .withTimeToLive(ttlInMs) .withAttributes(getParameters()) .withAdaptor(m_latencyStoringServiceMonitorAdaptor) .withAdaptor(m_invertedStatusServiceMonitorAdaptor) .execute() .get().getPollStatus(); LOG.debug("Finish polling {} using pkg {} result = {}", m_service, packageName, result);
@Override public CompletableFuture<PollerResult> execute() { Map<String, Object> props = Collections.unmodifiableMap(attributes); MonitoredService service = new SimpleMonitoredService(address, serviceName); CompletableFuture<PollerResponse> future = pollerClient.poll() .withService(service) .withMonitorClassName(className) .withTimeToLive(ttlInMs) .withAttributes(props) .execute(); // convert the response to PollResult. CompletableFuture<PollerResult> result = new CompletableFuture<>(); try { PollerResponse pollerResponse = future.get(); result.complete(new PollerResultImpl(pollerResponse.getPollStatus())); } catch (InterruptedException | ExecutionException e) { result.completeExceptionally(e); } return result; }
Mockito.when( client.poll() .withService(any()) .withMonitor(any()) .withTimeToLive(any()) .withAttributes(any()) .withAdaptor(any()) .withAdaptor(any()) .execute() ).thenReturn(future);
.withService(service) .withSystemId(systemId) .withMonitorClassName(className) .withTimeToLive(ttlInMs) .withAttributes(parse(attributes)) .execute();