Search in sources :

Example 1 with TransportThrottleException

use of org.neo4j.bolt.transport.TransportThrottleException in project neo4j by neo4j.

the class ChunkedOutput method flush.

@Override
public PackOutput flush() throws IOException {
    if (buffer != null && buffer.readableBytes() > 0) {
        closeChunkIfOpen();
        // check for and apply write throttles
        try {
            throttleGroup.writeThrottle().acquire(channel);
        } catch (TransportThrottleException ex) {
            throw new BoltIOException(Status.Request.InvalidUsage, ex.getMessage(), ex);
        }
        // Local copy and clear the buffer field. This ensures that the buffer is not re-released if the flush call fails
        ByteBuf out = this.buffer;
        this.buffer = null;
        channel.writeAndFlush(out, channel.voidPromise());
        buffer = allocateBuffer();
    }
    return this;
}
Also used : BoltIOException(org.neo4j.bolt.messaging.BoltIOException) TransportThrottleException(org.neo4j.bolt.transport.TransportThrottleException) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

ByteBuf (io.netty.buffer.ByteBuf)1 BoltIOException (org.neo4j.bolt.messaging.BoltIOException)1 TransportThrottleException (org.neo4j.bolt.transport.TransportThrottleException)1