From d1eb5a5b877711954614b70e034c1f08ba3f4885 Mon Sep 17 00:00:00 2001 From: Gerd Behrmann Date: Mon, 22 Aug 2016 10:31:52 +0200 Subject: [PATCH] xrootd4j: Upgrade to Netty 4.1 Target: master Acked-by: Paul Millar Reviewed at https://rb.dcache.org/r/9667/ --- pom.xml | 2 +- .../dcache/xrootd/standalone/DataServer.java | 1 - .../xrootd/protocol/messages/AsyncResponse.java | 8 ++++++++ .../xrootd/protocol/messages/ReadResponse.java | 17 +++++++++++++++-- .../xrootd/protocol/messages/ReadVResponse.java | 13 +++++++++++-- .../xrootd/protocol/messages/WriteRequest.java | 14 ++++++++++++++ 6 files changed, 49 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index a5bf570c..e746d569 100644 --- a/pom.xml +++ b/pom.xml @@ -131,7 +131,7 @@ io.netty netty-handler - 4.0.24.Final + 4.1.4.Final org.slf4j diff --git a/xrootd4j-standalone/src/main/java/org/dcache/xrootd/standalone/DataServer.java b/xrootd4j-standalone/src/main/java/org/dcache/xrootd/standalone/DataServer.java index 1683f5d2..39f675f6 100644 --- a/xrootd4j-standalone/src/main/java/org/dcache/xrootd/standalone/DataServer.java +++ b/xrootd4j-standalone/src/main/java/org/dcache/xrootd/standalone/DataServer.java @@ -73,7 +73,6 @@ public void run() { .group(bossGroup, workerGroup) .channel(channelClass) .localAddress(_configuration.port) - .option(ChannelOption.MAX_MESSAGES_PER_READ, 1) .childOption(ChannelOption.TCP_NODELAY, true) .childOption(ChannelOption.SO_KEEPALIVE, true) .childHandler(new DataServerChannelInitializer(_configuration)); diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/AsyncResponse.java b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/AsyncResponse.java index 9549d8f3..0f174ef8 100644 --- a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/AsyncResponse.java +++ b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/AsyncResponse.java @@ -25,6 +25,7 @@ import io.netty.channel.ChannelPromise; import io.netty.util.AbstractReferenceCounted; import io.netty.util.ReferenceCountUtil; +import io.netty.util.ReferenceCounted; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_asynresp; import static org.dcache.xrootd.protocol.XrootdProtocol.kXR_attn; @@ -115,6 +116,13 @@ public void operationComplete(ChannelFuture future) throws Exception } } + @Override + public ReferenceCounted touch(Object hint) + { + ReferenceCountUtil.touch(response, hint); + return this; + } + @Override protected void deallocate() { diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/ReadResponse.java b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/ReadResponse.java index e7ae17f8..fd93a84e 100644 --- a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/ReadResponse.java +++ b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/ReadResponse.java @@ -19,7 +19,6 @@ package org.dcache.xrootd.protocol.messages; import io.netty.buffer.ByteBuf; -import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; import io.netty.util.ReferenceCounted; @@ -75,7 +74,7 @@ public void writeTo(ChannelHandlerContext ctx, ChannelPromise promise) public ByteBuf getData() { - return Unpooled.unmodifiableBuffer(data); + return data.asReadOnly(); } @Override @@ -115,4 +114,18 @@ public boolean release(int decrement) { return data.release(decrement); } + + @Override + public ReferenceCounted touch() + { + data.touch(); + return this; + } + + @Override + public ReferenceCounted touch(Object hint) + { + data.touch(hint); + return this; + } } diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/ReadVResponse.java b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/ReadVResponse.java index 2043baed..23949a65 100644 --- a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/ReadVResponse.java +++ b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/ReadVResponse.java @@ -20,10 +20,10 @@ import io.netty.buffer.ByteBuf; import io.netty.buffer.CompositeByteBuf; -import io.netty.buffer.Unpooled; import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelPromise; import io.netty.util.AbstractReferenceCounted; +import io.netty.util.ReferenceCounted; import java.util.ArrayList; import java.util.List; @@ -85,7 +85,7 @@ public List getSegments() { List chunks = new ArrayList<>(length); for (int i = 0; i < length; i++) { - chunks.add(Unpooled.unmodifiableBuffer(data[index + i])); + chunks.add(data[index + i].asReadOnly()); } return chunks; } @@ -166,6 +166,15 @@ public String toString() return String.format("readv-response[elements=%d,bytes=%d]", length, payload); } + @Override + public ReferenceCounted touch(Object hint) + { + for (int i = 0; i < length; i++) { + data[i + index].touch(hint); + } + return this; + } + @Override protected void deallocate() { diff --git a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/WriteRequest.java b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/WriteRequest.java index 8cfab611..10410bfa 100644 --- a/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/WriteRequest.java +++ b/xrootd4j/src/main/java/org/dcache/xrootd/protocol/messages/WriteRequest.java @@ -119,4 +119,18 @@ public WriteRequest retain() data.retain(); return this; } + + @Override + public ReferenceCounted touch() + { + data.touch(); + return this; + } + + @Override + public ReferenceCounted touch(Object hint) + { + data.touch(hint); + return this; + } }