directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akaras...@apache.org
Subject svn commit: r442813 - in /directory/branches/apacheds/1.0: protocol-changepw/src/main/java/org/apache/directory/server/changepw/ protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/ protocol-ntp/src/main/java/org/apache/directory/s...
Date Wed, 13 Sep 2006 03:26:40 GMT
Author: akarasulu
Date: Tue Sep 12 20:26:39 2006
New Revision: 442813

URL: http://svn.apache.org/viewvc?view=rev&rev=442813
Log:
taking advice posted by trustin for DIRSERVER-740

Modified:
    directory/branches/apacheds/1.0/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
    directory/branches/apacheds/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KerberosServer.java
    directory/branches/apacheds/1.0/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
    directory/branches/apacheds/1.0/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java

Modified: directory/branches/apacheds/1.0/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java?view=diff&rev=442813&r1=442812&r2=442813
==============================================================================
--- directory/branches/apacheds/1.0/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
(original)
+++ directory/branches/apacheds/1.0/protocol-changepw/src/main/java/org/apache/directory/server/changepw/ChangePasswordServer.java
Tue Sep 12 20:26:39 2006
@@ -29,6 +29,7 @@
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -51,7 +52,8 @@
 
     private IoHandler handler;
 
-    public ChangePasswordServer(ChangePasswordConfiguration config, IoAcceptor acceptor,
PrincipalStore store)
+    public ChangePasswordServer(ChangePasswordConfiguration config, IoAcceptor acceptor,
IoServiceConfig serviceConfig, 
+        PrincipalStore store)
     {
         this.config = config;
         this.acceptor = acceptor;
@@ -64,7 +66,7 @@
         {
             handler = new ChangePasswordProtocolHandler( config, this.store );
 
-            acceptor.bind( new InetSocketAddress( port ), handler );
+            acceptor.bind( new InetSocketAddress( port ), handler, serviceConfig );
 
             log.debug( "{} listening on port {}", name, new Integer( port ) );
         }

Modified: directory/branches/apacheds/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KerberosServer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KerberosServer.java?view=diff&rev=442813&r1=442812&r2=442813
==============================================================================
--- directory/branches/apacheds/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KerberosServer.java
(original)
+++ directory/branches/apacheds/1.0/protocol-kerberos/src/main/java/org/apache/directory/server/kerberos/kdc/KerberosServer.java
Tue Sep 12 20:26:39 2006
@@ -29,6 +29,7 @@
 import org.apache.directory.server.kerberos.shared.store.PrincipalStore;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -52,7 +53,7 @@
     private IoHandler handler;
 
 
-    public KerberosServer(KdcConfiguration config, IoAcceptor acceptor, PrincipalStore store)
+    public KerberosServer( KdcConfiguration config, IoAcceptor acceptor, IoServiceConfig
serviceConfig, PrincipalStore store )
     {
         this.config = config;
         this.acceptor = acceptor;
@@ -65,7 +66,7 @@
         {
             handler = new KerberosProtocolHandler( new KdcConfiguration(), this.store );
 
-            acceptor.bind( new InetSocketAddress( port ), handler );
+            acceptor.bind( new InetSocketAddress( port ), handler, serviceConfig );
 
             log.debug( name + " listening on port " + port );
         }

Modified: directory/branches/apacheds/1.0/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java?view=diff&rev=442813&r1=442812&r2=442813
==============================================================================
--- directory/branches/apacheds/1.0/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
(original)
+++ directory/branches/apacheds/1.0/protocol-ntp/src/main/java/org/apache/directory/server/ntp/NtpServer.java
Tue Sep 12 20:26:39 2006
@@ -28,6 +28,7 @@
 import org.apache.directory.server.ntp.protocol.NtpProtocolHandler;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoHandler;
+import org.apache.mina.common.IoServiceConfig;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -43,7 +44,7 @@
     private IoHandler handler;
 
 
-    public NtpServer( NtpConfiguration config, IoAcceptor acceptor )
+    public NtpServer( NtpConfiguration config, IoAcceptor acceptor, IoServiceConfig serviceConfig
)
     {
         this.config = config;
         this.acceptor = acceptor;
@@ -55,7 +56,7 @@
         {
             handler = new NtpProtocolHandler();
 
-            acceptor.bind( new InetSocketAddress( port ), handler );
+            acceptor.bind( new InetSocketAddress( port ), handler, serviceConfig );
 
             log.debug( name + " listening on port " + port );
         }

Modified: directory/branches/apacheds/1.0/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java
URL: http://svn.apache.org/viewvc/directory/branches/apacheds/1.0/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java?view=diff&rev=442813&r1=442812&r2=442813
==============================================================================
--- directory/branches/apacheds/1.0/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java
(original)
+++ directory/branches/apacheds/1.0/server-jndi/src/main/java/org/apache/directory/server/jndi/ServerContextFactory.java
Tue Sep 12 20:26:39 2006
@@ -57,12 +57,13 @@
 import org.apache.directory.shared.ldap.exception.LdapNamingException;
 import org.apache.directory.shared.ldap.message.extended.NoticeOfDisconnect;
 import org.apache.mina.common.DefaultIoFilterChainBuilder;
+import org.apache.mina.common.ExecutorThreadModel;
 import org.apache.mina.common.IoAcceptor;
 import org.apache.mina.common.IoFilterChainBuilder;
 import org.apache.mina.common.IoSession;
 import org.apache.mina.common.WriteFuture;
-import org.apache.mina.filter.executor.ExecutorFilter;
 import org.apache.mina.transport.socket.nio.DatagramAcceptor;
+import org.apache.mina.transport.socket.nio.DatagramAcceptorConfig;
 import org.apache.mina.transport.socket.nio.SocketAcceptor;
 import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
 import org.apache.mina.transport.socket.nio.SocketSessionConfig;
@@ -70,6 +71,10 @@
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import edu.emory.mathcs.backport.java.util.concurrent.LinkedBlockingQueue;
+import edu.emory.mathcs.backport.java.util.concurrent.ThreadPoolExecutor;
+import edu.emory.mathcs.backport.java.util.concurrent.TimeUnit;
+
 
 /**
  * Adds additional bootstrapping for server socket listeners when firing
@@ -84,17 +89,11 @@
     private static final Logger log = LoggerFactory.getLogger( ServerContextFactory.class.getName()
);
     private static final String LDIF_FILES_DN = "ou=loadedLdifFiles,ou=configuration,ou=system";
 
-    protected static final IoAcceptor tcpAcceptor = new SocketAcceptor();
-    protected static final IoAcceptor udpAcceptor = new DatagramAcceptor();
-    protected static final ExecutorFilter threadPool;
+    protected static IoAcceptor tcpAcceptor;
+    protected static IoAcceptor udpAcceptor;
+    protected static ThreadPoolExecutor threadPoolExecutor;
+    protected static ExecutorThreadModel threadModel = ExecutorThreadModel.getInstance( "ApacheDS"
);
     
-    static
-    {
-        threadPool = new ExecutorFilter();
-        tcpAcceptor.getFilterChain().addFirst( "threadPool", threadPool );
-        udpAcceptor.getFilterChain().addFirst( "threadPool", threadPool );
-    }
-
     private static boolean ldapStarted;
     private static boolean ldapsStarted;
     private static KerberosServer tcpKdcServer;
@@ -108,9 +107,14 @@
 
     public void beforeStartup( DirectoryService service )
     {
-        // TODO Find out how now with executor we are to set the max pool size
+        int maxThreads = service.getConfiguration().getStartupConfiguration().getMaxThreads();
+        threadPoolExecutor = new ThreadPoolExecutor( maxThreads, maxThreads, 60, TimeUnit.SECONDS,

+            new LinkedBlockingQueue() );
+        threadModel.setExecutor( threadPoolExecutor );
         
-//        threadPool.setMaximumPoolSize( service.getConfiguration().getStartupConfiguration().getMaxThreads()
);
+        udpAcceptor = new DatagramAcceptor();
+        tcpAcceptor = new SocketAcceptor();
+
         this.directoryService = service;
     }
 
@@ -465,6 +469,8 @@
             acceptorCfg.setDisconnectOnUnbind( false );
             acceptorCfg.setReuseAddress( true );
             acceptorCfg.setFilterChainBuilder( chainBuilder );
+            acceptorCfg.setThreadModel( threadModel );
+            
             ((SocketSessionConfig)(acceptorCfg.getSessionConfig())).setTcpNoDelay( true );
             
             tcpAcceptor.bind( new InetSocketAddress( port ), protocolProvider.getHandler(),
acceptorCfg );
@@ -494,8 +500,18 @@
             {
                 KdcConfiguration kdcConfiguration = new KdcConfiguration( env, LoadStrategy.PROPS
);
                 PrincipalStore kdcStore = new JndiPrincipalStoreImpl( kdcConfiguration, this
);
-                tcpKdcServer = new KerberosServer( kdcConfiguration, tcpAcceptor, kdcStore
);
-                udpKdcServer = new KerberosServer( kdcConfiguration, udpAcceptor, kdcStore
);
+                
+                DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig();
+                udpConfig.setThreadModel( threadModel );
+
+                SocketAcceptorConfig tcpConfig = new SocketAcceptorConfig();
+                tcpConfig.setDisconnectOnUnbind( false );
+                tcpConfig.setReuseAddress( true );
+                tcpConfig.setFilterChainBuilder( new DefaultIoFilterChainBuilder() );
+                tcpConfig.setThreadModel( threadModel );
+
+                tcpKdcServer = new KerberosServer( kdcConfiguration, tcpAcceptor, tcpConfig,
kdcStore );
+                udpKdcServer = new KerberosServer( kdcConfiguration, udpAcceptor, udpConfig,
kdcStore );
             }
             catch ( Throwable t )
             {
@@ -514,8 +530,20 @@
                 ChangePasswordConfiguration changePasswordConfiguration = new ChangePasswordConfiguration(
env,
                     LoadStrategy.PROPS );
                 PrincipalStore store = new JndiPrincipalStoreImpl( changePasswordConfiguration,
this );
-                tcpChangePasswordServer = new ChangePasswordServer( changePasswordConfiguration,
tcpAcceptor, store );
-                udpChangePasswordServer = new ChangePasswordServer( changePasswordConfiguration,
udpAcceptor, store );
+
+                DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig();
+                udpConfig.setThreadModel( threadModel );
+
+                SocketAcceptorConfig tcpConfig = new SocketAcceptorConfig();
+                tcpConfig.setDisconnectOnUnbind( false );
+                tcpConfig.setReuseAddress( true );
+                tcpConfig.setFilterChainBuilder( new DefaultIoFilterChainBuilder() );
+                tcpConfig.setThreadModel( threadModel );
+
+                tcpChangePasswordServer = new ChangePasswordServer( changePasswordConfiguration,
tcpAcceptor, 
+                    tcpConfig, store );
+                udpChangePasswordServer = new ChangePasswordServer( changePasswordConfiguration,
udpAcceptor, 
+                    udpConfig, store );
             }
             catch ( Throwable t )
             {
@@ -532,8 +560,18 @@
             try
             {
                 NtpConfiguration ntpConfig = new NtpConfiguration( env, LoadStrategy.PROPS
);
-                tcpNtpServer = new NtpServer( ntpConfig, tcpAcceptor );
-                udpNtpServer = new NtpServer( ntpConfig, udpAcceptor );
+
+                DatagramAcceptorConfig udpConfig = new DatagramAcceptorConfig();
+                udpConfig.setThreadModel( threadModel );
+
+                SocketAcceptorConfig tcpConfig = new SocketAcceptorConfig();
+                tcpConfig.setDisconnectOnUnbind( false );
+                tcpConfig.setReuseAddress( true );
+                tcpConfig.setFilterChainBuilder( new DefaultIoFilterChainBuilder() );
+                tcpConfig.setThreadModel( threadModel );
+
+                tcpNtpServer = new NtpServer( ntpConfig, tcpAcceptor, tcpConfig );
+                udpNtpServer = new NtpServer( ntpConfig, udpAcceptor, udpConfig );
             }
             catch ( Throwable t )
             {



Mime
View raw message