Package org.elasticsearch.common.netty.channel

Examples of org.elasticsearch.common.netty.channel.ChannelFuture


                        } else {
                            writeBuffer.writeBytes(response.content(), 0, response.contentLength());
                        }
                    }
                }
                ChannelFuture future = channel.write(writeBuffer);
                if (releaseContentListener != null) {
                    future.addListener(releaseContentListener);
                }
            } catch (Exception e) {
                throw new MemcachedTransportException("Failed to write response", e);
            }
        } else {
View Full Code Here


            options.withCompress(true);
        }
        CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry();
        TransportStreams.buildResponse(cachedEntry, requestId, message, options);
        ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(cachedEntry.bytes().unsafeByteArray(), 0, cachedEntry.bytes().size());
        ChannelFuture future = channel.write(buffer);
        future.addListener(new NettyTransport.CacheFutureListener(cachedEntry));
    }
View Full Code Here

            too.writeObject(tx);
            too.close();
        }
        ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(stream.unsafeByteArray(), 0, stream.size());
        buffer.setInt(0, buffer.writerIndex() - 4); // update real size.
        ChannelFuture future = channel.write(buffer);
        future.addListener(new NettyTransport.CacheFutureListener(cachedEntry));
    }
View Full Code Here

                }
            }
        }

        // Write the response.
        ChannelFuture future = channel.write(resp);
        if (releaseContentListener != null) {
            future.addListener(releaseContentListener);
        }

        // Close the connection after the write operation is done if necessary.
        if (close) {
            future.addListener(ChannelFutureListener.CLOSE);
        }
    }
View Full Code Here

        }

        CachedStreamOutput.Entry cachedEntry = CachedStreamOutput.popEntry();
        TransportStreams.buildRequest(cachedEntry, requestId, action, message, options);
        ChannelBuffer buffer = ChannelBuffers.wrappedBuffer(cachedEntry.bytes().unsafeByteArray(), 0, cachedEntry.bytes().size());
        ChannelFuture future = targetChannel.write(buffer);
        future.addListener(new CacheFutureListener(cachedEntry));
        // We handle close connection exception in the #exceptionCaught method, which is the main reason we want to add this future
//        channelFuture.addListener(new ChannelFutureListener() {
//            @Override public void operationComplete(ChannelFuture future) throws Exception {
//                if (!future.isSuccess()) {
//                    // maybe add back the retry?
View Full Code Here

        }
    }

    private NodeChannels connectToChannelsLight(DiscoveryNode node) {
        InetSocketAddress address = ((InetSocketTransportAddress) node.address()).address();
        ChannelFuture connect = clientBootstrap.connect(address);
        connect.awaitUninterruptibly((long) (connectTimeout.millis() * 1.5));
        if (!connect.isSuccess()) {
            throw new ConnectTransportException(node, "connect_timeout[" + connectTimeout + "]", connect.getCause());
        }
        Channel[] channels = new Channel[1];
        channels[0] = connect.getChannel();
        channels[0].getCloseFuture().addListener(new ChannelCloseListener(node));
        return new NodeChannels(channels, channels, channels);
    }
View Full Code Here

                    } else {
                            buf = ChannelBuffers.copiedBuffer(response.content().toBytes(), response.content().arrayOffset(), response.content().length());
                    }
                    writeBuffer = ChannelBuffers.wrappedBuffer(writeBuffer, buf);
                }
                ChannelFuture future = channel.write(writeBuffer);
                if (releaseContentListener != null) {
                    future.addListener(releaseContentListener);
                }
            } catch (Exception e) {
                throw new MemcachedTransportException("Failed to write response", e);
            }
        } else {
View Full Code Here

TOP

Related Classes of org.elasticsearch.common.netty.channel.ChannelFuture

Copyright © 2018 www.massapicom. 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.