camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1453865 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/api/management/mbean/ main/java/org/apache/camel/management/mbean/ test/java/org/apache/camel/management/
Date Thu, 07 Mar 2013 13:47:32 GMT
Author: davsclaus
Date: Thu Mar  7 13:47:32 2013
New Revision: 1453865

URL: http://svn.apache.org/r1453865
Log:
CAMEL-6140: Added mbean attribute for getTaskQueueRemainingCapacity for thread pools. Thanks
to Pat Fox for the patch.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThreadPoolMBean.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThreadPool.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThreadPoolTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThreadPoolMBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThreadPoolMBean.java?rev=1453865&r1=1453864&r2=1453865&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThreadPoolMBean.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedThreadPoolMBean.java
Thu Mar  7 13:47:32 2013
@@ -78,4 +78,7 @@ public interface ManagedThreadPoolMBean 
     @ManagedOperation(description = "Purges the pool")
     void purge();
 
+    @ManagedOperation(description = "Returns the number of additional elements that the Task
queue can"
+            + " ideally (in the absence of memory or resource constraints) accept")
+    int getTaskQueueRemainingCapacity();
 }
\ No newline at end of file

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThreadPool.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThreadPool.java?rev=1453865&r1=1453864&r2=1453865&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThreadPool.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/mbean/ManagedThreadPool.java
Thu Mar  7 13:47:32 2013
@@ -143,4 +143,13 @@ public class ManagedThreadPool implement
         threadPool.purge();
     }
 
+    public int getTaskQueueRemainingCapacity() {
+        if (threadPool.getQueue() != null) {
+            return threadPool.getQueue().remainingCapacity();
+        } else {
+            // no queue found, so no capacity
+            return 0;
+        }
+    }
+
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThreadPoolTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThreadPoolTest.java?rev=1453865&r1=1453864&r2=1453865&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThreadPoolTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedThreadPoolTest.java
Thu Mar  7 13:47:32 2013
@@ -67,6 +67,9 @@ public class ManagedThreadPoolTest exten
 
         Boolean empty = (Boolean) mbeanServer.getAttribute(on, "TaskQueueEmpty");
         assertEquals(true, empty.booleanValue());
+
+        int remainingCapacity = (Integer) mbeanServer.invoke(on, "getTaskQueueRemainingCapacity",
null, null);
+        assertEquals("remainingCapacity", 200, remainingCapacity);
     }
 
     @Override
@@ -74,7 +77,7 @@ public class ManagedThreadPoolTest exten
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("direct:start").threads(15, 30).to("mock:result");
+                from("direct:start").threads(15, 30).maxQueueSize(200).to("mock:result");
             }
         };
     }



Mime
View raw message