FELIX-4623 : Event Admin - Make Async to Sync ThreadPool Ratio Configurable. Add metatype info

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1621308 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/eventadmin/impl/changelog.txt b/eventadmin/impl/changelog.txt
index 8b2eab7..56c4673 100644
--- a/eventadmin/impl/changelog.txt
+++ b/eventadmin/impl/changelog.txt
@@ -1,5 +1,7 @@
 Changes from 1.4.0 to 1.4.2
 ---------------------------
+** Improvement
+    * [FELIX-4623] - Make Async to Sync ThreadPool Ratio Configurable
 ** Bug
     * [FELIX-4617] - Empty configurations for ignore topic and ignore timeout lead to error messages in the log
     * [FELIX-4618] - NPE if config value for ignore topic or timeout is empty
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
index 8c4a362..42a90e5 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/Configuration.java
@@ -138,9 +138,9 @@
     private final BundleContext m_bundleContext;
 
     private int m_threadPoolSize;
-    
+
     private double m_asyncToSyncThreadRatio;
-    
+
     private int m_asyncThreadPoolSize;
 
     private int m_timeout;
@@ -247,11 +247,11 @@
             // be created.
             m_threadPoolSize = getIntProperty(
                 PROP_THREAD_POOL_SIZE, m_bundleContext.getProperty(PROP_THREAD_POOL_SIZE), 20, 2);
-            
+
             // The ratio of asynchronous to synchronous threads in the internal thread
-            // pool.  Ratio must be positive and may be adjusted to represent the 
+            // pool.  Ratio must be positive and may be adjusted to represent the
             // distribution of post to send operations.  Applications with higher number
-            // of post operations should have a higher ratio.  
+            // of post operations should have a higher ratio.
             m_asyncToSyncThreadRatio = getDoubleProperty(
             	PROP_ASYNC_TO_SYNC_THREAD_RATIO, m_bundleContext.getProperty(PROP_ASYNC_TO_SYNC_THREAD_RATIO), 0.5, 0.0);
 
@@ -482,7 +482,7 @@
         {
             return new MetaTypeProviderImpl((ManagedService)managedService,
                     m_threadPoolSize, m_timeout, m_requireTopic,
-                    m_ignoreTimeout, m_ignoreTopics);
+                    m_ignoreTimeout, m_ignoreTopics, m_asyncToSyncThreadRatio);
         }
         catch (final Throwable t)
         {
@@ -551,7 +551,7 @@
 
         return defaultValue;
     }
-    
+
     /**
      * Returns either the parsed double from the value of the property if it is set and
      * not less then the min value or the default. Additionally, a warning is
diff --git a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/MetaTypeProviderImpl.java b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/MetaTypeProviderImpl.java
index 8212411..786dd7c 100644
--- a/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/MetaTypeProviderImpl.java
+++ b/eventadmin/impl/src/main/java/org/apache/felix/eventadmin/impl/MetaTypeProviderImpl.java
@@ -41,6 +41,7 @@
     private final boolean m_requireTopic;
     private final String[] m_ignoreTimeout;
     private final String[] m_ignoreTopic;
+    private final double m_asyncThreadPoolRatio;
 
     private final ManagedService m_delegatee;
 
@@ -48,7 +49,8 @@
             final int threadPoolSize,
             final int timeout, final boolean requireTopic,
             final String[] ignoreTimeout,
-            final String[] ignoreTopic)
+            final String[] ignoreTopic,
+            final double asyncThreadPoolRatio)
     {
         m_threadPoolSize = threadPoolSize;
         m_timeout = timeout;
@@ -56,6 +58,7 @@
         m_delegatee = delegatee;
         m_ignoreTimeout = ignoreTimeout;
         m_ignoreTopic = ignoreTopic;
+        m_asyncThreadPoolRatio = asyncThreadPoolRatio;
     }
 
     private ObjectClassDefinition ocd;
@@ -133,6 +136,12 @@
                     "are ignored. If a single value neither ends with a dot nor with a start, this is assumed " +
                     "to define an exact topic. A single star can be used to disable delivery completely.",
                     AttributeDefinition.STRING, m_ignoreTopic, Integer.MAX_VALUE, null, null));
+            adList.add( new AttributeDefinitionImpl( Configuration.PROP_ASYNC_TO_SYNC_THREAD_RATIO, "Async/sync Thread Pool Ratio",
+                    "The ratio of asynchronous to synchronous threads in the internal thread" +
+                    " pool. Ratio must be positive and may be adjusted to represent the " +
+                    "distribution of post to send operations.  Applications with higher number " +
+                    "of post operations should have a higher ratio.",
+                    m_asyncThreadPoolRatio));
             ocd = new ObjectClassDefinition()
             {
 
@@ -205,6 +214,12 @@
                 { String.valueOf(defaultValue) }, 0, null, null );
         }
 
+        AttributeDefinitionImpl( final String id, final String name, final String description, final double defaultValue )
+        {
+            this( id, name, description, DOUBLE, new String[]
+                { String.valueOf(defaultValue) }, 0, null, null );
+        }
+
         AttributeDefinitionImpl( final String id, final String name, final String description, final int type,
             final String[] defaultValues, final int cardinality, final String[] optionLabels,
             final String[] optionValues )
diff --git a/eventadmin/impl/src/test/java/org/apache/felix/eventadmin/ittests/AbstractTest.java b/eventadmin/impl/src/test/java/org/apache/felix/eventadmin/ittests/AbstractTest.java
index e1b1035..2c1c12b 100644
--- a/eventadmin/impl/src/test/java/org/apache/felix/eventadmin/ittests/AbstractTest.java
+++ b/eventadmin/impl/src/test/java/org/apache/felix/eventadmin/ittests/AbstractTest.java
@@ -34,7 +34,7 @@
 import org.junit.runner.RunWith;
 import org.ops4j.pax.exam.Configuration;
 import org.ops4j.pax.exam.CoreOptions;
-import org.ops4j.pax.exam.Option;;
+import org.ops4j.pax.exam.Option;
 import org.ops4j.pax.exam.junit.PaxExam;
 import org.ops4j.pax.exam.options.AbstractDelegateProvisionOption;
 import org.osgi.framework.BundleContext;