ParameterConnection(Channel channel, final Map<String, ?> environment, final JMXServiceURL serviceUrl) { super(channel, environment); this.channel = channel; this.environment = environment; this.clientRequestManager = new ClientRequestManager(); this.clientExecutorManager = new ClientExecutorManager(environment); this.serviceUrl = serviceUrl; this.handlerRegistry = createHandlerRegistry(); }
public void handleError(Channel channel, IOException error) { getClientRequestManager().cancelAllRequests(error); }
public void handle(DataInput input, int correlationId) { VersionedIoFuture<TypeExceptionHolder<T>> future = getClientRequestManager().getFuture(correlationId); if (future == null) {
private String begin() throws IOException { VersionedIoFuture<TypeExceptionHolder<String>> future = new VersionedIoFuture<TypeExceptionHolder<String>>(); final int correlationId = clientRequestManager.reserveNextCorrelationId(future); try { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeByte(BEGIN); output.writeInt(correlationId); } }); log.tracef("[%d] begin - Request Sent", correlationId); IoFuture.Status result = future.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case FAILED: throw future.getException(); case DONE: TypeExceptionHolder<String> response = future.get(); if (response.e == null) { return response.value; } throw toIoException(response.e); default: throw new IOException("Unable to invoke begin, status=" + result.toString()); } } finally { clientRequestManager.releaseCorrelationId(correlationId); } }
/** * Reserves a correlation ID by taking the next value and ensuring it is stored in the Map. * * @return the next reserved correlation ID */ synchronized int reserveNextCorrelationId(VersionedIoFuture future) { Integer next = getNextCorrelationId(); // Not likely but possible to use all IDs and start back at beginning while // old request still in progress. while (requests.containsKey(next)) { next = getNextCorrelationId(); } requests.put(next, future); return next; }
private void setKeyPair(final String key, final String value) throws IOException { VersionedIoFuture<TypeExceptionHolder<Void>> future = new VersionedIoFuture<TypeExceptionHolder<Void>>(); final int correlationId = clientRequestManager.reserveNextCorrelationId(future); try { write(new MessageWriter() { clientRequestManager.releaseCorrelationId(correlationId);
/** * Reserves a correlation ID by taking the next value and ensuring it is stored in the Map. * * @return the next reserved correlation ID */ synchronized int reserveNextCorrelationId(VersionedIoFuture future) { Integer next = getNextCorrelationId(); // Not likely but possible to use all IDs and start back at beginning while // old request still in progress. while (requests.containsKey(next)) { next = getNextCorrelationId(); } requests.put(next, future); return next; }
public String[] getDomains() throws IOException { VersionedIoFuture<TypeExceptionHolder<String[]>> future = new VersionedIoFuture<TypeExceptionHolder<String[]>>(); final int correlationId = clientRequestManager.reserveNextCorrelationId(future); try { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeByte(GET_DOMAINS); output.writeInt(correlationId); } }); log.tracef("[%d] getDomains - Request Sent", correlationId); IoFuture.Status result = future.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case DONE: TypeExceptionHolder<String[]> response = future.get(); if (response.e == null) { return response.value; } jmRuntimeException(response.e); throw toIoException(response.e); case FAILED: throw future.getException(); default: throw new IOException("Unable to obtain Domains, status=" + result.toString()); } } finally { clientRequestManager.releaseCorrelationId(correlationId); } }
public void handleEnd(Channel channel) { getClientRequestManager().cancelAllRequests(new IOException("Connection Ended")); }
ParameterConnection(Channel channel, final Map<String, ?> environment, final JMXServiceURL serviceUrl) { super(channel, environment); this.channel = channel; this.environment = environment; this.clientRequestManager = new ClientRequestManager(); this.clientExecutorManager = new ClientExecutorManager(environment); this.serviceUrl = serviceUrl; this.handlerRegistry = createHandlerRegistry(); }
/** * Reserves a correlation ID by taking the next value and ensuring it is stored in the Map. * * @return the next reserved correlation ID */ synchronized int reserveNextCorrelationId(VersionedIoFuture future) { Integer next = getNextCorrelationId(); // Not likely but possible to use all IDs and start back at beginning while // old request still in progress. while (requests.containsKey(next)) { next = getNextCorrelationId(); } requests.put(next, future); return next; }
public void handle(DataInput input, int correlationId) { VersionedIoFuture<TypeExceptionHolder<T>> future = getClientRequestManager().getFuture(correlationId); if (future == null) {
public String getDefaultDomain() throws IOException { VersionedIoFuture<TypeExceptionHolder<String>> future = new VersionedIoFuture<TypeExceptionHolder<String>>(); final int correlationId = clientRequestManager.reserveNextCorrelationId(future); try { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeByte(GET_DEFAULT_DOMAIN); output.writeInt(correlationId); } }); log.tracef("[%d] getDefaultDomain - Request Sent", correlationId); IoFuture.Status result = future.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case DONE: TypeExceptionHolder<String> response = future.get(); if (response.e == null) { return response.value; } jmRuntimeException(response.e); throw toIoException(response.e); case FAILED: throw future.getException(); default: throw new IOException("Unable to obtain DefaultDomain, status=" + result.toString()); } } finally { clientRequestManager.releaseCorrelationId(correlationId); } }
public void handleError(Channel channel, IOException error) { getClientRequestManager().cancelAllRequests(error); }
ParameterConnection(Channel channel, final Map<String, ?> environment, final JMXServiceURL serviceUrl) { super(channel, environment); this.channel = channel; this.environment = environment; this.clientRequestManager = new ClientRequestManager(); this.clientExecutorManager = new ClientExecutorManager(environment); this.serviceUrl = serviceUrl; this.handlerRegistry = createHandlerRegistry(); }
public void handle(DataInput input, int correlationId) { VersionedIoFuture<TypeExceptionHolder<T>> future = getClientRequestManager().getFuture(correlationId); if (future == null) {
public Integer getMBeanCount() throws IOException { VersionedIoFuture<TypeExceptionHolder<Integer>> future = new VersionedIoFuture<TypeExceptionHolder<Integer>>(); final int correlationId = clientRequestManager.reserveNextCorrelationId(future); try { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeByte(GET_MBEAN_COUNT); output.writeInt(correlationId); } }); log.tracef("[%d] getMBeanCount - Request Sent", correlationId); IoFuture.Status result = future.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case DONE: TypeExceptionHolder<Integer> response = future.get(); if (response.e == null) { return response.value; } jmRuntimeException(response.e); throw toIoException(response.e); case FAILED: throw future.getException(); default: throw new IOException("Unable to obtain MBeanCount, status=" + result.toString()); } } finally { clientRequestManager.releaseCorrelationId(correlationId); } }
public void handleEnd(Channel channel) { getClientRequestManager().cancelAllRequests(new IOException("Connection Ended")); }
public Set<ObjectName> queryNames(final ObjectName name, final QueryExp query) throws IOException { VersionedIoFuture<TypeExceptionHolder<Set<ObjectName>>> future = new VersionedIoFuture<TypeExceptionHolder<Set<ObjectName>>>(); final int correlationId = clientRequestManager.reserveNextCorrelationId(future); try { write(new MessageWriter() { clientRequestManager.releaseCorrelationId(correlationId);
public void handleError(Channel channel, IOException error) { getClientRequestManager().cancelAllRequests(error); }