@Override public void cancel() { coapRequest.cancel(); }
@Override public void run() { responseTimedOut.set(true); coapRequest.cancel(); } }, timeoutInMs, TimeUnit.MILLISECONDS);
/** * Cancel observer. */ private void cancel() { Request request = this.request; request.cancel(); setCanceled(true); }
public Response waitForCoapResponse() throws InterruptedException { try { boolean timeElapsed = false; timeElapsed = !latch.await(timeout, TimeUnit.MILLISECONDS); if (timeElapsed || coapTimeout.get()) { coapRequest.cancel(); } } finally { coapRequest.removeMessageObserver(this); } if (exception.get() != null) { coapRequest.cancel(); throw exception.get(); } return ref.get(); } }
/** * Cancel observer. */ private void cancel() { Request request = this.request; request.cancel(); setCanceled(true); }
@Override public void receiveRequest(Request received) { counter.getAndIncrement(); if (cancelRequest) { request.cancel(); } } };
public OperationResponse waitForResponse() { try { final boolean latchTimeout = latch.await(timeout, TimeUnit.MILLISECONDS); if (!latchTimeout || coapTimeout.get()) { coapRequest.cancel(); if (exception.get() != null) { throw exception.get(); } else { throw new RuntimeException("Request Timed Out: " + coapRequest.getURI() + " (timeout)"); } } } catch (final InterruptedException e) { // no idea why some other thread should have interrupted this thread // but anyway, go ahead as if the timeout had been reached LOG.info("Caught an unexpected InterruptedException during execution of CoAP request " + e); } finally { coapRequest.removeMessageObserver(this); } if (exception.get() != null) { throw exception.get(); } return ref.get(); } }
public OperationResponse waitForResponse() { try { final boolean latchTimeout = latch.await(timeout, TimeUnit.MILLISECONDS); if (!latchTimeout || coapTimeout.get()) { coapRequest.cancel(); if (exception.get() != null) { throw exception.get(); } else { throw new RuntimeException("Request Timed Out: " + coapRequest.getURI() + " (timeout)"); } } } catch (final InterruptedException e) { // no idea why some other thread should have interrupted this thread // but anyway, go ahead as if the timeout had been reached LOG.info("Caught an unexpected InterruptedException during execution of CoAP request " + e); } finally { coapRequest.removeMessageObserver(this); } if (exception.get() != null) { throw exception.get(); } return ref.get(); } }
public T waitForResponse() { try { final boolean latchTimeout = latch.await(timeout, TimeUnit.MILLISECONDS); if (!latchTimeout || coapTimeout.get()) { clientRegistry.deregisterClient(client.getRegistrationId()); coapRequest.cancel(); if (exception.get() != null) { throw exception.get(); } else { throw new RequestTimeoutException(coapRequest.getURI(), timeout); } } } catch (final InterruptedException e) { // no idea why some other thread should have interrupted this thread // but anyway, go ahead as if the timeout had been reached LOG.debug("Caught an unexpected InterruptedException during execution of CoAP request", e); } finally { coapRequest.removeMessageObserver(this); } if (exception.get() != null) { throw exception.get(); } return ref.get(); } }
@Override public void cancelPendingRequests(Registration registration) { Validate.notNull(registration); String registrationId = registration.getId(); SortedMap<String, Request> requests = pendingRequests.subMap(getFloorKey(registrationId), getCeilingKey(registrationId)); for (Request coapRequest : requests.values()) { coapRequest.cancel(); } requests.clear(); }
private CoapResponse synchronous(Request request, Endpoint outEndpoint) { try { Response response = send(request, outEndpoint).waitForResponse(getTimeout()); if (response == null) { // Cancel request so appropriate clean up can happen. request.cancel(); return null; } else { return new CoapResponse(response); } } catch (InterruptedException e) { throw new RuntimeException(e); } }
request.cancel(); // stack should send RST
request.cancel();
request.cancel(); server.sendResponse(ACK, CONTENT).loadBoth("B").block2(1, true, 16).payload(respPayload.substring(16, 32)).go();