public String[] getDomains() throws IOException { VersionedIoFuture<TypeExceptionHolder<String[]>> future = new VersionedIoFuture<TypeExceptionHolder<String[]>>(); final int correlationId = 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 { releaseCorrelationId(correlationId); } }
public void handleMessage(Channel channel, MessageInputStream messageInputStream) { DataInputStream dis = new DataInputStream(messageInputStream); try { log.tracef("Bytes Available %d", dis.available()); byte[] firstThree = new byte[3]; dis.read(firstThree); log.tracef("First Three %s", new String(firstThree)); if (Arrays.equals(firstThree, "JMX".getBytes()) == false) { throw new IOException("Invalid leading bytes in header."); } log.tracef("Bytes Available %d", dis.available()); String connectionId = dis.readUTF(); future.setResult(connectionId); } catch (IOException e) { future.setException(e); } finally { IoUtils.safeClose(dis); } }
public void handleError(Channel channel, IOException e) { future.setException(e); }
public static IoFuture<String> getConnectionId(final Channel channel) { VersionedIoFuture<String> future = new VersionedIoFuture<String>(); channel.receiveMessage(new ConnectionIdReceiver(future)); return future; }
public void handleEnd(Channel channel) { future.setException(new IOException("Channel ended")); }
public static IoFuture<String> getConnectionId(final Channel channel) { VersionedIoFuture<String> future = new VersionedIoFuture<String>(); channel.receiveMessage(new ConnectionIdReceiver(future)); return future; }
public Integer getMBeanCount() throws IOException { VersionedIoFuture<TypeExceptionHolder<Integer>> future = new VersionedIoFuture<TypeExceptionHolder<Integer>>(); final int correlationId = 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 { releaseCorrelationId(correlationId); } }
response.e = unmarshaller.readObject(Exception.class); } else { future.setException(new IOException("Outcome not understood")); future.setResult(response); } catch (ClassCastException e) { future.setException(new IOException(e)); } catch (ClassNotFoundException e) { future.setException(new IOException(e)); } catch (IOException e) { future.setException(e);
private synchronized void cancelAllRequests(final IOException io) { for (VersionedIoFuture current : requests.values()) { current.setException(io); } requests.clear(); }
public static IoFuture<String> getConnectionId(final Channel channel) { VersionedIoFuture<String> future = new VersionedIoFuture<String>(); channel.receiveMessage(new ConnectionIdReceiver(future)); return future; }
public String getDefaultDomain() throws IOException { VersionedIoFuture<TypeExceptionHolder<String>> future = new VersionedIoFuture<TypeExceptionHolder<String>>(); final int correlationId = 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 { releaseCorrelationId(correlationId); } }
public void handleMessage(Channel channel, MessageInputStream messageInputStream) { DataInputStream dis = new DataInputStream(messageInputStream); try { log.tracef("Bytes Available %d", dis.available()); byte[] firstThree = new byte[3]; dis.read(firstThree); log.tracef("First Three %s", new String(firstThree)); if (Arrays.equals(firstThree, "JMX".getBytes()) == false) { throw new IOException("Invalid leading bytes in header."); } log.tracef("Bytes Available %d", dis.available()); String connectionId = dis.readUTF(); future.setResult(connectionId); } catch (IOException e) { future.setException(e); } finally { IoUtils.safeClose(dis); } }
public void handleError(Channel channel, IOException e) { future.setException(e); }
public boolean isRegistered(final ObjectName name) throws IOException { VersionedIoFuture<TypeExceptionHolder<Boolean>> future = new VersionedIoFuture<TypeExceptionHolder<Boolean>>(); final int correlationId = reserveNextCorrelationId(future); try { IoFuture.Status result = future.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case DONE: TypeExceptionHolder<Boolean> response = future.get(); if (response.e == null) { return response.value; throw toIoException(response.e); case FAILED: throw future.getException(); default: throw new IOException("Unable to obtain isRegistered, status=" + result.toString());
public void handleMessage(Channel channel, MessageInputStream messageInputStream) { DataInputStream dis = new DataInputStream(messageInputStream); try { log.tracef("Bytes Available %d", dis.available()); byte[] firstThree = new byte[3]; dis.read(firstThree); log.tracef("First Three %s", new String(firstThree)); if (Arrays.equals(firstThree, "JMX".getBytes()) == false) { throw new IOException("Invalid leading bytes in header."); } log.tracef("Bytes Available %d", dis.available()); String connectionId = dis.readUTF(); future.setResult(connectionId); } catch (IOException e) { future.setException(e); } finally { IoUtils.safeClose(dis); } }
public void handleError(Channel channel, IOException e) { future.setException(e); }
public Set<ObjectInstance> queryMBeans(final ObjectName name, final QueryExp query) throws IOException { VersionedIoFuture<TypeExceptionHolder<Set<ObjectInstance>>> future = new VersionedIoFuture<TypeExceptionHolder<Set<ObjectInstance>>>(); final int correlationId = reserveNextCorrelationId(future); try { IoFuture.Status result = future.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case FAILED: throw future.getException(); case DONE: TypeExceptionHolder<Set<ObjectInstance>> response = future.get(); if (response.e == null) { return response.value;
response.e = unmarshaller.readObject(Exception.class); } else { future.setException(new IOException("Outcome not understood")); future.setResult(response); } catch (ClassCastException e) { future.setException(new IOException(e)); } catch (ClassNotFoundException e) { future.setException(new IOException(e)); } catch (IOException e) { future.setException(e);
public void handleEnd(Channel channel) { future.setException(new IOException("Channel 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 = reserveNextCorrelationId(future); try { IoFuture.Status result = future.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case FAILED: throw future.getException(); case DONE: TypeExceptionHolder<Set<ObjectName>> response = future.get(); if (response.e == null) { return response.value;