public static VersionedConnection getConnection(final Channel channel, final Map<String, ?> environment, final JMXServiceURL serviceURL) throws IOException { ParameterConnection parameterConnection = new ParameterConnection(channel, environment, serviceURL); return parameterConnection.getConnection(); }
VersionedConnection getConnection() throws IOException { sendVersionHeader(); IoFuture<Void> futureWelcome = WelcomeMessageReceiver.awaitWelcomeMessage(channel); IoFuture.Status result = futureWelcome.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case DONE: // Set this first as something will need to start handling the response messages. channel.receiveMessage(new MessageReceiver()); break; case FAILED: throw futureWelcome.getException(); default: throw new IOException("Unable to obtain connectionId, status=" + result.toString()); } sendKeyPairs(); String connectionId = begin(); ClientConnection cc = new ClientConnection(channel, environment, clientRequestManager, clientExecutorManager, connectionId); cc.start(); return cc; }
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(); }
final int correlationId = clientRequestManager.reserveNextCorrelationId(future); try { write(new MessageWriter() { throw toIoException(response.e); default: throw new IOException("Unable to invoke unregisterMBean, status=" + result.toString());
private void sendVersionHeader() throws IOException { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeBytes("JMX"); output.writeByte(VersionTwo.getVersionIdentifier()); } }); }
private void sendKeyPairs() throws IOException { String path = serviceUrl.getURLPath(); if (path.contains("?")) { String parameters = path.substring(path.indexOf("?") + 1); String[] pairs = parameters.split(","); for (String currentPair : pairs) { String[] keyValue = currentPair.split("="); if (keyValue.length == 2) { setKeyPair(keyValue[0], keyValue[1]); } else { throw new IOException(String.format("Unable to parse key pairs from '%s'", parameters)); } } } }
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); } }
private void sendVersionHeader() throws IOException { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeBytes("JMX"); output.writeByte(VersionTwo.getVersionIdentifier()); } }); }
private void sendKeyPairs() throws IOException { String path = serviceUrl.getURLPath(); if (path.contains("?")) { String parameters = path.substring(path.indexOf("?") + 1); String[] pairs = parameters.split(","); for (String currentPair : pairs) { String[] keyValue = currentPair.split("="); if (keyValue.length == 2) { setKeyPair(keyValue[0], keyValue[1]); } else { throw new IOException(String.format("Unable to parse key pairs from '%s'", parameters)); } } } }
VersionedConnection getConnection() throws IOException { sendVersionHeader(); IoFuture<Void> futureWelcome = WelcomeMessageReceiver.awaitWelcomeMessage(channel); IoFuture.Status result = futureWelcome.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case DONE: // Set this first as something will need to start handling the response messages. channel.receiveMessage(new MessageReceiver()); break; case FAILED: throw futureWelcome.getException(); default: throw new IOException("Unable to obtain connectionId, status=" + result.toString()); } sendKeyPairs(); String connectionId = begin(); ClientConnection cc = new ClientConnection(channel, environment, clientRequestManager, clientExecutorManager, connectionId); cc.start(); return cc; }
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); } }
public static VersionedConnection getConnection(final Channel channel, final Map<String, ?> environment, final JMXServiceURL serviceURL) throws IOException { ParameterConnection parameterConnection = new ParameterConnection(channel, environment, serviceURL); return parameterConnection.getConnection(); }
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(); }
private void sendVersionHeader() throws IOException { write(new MessageWriter() { @Override public void write(DataOutput output) throws IOException { output.writeBytes("JMX"); output.writeByte(VersionTwo.getVersionIdentifier()); } }); }
private void sendKeyPairs() throws IOException { String path = serviceUrl.getURLPath(); if (path.contains("?")) { String parameters = path.substring(path.indexOf("?") + 1); String[] pairs = parameters.split(","); for (String currentPair : pairs) { String[] keyValue = currentPair.split("="); if (keyValue.length == 2) { setKeyPair(keyValue[0], keyValue[1]); } else { throw new IOException(String.format("Unable to parse key pairs from '%s'", parameters)); } } } }
VersionedConnection getConnection() throws IOException { sendVersionHeader(); IoFuture<Void> futureWelcome = WelcomeMessageReceiver.awaitWelcomeMessage(channel); IoFuture.Status result = futureWelcome.await(timeoutSeconds, TimeUnit.SECONDS); switch (result) { case DONE: // Set this first as something will need to start handling the response messages. channel.receiveMessage(new MessageReceiver()); break; case FAILED: throw futureWelcome.getException(); default: throw new IOException("Unable to obtain connectionId, status=" + result.toString()); } sendKeyPairs(); String connectionId = begin(); ClientConnection cc = new ClientConnection(channel, environment, clientRequestManager, clientExecutorManager, connectionId); cc.start(); return cc; }
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); } }
public static VersionedConnection getConnection(final Channel channel, final Map<String, ?> environment, final JMXServiceURL serviceURL) throws IOException { ParameterConnection parameterConnection = new ParameterConnection(channel, environment, serviceURL); return parameterConnection.getConnection(); }
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(); }
final int correlationId = clientRequestManager.reserveNextCorrelationId(future); try { write(new MessageWriter() { throw toIoException(response.e); default: throw new IOException("Unable to invoke unregisterMBean, status=" + result.toString());