Update to netty CR3

This commit is contained in:
md_5 2013-05-21 11:30:05 +10:00
parent 2a2c2717d5
commit 9be44d51a6
5 changed files with 7 additions and 187 deletions

View File

@ -59,7 +59,7 @@
<properties> <properties>
<build.number>unknown</build.number> <build.number>unknown</build.number>
<netty.version>4.0.0.CR1</netty.version> <netty.version>4.0.0.CR3</netty.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties> </properties>

View File

@ -84,7 +84,7 @@ public class BungeeCord extends ProxyServer
* Thread pools. * Thread pools.
*/ */
public final ScheduledThreadPoolExecutor executors = new BungeeThreadPool( new ThreadFactoryBuilder().setNameFormat( "Bungee Pool Thread #%1$d" ).build() ); public final ScheduledThreadPoolExecutor executors = new BungeeThreadPool( new ThreadFactoryBuilder().setNameFormat( "Bungee Pool Thread #%1$d" ).build() );
public final MultithreadEventLoopGroup eventLoops = new NioEventLoopGroup( 0, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread #%1$d" ).build() ); public final MultithreadEventLoopGroup eventLoops = new NioEventLoopGroup( NioEventLoopGroup.DEFAULT_EVENT_LOOP_THREADS, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread #%1$d" ).build() );
/** /**
* locations.yml save thread. * locations.yml save thread.
*/ */
@ -282,7 +282,7 @@ public class BungeeCord extends ProxyServer
} }
getLogger().info( "Closing IO threads" ); getLogger().info( "Closing IO threads" );
eventLoops.shutdown(); eventLoops.shutdownGracefully();
getLogger().info( "Saving reconnect locations" ); getLogger().info( "Saving reconnect locations" );
reconnectHandler.save(); reconnectHandler.save();

View File

@ -6,17 +6,15 @@ public class ChannelWrapper
{ {
private final Channel ch; private final Channel ch;
private final ReusableChannelPromise promise;
public ChannelWrapper(Channel ch) public ChannelWrapper(Channel ch)
{ {
this.ch = ch; this.ch = ch;
this.promise = new ReusableChannelPromise( ch );
} }
public void write(Object packet) public void write(Object packet)
{ {
ch.write( packet, promise ); ch.write( packet, ch.voidPromise() );
} }
public Channel getHandle() public Channel getHandle()

View File

@ -1,6 +1,7 @@
package net.md_5.bungee.netty; package net.md_5.bungee.netty;
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import io.netty.buffer.MessageBuf;
import io.netty.channel.ChannelHandlerContext; import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ReplayingDecoder; import io.netty.handler.codec.ReplayingDecoder;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
@ -25,7 +26,7 @@ public class PacketDecoder extends ReplayingDecoder<Void>
private int protocol; private int protocol;
@Override @Override
protected byte[] decode(ChannelHandlerContext ctx, ByteBuf in) throws Exception protected void decode(ChannelHandlerContext ctx, ByteBuf in, MessageBuf<Object> out) throws Exception
{ {
// While we have enough data // While we have enough data
while ( true ) while ( true )
@ -47,7 +48,7 @@ public class PacketDecoder extends ReplayingDecoder<Void>
// Checkpoint our state incase we don't have enough data for another packet // Checkpoint our state incase we don't have enough data for another packet
checkpoint(); checkpoint();
// Store our decoded message // Store our decoded message
return buf; out.add( buf );
} }
} }
} }

View File

@ -1,179 +0,0 @@
package net.md_5.bungee.netty;
import io.netty.channel.Channel;
import io.netty.channel.ChannelPromise;
import io.netty.util.concurrent.Future;
import io.netty.util.concurrent.GenericFutureListener;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import lombok.RequiredArgsConstructor;
@RequiredArgsConstructor
public class ReusableChannelPromise implements ChannelPromise
{
private final Channel ch;
@Override
public Channel channel()
{
return ch;
}
@Override
public ChannelPromise setSuccess(Void result)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise setSuccess()
{
return this;
}
@Override
public boolean trySuccess()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise setFailure(Throwable cause)
{
return this;
}
@Override
public ChannelPromise addListener(GenericFutureListener<? extends Future<Void>> listener)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise addListeners(GenericFutureListener<? extends Future<Void>>... listeners)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise removeListener(GenericFutureListener<? extends Future<Void>> listener)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise removeListeners(GenericFutureListener<? extends Future<Void>>... listeners)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise sync() throws InterruptedException
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise syncUninterruptibly()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise await() throws InterruptedException
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public ChannelPromise awaitUninterruptibly()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean isSuccess()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public Throwable cause()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean await(long timeout, TimeUnit unit) throws InterruptedException
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean await(long timeoutMillis) throws InterruptedException
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean awaitUninterruptibly(long timeout, TimeUnit unit)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean awaitUninterruptibly(long timeoutMillis)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public Void getNow()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean cancel(boolean mayInterruptIfRunning)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean isCancelled()
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean isDone()
{
return false;
}
@Override
public Void get() throws InterruptedException, ExecutionException
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public Void get(long timeout, TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean trySuccess(Void result)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
@Override
public boolean tryFailure(Throwable cause)
{
throw new UnsupportedOperationException( "Not supported yet." );
}
}