cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From egl...@apache.org
Subject svn commit: r748110 - in /cxf/trunk: rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ systests/src/test/java/org/apache/cxf/systest/ws/address...
Date Thu, 26 Feb 2009 12:22:33 GMT
Author: eglynn
Date: Thu Feb 26 12:22:33 2009
New Revision: 748110

URL: http://svn.apache.org/viewvc?rev=748110&view=rev
Log:
Restored some inadvertantly removed functionality around fallback zero-port config for JettyHTTPServerEngine
threading parameters.

Added:
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/server.xml
Modified:
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
    cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
    cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTest.java
    cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java?rev=748110&r1=748109&r2=748110&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngine.java
Thu Feb 26 12:22:33 2009
@@ -52,6 +52,7 @@
 import org.mortbay.jetty.servlet.HashSessionManager;
 import org.mortbay.jetty.servlet.SessionHandler;
 import org.mortbay.thread.BoundedThreadPool;
+import org.mortbay.thread.QueuedThreadPool;
 
 
 /**
@@ -305,14 +306,23 @@
                 server.start();
                
                 AbstractConnector aconn = (AbstractConnector) connector;
-                if (aconn.getThreadPool() instanceof BoundedThreadPool
-                    && isSetThreadingParameters()) {
-                    BoundedThreadPool pool = (BoundedThreadPool)aconn.getThreadPool();
-                    if (getThreadingParameters().isSetMinThreads()) {
-                        pool.setMinThreads(getThreadingParameters().getMinThreads());
-                    }
-                    if (getThreadingParameters().isSetMaxThreads()) {
-                        pool.setMaxThreads(getThreadingParameters().getMaxThreads());
+                if (isSetThreadingParameters()) {
+                    if (aconn.getThreadPool() instanceof BoundedThreadPool) {
+                        BoundedThreadPool pool = (BoundedThreadPool)aconn.getThreadPool();
+                        if (getThreadingParameters().isSetMinThreads()) {
+                            pool.setMinThreads(getThreadingParameters().getMinThreads());
+                        }
+                        if (getThreadingParameters().isSetMaxThreads()) {
+                            pool.setMaxThreads(getThreadingParameters().getMaxThreads());
+                        }
+                    } else if (aconn.getThreadPool() instanceof QueuedThreadPool) {
+                        QueuedThreadPool pool = (QueuedThreadPool)aconn.getThreadPool();
+                        if (getThreadingParameters().isSetMinThreads()) {
+                            pool.setMinThreads(getThreadingParameters().getMinThreads());
+                        }
+                        if (getThreadingParameters().isSetMaxThreads()) {
+                            pool.setMaxThreads(getThreadingParameters().getMaxThreads());
+                        }
                     }
                 }
             } catch (Exception e) {

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java?rev=748110&r1=748109&r2=748110&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPServerEngineFactory.java
Thu Feb 26 12:22:33 2009
@@ -24,6 +24,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
+import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.annotation.PostConstruct;
@@ -48,6 +49,8 @@
     private static final Logger LOG =
         LogUtils.getL7dLogger(JettyHTTPServerEngineFactory.class);    
     
+    private static final int FALLBACK_THREADING_PARAMS_KEY = 0;
+
     /**
      * This map holds references for allocated ports.
      */
@@ -63,6 +66,8 @@
      */
     private Map<String, ThreadingParameters> threadingParametersMap =
         new TreeMap<String, ThreadingParameters>();
+
+    private ThreadingParameters fallbackThreadingParameters;
     
     /**
      * This map holds TLS Server Parameters that are to be used to
@@ -134,7 +139,10 @@
     }
     
     public void setEnginesList(List<JettyHTTPServerEngine> enginesList) {
-        for (JettyHTTPServerEngine engine : enginesList) { 
+        for (JettyHTTPServerEngine engine : enginesList) {
+            if (engine.getPort() == FALLBACK_THREADING_PARAMS_KEY) {
+                fallbackThreadingParameters = engine.getThreadingParameters();
+            }
             portMap.put(engine.getPort(), engine);
         }    
     }
@@ -216,6 +224,18 @@
                         + "engine's protocol is " + ref.getProtocol()
                         + ", the url protocol is " + protocol);
         }
+
+        if (!(ref.isSetThreadingParameters()
+              || null == fallbackThreadingParameters)) {
+            if (LOG.isLoggable(Level.INFO)) {
+                final int min = fallbackThreadingParameters.getMinThreads();
+                final int max = fallbackThreadingParameters.getMaxThreads();
+                LOG.log(Level.INFO,
+                        "FALLBACK_THREADING_PARAMETERS_MSG",
+                        new Object[] {port, min, max});
+            }
+            ref.setThreadingParameters(fallbackThreadingParameters);
+        }
                 
         return ref;
     }

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties?rev=748110&r1=748109&r2=748110&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/Messages.properties
Thu Feb 26 12:22:33 2009
@@ -24,4 +24,5 @@
 CAN_NOT_FIND_HANDLER_MSG = Could not find the handler to remove for context url {0}
 FAILED_TO_SHUTDOWN_ENGINE_MSG = Failed to shutdown Jetty server on port {0,number,####0}
because it is still in use
 UNKNOWN_CONNECTOR_MSG = Unknown connector type {0}, can't set the socket reuseAddress flag.
-INVALID_ENCODING_MSG = Invalid character set {0} in request.
\ No newline at end of file
+INVALID_ENCODING_MSG = Invalid character set {0} in request.
+FALLBACK_THREADING_PARAMETERS_MSG = No explicitly configured threading parameters for port
{0}, using fallback values min:{1} max:{2}

Modified: cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java?rev=748110&r1=748109&r2=748110&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/ApplicationContextTest.java
Thu Feb 26 12:22:33 2009
@@ -148,6 +148,16 @@
         engine = (JettyHTTPServerEngine)jd4.getEngine();
         assertEquals(engine.getTlsServerParameters().getClientAuthentication().isWant(),
false);
         assertEquals(engine.getTlsServerParameters().getClientAuthentication().isRequired(),
false);
+
+        JettyHTTPDestination jd5 = 
+            (JettyHTTPDestination)factory.getDestination(
+                getEndpointInfo("sna", "foo", "http://localhost:9100"));
+        
+        engine = (JettyHTTPServerEngine)jd5.getEngine();
+        String r = "expected fallback thread parameters configured for port 0";
+        assertNotNull(r, engine.getThreadingParameters());
+        assertEquals(r, 21, engine.getThreadingParameters().getMinThreads());
+        assertEquals(r, 389, engine.getThreadingParameters().getMaxThreads());
     }
     
     private EndpointInfo getEndpointInfo(String serviceNS, 

Modified: cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml?rev=748110&r1=748109&r2=748110&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/spring/beans.xml
Thu Feb 26 12:22:33 2009
@@ -62,7 +62,7 @@
 	   </hj:engine>
 	   
 	   <hj:engine port="0">
-	      <hj:threadingParameters minThreads="99" maxThreads="777"/>
+	      <hj:threadingParameters minThreads="21" maxThreads="389"/>
 	   </hj:engine>
 	   
 	   <hj:engine port="9001">

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTest.java?rev=748110&r1=748109&r2=748110&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTest.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/MAPTest.java Thu
Feb 26 12:22:33 2009
@@ -66,5 +66,25 @@
         }
     }
 
+    @Test
+    public void testFallbackThreadPoolConfig() throws Exception { 
+        Runnable r = new Runnable() {
+            public void run() {
+                greeter.greetMeLater(10 * 1000);
+            }
+        };
+        Thread[] invokers = new Thread[4];
+        long start = System.currentTimeMillis();
+        for (int i = 0; i < invokers.length; i++) {
+            invokers[i] = new Thread(r);
+            invokers[i].start();
+        }
+        for (int i = 0; i < invokers.length; i++) {
+            invokers[i].join();
+        }
+        long end = System.currentTimeMillis();
+        assertTrue(end - start > 20 * 1000L);
+    }
+
 }
 

Modified: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java?rev=748110&r1=748109&r2=748110&view=diff
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java (original)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/Server.java Thu
Feb 26 12:22:33 2009
@@ -40,7 +40,7 @@
     protected void run()  {
 
         SpringBusFactory factory = new SpringBusFactory();
-        Bus bus = factory.createBus("org/apache/cxf/systest/ws/addressing/wsa_interceptors.xml");
+        Bus bus = factory.createBus("org/apache/cxf/systest/ws/addressing/server.xml");
         BusFactory.setDefaultBus(bus);
         setBus(bus);
 

Added: cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/server.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/server.xml?rev=748110&view=auto
==============================================================================
--- cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/server.xml (added)
+++ cxf/trunk/systests/src/test/java/org/apache/cxf/systest/ws/addressing/server.xml Thu Feb
26 12:22:33 2009
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+ 
+  http://www.apache.org/licenses/LICENSE-2.0
+ 
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:http-jetty="http://cxf.apache.org/transports/http-jetty/configuration"
+       xsi:schemaLocation="
+http://cxf.apache.org/transports/http-jetty/configuration http://cxf.apache.org/schemas/configuration/http-jetty.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+  
+    <http-jetty:engine-factory bus="cxf">
+        <http-jetty:engine port="0">
+	    <http-jetty:threadingParameters minThreads="1" maxThreads="2"/>   
+        </http-jetty:engine>
+    </http-jetty:engine-factory>
+    
+    <import resource="wsa_interceptors.xml"/>
+</beans>
+



Mime
View raw message