2013-07-02 03:57:42 +00:00
|
|
|
From eabbbdf2f175c602d04575c0d90062bba6e316b2 Mon Sep 17 00:00:00 2001
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
From: md_5 <md_5@live.com.au>
|
2013-07-01 23:08:07 +00:00
|
|
|
Date: Tue, 2 Jul 2013 09:06:29 +1000
|
2013-02-19 09:28:30 +00:00
|
|
|
Subject: [PATCH] Netty
|
|
|
|
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
|
|
|
|
diff --git a/pom.xml b/pom.xml
|
2013-07-02 03:14:40 +00:00
|
|
|
index 75ef3c9..2d8b3f3 100644
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- a/pom.xml
|
|
|
|
+++ b/pom.xml
|
2013-07-02 03:14:40 +00:00
|
|
|
@@ -139,6 +139,16 @@
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
<artifactId>trove4j</artifactId>
|
2013-07-02 03:03:56 +00:00
|
|
|
<version>3.0.3</version>
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
</dependency>
|
|
|
|
+ <dependency>
|
|
|
|
+ <groupId>io.netty</groupId>
|
2013-02-17 09:10:50 +00:00
|
|
|
+ <artifactId>netty-all</artifactId>
|
2013-06-29 05:36:18 +00:00
|
|
|
+ <version>4.0.0.CR7</version>
|
2013-05-16 08:11:03 +00:00
|
|
|
+ </dependency>
|
|
|
|
+ <dependency>
|
2013-06-29 05:36:18 +00:00
|
|
|
+ <groupId>org.javassist</groupId>
|
|
|
|
+ <artifactId>javassist</artifactId>
|
|
|
|
+ <version>3.18.0-GA</version>
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ </dependency>
|
|
|
|
</dependencies>
|
|
|
|
|
|
|
|
<!-- This builds a completely 'ready to start' jar with all dependencies inside -->
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/DedicatedServer.java b/src/main/java/net/minecraft/server/DedicatedServer.java
|
2013-07-02 03:03:56 +00:00
|
|
|
index ddb32ac..ec3d104 100644
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/DedicatedServer.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/DedicatedServer.java
|
2013-07-01 23:05:40 +00:00
|
|
|
@@ -100,7 +100,11 @@ public class DedicatedServer extends MinecraftServer implements IMinecraftServer
|
2013-07-02 03:03:56 +00:00
|
|
|
this.getLogger().info("Starting Minecraft server on " + (this.getServerIp().length() == 0 ? "*" : this.getServerIp()) + ":" + this.I());
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
|
|
|
|
try {
|
2013-07-02 03:03:56 +00:00
|
|
|
- this.s = new DedicatedServerConnection(this, inetaddress, this.I());
|
2013-07-01 23:05:40 +00:00
|
|
|
+ // Spigot start
|
2013-07-02 03:03:56 +00:00
|
|
|
+ this.s = ( org.spigotmc.SpigotConfig.listeners.get( 0 ).netty )
|
|
|
|
+ ? new org.spigotmc.netty.NettyServerConnection( this, inetaddress, this.I() )
|
|
|
|
+ : new DedicatedServerConnection( this, inetaddress, this.I() );
|
2013-06-23 06:33:18 +00:00
|
|
|
+ // Spigot end
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
} catch (Throwable ioexception) { // CraftBukkit - IOException -> Throwable
|
2013-03-15 21:35:56 +00:00
|
|
|
this.getLogger().warning("**** FAILED TO BIND TO PORT!");
|
|
|
|
this.getLogger().warning("The exception was: {0}", new Object[] { ioexception.toString()});
|
2013-02-24 01:01:33 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/INetworkManager.java b/src/main/java/net/minecraft/server/INetworkManager.java
|
|
|
|
new file mode 100644
|
2013-03-23 00:06:00 +00:00
|
|
|
index 0000000..6fcc5d7
|
2013-02-24 01:01:33 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/net/minecraft/server/INetworkManager.java
|
2013-03-23 00:06:00 +00:00
|
|
|
@@ -0,0 +1,26 @@
|
2013-02-24 01:01:33 +00:00
|
|
|
+package net.minecraft.server;
|
|
|
|
+
|
|
|
|
+import java.net.SocketAddress;
|
|
|
|
+
|
|
|
|
+public interface INetworkManager {
|
|
|
|
+
|
|
|
|
+ void a(Connection connection);
|
|
|
|
+
|
|
|
|
+ void queue(Packet packet);
|
|
|
|
+
|
|
|
|
+ void a();
|
|
|
|
+
|
|
|
|
+ void b();
|
|
|
|
+
|
|
|
|
+ SocketAddress getSocketAddress();
|
|
|
|
+
|
|
|
|
+ void d();
|
|
|
|
+
|
|
|
|
+ int e();
|
|
|
|
+
|
|
|
|
+ void a(String s, Object... aobject);
|
|
|
|
+
|
2013-03-23 00:06:00 +00:00
|
|
|
+ java.net.Socket getSocket(); // Spigot
|
|
|
|
+
|
|
|
|
+ void setSocketAddress(java.net.SocketAddress address); // Spigot
|
2013-02-24 01:01:33 +00:00
|
|
|
+}
|
2013-03-23 00:06:00 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
2013-07-02 03:03:56 +00:00
|
|
|
index c60abf1..e1b259b 100644
|
2013-03-23 00:06:00 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
2013-07-02 03:03:56 +00:00
|
|
|
@@ -25,7 +25,7 @@ public class NetworkManager implements INetworkManager {
|
2013-03-23 00:06:00 +00:00
|
|
|
private final Object h = new Object();
|
|
|
|
private final IConsoleLogManager i;
|
|
|
|
public Socket socket; // CraftBukkit - private -> public
|
|
|
|
- private final SocketAddress k;
|
|
|
|
+ private SocketAddress k; // Spigot - remove final
|
|
|
|
private volatile DataInputStream input;
|
|
|
|
private volatile DataOutputStream output;
|
|
|
|
private volatile boolean n = true;
|
2013-07-02 03:03:56 +00:00
|
|
|
@@ -370,4 +370,6 @@ public class NetworkManager implements INetworkManager {
|
2013-03-23 00:06:00 +00:00
|
|
|
static Thread h(NetworkManager networkmanager) {
|
|
|
|
return networkmanager.u;
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public void setSocketAddress(SocketAddress address) { k = address; } // Spigot
|
|
|
|
}
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
diff --git a/src/main/java/net/minecraft/server/PendingConnection.java b/src/main/java/net/minecraft/server/PendingConnection.java
|
2013-07-02 03:36:58 +00:00
|
|
|
index 252cea7..d07973d 100644
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- a/src/main/java/net/minecraft/server/PendingConnection.java
|
|
|
|
+++ b/src/main/java/net/minecraft/server/PendingConnection.java
|
2013-07-02 03:03:56 +00:00
|
|
|
@@ -16,7 +16,7 @@ public class PendingConnection extends Connection {
|
2013-03-15 22:08:53 +00:00
|
|
|
private static Random random = new Random();
|
|
|
|
private byte[] d;
|
|
|
|
private final MinecraftServer server;
|
|
|
|
- public final NetworkManager networkManager;
|
|
|
|
+ public final INetworkManager networkManager;
|
2013-07-02 03:03:56 +00:00
|
|
|
public boolean b;
|
|
|
|
private int f;
|
|
|
|
private String g;
|
|
|
|
@@ -26,10 +26,15 @@ public class PendingConnection extends Connection {
|
|
|
|
private SecretKey k;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
public String hostname = ""; // CraftBukkit - add field
|
|
|
|
|
|
|
|
+ public PendingConnection(MinecraftServer minecraftserver, org.spigotmc.netty.NettyNetworkManager networkManager) {
|
|
|
|
+ this.server = minecraftserver;
|
|
|
|
+ this.networkManager = networkManager;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
public PendingConnection(MinecraftServer minecraftserver, Socket socket, String s) throws java.io.IOException { // CraftBukkit - throws IOException
|
|
|
|
this.server = minecraftserver;
|
2013-07-02 03:03:56 +00:00
|
|
|
this.networkManager = new NetworkManager(minecraftserver.getLogger(), socket, s, this, minecraftserver.H().getPrivate());
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
- this.networkManager.e = 0;
|
|
|
|
+ // this.networkManager.e = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CraftBukkit start
|
2013-03-15 21:35:56 +00:00
|
|
|
@@ -146,7 +151,7 @@ public class PendingConnection extends Connection {
|
2013-07-02 03:03:56 +00:00
|
|
|
String s = null;
|
2013-02-10 05:50:54 +00:00
|
|
|
// CraftBukkit
|
|
|
|
org.bukkit.event.server.ServerListPingEvent pingEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callServerListPingEvent(this.server.server, getSocket().getInetAddress(), this.server.getMotd(), playerlist.getPlayerCount(), playerlist.getMaxPlayers());
|
2013-07-02 03:03:56 +00:00
|
|
|
- if (packet254getinfo.d()) {
|
2013-07-02 03:36:58 +00:00
|
|
|
+ if (false) { // Spigot: TODO: Use trick from Bungee maybe?
|
2013-07-02 03:03:56 +00:00
|
|
|
// CraftBukkit
|
|
|
|
s = pingEvent.getMotd() + "\u00A7" + playerlist.getPlayerCount() + "\u00A7" + pingEvent.getMaxPlayers();
|
|
|
|
} else {
|
|
|
|
@@ -172,9 +177,18 @@ public class PendingConnection extends Connection {
|
2013-04-18 18:27:29 +00:00
|
|
|
|
|
|
|
this.networkManager.queue(new Packet255KickDisconnect(s));
|
|
|
|
this.networkManager.d();
|
2013-07-02 03:03:56 +00:00
|
|
|
- if (inetaddress != null && this.server.ag() instanceof DedicatedServerConnection) {
|
|
|
|
- ((DedicatedServerConnection) this.server.ag()).a(inetaddress);
|
2013-04-19 07:45:39 +00:00
|
|
|
+ // Spigot start
|
2013-07-01 23:05:40 +00:00
|
|
|
+ if ( inetaddress != null )
|
|
|
|
+ {
|
2013-07-02 03:03:56 +00:00
|
|
|
+ if ( this.server.ag() instanceof DedicatedServerConnection )
|
2013-07-01 23:05:40 +00:00
|
|
|
+ {
|
2013-07-02 03:03:56 +00:00
|
|
|
+ ((DedicatedServerConnection) this.server.ag()).a(inetaddress);
|
2013-07-01 23:05:40 +00:00
|
|
|
+ } else
|
|
|
|
+ {
|
2013-07-02 03:36:58 +00:00
|
|
|
+ ((org.spigotmc.netty.NettyServerConnection)this.server.ag()).unThrottle( inetaddress );
|
2013-07-01 23:05:40 +00:00
|
|
|
+ }
|
2013-04-18 18:27:29 +00:00
|
|
|
}
|
2013-04-19 07:45:39 +00:00
|
|
|
+ // Spigot end
|
2013-04-18 18:27:29 +00:00
|
|
|
|
|
|
|
this.b = true;
|
2013-04-19 07:45:39 +00:00
|
|
|
} catch (Exception exception) {
|
2013-06-20 09:23:30 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
|
2013-07-01 23:05:40 +00:00
|
|
|
index a0a7790..c6ec91b 100644
|
2013-06-20 09:23:30 +00:00
|
|
|
--- a/src/main/java/org/spigotmc/SpigotConfig.java
|
|
|
|
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
|
2013-06-21 08:25:45 +00:00
|
|
|
@@ -6,6 +6,8 @@ import java.io.IOException;
|
2013-06-20 09:23:30 +00:00
|
|
|
import java.lang.reflect.InvocationTargetException;
|
|
|
|
import java.lang.reflect.Method;
|
|
|
|
import java.lang.reflect.Modifier;
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
2013-06-21 08:25:45 +00:00
|
|
|
import java.util.HashMap;
|
2013-06-21 07:30:13 +00:00
|
|
|
import java.util.List;
|
2013-06-21 08:25:45 +00:00
|
|
|
import java.util.Map;
|
2013-07-01 23:05:40 +00:00
|
|
|
@@ -148,4 +150,61 @@ public class SpigotConfig
|
2013-06-21 08:25:45 +00:00
|
|
|
commands.put( "restart", new RestartCommand( "restart" ) );
|
2013-06-20 09:23:30 +00:00
|
|
|
WatchdogThread.doStart( timeoutTime, restartOnCrash );
|
|
|
|
}
|
|
|
|
+
|
|
|
|
+ public static class Listener
|
|
|
|
+ {
|
|
|
|
+
|
|
|
|
+ public String host;
|
|
|
|
+ public int port;
|
|
|
|
+ public boolean netty;
|
|
|
|
+ public long connectionThrottle;
|
|
|
|
+
|
|
|
|
+ public Listener(String host, int port, boolean netty, long connectionThrottle)
|
|
|
|
+ {
|
|
|
|
+ this.host = host;
|
|
|
|
+ this.port = port;
|
|
|
|
+ this.netty = netty;
|
|
|
|
+ this.connectionThrottle = connectionThrottle;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ public static List<Listener> listeners = new ArrayList<Listener>();
|
2013-06-22 04:35:20 +00:00
|
|
|
+ public static int nettyThreads;
|
2013-07-01 23:05:40 +00:00
|
|
|
+
|
2013-06-21 08:57:20 +00:00
|
|
|
+ private static void listeners()
|
2013-06-20 09:23:30 +00:00
|
|
|
+ {
|
|
|
|
+ Map<String, Object> def = new HashMap<String, Object>();
|
|
|
|
+ def.put( "host", "default" );
|
|
|
|
+ def.put( "port", "default" );
|
|
|
|
+ def.put( "netty", true );
|
2013-06-23 06:45:43 +00:00
|
|
|
+ // def.put( "throttle", "default" );
|
2013-06-20 09:23:30 +00:00
|
|
|
+
|
|
|
|
+ config.addDefault( "listeners", Collections.singletonList( def ) );
|
|
|
|
+ for ( Map<String, Object> info : (List<Map<String, Object>>) config.getList( "listeners" ) )
|
|
|
|
+ {
|
|
|
|
+ String host = (String) info.get( "host" );
|
|
|
|
+ if ( "default".equals( host ) )
|
|
|
|
+ {
|
|
|
|
+ host = Bukkit.getIp();
|
2013-07-01 23:05:40 +00:00
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ throw new IllegalArgumentException( "Can only bind listener to default! Configure it in server.properties" );
|
|
|
|
+ }
|
|
|
|
+ int port ;
|
|
|
|
+
|
|
|
|
+ if (info.get( "port" ) instanceof Integer){
|
|
|
|
+ throw new IllegalArgumentException( "Can only bind port to default! Configure it in server.properties");
|
|
|
|
+ } else{
|
|
|
|
+ port = Bukkit.getPort();
|
2013-06-20 09:23:30 +00:00
|
|
|
+ }
|
|
|
|
+ boolean netty = (Boolean) info.get( "netty" );
|
2013-06-23 06:45:43 +00:00
|
|
|
+ // long connectionThrottle = ( info.get( "throttle" ) instanceof Number ) ? ( (Number) info.get( "throttle" ) ).longValue() : Bukkit.getConnectionThrottle();
|
|
|
|
+ listeners.add( new Listener( host, port, netty, Bukkit.getConnectionThrottle() ) );
|
2013-06-20 09:23:30 +00:00
|
|
|
+ }
|
2013-07-01 23:05:40 +00:00
|
|
|
+ if ( listeners.size() != 1 )
|
|
|
|
+ {
|
|
|
|
+ throw new IllegalArgumentException( "May only have one listener!" );
|
|
|
|
+ }
|
2013-06-22 04:35:20 +00:00
|
|
|
+
|
|
|
|
+ nettyThreads = getInt( "settings.netty-threads", 3 );
|
2013-06-20 09:23:30 +00:00
|
|
|
+ }
|
|
|
|
}
|
2013-05-16 06:41:34 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/CipherBase.java b/src/main/java/org/spigotmc/netty/CipherBase.java
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
new file mode 100644
|
2013-06-29 05:36:18 +00:00
|
|
|
index 0000000..c4306f7
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- /dev/null
|
2013-05-16 06:41:34 +00:00
|
|
|
+++ b/src/main/java/org/spigotmc/netty/CipherBase.java
|
2013-06-29 05:36:18 +00:00
|
|
|
@@ -0,0 +1,73 @@
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
|
|
|
+import io.netty.buffer.ByteBuf;
|
2013-06-29 05:36:18 +00:00
|
|
|
+import io.netty.channel.ChannelHandlerContext;
|
2013-02-24 01:38:41 +00:00
|
|
|
+import javax.crypto.Cipher;
|
|
|
|
+import javax.crypto.ShortBufferException;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+/**
|
2013-05-16 06:41:34 +00:00
|
|
|
+ * Class to expose an
|
|
|
|
+ * {@link #cipher(io.netty.buffer.ByteBuf, io.netty.buffer.ByteBuf)} method to
|
|
|
|
+ * aid in the efficient passing of ByteBuffers through a cipher.
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+class CipherBase
|
|
|
|
+{
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
2013-05-16 06:41:34 +00:00
|
|
|
+ private final Cipher cipher;
|
2013-04-12 03:57:00 +00:00
|
|
|
+ private ThreadLocal<byte[]> heapInLocal = new EmptyByteThreadLocal();
|
|
|
|
+ private ThreadLocal<byte[]> heapOutLocal = new EmptyByteThreadLocal();
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ private static class EmptyByteThreadLocal extends ThreadLocal<byte[]>
|
|
|
|
+ {
|
2013-04-12 03:57:00 +00:00
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ protected byte[] initialValue()
|
|
|
|
+ {
|
|
|
|
+ return new byte[ 0 ];
|
2013-04-12 03:57:00 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ protected CipherBase(Cipher cipher)
|
|
|
|
+ {
|
2013-05-16 06:41:34 +00:00
|
|
|
+ this.cipher = cipher;
|
2013-04-21 00:21:35 +00:00
|
|
|
+ }
|
|
|
|
+
|
2013-06-29 05:36:18 +00:00
|
|
|
+ private byte[] bufToByte(ByteBuf in)
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-04-12 03:57:00 +00:00
|
|
|
+ byte[] heapIn = heapInLocal.get();
|
2013-03-16 22:14:16 +00:00
|
|
|
+ int readableBytes = in.readableBytes();
|
2013-06-01 03:57:16 +00:00
|
|
|
+ if ( heapIn.length < readableBytes )
|
|
|
|
+ {
|
|
|
|
+ heapIn = new byte[ readableBytes ];
|
2013-06-02 04:43:20 +00:00
|
|
|
+ heapInLocal.set( heapIn );
|
2013-03-12 06:26:16 +00:00
|
|
|
+ }
|
2013-06-01 03:57:16 +00:00
|
|
|
+ in.readBytes( heapIn, 0, readableBytes );
|
2013-06-29 05:36:18 +00:00
|
|
|
+ return heapIn;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected ByteBuf cipher(ChannelHandlerContext ctx, ByteBuf in) throws ShortBufferException
|
|
|
|
+ {
|
|
|
|
+ int readableBytes = in.readableBytes();
|
|
|
|
+ byte[] heapIn = bufToByte( in );
|
|
|
|
+
|
|
|
|
+ ByteBuf heapOut = ctx.alloc().heapBuffer( cipher.getOutputSize( readableBytes ) );
|
|
|
|
+ heapOut.writerIndex( cipher.update( heapIn, 0, readableBytes, heapOut.array(), heapOut.arrayOffset() ) );
|
|
|
|
+
|
|
|
|
+ return heapOut;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ protected void cipher(ByteBuf in, ByteBuf out) throws ShortBufferException
|
|
|
|
+ {
|
|
|
|
+ int readableBytes = in.readableBytes();
|
|
|
|
+ byte[] heapIn = bufToByte( in );
|
2013-03-12 06:26:16 +00:00
|
|
|
+
|
2013-04-12 03:57:00 +00:00
|
|
|
+ byte[] heapOut = heapOutLocal.get();
|
2013-06-01 03:57:16 +00:00
|
|
|
+ int outputSize = cipher.getOutputSize( readableBytes );
|
|
|
|
+ if ( heapOut.length < outputSize )
|
|
|
|
+ {
|
|
|
|
+ heapOut = new byte[ outputSize ];
|
2013-06-02 04:43:20 +00:00
|
|
|
+ heapOutLocal.set( heapOut );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
2013-06-01 03:57:16 +00:00
|
|
|
+ out.writeBytes( heapOut, 0, cipher.update( heapIn, 0, readableBytes, heapOut ) );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+}
|
2013-05-16 06:41:34 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/CipherDecoder.java b/src/main/java/org/spigotmc/netty/CipherDecoder.java
|
|
|
|
new file mode 100644
|
2013-06-29 05:36:18 +00:00
|
|
|
index 0000000..a1094d2
|
2013-05-16 06:41:34 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/CipherDecoder.java
|
2013-06-29 05:36:18 +00:00
|
|
|
@@ -0,0 +1,24 @@
|
2013-05-16 06:41:34 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
|
|
|
+import io.netty.buffer.ByteBuf;
|
|
|
|
+import io.netty.channel.ChannelHandlerContext;
|
2013-06-29 05:36:18 +00:00
|
|
|
+import io.netty.channel.MessageList;
|
|
|
|
+import io.netty.handler.codec.MessageToMessageDecoder;
|
2013-05-16 06:41:34 +00:00
|
|
|
+import javax.crypto.Cipher;
|
|
|
|
+
|
2013-06-29 05:36:18 +00:00
|
|
|
+public class CipherDecoder extends MessageToMessageDecoder<ByteBuf>
|
2013-06-01 03:57:16 +00:00
|
|
|
+{
|
2013-05-16 06:41:34 +00:00
|
|
|
+
|
|
|
|
+ private final CipherBase cipher;
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public CipherDecoder(Cipher cipher)
|
|
|
|
+ {
|
|
|
|
+ this.cipher = new CipherBase( cipher );
|
2013-05-16 06:41:34 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-29 05:36:18 +00:00
|
|
|
+ protected void decode(ChannelHandlerContext ctx, ByteBuf msg, MessageList<Object> out) throws Exception
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ out.add( cipher.cipher( ctx, msg ) );
|
2013-05-16 06:41:34 +00:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/CipherEncoder.java b/src/main/java/org/spigotmc/netty/CipherEncoder.java
|
|
|
|
new file mode 100644
|
2013-06-29 05:36:18 +00:00
|
|
|
index 0000000..2eb1dcb
|
2013-05-16 06:41:34 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/CipherEncoder.java
|
2013-06-01 03:57:16 +00:00
|
|
|
@@ -0,0 +1,23 @@
|
2013-05-16 06:41:34 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
|
|
|
+import io.netty.buffer.ByteBuf;
|
|
|
|
+import io.netty.channel.ChannelHandlerContext;
|
2013-06-29 05:36:18 +00:00
|
|
|
+import io.netty.handler.codec.MessageToByteEncoder;
|
2013-05-16 06:41:34 +00:00
|
|
|
+import javax.crypto.Cipher;
|
|
|
|
+
|
2013-06-29 05:36:18 +00:00
|
|
|
+public class CipherEncoder extends MessageToByteEncoder<ByteBuf>
|
2013-06-01 03:57:16 +00:00
|
|
|
+{
|
2013-05-16 06:41:34 +00:00
|
|
|
+
|
|
|
|
+ private final CipherBase cipher;
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public CipherEncoder(Cipher cipher)
|
|
|
|
+ {
|
|
|
|
+ this.cipher = new CipherBase( cipher );
|
2013-05-16 06:41:34 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ protected void encode(ChannelHandlerContext ctx, ByteBuf in, ByteBuf out) throws Exception
|
|
|
|
+ {
|
|
|
|
+ cipher.cipher( in, out );
|
2013-05-16 06:41:34 +00:00
|
|
|
+ }
|
|
|
|
+}
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/NettyNetworkManager.java b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
|
|
|
|
new file mode 100644
|
2013-07-02 03:57:42 +00:00
|
|
|
index 0000000..f77b10c
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/NettyNetworkManager.java
|
2013-07-02 03:57:42 +00:00
|
|
|
@@ -0,0 +1,315 @@
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
2013-02-19 08:38:18 +00:00
|
|
|
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import io.netty.channel.Channel;
|
|
|
|
+import io.netty.channel.ChannelHandlerContext;
|
2013-06-29 05:36:18 +00:00
|
|
|
+import io.netty.channel.ChannelInboundHandlerAdapter;
|
|
|
|
+import io.netty.channel.MessageList;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import io.netty.channel.socket.SocketChannel;
|
|
|
|
+import java.net.Socket;
|
|
|
|
+import java.net.SocketAddress;
|
2013-02-09 09:58:03 +00:00
|
|
|
+import java.security.PrivateKey;
|
2013-04-21 00:21:35 +00:00
|
|
|
+import java.util.AbstractList;
|
2013-02-22 08:29:36 +00:00
|
|
|
+import java.util.List;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import java.util.Queue;
|
|
|
|
+import java.util.concurrent.ConcurrentLinkedQueue;
|
|
|
|
+import java.util.concurrent.ExecutorService;
|
|
|
|
+import java.util.concurrent.Executors;
|
2013-02-24 01:38:41 +00:00
|
|
|
+import javax.crypto.Cipher;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import javax.crypto.SecretKey;
|
|
|
|
+import net.minecraft.server.Connection;
|
|
|
|
+import net.minecraft.server.INetworkManager;
|
|
|
|
+import net.minecraft.server.MinecraftServer;
|
|
|
|
+import net.minecraft.server.Packet;
|
|
|
|
+import net.minecraft.server.Packet252KeyResponse;
|
2013-05-11 05:37:37 +00:00
|
|
|
+import net.minecraft.server.Packet255KickDisconnect;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import net.minecraft.server.PendingConnection;
|
2013-02-09 10:05:34 +00:00
|
|
|
+import net.minecraft.server.PlayerConnection;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * This class forms the basis of the Netty integration. It implements
|
|
|
|
+ * {@link INetworkManager} and handles all events and inbound messages provided
|
|
|
|
+ * by the upstream Netty process.
|
|
|
|
+ */
|
2013-06-29 05:36:18 +00:00
|
|
|
+public class NettyNetworkManager extends ChannelInboundHandlerAdapter implements INetworkManager
|
2013-06-01 03:57:16 +00:00
|
|
|
+{
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ private static final ExecutorService threadPool = Executors.newCachedThreadPool( new ThreadFactoryBuilder().setNameFormat( "Async Packet Handler - %1$d" ).build() );
|
2013-02-09 09:27:25 +00:00
|
|
|
+ private static final MinecraftServer server = MinecraftServer.getServer();
|
2013-07-02 03:36:58 +00:00
|
|
|
+ private static final PrivateKey key = server.H().getPrivate();
|
|
|
|
+ private static final NettyServerConnection serverConnection = (NettyServerConnection) server.ag();
|
2013-02-09 09:27:25 +00:00
|
|
|
+ /*========================================================================*/
|
2013-02-10 07:35:09 +00:00
|
|
|
+ private final Queue<Packet> syncPackets = new ConcurrentLinkedQueue<Packet>();
|
2013-06-01 03:57:16 +00:00
|
|
|
+ private final List<Packet> highPriorityQueue = new AbstractList<Packet>()
|
|
|
|
+ {
|
2013-04-21 00:21:35 +00:00
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void add(int index, Packet element)
|
|
|
|
+ {
|
2013-04-21 00:21:35 +00:00
|
|
|
+ // NOP
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public Packet get(int index)
|
|
|
|
+ {
|
2013-04-21 00:21:35 +00:00
|
|
|
+ throw new UnsupportedOperationException();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public int size()
|
|
|
|
+ {
|
2013-04-21 00:21:35 +00:00
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+ };
|
2013-02-13 01:22:25 +00:00
|
|
|
+ private volatile boolean connected;
|
2013-02-10 07:35:09 +00:00
|
|
|
+ private Channel channel;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ private SocketAddress address;
|
2013-05-27 21:21:11 +00:00
|
|
|
+ Connection connection;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ private SecretKey secret;
|
|
|
|
+ private String dcReason;
|
|
|
|
+ private Object[] dcArgs;
|
|
|
|
+ private Socket socketAdaptor;
|
2013-04-10 06:37:43 +00:00
|
|
|
+ private long writtenBytes;
|
2013-06-29 07:39:07 +00:00
|
|
|
+ private PacketWriter writer;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void channelActive(ChannelHandlerContext ctx) throws Exception
|
|
|
|
+ {
|
2013-02-13 01:22:25 +00:00
|
|
|
+ // Channel and address groundwork first
|
|
|
|
+ channel = ctx.channel();
|
|
|
|
+ address = channel.remoteAddress();
|
|
|
|
+ // Then the socket adaptor
|
2013-06-01 03:57:16 +00:00
|
|
|
+ socketAdaptor = NettySocketAdaptor.adapt( (SocketChannel) channel );
|
2013-02-13 01:22:25 +00:00
|
|
|
+ // Followed by their first handler
|
2013-06-01 03:57:16 +00:00
|
|
|
+ connection = new PendingConnection( server, this );
|
2013-06-29 07:39:07 +00:00
|
|
|
+ writer = new PacketWriter();
|
2013-02-13 01:22:25 +00:00
|
|
|
+ // Finally register the connection
|
|
|
|
+ connected = true;
|
2013-06-01 03:57:16 +00:00
|
|
|
+ serverConnection.register( (PendingConnection) connection );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void channelInactive(ChannelHandlerContext ctx) throws Exception
|
|
|
|
+ {
|
2013-06-29 07:39:07 +00:00
|
|
|
+ writer.release();
|
2013-06-01 03:57:16 +00:00
|
|
|
+ a( "disconnect.endOfStream", new Object[ 0 ] );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception
|
|
|
|
+ {
|
2013-02-13 01:22:25 +00:00
|
|
|
+ // TODO: Remove this once we are more stable
|
|
|
|
+ // Bukkit.getServer().getLogger().severe("======================= Start Netty Debug Log =======================");
|
|
|
|
+ // Bukkit.getServer().getLogger().log(Level.SEVERE, "Error caught whilst handling " + channel, cause);
|
|
|
|
+ // Bukkit.getServer().getLogger().severe("======================= End Netty Debug Log =======================");
|
|
|
|
+ // Disconnect with generic reason + exception
|
2013-06-01 03:57:16 +00:00
|
|
|
+ a( "disconnect.genericReason", new Object[]
|
|
|
|
+ {
|
|
|
|
+ "Internal exception: " + cause
|
|
|
|
+ } );
|
2013-07-02 03:57:42 +00:00
|
|
|
+ cause.printStackTrace();
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-29 05:36:18 +00:00
|
|
|
+ public void messageReceived(ChannelHandlerContext ctx, MessageList<Object> msgs) throws Exception
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ MessageList<Packet> packets = msgs.cast();
|
|
|
|
+ for ( final Packet msg : packets )
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ if ( connected )
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ if ( msg instanceof Packet252KeyResponse )
|
|
|
|
+ {
|
|
|
|
+ secret = ( (Packet252KeyResponse) msg ).a( key );
|
|
|
|
+ Cipher decrypt = NettyServerConnection.getCipher( Cipher.DECRYPT_MODE, secret );
|
|
|
|
+ channel.pipeline().addBefore( "decoder", "decrypt", new CipherDecoder( decrypt ) );
|
|
|
|
+ }
|
2013-03-26 01:09:44 +00:00
|
|
|
+
|
2013-06-29 05:36:18 +00:00
|
|
|
+ if ( msg.a_() )
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ threadPool.submit( new Runnable()
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ public void run()
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ Packet packet = PacketListener.callReceived( NettyNetworkManager.this, connection, msg );
|
|
|
|
+ if ( packet != null )
|
|
|
|
+ {
|
|
|
|
+ packet.handle( connection );
|
|
|
|
+ }
|
2013-03-26 01:09:44 +00:00
|
|
|
+ }
|
2013-06-29 05:36:18 +00:00
|
|
|
+ } );
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ syncPackets.add( msg );
|
|
|
|
+ }
|
2013-03-26 01:09:44 +00:00
|
|
|
+ }
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public Socket getSocket()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return socketAdaptor;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * setHandler. Set the {@link NetHandler} used to process received packets.
|
|
|
|
+ *
|
|
|
|
+ * @param nh the new {@link NetHandler} instance
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void a(Connection nh)
|
|
|
|
+ {
|
2013-02-19 07:01:42 +00:00
|
|
|
+ connection = nh;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * queue. Queue a packet for sending, or in this case send it to be write it
|
|
|
|
+ * straight to the channel.
|
|
|
|
+ *
|
|
|
|
+ * @param packet the packet to queue
|
|
|
|
+ */
|
2013-06-29 05:36:18 +00:00
|
|
|
+ public void queue(final Packet packet)
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-02-13 01:22:25 +00:00
|
|
|
+ // Only send if channel is still connected
|
2013-06-01 03:57:16 +00:00
|
|
|
+ if ( connected )
|
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ if ( channel.eventLoop().inEventLoop() )
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ queue0( packet );
|
|
|
|
+ } else
|
|
|
|
+ {
|
|
|
|
+ channel.eventLoop().execute( new Runnable()
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ public void run()
|
|
|
|
+ {
|
|
|
|
+ queue0( packet );
|
|
|
|
+ }
|
|
|
|
+ } );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
2013-04-21 00:21:35 +00:00
|
|
|
+
|
2013-06-29 05:36:18 +00:00
|
|
|
+ private void queue0(Packet packet)
|
|
|
|
+ {
|
|
|
|
+ // Process packet via handler
|
|
|
|
+ packet = PacketListener.callQueued( this, connection, packet );
|
|
|
|
+ // If handler indicates packet send
|
|
|
|
+ if ( packet != null )
|
|
|
|
+ {
|
|
|
|
+ highPriorityQueue.add( packet );
|
|
|
|
+
|
|
|
|
+ if ( packet instanceof Packet255KickDisconnect )
|
|
|
|
+ {
|
2013-06-29 07:39:07 +00:00
|
|
|
+ writer.lastFlush = 0;
|
2013-06-29 05:36:18 +00:00
|
|
|
+ }
|
|
|
|
+
|
2013-06-29 07:39:07 +00:00
|
|
|
+ writer.write( channel, this, packet );
|
2013-06-29 05:36:18 +00:00
|
|
|
+ if ( packet instanceof Packet252KeyResponse )
|
|
|
|
+ {
|
|
|
|
+ Cipher encrypt = NettyServerConnection.getCipher( Cipher.ENCRYPT_MODE, secret );
|
|
|
|
+ channel.pipeline().addBefore( "decoder", "encrypt", new CipherEncoder( encrypt ) );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * wakeThreads. In Vanilla this method will interrupt the network read and
|
|
|
|
+ * write threads, thus waking them.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void a()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * processPackets. Remove up to 1000 packets from the queue and process
|
|
|
|
+ * them. This method should only be called from the main server thread.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void b()
|
|
|
|
+ {
|
|
|
|
+ for ( int i = 1000; !syncPackets.isEmpty() && i >= 0; i-- )
|
|
|
|
+ {
|
|
|
|
+ if ( connection instanceof PendingConnection ? ( (PendingConnection) connection ).b : ( (PlayerConnection) connection ).disconnected )
|
|
|
|
+ {
|
2013-02-09 22:33:31 +00:00
|
|
|
+ syncPackets.clear();
|
2013-02-09 12:00:03 +00:00
|
|
|
+ break;
|
2013-02-09 10:05:34 +00:00
|
|
|
+ }
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ Packet packet = PacketListener.callReceived( this, connection, syncPackets.poll() );
|
|
|
|
+ if ( packet != null )
|
|
|
|
+ {
|
|
|
|
+ packet.handle( connection );
|
2013-02-17 09:47:27 +00:00
|
|
|
+ }
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
2013-02-09 10:55:33 +00:00
|
|
|
+
|
|
|
|
+ // Disconnect via the handler - this performs all plugin related cleanup + logging
|
2013-06-01 03:57:16 +00:00
|
|
|
+ if ( !connected && ( dcReason != null || dcArgs != null ) )
|
|
|
|
+ {
|
|
|
|
+ connection.a( dcReason, dcArgs );
|
2013-02-09 10:55:33 +00:00
|
|
|
+ }
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * getSocketAddress. Return the remote address of the connected user. It is
|
|
|
|
+ * important that this method returns a value even after disconnect.
|
|
|
|
+ *
|
|
|
|
+ * @return the remote address of this connection
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public SocketAddress getSocketAddress()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return address;
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void setSocketAddress(SocketAddress address)
|
|
|
|
+ {
|
2013-03-23 00:06:00 +00:00
|
|
|
+ this.address = address;
|
|
|
|
+ }
|
|
|
|
+
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ /**
|
|
|
|
+ * close. Close and release all resources associated with this connection.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void d()
|
|
|
|
+ {
|
|
|
|
+ if ( connected )
|
|
|
|
+ {
|
2013-02-13 01:22:25 +00:00
|
|
|
+ connected = false;
|
|
|
|
+ channel.close();
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * queueSize. Return the number of packets in the low priority queue. In a
|
|
|
|
+ * NIO environment this will always be 0.
|
|
|
|
+ *
|
|
|
|
+ * @return the size of the packet send queue
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public int e()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return 0;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * networkShutdown. Shuts down this connection, storing the reason and
|
|
|
|
+ * parameters, used to notify the current {@link Connection}.
|
|
|
|
+ *
|
|
|
|
+ * @param reason the main disconnect reason
|
|
|
|
+ * @param arguments additional disconnect arguments, for example, the
|
|
|
|
+ * exception which triggered the disconnect.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void a(String reason, Object... arguments)
|
|
|
|
+ {
|
|
|
|
+ if ( connected )
|
|
|
|
+ {
|
2013-02-13 01:22:25 +00:00
|
|
|
+ dcReason = reason;
|
|
|
|
+ dcArgs = arguments;
|
|
|
|
+ d();
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
2013-04-10 06:37:43 +00:00
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public long getWrittenBytes()
|
|
|
|
+ {
|
2013-04-10 06:37:43 +00:00
|
|
|
+ return writtenBytes;
|
|
|
|
+ }
|
2013-04-28 09:52:35 +00:00
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void addWrittenBytes(int written)
|
|
|
|
+ {
|
2013-04-28 09:52:35 +00:00
|
|
|
+ writtenBytes += written;
|
|
|
|
+ }
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/NettyServerConnection.java b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
|
|
|
|
new file mode 100644
|
2013-07-01 23:05:40 +00:00
|
|
|
index 0000000..b29ca98
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
|
2013-07-01 23:05:40 +00:00
|
|
|
@@ -0,0 +1,170 @@
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
2013-02-19 08:38:18 +00:00
|
|
|
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import io.netty.bootstrap.ServerBootstrap;
|
|
|
|
+import io.netty.channel.Channel;
|
2013-02-10 01:35:52 +00:00
|
|
|
+import io.netty.channel.ChannelException;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import io.netty.channel.ChannelFuture;
|
|
|
|
+import io.netty.channel.ChannelInitializer;
|
|
|
|
+import io.netty.channel.ChannelOption;
|
2013-06-22 04:35:20 +00:00
|
|
|
+import io.netty.channel.EventLoopGroup;
|
2013-02-17 09:15:48 +00:00
|
|
|
+import io.netty.channel.nio.NioEventLoopGroup;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import io.netty.channel.socket.nio.NioServerSocketChannel;
|
|
|
|
+import io.netty.handler.timeout.ReadTimeoutHandler;
|
|
|
|
+import java.net.InetAddress;
|
2013-06-01 04:23:53 +00:00
|
|
|
+import java.net.InetSocketAddress;
|
2013-02-24 01:38:41 +00:00
|
|
|
+import java.security.GeneralSecurityException;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import java.security.Key;
|
2013-07-01 23:05:40 +00:00
|
|
|
+import java.util.ArrayList;
|
|
|
|
+import java.util.Collections;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.logging.Level;
|
2013-02-24 01:38:41 +00:00
|
|
|
+import javax.crypto.Cipher;
|
|
|
|
+import javax.crypto.spec.IvParameterSpec;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import net.minecraft.server.MinecraftServer;
|
2013-07-01 23:05:40 +00:00
|
|
|
+import net.minecraft.server.PendingConnection;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import net.minecraft.server.ServerConnection;
|
2013-07-01 23:05:40 +00:00
|
|
|
+import org.bukkit.Bukkit;
|
2013-06-23 06:33:18 +00:00
|
|
|
+import org.spigotmc.SpigotConfig;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * This is the NettyServerConnection class. It implements
|
|
|
|
+ * {@link ServerConnection} and is the main interface between the Minecraft
|
|
|
|
+ * server and this NIO implementation. It handles starting, stopping and
|
|
|
|
+ * processing the Netty backend.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+public class NettyServerConnection extends ServerConnection
|
|
|
|
+{
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+ private final ChannelFuture socket;
|
2013-06-22 04:35:20 +00:00
|
|
|
+ private static EventLoopGroup group;
|
2013-07-01 23:05:40 +00:00
|
|
|
+ private final Map<InetAddress, Long> throttle = new HashMap<InetAddress, Long>();
|
|
|
|
+ private final List<PendingConnection> pending = Collections.synchronizedList( new ArrayList<PendingConnection>() );
|
|
|
|
+
|
|
|
|
+ public void unThrottle(InetAddress address)
|
|
|
|
+ {
|
|
|
|
+ if ( address != null )
|
|
|
|
+ {
|
|
|
|
+ synchronized ( throttle )
|
|
|
|
+ {
|
|
|
|
+ throttle.remove( address );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public boolean throttle(InetAddress address)
|
|
|
|
+ {
|
|
|
|
+ long currentTime = System.currentTimeMillis();
|
|
|
|
+ synchronized ( throttle )
|
|
|
|
+ {
|
|
|
|
+ Long value = throttle.get( address );
|
|
|
|
+ if ( value != null && !address.isLoopbackAddress() && currentTime - value < d().server.getConnectionThrottle() )
|
|
|
|
+ {
|
|
|
|
+ throttle.put( address, currentTime );
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ throttle.put( address, currentTime );
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
2013-04-19 07:45:39 +00:00
|
|
|
+
|
2013-06-01 04:23:53 +00:00
|
|
|
+ public NettyServerConnection(final MinecraftServer ms, InetAddress host, int port)
|
2013-06-01 03:57:16 +00:00
|
|
|
+ {
|
|
|
|
+ super( ms );
|
2013-06-22 04:35:20 +00:00
|
|
|
+ if ( group == null )
|
|
|
|
+ {
|
2013-06-23 06:33:18 +00:00
|
|
|
+ group = new NioEventLoopGroup( SpigotConfig.nettyThreads, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread - %1$d" ).build() );
|
2013-06-22 04:35:20 +00:00
|
|
|
+ }
|
2013-06-23 06:33:18 +00:00
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ socket = new ServerBootstrap().channel( NioServerSocketChannel.class ).childHandler( new ChannelInitializer()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void initChannel(Channel ch) throws Exception
|
|
|
|
+ {
|
2013-06-01 04:23:53 +00:00
|
|
|
+ // Check the throttle
|
2013-07-01 23:05:40 +00:00
|
|
|
+ if ( throttle( ( (InetSocketAddress) ch.remoteAddress() ).getAddress() ) )
|
2013-06-01 04:23:53 +00:00
|
|
|
+ {
|
|
|
|
+ ch.close();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Set IP_TOS
|
2013-06-01 03:57:16 +00:00
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ ch.config().setOption( ChannelOption.IP_TOS, 0x18 );
|
|
|
|
+ } catch ( ChannelException ex )
|
|
|
|
+ {
|
2013-02-10 01:35:52 +00:00
|
|
|
+ // IP_TOS is not supported (Windows XP / Windows Server 2003)
|
|
|
|
+ }
|
2013-02-10 03:26:59 +00:00
|
|
|
+
|
2013-04-10 06:37:43 +00:00
|
|
|
+ NettyNetworkManager networkManager = new NettyNetworkManager();
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ ch.pipeline()
|
2013-06-01 03:57:16 +00:00
|
|
|
+ .addLast( "timer", new ReadTimeoutHandler( 30 ) )
|
|
|
|
+ .addLast( "decoder", new PacketDecoder() )
|
|
|
|
+ .addLast( "manager", networkManager );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
2013-06-23 06:33:18 +00:00
|
|
|
+ } ).childOption( ChannelOption.TCP_NODELAY, false ).group( group ).localAddress( host, port ).bind().syncUninterruptibly();
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Shutdown. This method is called when the server is shutting down and the
|
|
|
|
+ * server socket and all clients should be terminated with no further
|
|
|
|
+ * action.
|
|
|
|
+ */
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void a()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ socket.channel().close().syncUninterruptibly();
|
|
|
|
+ }
|
|
|
|
+
|
2013-07-01 23:05:40 +00:00
|
|
|
+ @Override
|
|
|
|
+ public void b()
|
|
|
|
+ {
|
|
|
|
+ super.b(); // pulse PlayerConnections
|
|
|
|
+ for ( int i = 0; i < pending.size(); ++i )
|
|
|
|
+ {
|
|
|
|
+ PendingConnection connection = pending.get( i );
|
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ connection.c();
|
|
|
|
+ } catch ( Exception ex )
|
|
|
|
+ {
|
|
|
|
+ connection.disconnect( "Internal server error" );
|
|
|
|
+ Bukkit.getServer().getLogger().log( Level.WARNING, "Failed to handle packet: " + ex, ex );
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if ( connection.b )
|
|
|
|
+ {
|
|
|
|
+ pending.remove( i-- );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void register(PendingConnection conn)
|
|
|
|
+ {
|
|
|
|
+ pending.add( conn );
|
|
|
|
+ }
|
|
|
|
+
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ /**
|
|
|
|
+ * Return a Minecraft compatible cipher instance from the specified key.
|
|
|
|
+ *
|
2013-02-24 01:38:41 +00:00
|
|
|
+ * @param opMode the mode to initialize the cipher in
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ * @param key to use as the initial vector
|
|
|
|
+ * @return the initialized cipher
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public static Cipher getCipher(int opMode, Key key)
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ Cipher cip = Cipher.getInstance( "AES/CFB8/NoPadding" );
|
|
|
|
+ cip.init( opMode, key, new IvParameterSpec( key.getEncoded() ) );
|
2013-02-24 01:38:41 +00:00
|
|
|
+ return cip;
|
2013-06-01 03:57:16 +00:00
|
|
|
+ } catch ( GeneralSecurityException ex )
|
|
|
|
+ {
|
|
|
|
+ throw new RuntimeException( ex );
|
2013-02-24 01:38:41 +00:00
|
|
|
+ }
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/NettySocketAdaptor.java b/src/main/java/org/spigotmc/netty/NettySocketAdaptor.java
|
|
|
|
new file mode 100644
|
2013-06-01 03:57:16 +00:00
|
|
|
index 0000000..5da8a59
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/NettySocketAdaptor.java
|
2013-06-01 03:57:16 +00:00
|
|
|
@@ -0,0 +1,294 @@
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
|
|
|
+import io.netty.channel.Channel;
|
|
|
|
+import io.netty.channel.ChannelOption;
|
|
|
|
+import java.io.IOException;
|
|
|
|
+import java.io.InputStream;
|
|
|
|
+import java.io.OutputStream;
|
|
|
|
+import java.net.InetAddress;
|
|
|
|
+import java.net.Socket;
|
|
|
|
+import java.net.SocketAddress;
|
|
|
|
+import java.net.SocketException;
|
|
|
|
+import java.nio.channels.SocketChannel;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * This class wraps a Netty {@link Channel} in a {@link Socket}. It overrides
|
|
|
|
+ * all methods in {@link Socket} to ensure that calls are not mistakingly made
|
|
|
|
+ * to the unsupported super socket. All operations that can be sanely applied to
|
|
|
|
+ * a {@link Channel} are implemented here. Those which cannot will throw an
|
|
|
|
+ * {@link UnsupportedOperationException}.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+public class NettySocketAdaptor extends Socket
|
|
|
|
+{
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+ private final io.netty.channel.socket.SocketChannel ch;
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ private NettySocketAdaptor(io.netty.channel.socket.SocketChannel ch)
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ this.ch = ch;
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public static NettySocketAdaptor adapt(io.netty.channel.socket.SocketChannel ch)
|
|
|
|
+ {
|
|
|
|
+ return new NettySocketAdaptor( ch );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void bind(SocketAddress bindpoint) throws IOException
|
|
|
|
+ {
|
|
|
|
+ ch.bind( bindpoint ).syncUninterruptibly();
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public synchronized void close() throws IOException
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ ch.close().syncUninterruptibly();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void connect(SocketAddress endpoint) throws IOException
|
|
|
|
+ {
|
|
|
|
+ ch.connect( endpoint ).syncUninterruptibly();
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void connect(SocketAddress endpoint, int timeout) throws IOException
|
|
|
|
+ {
|
|
|
|
+ ch.config().setConnectTimeoutMillis( timeout );
|
|
|
|
+ ch.connect( endpoint ).syncUninterruptibly();
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean equals(Object obj)
|
|
|
|
+ {
|
|
|
|
+ return obj instanceof NettySocketAdaptor && ch.equals( ( (NettySocketAdaptor) obj ).ch );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public SocketChannel getChannel()
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public InetAddress getInetAddress()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.remoteAddress().getAddress();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public InputStream getInputStream() throws IOException
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean getKeepAlive() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ return ch.config().getOption( ChannelOption.SO_KEEPALIVE );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public InetAddress getLocalAddress()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.localAddress().getAddress();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public int getLocalPort()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.localAddress().getPort();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public SocketAddress getLocalSocketAddress()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.localAddress();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean getOOBInline() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public OutputStream getOutputStream() throws IOException
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public int getPort()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.remoteAddress().getPort();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public synchronized int getReceiveBufferSize() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ return ch.config().getOption( ChannelOption.SO_RCVBUF );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public SocketAddress getRemoteSocketAddress()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.remoteAddress();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean getReuseAddress() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ return ch.config().getOption( ChannelOption.SO_REUSEADDR );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public synchronized int getSendBufferSize() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ return ch.config().getOption( ChannelOption.SO_SNDBUF );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public int getSoLinger() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ return ch.config().getOption( ChannelOption.SO_LINGER );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public synchronized int getSoTimeout() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean getTcpNoDelay() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ return ch.config().getOption( ChannelOption.TCP_NODELAY );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public int getTrafficClass() throws SocketException
|
|
|
|
+ {
|
|
|
|
+ return ch.config().getOption( ChannelOption.IP_TOS );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public int hashCode()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.hashCode();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean isBound()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.localAddress() != null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean isClosed()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return !ch.isOpen();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean isConnected()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.isActive();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean isInputShutdown()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.isInputShutdown();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public boolean isOutputShutdown()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.isOutputShutdown();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void sendUrgentData(int data) throws IOException
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void setKeepAlive(boolean on) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ ch.config().setOption( ChannelOption.SO_KEEPALIVE, on );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void setOOBInline(boolean on) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void setPerformancePreferences(int connectionTime, int latency, int bandwidth)
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public synchronized void setReceiveBufferSize(int size) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ ch.config().setOption( ChannelOption.SO_RCVBUF, size );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void setReuseAddress(boolean on) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ ch.config().setOption( ChannelOption.SO_REUSEADDR, on );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public synchronized void setSendBufferSize(int size) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ ch.config().setOption( ChannelOption.SO_SNDBUF, size );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void setSoLinger(boolean on, int linger) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ ch.config().setOption( ChannelOption.SO_LINGER, linger );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public synchronized void setSoTimeout(int timeout) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void setTcpNoDelay(boolean on) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ ch.config().setOption( ChannelOption.TCP_NODELAY, on );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void setTrafficClass(int tc) throws SocketException
|
|
|
|
+ {
|
|
|
|
+ ch.config().setOption( ChannelOption.IP_TOS, tc );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void shutdownInput() throws IOException
|
|
|
|
+ {
|
|
|
|
+ throw new UnsupportedOperationException( "Operation not supported on Channel wrapper." );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public void shutdownOutput() throws IOException
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ ch.shutdownOutput().syncUninterruptibly();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public String toString()
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return ch.toString();
|
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/PacketDecoder.java b/src/main/java/org/spigotmc/netty/PacketDecoder.java
|
|
|
|
new file mode 100644
|
2013-07-02 03:57:42 +00:00
|
|
|
index 0000000..b955914
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/PacketDecoder.java
|
2013-07-02 03:57:42 +00:00
|
|
|
@@ -0,0 +1,69 @@
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
|
|
|
+import io.netty.buffer.ByteBuf;
|
|
|
|
+import io.netty.buffer.ByteBufInputStream;
|
|
|
|
+import io.netty.channel.ChannelHandlerContext;
|
2013-06-29 05:36:18 +00:00
|
|
|
+import io.netty.channel.MessageList;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import io.netty.handler.codec.ReplayingDecoder;
|
2013-07-02 03:57:42 +00:00
|
|
|
+import java.io.DataInput;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import java.io.DataInputStream;
|
2013-02-10 00:54:49 +00:00
|
|
|
+import java.io.EOFException;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import java.io.IOException;
|
2013-03-15 22:08:53 +00:00
|
|
|
+import net.minecraft.server.MinecraftServer;
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+import net.minecraft.server.Packet;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Packet decoding class backed by a reusable {@link DataInputStream} which
|
|
|
|
+ * backs the input {@link ByteBuf}. Reads an unsigned byte packet header and
|
|
|
|
+ * then decodes the packet accordingly.
|
|
|
|
+ */
|
2013-05-21 01:28:02 +00:00
|
|
|
+public class PacketDecoder extends ReplayingDecoder<ReadState>
|
|
|
|
+{
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
2013-07-02 03:57:42 +00:00
|
|
|
+ private DataInput input;
|
2013-02-13 01:11:37 +00:00
|
|
|
+ private Packet packet;
|
|
|
|
+
|
2013-05-21 01:28:02 +00:00
|
|
|
+ public PacketDecoder()
|
|
|
|
+ {
|
|
|
|
+ super( ReadState.HEADER );
|
2013-02-13 01:11:37 +00:00
|
|
|
+ }
|
2013-02-10 03:26:59 +00:00
|
|
|
+
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ @Override
|
2013-06-29 05:36:18 +00:00
|
|
|
+ protected void decode(ChannelHandlerContext ctx, ByteBuf in, MessageList<Object> out) throws Exception
|
2013-05-21 01:28:02 +00:00
|
|
|
+ {
|
|
|
|
+ if ( input == null )
|
|
|
|
+ {
|
2013-07-02 03:57:42 +00:00
|
|
|
+ input = new ByteBufInputStream( in );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+
|
2013-05-21 01:28:02 +00:00
|
|
|
+ while ( true )
|
|
|
|
+ {
|
|
|
|
+ switch ( state() )
|
|
|
|
+ {
|
2013-05-16 06:41:34 +00:00
|
|
|
+ case HEADER:
|
2013-07-02 03:57:42 +00:00
|
|
|
+ int packetId = input.readUnsignedByte();
|
2013-05-21 01:28:02 +00:00
|
|
|
+ packet = Packet.a( MinecraftServer.getServer().getLogger(), packetId );
|
|
|
|
+ if ( packet == null )
|
|
|
|
+ {
|
|
|
|
+ throw new IOException( "Bad packet id " + packetId );
|
2013-05-16 06:41:34 +00:00
|
|
|
+ }
|
2013-05-21 01:28:02 +00:00
|
|
|
+ checkpoint( ReadState.DATA );
|
2013-05-16 06:41:34 +00:00
|
|
|
+ case DATA:
|
2013-05-21 01:28:02 +00:00
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ packet.a( input );
|
|
|
|
+ } catch ( EOFException ex )
|
|
|
|
+ {
|
2013-06-29 05:36:18 +00:00
|
|
|
+ return;
|
2013-05-16 06:41:34 +00:00
|
|
|
+ }
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
2013-05-21 01:28:02 +00:00
|
|
|
+ checkpoint( ReadState.HEADER );
|
2013-06-29 05:36:18 +00:00
|
|
|
+ out.add( packet );
|
2013-05-16 06:41:34 +00:00
|
|
|
+ packet = null;
|
2013-06-29 05:36:18 +00:00
|
|
|
+ break;
|
2013-05-16 06:41:34 +00:00
|
|
|
+ default:
|
|
|
|
+ throw new IllegalStateException();
|
|
|
|
+ }
|
2013-02-13 01:11:37 +00:00
|
|
|
+ }
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+}
|
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/PacketListener.java b/src/main/java/org/spigotmc/netty/PacketListener.java
|
|
|
|
new file mode 100644
|
2013-06-01 03:57:16 +00:00
|
|
|
index 0000000..965ba12
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/PacketListener.java
|
2013-06-01 03:57:16 +00:00
|
|
|
@@ -0,0 +1,112 @@
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
|
|
|
+import com.google.common.base.Preconditions;
|
|
|
|
+import java.util.Arrays;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.Map;
|
|
|
|
+import java.util.logging.Level;
|
|
|
|
+import net.minecraft.server.Connection;
|
|
|
|
+import net.minecraft.server.INetworkManager;
|
|
|
|
+import net.minecraft.server.Packet;
|
|
|
|
+import org.bukkit.Bukkit;
|
|
|
|
+import org.bukkit.plugin.Plugin;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * This class is used for plugins that wish to register to listen to incoming
|
|
|
|
+ * and outgoing packets. To use this class, simply create a new instance,
|
|
|
|
+ * override the methods you wish to use, and call
|
|
|
|
+ * {@link #register(org.spigotmc.netty.PacketListener, org.bukkit.plugin.Plugin)}.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+public class PacketListener
|
|
|
|
+{
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * A mapping of all registered listeners and their owning plugins.
|
|
|
|
+ */
|
|
|
|
+ private static final Map<PacketListener, Plugin> listeners = new HashMap<PacketListener, Plugin>();
|
|
|
|
+ /**
|
|
|
|
+ * A baked list of all listeners, for efficiency sake.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ private static PacketListener[] baked = new PacketListener[ 0 ];
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Used to register a handler for receiving notifications of packet
|
|
|
|
+ * activity.
|
|
|
|
+ *
|
|
|
|
+ * @param listener the listener to register
|
|
|
|
+ * @param plugin the plugin owning this listener
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public static synchronized void register(PacketListener listener, Plugin plugin)
|
|
|
|
+ {
|
|
|
|
+ Preconditions.checkNotNull( listener, "listener" );
|
|
|
|
+ Preconditions.checkNotNull( plugin, "plugin" );
|
|
|
|
+ Preconditions.checkState( !listeners.containsKey( listener ), "listener already registered" );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+
|
|
|
|
+ int size = listeners.size();
|
2013-06-01 03:57:16 +00:00
|
|
|
+ Preconditions.checkState( baked.length == size );
|
|
|
|
+ listeners.put( listener, plugin );
|
|
|
|
+ baked = Arrays.copyOf( baked, size + 1 );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ baked[size] = listener;
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ static Packet callReceived(INetworkManager networkManager, Connection connection, Packet packet)
|
|
|
|
+ {
|
|
|
|
+ for ( PacketListener listener : baked )
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ packet = listener.packetReceived( networkManager, connection, packet );
|
|
|
|
+ } catch ( Throwable t )
|
|
|
|
+ {
|
|
|
|
+ Bukkit.getServer().getLogger().log( Level.SEVERE, "Error whilst firing receive hook for packet", t );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return packet;
|
|
|
|
+ }
|
|
|
|
+
|
2013-06-01 03:57:16 +00:00
|
|
|
+ static Packet callQueued(INetworkManager networkManager, Connection connection, Packet packet)
|
|
|
|
+ {
|
|
|
|
+ for ( PacketListener listener : baked )
|
|
|
|
+ {
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ packet = listener.packetQueued( networkManager, connection, packet );
|
|
|
|
+ } catch ( Throwable t )
|
|
|
|
+ {
|
|
|
|
+ Bukkit.getServer().getLogger().log( Level.SEVERE, "Error whilst firing queued hook for packet", t );
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return packet;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Called when a packet has been received and is about to be handled by the
|
|
|
|
+ * current {@link Connection}. The returned packet will be the packet passed
|
|
|
|
+ * on for handling, or in the case of null being returned, not handled at
|
|
|
|
+ * all.
|
|
|
|
+ *
|
|
|
|
+ * @param networkManager the NetworkManager receiving the packet
|
|
|
|
+ * @param connection the connection which will handle the packet
|
|
|
|
+ * @param packet the received packet
|
|
|
|
+ * @return the packet to be handled, or null to cancel
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public Packet packetReceived(INetworkManager networkManager, Connection connection, Packet packet)
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return packet;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Called when a packet is queued to be sent. The returned packet will be
|
|
|
|
+ * the packet sent. In the case of null being returned, the packet will not
|
|
|
|
+ * be sent.
|
|
|
|
+ *
|
|
|
|
+ * @param networkManager the NetworkManager which will send the packet
|
|
|
|
+ * @param connection the connection which queued the packet
|
|
|
|
+ * @param packet the queue packet
|
|
|
|
+ * @return the packet to be sent, or null if the packet will not be sent.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+ public Packet packetQueued(INetworkManager networkManager, Connection connection, Packet packet)
|
|
|
|
+ {
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
+ return packet;
|
|
|
|
+ }
|
|
|
|
+}
|
2013-06-29 07:39:07 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/PacketWriter.java b/src/main/java/org/spigotmc/netty/PacketWriter.java
|
|
|
|
new file mode 100644
|
2013-07-02 03:57:42 +00:00
|
|
|
index 0000000..ca8d16b
|
2013-06-29 07:39:07 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/PacketWriter.java
|
2013-07-02 03:57:42 +00:00
|
|
|
@@ -0,0 +1,85 @@
|
2013-06-29 07:39:07 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
|
|
|
+import io.netty.buffer.ByteBuf;
|
|
|
|
+import io.netty.buffer.ByteBufOutputStream;
|
|
|
|
+import io.netty.channel.Channel;
|
|
|
|
+import io.netty.channel.MessageList;
|
|
|
|
+import io.netty.handler.codec.EncoderException;
|
2013-07-02 03:57:42 +00:00
|
|
|
+import java.io.DataOutput;
|
2013-06-29 07:39:07 +00:00
|
|
|
+import java.io.IOException;
|
|
|
|
+import net.minecraft.server.Packet;
|
|
|
|
+import net.minecraft.server.PendingConnection;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Netty encoder which takes a packet and encodes it, and adds a byte packet id
|
|
|
|
+ * header.
|
|
|
|
+ */
|
|
|
|
+public class PacketWriter
|
|
|
|
+{
|
|
|
|
+
|
|
|
|
+ private static final int FLUSH_TIME = 1;
|
|
|
|
+ /*========================================================================*/
|
|
|
|
+ long lastFlush;
|
|
|
|
+ private final MessageList<Packet> pending = MessageList.newInstance();
|
|
|
|
+
|
|
|
|
+ void release()
|
|
|
|
+ {
|
|
|
|
+ pending.recycle();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void write(Channel channel, NettyNetworkManager networkManager, Packet msg)
|
|
|
|
+ {
|
|
|
|
+ // Append messages to queue
|
|
|
|
+ pending.add( msg );
|
|
|
|
+
|
|
|
|
+ // If we are not in the pending connect phase, and we have not reached our timer
|
|
|
|
+ if ( !( networkManager.connection instanceof PendingConnection ) && System.currentTimeMillis() - lastFlush < FLUSH_TIME )
|
|
|
|
+ {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ // Update our last write time
|
|
|
|
+ lastFlush = System.currentTimeMillis();
|
|
|
|
+
|
|
|
|
+ // Since we are writing in batches it can be useful to guess the size of our output to limit memcpy
|
|
|
|
+ int estimatedSize = 0;
|
|
|
|
+ for ( Packet packet : pending )
|
|
|
|
+ {
|
|
|
|
+ estimatedSize += packet.a();
|
|
|
|
+ }
|
|
|
|
+ // Allocate an output buffer of estimated size
|
|
|
|
+ ByteBuf outBuf = channel.alloc().buffer( estimatedSize );
|
|
|
|
+ // And a stream to which we can write this buffer to
|
2013-07-02 03:57:42 +00:00
|
|
|
+ DataOutput dataOut = new ByteBufOutputStream( outBuf );
|
2013-06-29 07:39:07 +00:00
|
|
|
+
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ // Iterate through all packets, this is safe as we know we will only ever get packets in the pipeline
|
|
|
|
+ for ( Packet packet : pending )
|
|
|
|
+ {
|
|
|
|
+ // Write packet ID
|
|
|
|
+ outBuf.writeByte( packet.n() );
|
|
|
|
+ // Write packet data
|
|
|
|
+ try
|
|
|
|
+ {
|
|
|
|
+ packet.a( dataOut );
|
|
|
|
+ } catch ( IOException ex )
|
|
|
|
+ {
|
|
|
|
+ throw new EncoderException( ex );
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // Add to the courtesy API providing number of written bytes
|
|
|
|
+ networkManager.addWrittenBytes( outBuf.readableBytes() );
|
|
|
|
+ // Write down our single ByteBuf
|
|
|
|
+ channel.write( outBuf );
|
|
|
|
+ } finally
|
|
|
|
+ {
|
|
|
|
+ // Reset packet queue
|
|
|
|
+ pending.clear();
|
|
|
|
+ // Since we are now in the event loop, the bytes have been written, we can free them if this was not the case
|
|
|
|
+ if ( outBuf.refCnt() != 0 )
|
|
|
|
+ {
|
|
|
|
+ outBuf.release();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+}
|
2013-02-13 01:11:37 +00:00
|
|
|
diff --git a/src/main/java/org/spigotmc/netty/ReadState.java b/src/main/java/org/spigotmc/netty/ReadState.java
|
|
|
|
new file mode 100644
|
2013-06-01 03:57:16 +00:00
|
|
|
index 0000000..d3a9cab
|
2013-02-13 01:11:37 +00:00
|
|
|
--- /dev/null
|
|
|
|
+++ b/src/main/java/org/spigotmc/netty/ReadState.java
|
2013-06-01 03:57:16 +00:00
|
|
|
@@ -0,0 +1,17 @@
|
2013-02-13 01:11:37 +00:00
|
|
|
+package org.spigotmc.netty;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Stores the state of the packet currently being read.
|
|
|
|
+ */
|
2013-06-01 03:57:16 +00:00
|
|
|
+public enum ReadState
|
|
|
|
+{
|
2013-02-13 01:11:37 +00:00
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Indicates the byte representing the ID has been read.
|
|
|
|
+ */
|
|
|
|
+ HEADER,
|
|
|
|
+ /**
|
|
|
|
+ * Shows the packet body is being read.
|
|
|
|
+ */
|
|
|
|
+ DATA;
|
|
|
|
+}
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
--
|
2013-06-01 03:57:16 +00:00
|
|
|
1.8.1.2
|
Implement an uber efficient network engine based on the Java NIO framework Netty. This is basically a complete rewrite of the Minecraft network engine with many distinct advantages. First and foremost, there will no longer be the horrid, and redundant case of 2, or even at times, 3 threads per a connection. Instead low level select/epoll based NIO is used. The number of threads used for network reading and writing will scale automatically to the number of cores for use on your server. In most cases this will be around 8 threads for a 4 core server, much better than the up to 1000 threads that could be in use at one time with the old engine. To facilitate asynchronous packet sending or receiving (currently only chat), a cached thread pool is kept handy. Currently this pool is unbounded, however at this stage we do not need to worry about servers being resource starved due to excessive spam or chat.
== Plugin incompatibilities
As a side effect of this change, plugins which rely on very specific implementation level details within Minecraft are broken. At this point in time, TagAPI and ProtocolLib are affected. If you are a user of ProtocolLib you are advised to update to the latest build, where full support is enabled. If you are a user of TagAPI, support has not yet been added, so you will need to install the updated ProtocolLib so that TagAPI may use its functions.
== Stability
The code within this commit has been very lightly tested in production (300 players for approximately 24 hours), however it is not guaranteed to be free from all bugs. If you experence weird connection behaviour, reporting the bug and steps to reproduce are advised. You are also free to downgrade to the latest recommend build, which is guaranteed to be stable.
== Summary
This commit provides a reduction in threads, which gives the CPU / operating system more time to allocate to the main server threads, as well as various other side benefits such as chat thread pooling and a slight reduction in latency.
This commit is licensed under the Creative Commons Attribution-ShareAlike 3.0 Unported license.
2013-02-09 06:16:27 +00:00
|
|
|
|