camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1292384 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/management/ main/java/org/apache/camel/model/ test/java/org/apache/camel/management/
Date Wed, 22 Feb 2012 16:35:37 GMT
Author: davsclaus
Date: Wed Feb 22 16:35:36 2012
New Revision: 1292384

URL: http://svn.apache.org/viewvc?rev=1292384&view=rev
Log:
CAMEL-5027: Fixed JMS stats for load balancer EIP

Added:
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedLoadBalancerTest.java
      - copied, changed from r1292271, camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSedaEndpointTest.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedMulticastTest.java
Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/DelegatePerformanceCounter.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/DelegatePerformanceCounter.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/DelegatePerformanceCounter.java?rev=1292384&r1=1292383&r2=1292384&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/DelegatePerformanceCounter.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/DelegatePerformanceCounter.java
Wed Feb 22 16:35:36 2012
@@ -68,4 +68,9 @@ public class DelegatePerformanceCounter 
             this.statisticsEnabled = statisticsEnabled;
         }
     }
+
+    @Override
+    public String toString() {
+        return counter != null ? counter.toString() : super.toString();
+    }
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java?rev=1292384&r1=1292383&r2=1292384&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/management/InstrumentationProcessor.java
Wed Feb 22 16:35:36 2012
@@ -80,6 +80,11 @@ public class InstrumentationProcessor ex
                     callback.done(doneSync);
                 }
             }
+
+            @Override
+            public String toString() {
+                return InstrumentationProcessor.this.toString();
+            }
         });
     }
 

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java?rev=1292384&r1=1292383&r2=1292384&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/model/LoadBalanceDefinition.java
Wed Feb 22 16:35:36 2012
@@ -139,7 +139,7 @@ public class LoadBalanceDefinition exten
                 throw new IllegalArgumentException("Loadbalancer already configured to: "
+ loadBalancerType + ". Cannot set it to: " + processorType);
             }
             Processor processor = processorType.createProcessor(routeContext);
-            processor = wrapProcessor(routeContext, processor);
+            processor = wrapChannel(routeContext, processor, processorType);
             loadBalancer.addProcessor(processor);
         }
         return loadBalancer;

Copied: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedLoadBalancerTest.java
(from r1292271, camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSedaEndpointTest.java)
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedLoadBalancerTest.java?p2=camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedLoadBalancerTest.java&p1=camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSedaEndpointTest.java&r1=1292271&r2=1292384&rev=1292384&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedSedaEndpointTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedLoadBalancerTest.java
Wed Feb 22 16:35:36 2012
@@ -24,48 +24,33 @@ import org.apache.camel.builder.RouteBui
 /**
  * @version 
  */
-public class ManagedSedaEndpointTest extends ManagementTestSupport {
+public class ManagedLoadBalancerTest extends ManagementTestSupport {
 
-    public void testSedaEndpoint() throws Exception {
-        getMockEndpoint("mock:result").expectedMessageCount(2);
-
-        template.sendBody("seda:start", "Hello World");
-        template.sendBody("seda:start", "Bye World");
+    public void testLoadBalancer() throws Exception {
+        getMockEndpoint("mock:a").expectedBodiesReceived("Hello World", "Hi World");
+        getMockEndpoint("mock:b").expectedBodiesReceived("Bye World");
+
+        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Bye World");
+        template.sendBody("direct:start", "Hi World");
 
         assertMockEndpointsSatisfied();
 
         MBeanServer mbeanServer = getMBeanServer();
 
-        ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"seda://start\"");
-        String uri = (String) mbeanServer.getAttribute(name, "EndpointUri");
-        assertEquals("seda://start", uri);
-
-        Long timeout = (Long) mbeanServer.getAttribute(name, "Timeout");
-        assertEquals(30000, timeout.intValue());
-
-        Integer size = (Integer) mbeanServer.getAttribute(name, "CurrentQueueSize");
-        assertEquals(0, size.intValue());
-
-        // stop route
-        context.stopRoute("foo");
-
-        // send a message to queue
-        template.sendBody("seda:start", "Hi World");
-
-        size = (Integer) mbeanServer.getAttribute(name, "CurrentQueueSize");
-        assertEquals(1, size.intValue());
-
-        Long size2 = (Long) mbeanServer.invoke(name, "queueSize", null, null);
-        assertEquals(1, size2.longValue());
-
-        String out = (String) mbeanServer.invoke(name, "browseExchange", new Object[]{0},
new String[]{"java.lang.Integer"});
-        assertNotNull(out);
-        assertTrue(out.contains("Hi World"));
-
-        mbeanServer.invoke(name, "purgeQueue", null, null);
-
-        size = (Integer) mbeanServer.getAttribute(name, "CurrentQueueSize");
-        assertEquals(0, size.intValue());
+        ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://a\"");
+        Long queueSize = (Long) mbeanServer.invoke(name, "queueSize", null, null);
+        assertEquals(2, queueSize.intValue());
+
+        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://b\"");
+        queueSize = (Long) mbeanServer.invoke(name, "queueSize", null, null);
+        assertEquals(1, queueSize.intValue());
+
+        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=processors,name=\"myBalancer\"");
+        mbeanServer.isRegistered(name);
+        
+        Long total = (Long) mbeanServer.getAttribute(name, "ExchangesTotal");
+        assertEquals(3, total.intValue());
     }
 
     @Override
@@ -73,7 +58,9 @@ public class ManagedSedaEndpointTest ext
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
-                from("seda:start").routeId("foo").to("log:foo").to("mock:result");
+                from("direct:start").routeId("foo")
+                    .loadBalance().id("myBalancer").roundRobin()
+                        .to("mock:a").to("mock:b");
             }
         };
     }

Added: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedMulticastTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedMulticastTest.java?rev=1292384&view=auto
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedMulticastTest.java
(added)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedMulticastTest.java
Wed Feb 22 16:35:36 2012
@@ -0,0 +1,68 @@
+/**
+ * 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.
+ */
+package org.apache.camel.management;
+
+import javax.management.MBeanServer;
+import javax.management.ObjectName;
+
+import org.apache.camel.builder.RouteBuilder;
+
+/**
+ * @version 
+ */
+public class ManagedMulticastTest extends ManagementTestSupport {
+
+    public void testMulticast() throws Exception {
+        getMockEndpoint("mock:a").expectedMessageCount(3);
+        getMockEndpoint("mock:b").expectedMessageCount(3);
+
+        template.sendBody("direct:start", "Hello World");
+        template.sendBody("direct:start", "Bye World");
+        template.sendBody("direct:start", "Hi World");
+
+        assertMockEndpointsSatisfied();
+
+        MBeanServer mbeanServer = getMBeanServer();
+
+        ObjectName name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://a\"");
+        Long queueSize = (Long) mbeanServer.invoke(name, "queueSize", null, null);
+        assertEquals(3, queueSize.intValue());
+
+        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=endpoints,name=\"mock://b\"");
+        queueSize = (Long) mbeanServer.invoke(name, "queueSize", null, null);
+        assertEquals(3, queueSize.intValue());
+
+        name = ObjectName.getInstance("org.apache.camel:context=localhost/camel-1,type=processors,name=\"myMulticast\"");
+        mbeanServer.isRegistered(name);
+        
+        Long total = (Long) mbeanServer.getAttribute(name, "ExchangesTotal");
+        assertEquals(3, total.intValue());
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start").routeId("foo")
+                    .multicast().id("myMulticast")
+                        .to("mock:a").to("mock:b");
+            }
+        };
+    }
+
+}



Mime
View raw message