Examples of DownstreamMessageEvent


Examples of com.facebook.presto.jdbc.internal.netty.channel.DownstreamMessageEvent

            SpdyDataFrame[] spdyDataFrames, SocketAddress remoteAddress) {

        ChannelFuture dataFuture = future;
        for (int i = spdyDataFrames.length; --i >= 0;) {
            future = Channels.future(ctx.getChannel());
            future.addListener(new SpdyFrameWriter(ctx, new DownstreamMessageEvent(
                    ctx.getChannel(), dataFuture, spdyDataFrames[i], remoteAddress)));
            dataFuture = future;
        }
        return dataFuture;
    }
View Full Code Here

Examples of com.facebook.presto.jdbc.internal.netty.channel.DownstreamMessageEvent

                    ByteBuffer outAppBuf = pendingWrite.outAppBuf;
                    if (outAppBuf == null) {
                        // A write request with an empty buffer
                        pendingUnencryptedWrites.remove();
                        offerEncryptedWriteRequest(
                                new DownstreamMessageEvent(
                                        channel, pendingWrite.future,
                                        ChannelBuffers.EMPTY_BUFFER,
                                        channel.getRemoteAddress()));
                        offered = true;
                    } else {
                        synchronized (handshakeLock) {
                            SSLEngineResult result = null;
                            try {
                                result = engine.wrap(outAppBuf, outNetBuf);
                            } finally {
                                if (!outAppBuf.hasRemaining()) {
                                    pendingUnencryptedWrites.remove();
                                }
                            }

                            if (result.bytesProduced() > 0) {
                                outNetBuf.flip();
                                int remaining = outNetBuf.remaining();
                                msg = ctx.getChannel().getConfig().getBufferFactory().getBuffer(remaining);

                                // Transfer the bytes to the new ChannelBuffer using some safe method that will also
                                // work with "non" heap buffers
                                //
                                // See https://github.com/netty/netty/issues/329
                                msg.writeBytes(outNetBuf);
                                outNetBuf.clear();

                                ChannelFuture future;
                                if (pendingWrite.outAppBuf.hasRemaining()) {
                                    // pendingWrite's future shouldn't be notified if
                                    // only partial data is written.
                                    future = succeededFuture(channel);
                                } else {
                                    future = pendingWrite.future;
                                }

                                MessageEvent encryptedWrite = new DownstreamMessageEvent(
                                        channel, future, msg, channel.getRemoteAddress());
                                offerEncryptedWriteRequest(encryptedWrite);
                                offered = true;
                            } else if (result.getStatus() == Status.CLOSED) {
                                // SSLEngine has been closed already.
View Full Code Here

Examples of io.netty.channel.DownstreamMessageEvent

                    ByteBuffer outAppBuf = pendingWrite.outAppBuf;
                    if (outAppBuf == null) {
                        // A write request with an empty buffer
                        pendingUnencryptedWrites.remove();
                        offerEncryptedWriteRequest(
                                new DownstreamMessageEvent(
                                        channel, pendingWrite.future,
                                        ChannelBuffers.EMPTY_BUFFER,
                                        channel.getRemoteAddress()));
                        offered = true;
                    } else {
                        SSLEngineResult result = null;
                        try {
                            synchronized (handshakeLock) {
                                result = engine.wrap(outAppBuf, outNetBuf);
                            }
                        } finally {
                            if (!outAppBuf.hasRemaining()) {
                                pendingUnencryptedWrites.remove();
                            }
                        }

                        if (result.bytesProduced() > 0) {
                            outNetBuf.flip();
                            msg = ChannelBuffers.buffer(outNetBuf.remaining());
                            msg.writeBytes(outNetBuf.array(), 0, msg.capacity());
                            outNetBuf.clear();

                            if (pendingWrite.outAppBuf.hasRemaining()) {
                                // pendingWrite's future shouldn't be notified if
                                // only partial data is written.
                                future = succeededFuture(channel);
                            } else {
                                future = pendingWrite.future;
                            }

                            MessageEvent encryptedWrite = new DownstreamMessageEvent(
                                    channel, future, msg, channel.getRemoteAddress());
                            offerEncryptedWriteRequest(encryptedWrite);
                            offered = true;
                        } else if (result.getStatus() == Status.CLOSED) {
                            // SSLEngine has been closed already.
View Full Code Here

Examples of org.jboss.netty.channel.DownstreamMessageEvent

    {
      Constants.ahessianLogger.warn("",ex);
    }
    if (future == null)
    future = Channels.future(_ctx.getChannel());
        _ctx.sendDownstream(new DownstreamMessageEvent(_ctx.getChannel(), future, _buf, _ctx.getChannel().getRemoteAddress()));
    _buf = dynamicBuffer(1024);
    return future;
  }
View Full Code Here

Examples of org.jboss.netty.channel.DownstreamMessageEvent

      StringBuilder sb = new StringBuilder();

    //System.out.println(e);
    if (e instanceof DownstreamMessageEvent)
    {
      DownstreamMessageEvent devm = (DownstreamMessageEvent) e;
      Object mes = devm.getMessage();
      sb.append('[');
      sb.append(e.getChannel().getId());
      sb.append(" >out> ");
      if (mes instanceof ChannelBuffer)
        encodeBuffer((ChannelBuffer)((DownstreamMessageEvent)e).getMessage(), sb);
View Full Code Here

Examples of org.jboss.netty.channel.DownstreamMessageEvent

  {
      Constants.ahessianLogger.info("write timed out -> send empty buffer heartbeat");
    ChannelFuture future = Channels.future(_ctx.getChannel());
    ChannelBuffer b = ChannelBuffers.buffer(1);
    b.writeByte(0);
        _ctx.sendDownstream(new DownstreamMessageEvent(_ctx.getChannel(), future, b, _ctx.getChannel().getRemoteAddress()));
  }
View Full Code Here

Examples of org.jboss.netty.channel.DownstreamMessageEvent

  @Override
  public void sendDownstreamAsBinary(ChannelHandlerContext ctx, ChannelFuture future)
  {
    ChannelBuffer buffer = toBinaryChannelBuffer();
    ctx.sendDownstream(new DownstreamMessageEvent(ctx.getChannel(), future, buffer,
                                                  ctx.getChannel().getRemoteAddress()));
  }
View Full Code Here

Examples of org.jboss.netty.channel.DownstreamMessageEvent

  public void writeToChannelAsBinary(ChannelHandlerContext ctx, ChannelFuture future)
  {
    ChannelFuture realFuture = (null != future) ? future : Channels.future(ctx.getChannel());

    ChannelBuffer serializedResponse = serializeToBinary();
    DownstreamMessageEvent e = new DownstreamMessageEvent(ctx.getChannel(), realFuture,
                                                          serializedResponse,
                                                          ctx.getChannel().getRemoteAddress());
    ctx.sendDownstream(e);
  }
View Full Code Here

Examples of org.jboss.netty.channel.DownstreamMessageEvent

      // =====================================================================
     
      // =====================================================================
      // Comment the next line to ditch the CompatibleObjectEncoder from the pipeline
      // =====================================================================
      ctx.sendDownstream(new DownstreamMessageEvent(e.getChannel(), Channels.future(e.getChannel()), ret, e.getChannel().getRemoteAddress()));
     
     
    } else {
      System.err.println("WTF..... anything getting here should be a string but we got a [" + msg.getClass().getName() + "]");
    }
View Full Code Here

Examples of org.jboss.netty.channel.DownstreamMessageEvent

    response.setHeader(CONTENT_LENGTH, cb.readableBytes());
    response.setHeader(CONTENT_TYPE, "application/json");
    response.setHeader(CACHE_CONTROL, "no-cache");
    response.setContent(cb);
    ChannelFuture cf = Channels.future(channel);
    ctx.sendDownstream(new DownstreamMessageEvent(channel, cf, response, channel.getRemoteAddress()));
   
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.