diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/DirectChannelMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/DirectChannelMetrics.java
index 319396e12d..3173504e26 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/DirectChannelMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/DirectChannelMetrics.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2009-2010 the original author or authors.
- *
+ * Copyright 2009-2014 the original author or authors.
+ *
* Licensed 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.
@@ -13,21 +13,22 @@
package org.springframework.integration.monitor;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageChannel;
-import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.util.StopWatch;
/**
* Registers all message channels, and accumulates statistics about their performance. The statistics are then published
* locally for other components to consume and publish remotely.
- *
+ *
* @author Dave Syer
* @author Helena Edelson
* @since 2.0
@@ -56,9 +57,9 @@ public class DirectChannelMetrics implements MethodInterceptor, MessageChannelMe
private final ExponentialMovingAverageRate sendRate = new ExponentialMovingAverageRate(
ONE_SECOND_SECONDS, ONE_MINUTE_SECONDS, DEFAULT_MOVING_AVERAGE_WINDOW);
- private final AtomicInteger sendCount = new AtomicInteger();
+ private final AtomicLong sendCount = new AtomicLong();
- private final AtomicInteger sendErrorCount = new AtomicInteger();
+ private final AtomicLong sendErrorCount = new AtomicLong();
private final String name;
@@ -136,7 +137,7 @@ public class DirectChannelMetrics implements MethodInterceptor, MessageChannelMe
}
}
}
-
+
public synchronized void reset() {
sendDuration.reset();
sendErrorRate.reset();
@@ -147,10 +148,18 @@ public class DirectChannelMetrics implements MethodInterceptor, MessageChannelMe
}
public int getSendCount() {
+ return (int) sendCount.get();
+ }
+
+ public long getSendCountLong() {
return sendCount.get();
}
public int getSendErrorCount() {
+ return (int) sendErrorCount.get();
+ }
+
+ public long getSendErrorCountLong() {
return sendErrorCount.get();
}
@@ -185,11 +194,11 @@ public class DirectChannelMetrics implements MethodInterceptor, MessageChannelMe
public double getStandardDeviationSendDuration() {
return sendDuration.getStandardDeviation();
}
-
+
public Statistics getSendDuration() {
return sendDuration.getStatistics();
}
-
+
public Statistics getSendRate() {
return sendRate.getStatistics();
}
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverage.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverage.java
index 62a770c448..2170eb998a 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverage.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverage.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2009-2010 the original author or authors.
- *
+ * Copyright 2009-2014 the original author or authors.
+ *
* Licensed 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.
@@ -20,13 +20,13 @@ package org.springframework.integration.monitor;
* weight, with a decay factor determined by a "window" size chosen by the caller. The result is a good approximation to
* the statistics of the series but with more weight given to recent measurements, so if the statistics change over time
* those trends can be approximately reflected.
- *
+ *
* @author Dave Syer
* @since 2.0
*/
public class ExponentialMovingAverage {
- private volatile int count;
+ private volatile long count;
private volatile double weight;
@@ -44,7 +44,7 @@ public class ExponentialMovingAverage {
/**
* Create a moving average accumulator with decay lapse window provided. Measurements older than this will have
* smaller weight than 1/e.
- *
+ *
* @param window the exponential lapse window (number of measurements)
*/
public ExponentialMovingAverage(int window) {
@@ -63,7 +63,7 @@ public class ExponentialMovingAverage {
/**
* Add a new measurement to the series.
- *
+ *
* @param value the measurement to append
*/
public synchronized void append(double value) {
@@ -83,6 +83,13 @@ public class ExponentialMovingAverage {
* @return the number of measurements recorded
*/
public int getCount() {
+ return (int) count;
+ }
+
+ /**
+ * @return the number of measurements recorded
+ */
+ public long getCountLong() {
return count;
}
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverageRate.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverageRate.java
index db6d68880d..8c525b8f59 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverageRate.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverageRate.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2013 the original author or authors.
+ * Copyright 2009-2014 the original author or authors.
*
* Licensed 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
@@ -96,6 +96,14 @@ public class ExponentialMovingAverageRate {
return rates.getCount();
}
+ /**
+ * @return the number of measurements recorded
+ * @since 3.0
+ */
+ public long getCountLong() {
+ return rates.getCountLong();
+ }
+
/**
* @return the time in seconds since the last measurement
*/
@@ -107,7 +115,7 @@ public class ExponentialMovingAverageRate {
* @return the mean value
*/
public double getMean() {
- int count = rates.getCount();
+ long count = rates.getCountLong();
if (count == 0) {
return 0;
}
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverageRatio.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverageRatio.java
index afa371a20f..1752f9ab89 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverageRatio.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/ExponentialMovingAverageRatio.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2009-2010 the original author or authors.
+ * Copyright 2009-2014 the original author or authors.
*
* Licensed 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
@@ -88,6 +88,13 @@ public class ExponentialMovingAverageRatio {
return cumulative.getCount();
}
+ /**
+ * @return the number of measurements recorded
+ */
+ public long getCountLong() {
+ return cumulative.getCountLong();
+ }
+
/**
* @return the time in seconds since the last measurement
*/
@@ -99,7 +106,7 @@ public class ExponentialMovingAverageRatio {
* @return the mean success rate
*/
public double getMean() {
- int count = cumulative.getCount();
+ long count = cumulative.getCountLong();
if (count == 0) {
// Optimistic to start: success rate is 100%
return 1;
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMBeanExporter.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMBeanExporter.java
index 088efe1b5a..b9770297a1 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMBeanExporter.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/IntegrationMBeanExporter.java
@@ -631,9 +631,14 @@ public class IntegrationMBeanExporter extends MBeanExporter implements BeanPostP
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Active Handler Count")
public int getActiveHandlerCount() {
+ return (int) getActiveHandlerCountLong();
+ }
+
+ @ManagedMetric(metricType = MetricType.GAUGE, displayName = "Active Handler Count")
+ public long getActiveHandlerCountLong() {
int count = 0;
for (MessageHandlerMetrics monitor : handlers) {
- count += monitor.getActiveCount();
+ count += monitor.getActiveCountLong();
}
return count;
}
@@ -663,17 +668,25 @@ public class IntegrationMBeanExporter extends MBeanExporter implements BeanPostP
}
public int getSourceMessageCount(String name) {
+ return (int) getSourceMessageCountLong(name);
+ }
+
+ public long getSourceMessageCountLong(String name) {
if (sourcesByName.containsKey(name)) {
- return sourcesByName.get(name).getMessageCount();
+ return sourcesByName.get(name).getMessageCountLong();
}
logger.debug("No source found for (" + name + ")");
return -1;
}
public int getChannelReceiveCount(String name) {
+ return (int) getChannelReceiveCountLong(name);
+ }
+
+ public long getChannelReceiveCountLong(String name) {
if (channelsByName.containsKey(name)) {
if (channelsByName.get(name) instanceof PollableChannelMetrics) {
- return ((PollableChannelMetrics) channelsByName.get(name)).getReceiveCount();
+ return ((PollableChannelMetrics) channelsByName.get(name)).getReceiveCountLong();
}
}
logger.debug("No channel found for (" + name + ")");
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/LifecycleMessageHandlerMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/LifecycleMessageHandlerMetrics.java
index cc0e8123d2..2e7a93ee53 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/LifecycleMessageHandlerMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/LifecycleMessageHandlerMetrics.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import org.springframework.jmx.export.annotation.ManagedResource;
/**
* A {@link MessageHandlerMetrics} that exposes in addition the {@link Lifecycle} interface. The lifecycle methods can
* be used to stop and start polling endpoints, for instance, in a live system.
- *
+ *
* @author Dave Syer
* @since 2.0
*/
@@ -41,64 +41,92 @@ public class LifecycleMessageHandlerMetrics implements MessageHandlerMetrics, Li
this.delegate = delegate;
}
-
+ @Override
@ManagedAttribute
public boolean isRunning() {
return this.lifecycle.isRunning();
}
+ @Override
@ManagedOperation
public void start() {
this.lifecycle.start();
}
+ @Override
@ManagedOperation
public void stop() {
this.lifecycle.stop();
}
+ @Override
public void reset() {
this.delegate.reset();
}
+ @Override
public int getErrorCount() {
return this.delegate.getErrorCount();
}
+ @Override
public int getHandleCount() {
return this.delegate.getHandleCount();
}
+ @Override
public double getMaxDuration() {
return this.delegate.getMaxDuration();
}
+ @Override
public double getMeanDuration() {
return this.delegate.getMeanDuration();
}
+ @Override
public double getMinDuration() {
return this.delegate.getMinDuration();
}
+ @Override
public double getStandardDeviationDuration() {
return this.delegate.getStandardDeviationDuration();
}
+ @Override
public Statistics getDuration() {
return this.delegate.getDuration();
}
+ @Override
public String getName() {
return this.delegate.getName();
}
+ @Override
public String getSource() {
return this.delegate.getSource();
}
+ @Override
public int getActiveCount() {
return this.delegate.getActiveCount();
}
+ @Override
+ public long getHandleCountLong() {
+ return this.delegate.getHandleCountLong();
+ }
+
+ @Override
+ public long getErrorCountLong() {
+ return this.delegate.getErrorCountLong();
+ }
+
+ @Override
+ public long getActiveCountLong() {
+ return this.delegate.getActiveCountLong();
+ }
+
}
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/LifecycleMessageSourceMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/LifecycleMessageSourceMetrics.java
index fe51f498b8..3a59880c99 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/LifecycleMessageSourceMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/LifecycleMessageSourceMetrics.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,7 +24,7 @@ import org.springframework.jmx.export.annotation.ManagedResource;
/**
* A {@link MessageSourceMetrics} that exposes in addition the {@link Lifecycle} interface. The lifecycle methods can
* be used to start and stop polling endpoints, for instance, in a live system.
- *
+ *
* @author Dave Syer
* @since 2.0
*/
@@ -78,4 +78,9 @@ public class LifecycleMessageSourceMetrics implements MessageSourceMetrics, Life
return this.delegate.getMessageCount();
}
+ @Override
+ public long getMessageCountLong() {
+ return this.delegate.getMessageCountLong();
+ }
+
}
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageChannelMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageChannelMetrics.java
index 92c5058997..1f95cc2abb 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageChannelMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageChannelMetrics.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@ import org.springframework.jmx.support.MetricType;
/**
* Interface for all message channel monitors containing accessors for various useful metrics that are generic for all
* channel types.
- *
+ *
* @author Dave Syer
* @since 2.0
*/
@@ -38,12 +38,26 @@ public interface MessageChannelMetrics {
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Send Count")
int getSendCount();
+ /**
+ * @return the number of successful sends
+ * @since 3.0
+ */
+ @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Send Count")
+ long getSendCountLong();
+
/**
* @return the number of failed sends (either throwing an exception or rejected by the channel)
*/
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Send Error Count")
int getSendErrorCount();
+ /**
+ * @return the number of failed sends (either throwing an exception or rejected by the channel)
+ * @since 3.0
+ */
+ @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Send Error Count")
+ long getSendErrorCountLong();
+
/**
* @return the time in seconds since the last send
*/
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageHandlerMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageHandlerMetrics.java
index 903f200dfe..4d102a3435 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageHandlerMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageHandlerMetrics.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -35,12 +35,26 @@ public interface MessageHandlerMetrics {
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Execution Count")
int getHandleCount();
+ /**
+ * @return the number of successful handler calls
+ * @since 3.0
+ */
+ @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Execution Count")
+ long getHandleCountLong();
+
/**
* @return the number of failed handler calls
*/
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Error Count")
int getErrorCount();
+ /**
+ * @return the number of failed handler calls
+ * @since 3.0
+ */
+ @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Error Count")
+ long getErrorCountLong();
+
/**
* @return the mean handler duration (milliseconds)
*/
@@ -64,10 +78,13 @@ public interface MessageHandlerMetrics {
*/
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Handler Standard Deviation Duration in Milliseconds")
double getStandardDeviationDuration();
-
+
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Handler Active Execution Count")
int getActiveCount();
-
+
+ @ManagedMetric(metricType = MetricType.GAUGE, displayName = "Handler Active Execution Count")
+ long getActiveCountLong();
+
/**
* @return summary statistics about the handler duration (milliseconds)
*/
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageSourceMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageSourceMetrics.java
index 7fda97d47f..a07a27f9e7 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageSourceMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/MessageSourceMetrics.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2002-2010 the original author or authors.
- *
+ * Copyright 2002-2014 the original author or authors.
+ *
* Licensed 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.
@@ -32,6 +32,13 @@ public interface MessageSourceMetrics {
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Message Source Message Count")
int getMessageCount();
+ /**
+ * @return the number of successful handler calls
+ * @since 3.0
+ */
+ @ManagedMetric(metricType = MetricType.COUNTER, displayName = "Message Source Message Count")
+ long getMessageCountLong();
+
String getName();
String getSource();
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/PollableChannelMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/PollableChannelMetrics.java
index 5d216be0e2..89b6ed8b27 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/PollableChannelMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/PollableChannelMetrics.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,13 +16,14 @@
package org.springframework.integration.monitor;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
import org.aopalliance.intercept.MethodInvocation;
-import org.springframework.messaging.MessageChannel;
+
import org.springframework.jmx.export.annotation.ManagedMetric;
import org.springframework.jmx.export.annotation.ManagedOperation;
import org.springframework.jmx.support.MetricType;
+import org.springframework.messaging.MessageChannel;
/**
* @author Dave Syer
@@ -30,9 +31,9 @@ import org.springframework.jmx.support.MetricType;
*/
public class PollableChannelMetrics extends DirectChannelMetrics {
- private final AtomicInteger receiveCount = new AtomicInteger();
+ private final AtomicLong receiveCount = new AtomicLong();
- private final AtomicInteger receiveErrorCount = new AtomicInteger();
+ private final AtomicLong receiveErrorCount = new AtomicLong();
public PollableChannelMetrics(MessageChannel messageChannel, String name) {
@@ -73,11 +74,21 @@ public class PollableChannelMetrics extends DirectChannelMetrics {
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count")
public int getReceiveCount() {
+ return (int) this.receiveCount.get();
+ }
+
+ @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count")
+ public long getReceiveCountLong() {
return this.receiveCount.get();
}
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Error Count")
public int getReceiveErrorCount() {
+ return (int) this.receiveErrorCount.get();
+ }
+
+ @ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Error Count")
+ public long getReceiveErrorCountLong() {
return this.receiveErrorCount.get();
}
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/SimpleMessageHandlerMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/SimpleMessageHandlerMetrics.java
index 67c3410693..fa2e674981 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/SimpleMessageHandlerMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/SimpleMessageHandlerMetrics.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,15 +16,16 @@
package org.springframework.integration.monitor;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+
+import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
-import org.springframework.jmx.export.annotation.ManagedResource;
import org.springframework.util.StopWatch;
/**
@@ -41,11 +42,11 @@ public class SimpleMessageHandlerMetrics implements MethodInterceptor, MessageHa
private final MessageHandler handler;
- private final AtomicInteger activeCount = new AtomicInteger();
+ private final AtomicLong activeCount = new AtomicLong();
- private final AtomicInteger handleCount = new AtomicInteger();
+ private final AtomicLong handleCount = new AtomicLong();
- private final AtomicInteger errorCount = new AtomicInteger();
+ private final AtomicLong errorCount = new AtomicLong();
private final ExponentialMovingAverage duration = new ExponentialMovingAverage(DEFAULT_MOVING_AVERAGE_WINDOW);
@@ -123,14 +124,22 @@ public class SimpleMessageHandlerMetrics implements MethodInterceptor, MessageHa
this.handleCount.set(0);
}
- public int getHandleCount() {
+ public long getHandleCountLong() {
if (logger.isTraceEnabled()) {
logger.trace("Getting Handle Count:" + this);
}
return this.handleCount.get();
}
+ public int getHandleCount() {
+ return (int) getHandleCountLong();
+ }
+
public int getErrorCount() {
+ return (int) this.errorCount.get();
+ }
+
+ public long getErrorCountLong() {
return this.errorCount.get();
}
@@ -151,6 +160,10 @@ public class SimpleMessageHandlerMetrics implements MethodInterceptor, MessageHa
}
public int getActiveCount() {
+ return (int) this.activeCount.get();
+ }
+
+ public long getActiveCountLong() {
return this.activeCount.get();
}
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/SimpleMessageSourceMetrics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/SimpleMessageSourceMetrics.java
index 3241f5fbd3..ff04e3f663 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/SimpleMessageSourceMetrics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/SimpleMessageSourceMetrics.java
@@ -1,11 +1,11 @@
/*
- * Copyright 2002-2010 the original author or authors.
- *
+ * Copyright 2002-2014 the original author or authors.
+ *
* Licensed 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.
@@ -13,10 +13,11 @@
package org.springframework.integration.monitor;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
import org.aopalliance.intercept.MethodInterceptor;
import org.aopalliance.intercept.MethodInvocation;
+
import org.springframework.integration.core.MessageSource;
/**
@@ -25,7 +26,7 @@ import org.springframework.integration.core.MessageSource;
*/
public class SimpleMessageSourceMetrics implements MethodInterceptor, MessageSourceMetrics {
- private final AtomicInteger messageCount = new AtomicInteger();
+ private final AtomicLong messageCount = new AtomicLong();
private final MessageSource> messageSource;
@@ -35,7 +36,7 @@ public class SimpleMessageSourceMetrics implements MethodInterceptor, MessageSou
public SimpleMessageSourceMetrics(MessageSource> messageSource) {
- this.messageSource = messageSource;
+ this.messageSource = messageSource;
}
@@ -64,6 +65,10 @@ public class SimpleMessageSourceMetrics implements MethodInterceptor, MessageSou
}
public int getMessageCount() {
+ return (int) this.messageCount.get();
+ }
+
+ public long getMessageCountLong() {
return this.messageCount.get();
}
diff --git a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/Statistics.java b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/Statistics.java
index 3bd15bf867..5f6b838963 100644
--- a/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/Statistics.java
+++ b/spring-integration-jmx/src/main/java/org/springframework/integration/monitor/Statistics.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,7 +22,7 @@ package org.springframework.integration.monitor;
*/
public class Statistics {
- private final int count;
+ private final long count;
private final double min;
@@ -33,7 +33,7 @@ public class Statistics {
private final double standardDeviation;
- public Statistics(int count, double min, double max, double mean, double standardDeviation) {
+ public Statistics(long count, double min, double max, double mean, double standardDeviation) {
this.count = count;
this.min = min;
this.max = max;
@@ -43,29 +43,33 @@ public class Statistics {
public int getCount() {
- return count;
+ return (int) this.count;
+ }
+
+ public long getCountLong() {
+ return this.count;
}
public double getMin() {
- return min;
+ return this.min;
}
public double getMax() {
- return max;
+ return this.max;
}
public double getMean() {
- return mean;
+ return this.mean;
}
public double getStandardDeviation() {
- return standardDeviation;
+ return this.standardDeviation;
}
@Override
public String toString() {
return String.format("[N=%d, min=%f, max=%f, mean=%f, sigma=%f]",
- count, min, max, getMean(), getStandardDeviation());
+ this.count, this.min, this.max, getMean(), getStandardDeviation());
}
}
diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/MBeanAttributeFilterTests-context.xml b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/MBeanAttributeFilterTests-context.xml
index c50125252f..24f3c22539 100644
--- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/MBeanAttributeFilterTests-context.xml
+++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/MBeanAttributeFilterTests-context.xml
@@ -61,7 +61,9 @@
SendCount
+ SendCountLong
SendErrorCount
+ SendErrorCountLong
diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/MBeanAttributeFilterTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/MBeanAttributeFilterTests.java
index f328b2131d..d4fb4add20 100644
--- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/MBeanAttributeFilterTests.java
+++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/MBeanAttributeFilterTests.java
@@ -25,6 +25,7 @@ import java.util.Map;
import org.junit.Test;
import org.junit.runner.RunWith;
+
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.integration.endpoint.SourcePollingChannelAdapter;
@@ -104,6 +105,8 @@ public class MBeanAttributeFilterTests {
assertEquals(8, bean.size());
assertFalse(bean.containsKey("SendCount"));
assertFalse(bean.containsKey("SendErrorCount"));
+ assertFalse(bean.containsKey("SendCountLong"));
+ assertFalse(bean.containsKey("SendErrorCountLong"));
adapterNot.stop();
}
diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/ControlBusParserTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/ControlBusParserTests.java
index 5ca728950c..36a6d18413 100644
--- a/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/ControlBusParserTests.java
+++ b/spring-integration-jmx/src/test/java/org/springframework/integration/jmx/config/ControlBusParserTests.java
@@ -1,5 +1,5 @@
/*
- * Copyright 2002-2010 the original author or authors.
+ * Copyright 2002-2014 the original author or authors.
*
* Licensed 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
@@ -43,7 +43,7 @@ public class ControlBusParserTests {
MessagingTemplate messagingTemplate = new MessagingTemplate();
Object value = messagingTemplate.convertSendAndReceive(control,
"@integrationMbeanExporter.getChannelSendRate('testChannel').count", null);
- assertEquals(new Integer(0), value);
+ assertEquals(0, value);
MBeanExporter exporter = this.context.getBean(MBeanExporter.class);
exporter.destroy();
}
diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/HandlerMonitoringIntegrationTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/HandlerMonitoringIntegrationTests.java
index 3b3abc4473..e3f257d2c0 100644
--- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/HandlerMonitoringIntegrationTests.java
+++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/HandlerMonitoringIntegrationTests.java
@@ -1,11 +1,11 @@
/*
* Copyright 2009-2010 the original author or authors.
- *
+ *
* Licensed 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.
@@ -36,11 +36,11 @@ public class HandlerMonitoringIntegrationTests {
private Service service;
private IntegrationMBeanExporter messageHandlersMonitor;
-
+
public void setMessageHandlersMonitor(IntegrationMBeanExporter messageHandlersMonitor) {
this.messageHandlersMonitor = messageHandlersMonitor;
}
-
+
public void setService(Service service) {
this.service = service;
}
@@ -104,7 +104,7 @@ public class HandlerMonitoringIntegrationTests {
void execute(String input) throws Exception;
int getCounter();
}
-
+
public static class SimpleService implements Service {
private int counter;
@@ -117,7 +117,7 @@ public class HandlerMonitoringIntegrationTests {
return counter;
}
}
-
+
@Aspect
public static class HandlerInterceptor {
@Before("execution(* *..*Tests*(String)) && args(input)")
diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageChannelsMonitorIntegrationTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageChannelsMonitorIntegrationTests.java
index f18da3791e..3dafe10395 100644
--- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageChannelsMonitorIntegrationTests.java
+++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageChannelsMonitorIntegrationTests.java
@@ -91,6 +91,8 @@ public class MessageChannelsMonitorIntegrationTests {
// The handler monitor is registered under the endpoint id (since it is explicit)
int sends = messageChannelsMonitor.getChannelSendRate("" + channel).getCount();
assertEquals("No send statistics for input channel", 50, sends, 0.01);
+ long sendsLong = messageChannelsMonitor.getChannelSendRate("" + channel).getCountLong();
+ assertEquals("No send statistics for input channel", sendsLong, sends, 0.01);
}
finally {
diff --git a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageSourceMonitoringIntegrationTests.java b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageSourceMonitoringIntegrationTests.java
index 38c2082a1d..9ab21fbd33 100644
--- a/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageSourceMonitoringIntegrationTests.java
+++ b/spring-integration-jmx/src/test/java/org/springframework/integration/monitor/MessageSourceMonitoringIntegrationTests.java
@@ -1,15 +1,16 @@
/*
* Copyright 2009-2010 the original author or authors.
- *
+ *
* Licensed 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.springframework.integration.monitor;
import static org.junit.Assert.assertTrue;
@@ -26,11 +27,11 @@ public class MessageSourceMonitoringIntegrationTests {
private Service service;
private IntegrationMBeanExporter exporter;
-
+
public void setMessageHandlersMonitor(IntegrationMBeanExporter exporter) {
this.exporter = exporter;
}
-
+
public void setService(Service service) {
this.service = service;
}
@@ -78,7 +79,7 @@ public class MessageSourceMonitoringIntegrationTests {
String execute() throws Exception;
int getCounter();
}
-
+
public static class SimpleService implements Service {
private int counter;
@@ -92,5 +93,5 @@ public class MessageSourceMonitoringIntegrationTests {
return counter;
}
}
-
+
}