/** * {@inheritDoc} * * @see org.helios.apmrouter.jmx.mbeanserver.MBeanServerConnectionAdmin#onSynchronousResponse(int, * java.lang.Object) */ @Override public void onSynchronousResponse(int requestId, Object value) { SimpleLogger.debug("Response for req [", requestId, "]:[", value, "]"); synchResultMap.putIfAbsent(requestId, value); CountDownLatch latch = synchTimeoutMap.remove(requestId); if (latch != null) { latch.countDown(); SimpleLogger.debug("Counted Down Latch for req [", requestId, "]:[", value, "]"); } }
/** * {@inheritDoc} * * @see * org.helios.apmrouter.jmx.mbeanserver.MBeanServerConnectionAdmin#waitForSynchronousResponse(int, * long) */ @Override public void waitForSynchronousResponse(int requestId, long timeout) { CountDownLatch latch = new CountDownLatch(1); synchTimeoutMap.put(requestId, latch); try { SimpleLogger.debug("Waiting for response to [", requestId, "]...."); boolean timedout = latch.await(timeout, TimeUnit.MILLISECONDS); SimpleLogger.debug("Result of Waiting for response to [", requestId, "]:", timedout); } catch (InterruptedException iex) { synchResultMap.putIfAbsent( requestId, new IOException( "Thread was interrupted while waiting on Operation completion", new Throwable())); } }