Add netty-threads option

This commit is contained in:
md_5 2013-06-22 14:35:20 +10:00
parent 6ec312912d
commit 66a7394806
6 changed files with 32 additions and 25 deletions

View File

@ -1,4 +1,4 @@
From 33f4ba2034fd8cd22a8b9da2115c25000154c038 Mon Sep 17 00:00:00 2001
From 7186970386ca7b9887fc79e00510154f2b248d86 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 18:23:00 +1000
Subject: [PATCH] Netty
@ -350,7 +350,7 @@ index 0000000..386c2f8
+ }
+}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index b7f3896..606b01e 100644
index b7f3896..910d0de 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -6,6 +6,8 @@ import java.io.IOException;
@ -362,7 +362,7 @@ index b7f3896..606b01e 100644
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -148,4 +150,44 @@ public class SpigotConfig
@@ -148,4 +150,47 @@ public class SpigotConfig
commands.put( "restart", new RestartCommand( "restart" ) );
WatchdogThread.doStart( timeoutTime, restartOnCrash );
}
@ -384,6 +384,7 @@ index b7f3896..606b01e 100644
+ }
+ }
+ public static List<Listener> listeners = new ArrayList<Listener>();
+ public static int nettyThreads;
+ private static void listeners()
+ {
+ Map<String, Object> def = new HashMap<String, Object>();
@ -405,6 +406,8 @@ index b7f3896..606b01e 100644
+ long connectionThrottle = ( info.get( "throttle" ) instanceof Number ) ? ( (Number) info.get( "throttle" ) ).longValue() : Bukkit.getConnectionThrottle();
+ listeners.add( new Listener( host, port, netty, connectionThrottle ) );
+ }
+
+ nettyThreads = getInt( "settings.netty-threads", 3 );
+ }
}
diff --git a/src/main/java/org/spigotmc/netty/CipherBase.java b/src/main/java/org/spigotmc/netty/CipherBase.java
@ -825,10 +828,10 @@ index 0000000..fdef0c8
+}
diff --git a/src/main/java/org/spigotmc/netty/NettyServerConnection.java b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
new file mode 100644
index 0000000..575db8b
index 0000000..f232efd
--- /dev/null
+++ b/src/main/java/org/spigotmc/netty/NettyServerConnection.java
@@ -0,0 +1,100 @@
@@ -0,0 +1,104 @@
+package org.spigotmc.netty;
+
+import com.google.common.util.concurrent.ThreadFactoryBuilder;
@ -838,6 +841,7 @@ index 0000000..575db8b
+import io.netty.channel.ChannelFuture;
+import io.netty.channel.ChannelInitializer;
+import io.netty.channel.ChannelOption;
+import io.netty.channel.EventLoopGroup;
+import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.channel.socket.nio.NioServerSocketChannel;
+import io.netty.handler.timeout.ReadTimeoutHandler;
@ -861,11 +865,15 @@ index 0000000..575db8b
+{
+
+ private final ChannelFuture socket;
+ private static EventLoopGroup group;
+
+ public NettyServerConnection(final MinecraftServer ms, InetAddress host, int port)
+ {
+ super( ms );
+ int threads = Integer.getInteger( "org.spigotmc.netty.threads", 3 );
+ if ( group == null )
+ {
+ group = new NioEventLoopGroup( org.spigotmc.SpigotConfig.nettyThreads, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread - %1$d" ).build() );
+ }
+ socket = new ServerBootstrap().channel( NioServerSocketChannel.class ).childHandler( new ChannelInitializer()
+ {
+ @Override
@ -894,8 +902,7 @@ index 0000000..575db8b
+ .addLast( "encoder", new PacketEncoder( networkManager ) )
+ .addLast( "manager", networkManager );
+ }
+ } ).childOption( ChannelOption.TCP_NODELAY, false ).group( new NioEventLoopGroup( threads, new ThreadFactoryBuilder().setNameFormat( "Netty IO Thread - %1$d" ).build() ) ).localAddress( host, port ).bind();
+ MinecraftServer.getServer().getLogger().info( "Using Netty NIO with " + threads + " threads for network connections." );
+ } ).childOption( ChannelOption.TCP_NODELAY, false ).group( group ).localAddress( host, port ).bind();
+ }
+
+ /**

View File

@ -1,4 +1,4 @@
From 2aec923f52118621b312e361b2a38b3b92c185c2 Mon Sep 17 00:00:00 2001
From 150ae92bc058a84187b9c27bd4f65ff27728638d Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Sat, 23 Mar 2013 11:15:11 +1100
Subject: [PATCH] BungeeCord Support
@ -75,7 +75,7 @@ index 7cae665..21141f2 100644
public Spigot spigot()
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 606b01e..042241c 100644
index 910d0de..b71d425 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -7,6 +7,7 @@ import java.lang.reflect.InvocationTargetException;
@ -86,9 +86,9 @@ index 606b01e..042241c 100644
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
@@ -190,4 +191,14 @@ public class SpigotConfig
listeners.add( new Listener( host, port, netty, connectionThrottle ) );
}
@@ -193,4 +194,14 @@ public class SpigotConfig
nettyThreads = getInt( "settings.netty-threads", 3 );
}
+ public static List<String> bungeeAddresses = Arrays.asList( new String[]
+ {

View File

@ -1,4 +1,4 @@
From 157f91f16c4c3e8bf3fb86756b9da2a9c5e4c7fd Mon Sep 17 00:00:00 2001
From ca4219456ce6b7f5ea1b18b4b7adce3fc08f9cf1 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 17:59:22 +1000
Subject: [PATCH] Spam Filter Exclusions
@ -19,10 +19,10 @@ index 998ac8d..a292c1a 100644
Waitable waitable = new Waitable() {
@Override
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 042241c..d2d7ffc 100644
index b71d425..1685d9f 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -201,4 +201,13 @@ public class SpigotConfig
@@ -204,4 +204,13 @@ public class SpigotConfig
bungeeAddresses = getList( "settings.bungeecord-addresses", bungee );
bungee = getBoolean( "settings.bungeecord", true );
}

View File

@ -1,4 +1,4 @@
From c2e12f59e2d9d0ca80738e24565da4043c333413 Mon Sep 17 00:00:00 2001
From f78427a84375f14b3204f9891f62783c8c2840bb Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 18:01:29 +1000
Subject: [PATCH] Allow Disabling of Command Logging
@ -23,10 +23,10 @@ index a292c1a..0e8d292 100644
org.bukkit.craftbukkit.SpigotTimings.playerCommandTimer.stopTiming(); // Spigot
return;
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index d2d7ffc..c7de211 100644
index 1685d9f..9214f16 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -210,4 +210,10 @@ public class SpigotConfig
@@ -213,4 +213,10 @@ public class SpigotConfig
"/skill"
} ) );
}

View File

@ -1,4 +1,4 @@
From c92028eb307ed2d2a654b54df8e3e0123352864f Mon Sep 17 00:00:00 2001
From ef86c38f34b99933811189b6710f79cdfe593557 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 18:05:54 +1000
Subject: [PATCH] Allow Disabling of Command TabComplete
@ -18,10 +18,10 @@ index 1fcbd33..42600a6 100644
player.sendMessage(ChatColor.RED + "An internal error occurred while attempting to tab-complete this command");
getLogger().log(Level.SEVERE, "Exception when " + player.getName() + " attempted to tab complete " + message, ex);
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index c7de211..4b18e72 100644
index 9214f16..3cccb72 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -216,4 +216,10 @@ public class SpigotConfig
@@ -219,4 +219,10 @@ public class SpigotConfig
{
logCommands = getBoolean( "commands.log", true );
}

View File

@ -1,4 +1,4 @@
From 26b56fde0ad7602876b78a4f22e034936899a957 Mon Sep 17 00:00:00 2001
From 866aee41f87d8a15b7181248f1f36076e818c67a Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au>
Date: Fri, 21 Jun 2013 19:21:58 +1000
Subject: [PATCH] Configurable Messages
@ -31,7 +31,7 @@ index 42600a6..9d71ae3 100644
return false;
}
diff --git a/src/main/java/org/spigotmc/SpigotConfig.java b/src/main/java/org/spigotmc/SpigotConfig.java
index 4b18e72..147e407 100644
index 3cccb72..102c5fa 100644
--- a/src/main/java/org/spigotmc/SpigotConfig.java
+++ b/src/main/java/org/spigotmc/SpigotConfig.java
@@ -15,6 +15,7 @@ import java.util.Map;
@ -42,7 +42,7 @@ index 4b18e72..147e407 100644
import org.bukkit.command.Command;
import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.craftbukkit.command.TicksPerSecondCommand;
@@ -222,4 +223,16 @@ public class SpigotConfig
@@ -225,4 +226,16 @@ public class SpigotConfig
{
tabComplete = getBoolean( "commands.tab-complete", true );
}