camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1467758 - in /camel/trunk/camel-core/src: main/java/org/apache/camel/api/management/mbean/ main/java/org/apache/camel/impl/converter/ main/java/org/apache/camel/spi/ test/java/org/apache/camel/management/
Date Sun, 14 Apr 2013 10:08:13 GMT
Author: davsclaus
Date: Sun Apr 14 10:08:13 2013
New Revision: 1467758

URL: http://svn.apache.org/r1467758
Log:
CAMEL-6264: Disabled and @deprecated utilization stats on type converter registry to avoid
performance degration on very high concurrent usages.

Modified:
    camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
    camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java
    camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java?rev=1467758&r1=1467757&r2=1467758&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/api/management/mbean/ManagedTypeConverterRegistryMBean.java
Sun Apr 14 10:08:13 2013
@@ -25,18 +25,23 @@ import org.apache.camel.api.management.M
 public interface ManagedTypeConverterRegistryMBean extends ManagedServiceMBean {
 
     @ManagedAttribute(description = "Number of type conversion attempts")
+    @Deprecated
     long getAttemptCounter();
 
     @ManagedAttribute(description = "Number of type conversion hits (successful conversions)")
+    @Deprecated
     long getHitCounter();
 
     @ManagedAttribute(description = "Number of type conversion misses (no suitable type converter)")
+    @Deprecated
     long getMissCounter();
 
     @ManagedAttribute(description = "Number of type conversion failures (failed conversions)")
+    @Deprecated
     long getFailedCounter();
 
     @ManagedOperation(description = "Resets the type conversion counters")
+    @Deprecated
     void resetTypeConversionCounters();
 
 }

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java?rev=1467758&r1=1467757&r2=1467758&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
(original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/impl/converter/BaseTypeConverterRegistry.java
Sun Apr 14 10:08:13 2013
@@ -27,7 +27,6 @@ import java.util.concurrent.ConcurrentHa
 import java.util.concurrent.ConcurrentMap;
 import java.util.concurrent.CopyOnWriteArrayList;
 import java.util.concurrent.ExecutionException;
-import java.util.concurrent.atomic.AtomicLong;
 
 import org.apache.camel.CamelExecutionException;
 import org.apache.camel.Exchange;
@@ -64,10 +63,6 @@ public abstract class BaseTypeConverterR
     protected Injector injector;
     protected final FactoryFinder factoryFinder;
     protected final Statistics statistics = new UtilizationStatistics();
-    protected final AtomicLong attemptCounter = new AtomicLong();
-    protected final AtomicLong missCounter = new AtomicLong();
-    protected final AtomicLong hitCounter = new AtomicLong();
-    protected final AtomicLong failedCounter = new AtomicLong();
 
     public BaseTypeConverterRegistry(PackageScanClassResolver resolver, Injector injector,
FactoryFinder factoryFinder) {
         this.resolver = resolver;
@@ -107,10 +102,8 @@ public abstract class BaseTypeConverterR
 
         Object answer;
         try {
-            attemptCounter.incrementAndGet();
             answer = doConvertTo(type, exchange, value, false);
         } catch (Exception e) {
-            failedCounter.incrementAndGet();
             // if its a ExecutionException then we have rethrow it as its not due to failed
conversion
             // this is special for FutureTypeConverter
             boolean execution = ObjectHelper.getException(ExecutionException.class, e) !=
null
@@ -128,11 +121,8 @@ public abstract class BaseTypeConverterR
         }
         if (answer == Void.TYPE) {
             // Could not find suitable conversion
-            missCounter.incrementAndGet();
-            // Could not find suitable conversion
             return null;
         } else {
-            hitCounter.incrementAndGet();
             return (T) answer;
         }
     }
@@ -151,10 +141,8 @@ public abstract class BaseTypeConverterR
 
         Object answer;
         try {
-            attemptCounter.incrementAndGet();
             answer = doConvertTo(type, exchange, value, false);
         } catch (Exception e) {
-            failedCounter.incrementAndGet();
             // error occurred during type conversion
             if (e instanceof TypeConversionException) {
                 throw (TypeConversionException) e;
@@ -164,11 +152,8 @@ public abstract class BaseTypeConverterR
         }
         if (answer == Void.TYPE || value == null) {
             // Could not find suitable conversion
-            missCounter.incrementAndGet();
-            // Could not find suitable conversion
             throw new NoTypeConversionAvailableException(value, type);
         } else {
-            hitCounter.incrementAndGet();
             return (T) answer;
         }
     }
@@ -187,18 +172,14 @@ public abstract class BaseTypeConverterR
 
         Object answer;
         try {
-            attemptCounter.incrementAndGet();
             answer = doConvertTo(type, exchange, value, true);
         } catch (Exception e) {
-            failedCounter.incrementAndGet();
             return null;
         }
         if (answer == Void.TYPE) {
-            missCounter.incrementAndGet();
             // Could not find suitable conversion
             return null;
         } else {
-            hitCounter.incrementAndGet();
             return (T) answer;
         }
     }
@@ -516,11 +497,6 @@ public abstract class BaseTypeConverterR
 
     @Override
     protected void doStop() throws Exception {
-        // log utilization statistics when stopping, including mappings
-        String info = statistics.toString();
-        info += String.format(" mappings[total=%s, misses=%s]", typeMappings.size(), misses.size());
-        log.info(info);
-
         typeMappings.clear();
         misses.clear();
         statistics.reset();
@@ -529,34 +505,32 @@ public abstract class BaseTypeConverterR
     /**
      * Represents utilization statistics
      */
+    @Deprecated
     private final class UtilizationStatistics implements Statistics {
 
         @Override
         public long getAttemptCounter() {
-            return attemptCounter.get();
+            return 0;
         }
 
         @Override
         public long getHitCounter() {
-            return hitCounter.get();
+            return 0;
         }
 
         @Override
         public long getMissCounter() {
-            return missCounter.get();
+            return 0;
         }
 
         @Override
         public long getFailedCounter() {
-            return failedCounter.get();
+            return 0;
         }
 
         @Override
         public void reset() {
-            attemptCounter.set(0);
-            hitCounter.set(0);
-            missCounter.set(0);
-            failedCounter.set(0);
+            // noop
         }
 
         @Override

Modified: camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java?rev=1467758&r1=1467757&r2=1467758&view=diff
==============================================================================
--- camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java (original)
+++ camel/trunk/camel-core/src/main/java/org/apache/camel/spi/TypeConverterRegistry.java Sun
Apr 14 10:08:13 2013
@@ -28,7 +28,9 @@ public interface TypeConverterRegistry e
 
     /**
      * Utilization statistics of the this registry.
+     * @deprecated the statistics has been disabled and the API will be removed in Camel
2.12
      */
+    @Deprecated
     interface Statistics {
 
         /**
@@ -101,7 +103,9 @@ public interface TypeConverterRegistry e
      * Gets the utilization statistics of this type converter registry
      *
      * @return the utilization statistics
+     * @deprecated the statistics has been disabled and the API will be removed in Camel
2.12
      */
+    @Deprecated
     Statistics getStatistics();
 
 }

Modified: camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java?rev=1467758&r1=1467757&r2=1467758&view=diff
==============================================================================
--- camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java
(original)
+++ camel/trunk/camel-core/src/test/java/org/apache/camel/management/ManagedTypeConverterRegistryTest.java
Sun Apr 14 10:08:13 2013
@@ -49,32 +49,6 @@ public class ManagedTypeConverterRegistr
             }
         }
         assertNotNull("Cannot find DefaultTypeConverter", name);
-
-        Long failed = (Long) mbeanServer.getAttribute(name, "FailedCounter");
-        assertEquals(0, failed.intValue());
-        Long miss = (Long) mbeanServer.getAttribute(name, "MissCounter");
-        assertEquals(0, miss.intValue());
-
-        try {
-            template.sendBody("direct:start", "foo");
-            fail("Should have thrown exception");
-        } catch (Exception e) {
-            // expected
-        }
-
-        // should now have a failed
-        failed = (Long) mbeanServer.getAttribute(name, "FailedCounter");
-        assertEquals(1, failed.intValue());
-        miss = (Long) mbeanServer.getAttribute(name, "MissCounter");
-        assertEquals(0, miss.intValue());
-
-        // reset
-        mbeanServer.invoke(name, "resetTypeConversionCounters", null, null);
-
-        failed = (Long) mbeanServer.getAttribute(name, "FailedCounter");
-        assertEquals(0, failed.intValue());
-        miss = (Long) mbeanServer.getAttribute(name, "MissCounter");
-        assertEquals(0, miss.intValue());
     }
 
     @Override



Mime
View raw message