james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nor...@apache.org
Subject svn commit: r1221179 - in /james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty: AbstractChannelPipelineFactory.java NettyServer.java
Date Tue, 20 Dec 2011 10:05:17 GMT
Author: norman
Date: Tue Dec 20 10:05:17 2011
New Revision: 1221179

URL: http://svn.apache.org/viewvc?rev=1221179&view=rev
Log:
Allow to set maximal current connections in NettyServer. See PROTOCOLS-57

Modified:
    james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java
    james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java

Modified: james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java?rev=1221179&r1=1221178&r2=1221179&view=diff
==============================================================================
--- james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java
(original)
+++ james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/AbstractChannelPipelineFactory.java
Tue Dec 20 10:05:17 2011
@@ -39,8 +39,8 @@ import org.jboss.netty.util.HashedWheelT
 public abstract class AbstractChannelPipelineFactory implements ChannelPipelineFactory, ExternalResourceReleasable{
 
     public final static int MAX_LINE_LENGTH = 8192;
-    private final ConnectionLimitUpstreamHandler connectionLimitHandler;
-    private final ConnectionPerIpLimitUpstreamHandler connectionPerIpLimitHandler;
+    protected final ConnectionLimitUpstreamHandler connectionLimitHandler;
+    protected final ConnectionPerIpLimitUpstreamHandler connectionPerIpLimitHandler;
     private final HashedWheelTimer timer = new HashedWheelTimer();
     private final ChannelGroupHandler groupHandler;
 	private final int timeout;

Modified: james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java
URL: http://svn.apache.org/viewvc/james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java?rev=1221179&r1=1221178&r2=1221179&view=diff
==============================================================================
--- james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java
(original)
+++ james/protocols/trunk/netty/src/main/java/org/apache/james/protocols/netty/NettyServer.java
Tue Dec 20 10:05:17 2011
@@ -24,7 +24,6 @@ import javax.net.ssl.SSLContext;
 import org.apache.james.protocols.api.Protocol;
 import org.apache.james.protocols.api.Encryption;
 import org.apache.james.protocols.api.handler.ProtocolHandler;
-import org.jboss.netty.channel.ChannelPipeline;
 import org.jboss.netty.channel.ChannelPipelineFactory;
 import org.jboss.netty.channel.ChannelUpstreamHandler;
 import org.jboss.netty.channel.group.ChannelGroup;
@@ -48,10 +47,9 @@ public class NettyServer extends Abstrac
 
     protected final Encryption secure;
 
-    private final ConnectionLimitUpstreamHandler connLimit = new ConnectionLimitUpstreamHandler(-1);
+    private int maxCurConnections;
 
-    
-    private final ConnectionPerIpLimitUpstreamHandler connPerIPLimit =  new ConnectionPerIpLimitUpstreamHandler(-1);
+    private int maxCurConnectionsPerIP;
    
     public NettyServer(Protocol protocol) {
         this(protocol, null);
@@ -88,11 +86,13 @@ public class NettyServer extends Abstrac
     }
     
     public void setMaxConcurrentConnections(int maxCurConnections) {
-        connLimit.setMaxConnections(maxCurConnections);
+        if (isBound()) throw new IllegalStateException("Server running already");
+        this.maxCurConnections = maxCurConnections;
     }
   
     public void setMaxConcurrentConnectionsPerIP(int maxCurConnectionsPerIP) {
-        connPerIPLimit.setMaxConnectionsPerIp(maxCurConnectionsPerIP);
+        if (isBound()) throw new IllegalStateException("Server running already");
+        this.maxCurConnectionsPerIP = maxCurConnectionsPerIP;
     }
     protected ChannelUpstreamHandler createCoreHandler() {
         return new BasicChannelUpstreamHandler(protocol, logger, secure);
@@ -108,16 +108,7 @@ public class NettyServer extends Abstrac
     @Override
     protected ChannelPipelineFactory createPipelineFactory(ChannelGroup group) {
 
-        return new AbstractSSLAwareChannelPipelineFactory(getTimeout(), 0, getBacklog(),
group, eHandler) {
-            
-            @Override
-            public ChannelPipeline getPipeline() throws Exception {
-                ChannelPipeline cp =  super.getPipeline();
-                cp.addFirst(HandlerConstants.CONNECTION_PER_IP_LIMIT_HANDLER, connPerIPLimit);
-                cp.addFirst(HandlerConstants.CONNECTION_LIMIT_HANDLER, connLimit);
-                
-                return cp;
-            }
+        return new AbstractSSLAwareChannelPipelineFactory(getTimeout(), maxCurConnections,
maxCurConnectionsPerIP, group, eHandler) {
 
             @Override
             protected ChannelUpstreamHandler createHandler() {



---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message