Add written bytes tracking for @bergerkiller
This commit is contained in:
parent
d9c76252eb
commit
db79d01b57
@ -1,4 +1,4 @@
|
|||||||
From 591d89bd222a5e52f2dab0bf93e7df8f861cee29 Mon Sep 17 00:00:00 2001
|
From 4c6632fc189e01d8cf3ab5d519c78ae31c08c398 Mon Sep 17 00:00:00 2001
|
||||||
From: md_5 <md_5@live.com.au>
|
From: md_5 <md_5@live.com.au>
|
||||||
Date: Thu, 14 Feb 2013 17:32:20 +1100
|
Date: Thu, 14 Feb 2013 17:32:20 +1100
|
||||||
Subject: [PATCH] Netty
|
Subject: [PATCH] Netty
|
||||||
@ -284,10 +284,10 @@ index 0000000..54928b4
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
|
diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..f551bbe
|
index 0000000..340d65a
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
|
+++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
|
||||||
@@ -0,0 +1,235 @@
|
@@ -0,0 +1,244 @@
|
||||||
+package org.spigotmc.netty;
|
+package org.spigotmc.netty;
|
||||||
+
|
+
|
||||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
@ -351,6 +351,7 @@ index 0000000..f551bbe
|
|||||||
+ private String dcReason;
|
+ private String dcReason;
|
||||||
+ private Object[] dcArgs;
|
+ private Object[] dcArgs;
|
||||||
+ private Socket socketAdaptor;
|
+ private Socket socketAdaptor;
|
||||||
|
+ private long writtenBytes;
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
+ public void channelActive(ChannelHandlerContext ctx) throws Exception {
|
||||||
@ -522,13 +523,21 @@ index 0000000..f551bbe
|
|||||||
+ d();
|
+ d();
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ public long getWrittenBytes() {
|
||||||
|
+ return writtenBytes;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void addWrittenBytes(int written) {
|
||||||
|
+ writtenBytes += written;
|
||||||
|
+ }
|
||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/spigotmc/netty/NettyServerConnection.java b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
|
diff --git a/src/main/java/org/spigotmc/netty/NettyServerConnection.java b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..9803105
|
index 0000000..790f325
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
|
+++ b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
|
||||||
@@ -0,0 +1,109 @@
|
@@ -0,0 +1,110 @@
|
||||||
+package org.spigotmc.netty;
|
+package org.spigotmc.netty;
|
||||||
+
|
+
|
||||||
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
@ -578,11 +587,12 @@ index 0000000..9803105
|
|||||||
+ // IP_TOS is not supported (Windows XP / Windows Server 2003)
|
+ // IP_TOS is not supported (Windows XP / Windows Server 2003)
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
|
+ NettyNetworkManager networkManager = new NettyNetworkManager();
|
||||||
+ ch.pipeline()
|
+ ch.pipeline()
|
||||||
+ .addLast("timer", new ReadTimeoutHandler(30))
|
+ .addLast("timer", new ReadTimeoutHandler(30))
|
||||||
+ .addLast("decoder", new PacketDecoder())
|
+ .addLast("decoder", new PacketDecoder())
|
||||||
+ .addLast("encoder", new PacketEncoder())
|
+ .addLast("encoder", new PacketEncoder(networkManager))
|
||||||
+ .addLast("manager", new NettyNetworkManager());
|
+ .addLast("manager", networkManager);
|
||||||
+ }
|
+ }
|
||||||
+ }).group(new NioEventLoopGroup(threads, new ThreadFactoryBuilder().setNameFormat("Netty IO Thread - %1$d").build())).localAddress(host, port).bind();
|
+ }).group(new NioEventLoopGroup(threads, new ThreadFactoryBuilder().setNameFormat("Netty IO Thread - %1$d").build())).localAddress(host, port).bind();
|
||||||
+ MinecraftServer.getServer().getLogger().info("Using Netty NIO with " + threads + " threads for network connections.");
|
+ MinecraftServer.getServer().getLogger().info("Using Netty NIO with " + threads + " threads for network connections.");
|
||||||
@ -964,10 +974,10 @@ index 0000000..65074d2
|
|||||||
+}
|
+}
|
||||||
diff --git a/src/main/java/org/spigotmc/netty/PacketEncoder.java b/src/main/java/org/spigotmc/netty/PacketEncoder.java
|
diff --git a/src/main/java/org/spigotmc/netty/PacketEncoder.java b/src/main/java/org/spigotmc/netty/PacketEncoder.java
|
||||||
new file mode 100644
|
new file mode 100644
|
||||||
index 0000000..e671a0d
|
index 0000000..c8832d6
|
||||||
--- /dev/null
|
--- /dev/null
|
||||||
+++ b/src/main/java/org/spigotmc/netty/PacketEncoder.java
|
+++ b/src/main/java/org/spigotmc/netty/PacketEncoder.java
|
||||||
@@ -0,0 +1,43 @@
|
@@ -0,0 +1,50 @@
|
||||||
+package org.spigotmc.netty;
|
+package org.spigotmc.netty;
|
||||||
+
|
+
|
||||||
+import io.netty.buffer.ByteBuf;
|
+import io.netty.buffer.ByteBuf;
|
||||||
@ -985,6 +995,11 @@ index 0000000..e671a0d
|
|||||||
+
|
+
|
||||||
+ private ByteBuf outBuf;
|
+ private ByteBuf outBuf;
|
||||||
+ private DataOutputStream dataOut;
|
+ private DataOutputStream dataOut;
|
||||||
|
+ private final NettyNetworkManager networkManager;
|
||||||
|
+
|
||||||
|
+ public PacketEncoder(NettyNetworkManager networkManager) {
|
||||||
|
+ this.networkManager = networkManager;
|
||||||
|
+ }
|
||||||
+
|
+
|
||||||
+ @Override
|
+ @Override
|
||||||
+ public void encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out) throws Exception {
|
+ public void encode(ChannelHandlerContext ctx, Packet msg, ByteBuf out) throws Exception {
|
||||||
@ -997,6 +1012,8 @@ index 0000000..e671a0d
|
|||||||
+
|
+
|
||||||
+ out.writeByte(msg.n());
|
+ out.writeByte(msg.n());
|
||||||
+ msg.a(dataOut);
|
+ msg.a(dataOut);
|
||||||
|
+
|
||||||
|
+ networkManager.addWrittenBytes(outBuf.readableBytes());
|
||||||
+ out.writeBytes(outBuf);
|
+ out.writeBytes(outBuf);
|
||||||
+ out.discardSomeReadBytes();
|
+ out.discardSomeReadBytes();
|
||||||
+ }
|
+ }
|
||||||
|
Loading…
Reference in New Issue
Block a user