use of org.jboss.netty.channel.ChannelFuture in project databus by linkedin.
the class ChunkedBodyWritableByteChannel method writeToChannel.
private void writeToChannel(Object o, int flushSize) throws IOException {
ChannelFuture channelFuture = _channel.write(o);
if (flushSize > 0 && !_channel.isWritable()) {
ChannelConfig channelConfig = _channel.getConfig();
if (channelConfig instanceof NioSocketChannelConfig) {
NioSocketChannelConfig nioSocketConfig = (NioSocketChannelConfig) channelConfig;
nioSocketConfig.setWriteBufferLowWaterMark(flushSize);
nioSocketConfig.setWriteBufferHighWaterMark(flushSize);
}
}
awaitChannelFuture(channelFuture);
if (!channelFuture.isSuccess()) {
throw new IOException(channelFuture.getCause());
}
}
use of org.jboss.netty.channel.ChannelFuture in project databus by linkedin.
the class TestHttpResponseProcessor method sendServerClose.
void sendServerClose(SocketAddress clientAddr, long timeoutMillis) {
Channel childChannel = _dummyServer.getChildChannel(clientAddr);
Assert.assertNotEquals(childChannel, null);
ChannelFuture closeFuture = childChannel.close();
if (timeoutMillis > 0) {
try {
closeFuture.await(timeoutMillis);
} catch (InterruptedException e) {
//NOOP
}
Assert.assertTrue(closeFuture.isDone());
Assert.assertTrue(closeFuture.isSuccess());
}
}
use of org.jboss.netty.channel.ChannelFuture in project crate by crate.
the class Messages method sendAuthenticationOK.
static void sendAuthenticationOK(Channel channel) {
ChannelBuffer buffer = ChannelBuffers.buffer(9);
buffer.writeByte('R');
// size excluding char
buffer.writeInt(8);
buffer.writeInt(0);
ChannelFuture channelFuture = channel.write(buffer);
if (LOGGER.isTraceEnabled()) {
channelFuture.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
LOGGER.trace("sentAuthenticationOK");
}
});
}
}
use of org.jboss.netty.channel.ChannelFuture in project crate by crate.
the class Messages method sendParameterStatus.
/**
* | 'S' | int32 len | str name | str value
* <p>
* See https://www.postgresql.org/docs/9.2/static/protocol-flow.html#PROTOCOL-ASYNC
* <p>
* > At present there is a hard-wired set of parameters for which ParameterStatus will be generated: they are
* <p>
* - server_version,
* - server_encoding,
* - client_encoding,
* - application_name,
* - is_superuser,
* - session_authorization,
* - DateStyle,
* - IntervalStyle,
* - TimeZone,
* - integer_datetimes,
* - standard_conforming_string
*/
static void sendParameterStatus(Channel channel, final String name, final String value) {
byte[] nameBytes = name.getBytes(StandardCharsets.UTF_8);
byte[] valueBytes = value.getBytes(StandardCharsets.UTF_8);
int length = 4 + nameBytes.length + 1 + valueBytes.length + 1;
ChannelBuffer buffer = ChannelBuffers.buffer(length + 1);
buffer.writeByte('S');
buffer.writeInt(length);
writeCString(buffer, nameBytes);
writeCString(buffer, valueBytes);
ChannelFuture channelFuture = channel.write(buffer);
if (LOGGER.isTraceEnabled()) {
channelFuture.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
LOGGER.trace("sentParameterStatus {}={}", name, value);
}
});
}
}
use of org.jboss.netty.channel.ChannelFuture in project crate by crate.
the class Messages method sendReadyForQuery.
/**
* ReadyForQuery (B)
* <p>
* Byte1('Z')
* Identifies the message type. ReadyForQuery is sent whenever the
* backend is ready for a new query cycle.
* <p>
* Int32(5)
* Length of message contents in bytes, including self.
* <p>
* Byte1
* Current backend transaction status indicator. Possible values are
* 'I' if idle (not in a transaction block); 'T' if in a transaction
* block; or 'E' if in a failed transaction block (queries will be
* rejected until block is ended).
*/
static void sendReadyForQuery(Channel channel) {
ChannelBuffer buffer = ChannelBuffers.buffer(6);
buffer.writeByte('Z');
buffer.writeInt(5);
buffer.writeByte('I');
ChannelFuture channelFuture = channel.write(buffer);
if (LOGGER.isTraceEnabled()) {
channelFuture.addListener(new ChannelFutureListener() {
@Override
public void operationComplete(ChannelFuture future) throws Exception {
LOGGER.trace("sentReadyForQuery");
}
});
}
}
Aggregations