Skip to content

Commit

Permalink
xrootd4j: Upgrade to Netty 4.1
Browse files Browse the repository at this point in the history
Target: master
Acked-by: Paul Millar <[email protected]>

Reviewed at https://rb.dcache.org/r/9667/
  • Loading branch information
gbehrmann committed Aug 22, 2016
1 parent 2ca53cf commit d1eb5a5
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-handler</artifactId>
<version>4.0.24.Final</version>
<version>4.1.4.Final</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -75,7 +74,7 @@ public void writeTo(ChannelHandlerContext ctx, ChannelPromise promise)

public ByteBuf getData()
{
return Unpooled.unmodifiableBuffer(data);
return data.asReadOnly();
}

@Override
Expand Down Expand Up @@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,7 +85,7 @@ public List<ByteBuf> getSegments()
{
List<ByteBuf> 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;
}
Expand Down Expand Up @@ -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()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit d1eb5a5

Please sign in to comment.