public Connector createConnector(final Map<String, Object> configuration, final BufferHandler handler, final ConnectionLifeCycleListener listener, final Executor closeExecutor, final Executor threadPool, final ScheduledExecutorService scheduledThreadPool) { return new NettyConnector(configuration, handler, listener, closeExecutor, threadPool, scheduledThreadPool); }
public void finalize() throws Throwable { close(); super.finalize(); }
/** * Creates an arbitrary number of random bytes * * @param size the number of random bytes to create * @return An array of random bytes */ private static byte[] randomBytes(int size) { byte[] bytes = new byte[size]; for (int index = 0; index < size; index++) { bytes[index] = (byte) randomNumber(0, 255); } return bytes; }
byte[] nonce = randomBytes(16); String key = base64(nonce); request.headers().set(SEC_HORNETQ_REMOTING_KEY, key); ch.attr(REMOTING_KEY).set(key);
@Override public void channelRead0(ChannelHandlerContext ctx, HttpObject msg) throws Exception { if (msg instanceof HttpResponse) { HttpResponse response = (HttpResponse) msg; if (response.getStatus().code() == HttpResponseStatus.SWITCHING_PROTOCOLS.code() && response.headers().get(HttpHeaders.Names.UPGRADE).equals(HORNETQ_REMOTING)) { String accept = response.headers().get(SEC_HORNETQ_REMOTING_ACCEPT); String expectedResponse = createExpectedResponse(MAGIC_NUMBER, ctx.channel().attr(REMOTING_KEY).get()); if (expectedResponse.equals(accept)) { // remove the http handlers and flag the hornetq channel handler as active pipeline.remove(httpClientCodec); pipeline.remove(this); handshakeComplete = true; HornetQChannelHandler channelHandler = pipeline.get(HornetQChannelHandler.class); channelHandler.active = true; } else { HornetQClientLogger.LOGGER.httpHandshakeFailed(accept, expectedResponse); ctx.close(); } } latch.countDown(); } }
close(); IllegalStateException ise = new IllegalStateException("Unable to create NettyConnector for " + host + ":" + port); ise.initCause(e);
public Connector createConnector(final Map<String, Object> configuration, final BufferHandler handler, final ConnectionLifeCycleListener listener, final Executor closeExecutor, final Executor threadPool, final ScheduledExecutorService scheduledThreadPool) { return new NettyConnector(configuration, handler, listener, closeExecutor, threadPool, scheduledThreadPool); }
close(); IllegalStateException ise = new IllegalStateException("Unable to create NettyConnector for " + host); ise.initCause(e);