Remove Legacy Metrics
- Simplify MBeans - instead of wrapping to expose lifecycle methods, implement `ManageableLifecycle`. Register an additional MBean for polled endpoints to control the lifecycle. * Polishing - Move `QueueChannel` `@ManagedAttribute`s to `QueueChannelOperations` - Make all `AbstractEndpoints` `IntegrationManagedResource`s and remove `ManagedEndpoint` to allow exposure of any `@Managed*` methods (including those on `Pausable`) - Revert to `Lifecycle` for classes that are not related to endpoints - Remove legacy metrics from docs
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -29,7 +29,6 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.rabbit.listener.AbstractMessageListenerContainer;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.amqp.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.MessageDispatchingException;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
|
||||
@@ -38,6 +37,7 @@ import org.springframework.integration.dispatcher.AbstractDispatcher;
|
||||
import org.springframework.integration.dispatcher.MessageDispatcher;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.integration.support.MessageBuilderFactory;
|
||||
import org.springframework.integration.support.management.ManageableSmartLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
@@ -52,7 +52,7 @@ import org.springframework.util.Assert;
|
||||
* @since 2.1
|
||||
*/
|
||||
abstract class AbstractSubscribableAmqpChannel extends AbstractAmqpChannel
|
||||
implements SubscribableChannel, SmartLifecycle {
|
||||
implements SubscribableChannel, ManageableSmartLifecycle {
|
||||
|
||||
private final String channelName;
|
||||
|
||||
|
||||
@@ -50,10 +50,8 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
implements PollableChannel, org.springframework.integration.support.management.PollableChannelManagement,
|
||||
ExecutorChannelInterceptorAware {
|
||||
implements PollableChannel, ExecutorChannelInterceptorAware {
|
||||
|
||||
private final String channelName;
|
||||
|
||||
@@ -115,50 +113,6 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
setAdmin(amqpAdmin);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return receive count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getReceiveCount() {
|
||||
return getMetrics().getReceiveCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return receive count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getReceiveCountLong() {
|
||||
return getMetrics().getReceiveCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return receive error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getReceiveErrorCount() {
|
||||
return getMetrics().getReceiveErrorCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return receive error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getReceiveErrorCountLong() {
|
||||
return getMetrics().getReceiveErrorCountLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRoutingKey() {
|
||||
return this.queue != null ? this.queue.getName() : super.getRoutingKey();
|
||||
@@ -208,7 +162,6 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
ChannelInterceptorList interceptorList = getIChannelInterceptorList();
|
||||
Deque<ChannelInterceptor> interceptorStack = null;
|
||||
AtomicBoolean counted = new AtomicBoolean();
|
||||
boolean countsEnabled = isCountsEnabled();
|
||||
boolean traceEnabled = isLoggingEnabled() && logger.isTraceEnabled();
|
||||
try {
|
||||
if (traceEnabled) {
|
||||
@@ -221,8 +174,7 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
}
|
||||
}
|
||||
Object object = performReceive(timeout);
|
||||
Message<?> message = buildMessageFromResult(object, traceEnabled, countsEnabled ? counted : null);
|
||||
|
||||
Message<?> message = buildMessageFromResult(object, traceEnabled, counted);
|
||||
|
||||
if (message != null) {
|
||||
message = interceptorList.postReceive(message, this);
|
||||
@@ -231,7 +183,7 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
return message;
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
if (countsEnabled && !counted.get()) {
|
||||
if (!counted.get()) {
|
||||
incrementReceiveErrorCounter(ex);
|
||||
}
|
||||
interceptorList.afterReceiveCompletion(null, this, ex, interceptorStack);
|
||||
@@ -279,16 +231,10 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
}
|
||||
}
|
||||
|
||||
private Message<?> buildMessageFromResult(@Nullable Object object, boolean traceEnabled,
|
||||
@Nullable AtomicBoolean counted) {
|
||||
private Message<?> buildMessageFromResult(@Nullable Object object, boolean traceEnabled, AtomicBoolean counted) {
|
||||
|
||||
Message<?> message = null;
|
||||
if (object != null) {
|
||||
if (counted != null) {
|
||||
incrementReceiveCounter();
|
||||
getMetrics().afterReceive();
|
||||
counted.set(true);
|
||||
}
|
||||
if (object instanceof Message<?>) {
|
||||
message = (Message<?>) object;
|
||||
}
|
||||
@@ -298,6 +244,8 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
.build();
|
||||
}
|
||||
}
|
||||
incrementReceiveCounter();
|
||||
counted.set(true);
|
||||
|
||||
if (traceEnabled) {
|
||||
logger.trace("postReceive on channel '" + this
|
||||
@@ -322,7 +270,6 @@ public class PollableAmqpChannel extends AbstractAmqpChannel
|
||||
if (metricsCaptor != null) {
|
||||
buildReceiveCounter(metricsCaptor, ex).increment();
|
||||
}
|
||||
getMetrics().afterError();
|
||||
}
|
||||
|
||||
private CounterFacade buildReceiveCounter(MetricsCaptor metricsCaptor, @Nullable Exception ex) {
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.springframework.amqp.rabbit.core.RabbitTemplate;
|
||||
import org.springframework.amqp.support.AmqpHeaders;
|
||||
import org.springframework.amqp.support.converter.MessageConverter;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.integration.amqp.support.AmqpHeaderMapper;
|
||||
import org.springframework.integration.amqp.support.DefaultAmqpHeaderMapper;
|
||||
@@ -46,6 +45,7 @@ import org.springframework.integration.mapping.AbstractHeaderMapper;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.integration.support.DefaultErrorMessageStrategy;
|
||||
import org.springframework.integration.support.ErrorMessageStrategy;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -61,7 +61,7 @@ import org.springframework.util.concurrent.SettableListenableFuture;
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractAmqpOutboundEndpoint extends AbstractReplyProducingMessageHandler
|
||||
implements Lifecycle {
|
||||
implements ManageableLifecycle {
|
||||
|
||||
private static final String NO_ID = new UUID(0L, 0L).toString();
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ import org.springframework.integration.store.UniqueExpiryCallback;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.integration.support.locks.DefaultLockRegistry;
|
||||
import org.springframework.integration.support.locks.LockRegistry;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.integration.util.UUIDConverter;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -103,7 +104,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @since 2.0
|
||||
*/
|
||||
public abstract class AbstractCorrelatingMessageHandler extends AbstractMessageProducingHandler
|
||||
implements DiscardingMessageHandler, ApplicationEventPublisherAware, Lifecycle {
|
||||
implements DiscardingMessageHandler, ApplicationEventPublisherAware, ManageableLifecycle {
|
||||
|
||||
private final Comparator<Message<?>> sequenceNumberComparator = new MessageSequenceComparator();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2020 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.
|
||||
@@ -27,6 +27,7 @@ import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
||||
import org.springframework.integration.support.MessageBuilderFactory;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -49,7 +50,8 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public class DelegatingMessageGroupProcessor implements MessageGroupProcessor, BeanFactoryAware, Lifecycle {
|
||||
public class DelegatingMessageGroupProcessor implements MessageGroupProcessor, BeanFactoryAware,
|
||||
ManageableLifecycle {
|
||||
|
||||
private final MessageGroupProcessor delegate;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2019-2020 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.
|
||||
@@ -21,11 +21,11 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.IntegrationMessageHeaderAccessor;
|
||||
import org.springframework.integration.IntegrationPatternType;
|
||||
import org.springframework.integration.channel.ReactiveStreamsSubscribableChannel;
|
||||
import org.springframework.integration.handler.AbstractMessageProducingHandler;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -53,7 +53,7 @@ import reactor.core.publisher.Mono;
|
||||
*
|
||||
* @since 5.2
|
||||
*/
|
||||
public class FluxAggregatorMessageHandler extends AbstractMessageProducingHandler implements Lifecycle {
|
||||
public class FluxAggregatorMessageHandler extends AbstractMessageProducingHandler implements ManageableLifecycle {
|
||||
|
||||
private final AtomicBoolean subscribed = new AtomicBoolean();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -21,8 +21,8 @@ import java.lang.reflect.Method;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.handler.MethodInvokingMessageProcessor;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -34,7 +34,7 @@ import org.springframework.util.Assert;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class MethodInvokingCorrelationStrategy implements CorrelationStrategy, BeanFactoryAware, Lifecycle {
|
||||
public class MethodInvokingCorrelationStrategy implements CorrelationStrategy, BeanFactoryAware, ManageableLifecycle {
|
||||
|
||||
private final MethodInvokingMessageProcessor<?> processor;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -21,10 +21,10 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.annotation.Aggregator;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
/**
|
||||
@@ -39,7 +39,7 @@ import org.springframework.messaging.Message;
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MethodInvokingMessageGroupProcessor extends AbstractAggregatingMessageGroupProcessor
|
||||
implements Lifecycle {
|
||||
implements ManageableLifecycle {
|
||||
|
||||
private final MethodInvokingMessageListProcessor<Object> processor;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,8 +22,8 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.handler.support.MessagingMethodInvokerHelper;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -38,7 +38,7 @@ import org.springframework.messaging.Message;
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MethodInvokingMessageListProcessor<T> extends AbstractExpressionEvaluator
|
||||
implements Lifecycle {
|
||||
implements ManageableLifecycle {
|
||||
|
||||
private final MessagingMethodInvokerHelper delegate;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -20,9 +20,9 @@ import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.store.MessageGroup;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
|
||||
/**
|
||||
* A {@link ReleaseStrategy} that invokes a method on a plain old Java object.
|
||||
@@ -31,7 +31,7 @@ import org.springframework.integration.store.MessageGroup;
|
||||
* @author Dave Syer
|
||||
* @author Artme Bilan
|
||||
*/
|
||||
public class MethodInvokingReleaseStrategy implements ReleaseStrategy, BeanFactoryAware, Lifecycle {
|
||||
public class MethodInvokingReleaseStrategy implements ReleaseStrategy, BeanFactoryAware, ManageableLifecycle {
|
||||
|
||||
private final MethodInvokingMessageListProcessor<Boolean> adapter;
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.history.MessageHistory;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.IntegrationManagement;
|
||||
import org.springframework.integration.support.management.TrackableComponent;
|
||||
import org.springframework.integration.support.management.metrics.MeterFacade;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
@@ -66,13 +67,9 @@ import org.springframework.util.StringUtils;
|
||||
@IntegrationManagedResource
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
implements MessageChannel, TrackableComponent, InterceptableChannel,
|
||||
org.springframework.integration.support.management.MessageChannelMetrics,
|
||||
org.springframework.integration.support.management.ConfigurableMetricsAware<
|
||||
org.springframework.integration.support.management.AbstractMessageChannelMetrics>,
|
||||
IntegrationPattern {
|
||||
implements MessageChannel, TrackableComponent, InterceptableChannel, IntegrationManagement, IntegrationPattern {
|
||||
|
||||
protected final ChannelInterceptorList interceptors; // NOSONAR
|
||||
protected final ChannelInterceptorList interceptors = new ChannelInterceptorList(logger); // NOSONAR
|
||||
|
||||
private final Comparator<Object> orderComparator = new OrderComparator();
|
||||
|
||||
@@ -88,25 +85,14 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
|
||||
private volatile MessageConverter messageConverter;
|
||||
|
||||
private volatile boolean countsEnabled;
|
||||
|
||||
private volatile boolean statsEnabled;
|
||||
|
||||
private volatile boolean loggingEnabled = true;
|
||||
|
||||
private volatile org.springframework.integration.support.management.AbstractMessageChannelMetrics channelMetrics
|
||||
= new org.springframework.integration.support.management.DefaultMessageChannelMetrics();
|
||||
|
||||
private MetricsCaptor metricsCaptor;
|
||||
|
||||
private TimerFacade successTimer;
|
||||
|
||||
private TimerFacade failureTimer;
|
||||
|
||||
public AbstractMessageChannel() {
|
||||
this.interceptors = new ChannelInterceptorList(logger);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "channel";
|
||||
@@ -132,37 +118,6 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
return this.metricsCaptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountsEnabled(boolean countsEnabled) {
|
||||
this.countsEnabled = countsEnabled;
|
||||
this.managementOverrides.countsConfigured = true;
|
||||
if (!countsEnabled) {
|
||||
this.statsEnabled = false;
|
||||
this.managementOverrides.statsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCountsEnabled() {
|
||||
return this.countsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatsEnabled(boolean statsEnabled) {
|
||||
if (statsEnabled) {
|
||||
this.countsEnabled = true;
|
||||
this.managementOverrides.countsConfigured = true;
|
||||
}
|
||||
this.statsEnabled = statsEnabled;
|
||||
this.channelMetrics.setFullStatsEnabled(statsEnabled);
|
||||
this.managementOverrides.statsConfigured = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatsEnabled() {
|
||||
return this.statsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoggingEnabled() {
|
||||
return this.loggingEnabled;
|
||||
@@ -174,31 +129,6 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
this.managementOverrides.loggingConfigured = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return channel metrics.
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
protected org.springframework.integration.support.management.AbstractMessageChannelMetrics getMetrics() {
|
||||
return this.channelMetrics;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @param metrics the metrics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void configureMetrics(
|
||||
org.springframework.integration.support.management.AbstractMessageChannelMetrics metrics) {
|
||||
|
||||
Assert.notNull(metrics, "'metrics' must not be null");
|
||||
this.channelMetrics = metrics;
|
||||
this.managementOverrides.metricsConfigured = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Specify the Message payload datatype(s) supported by this channel. If a
|
||||
* payload type does not match directly, but the 'conversionService' is
|
||||
@@ -289,181 +219,6 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
return this.interceptors;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void reset() {
|
||||
this.channelMetrics.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return send count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getSendCount() {
|
||||
return this.channelMetrics.getSendCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return send count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getSendCountLong() {
|
||||
return this.channelMetrics.getSendCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return send error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getSendErrorCount() {
|
||||
return this.channelMetrics.getSendErrorCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return send error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getSendErrorCountLong() {
|
||||
return this.channelMetrics.getSendErrorCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return time since last
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getTimeSinceLastSend() {
|
||||
return this.channelMetrics.getTimeSinceLastSend();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean send rate
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanSendRate() {
|
||||
return this.channelMetrics.getMeanSendRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean error rate
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanErrorRate() {
|
||||
return this.channelMetrics.getMeanErrorRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean error ratio
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanErrorRatio() {
|
||||
return this.channelMetrics.getMeanErrorRatio();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean send duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanSendDuration() {
|
||||
return this.channelMetrics.getMeanSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return min send duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMinSendDuration() {
|
||||
return this.channelMetrics.getMinSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return max send duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMaxSendDuration() {
|
||||
return this.channelMetrics.getMaxSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return standard deviation send duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getStandardDeviationSendDuration() {
|
||||
return this.channelMetrics.getStandardDeviationSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return statistics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public org.springframework.integration.support.management.Statistics getSendDuration() {
|
||||
return this.channelMetrics.getSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return statistics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public org.springframework.integration.support.management.Statistics getSendRate() {
|
||||
return this.channelMetrics.getSendRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return statistics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public org.springframework.integration.support.management.Statistics getErrorRate() {
|
||||
return this.channelMetrics.getErrorRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagementOverrides getOverrides() {
|
||||
return this.managementOverrides;
|
||||
@@ -484,9 +239,6 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
MessageConverter.class);
|
||||
}
|
||||
}
|
||||
if (this.statsEnabled) {
|
||||
this.channelMetrics.setFullStatsEnabled(true);
|
||||
}
|
||||
this.fullChannelName = null;
|
||||
}
|
||||
|
||||
@@ -544,10 +296,7 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
Deque<ChannelInterceptor> interceptorStack = null;
|
||||
boolean sent = false;
|
||||
boolean metricsProcessed = false;
|
||||
org.springframework.integration.support.management.MetricsContext metricsContext = null;
|
||||
boolean countsAreEnabled = this.countsEnabled;
|
||||
ChannelInterceptorList interceptorList = this.interceptors;
|
||||
org.springframework.integration.support.management.AbstractMessageChannelMetrics metrics = this.channelMetrics;
|
||||
SampleFacade sample = null;
|
||||
try {
|
||||
message = convertPayloadIfNecessary(message);
|
||||
@@ -562,21 +311,14 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (countsAreEnabled) {
|
||||
metricsContext = metrics.beforeSend();
|
||||
if (this.metricsCaptor != null) {
|
||||
sample = this.metricsCaptor.start();
|
||||
}
|
||||
sent = doSend(message, timeout);
|
||||
if (sample != null) {
|
||||
sample.stop(sendTimer(sent));
|
||||
}
|
||||
metrics.afterSend(metricsContext, sent);
|
||||
metricsProcessed = true;
|
||||
if (this.metricsCaptor != null) {
|
||||
sample = this.metricsCaptor.start();
|
||||
}
|
||||
else {
|
||||
sent = doSend(message, timeout);
|
||||
sent = doSend(message, timeout);
|
||||
if (sample != null) {
|
||||
sample.stop(sendTimer(sent));
|
||||
}
|
||||
metricsProcessed = true;
|
||||
|
||||
if (debugEnabled) {
|
||||
logger.debug("postSend (sent=" + sent + ") on channel '" + this + "', message: " + message);
|
||||
@@ -588,11 +330,10 @@ public abstract class AbstractMessageChannel extends IntegrationObjectSupport
|
||||
return sent;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
if (countsAreEnabled && !metricsProcessed) {
|
||||
if (!metricsProcessed) {
|
||||
if (sample != null) {
|
||||
sample.stop(buildSendTimer(false, ex.getClass().getSimpleName()));
|
||||
}
|
||||
metrics.afterSend(metricsContext, false);
|
||||
}
|
||||
if (interceptorStack != null) {
|
||||
interceptorList.afterSendCompletion(message, this, sent, ex, interceptorStack);
|
||||
|
||||
@@ -39,57 +39,12 @@ import org.springframework.messaging.support.ExecutorChannelInterceptor;
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class AbstractPollableChannel extends AbstractMessageChannel
|
||||
implements PollableChannel, org.springframework.integration.support.management.PollableChannelManagement,
|
||||
ExecutorChannelInterceptorAware {
|
||||
implements PollableChannel, ExecutorChannelInterceptorAware {
|
||||
|
||||
private int executorInterceptorsSize;
|
||||
|
||||
private CounterFacade receiveCounter;
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return receive count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getReceiveCount() {
|
||||
return getMetrics().getReceiveCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return receive count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getReceiveCountLong() {
|
||||
return getMetrics().getReceiveCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getReceiveErrorCount() {
|
||||
return getMetrics().getReceiveErrorCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getReceiveErrorCountLong() {
|
||||
return getMetrics().getReceiveErrorCountLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegrationPatternType getIntegrationPatternType() {
|
||||
return IntegrationPatternType.pollable_channel;
|
||||
@@ -124,7 +79,6 @@ public abstract class AbstractPollableChannel extends AbstractMessageChannel
|
||||
ChannelInterceptorList interceptorList = getIChannelInterceptorList();
|
||||
Deque<ChannelInterceptor> interceptorStack = null;
|
||||
boolean counted = false;
|
||||
boolean countsEnabled = isCountsEnabled();
|
||||
boolean traceEnabled = isLoggingEnabled() && logger.isTraceEnabled();
|
||||
try {
|
||||
if (traceEnabled) {
|
||||
@@ -144,11 +98,8 @@ public abstract class AbstractPollableChannel extends AbstractMessageChannel
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (countsEnabled) {
|
||||
incrementReceiveCounter();
|
||||
getMetrics().afterReceive();
|
||||
counted = true;
|
||||
}
|
||||
incrementReceiveCounter();
|
||||
counted = true;
|
||||
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("postReceive on channel '" + this + "', message: " + message);
|
||||
@@ -162,7 +113,7 @@ public abstract class AbstractPollableChannel extends AbstractMessageChannel
|
||||
return message;
|
||||
}
|
||||
catch (RuntimeException ex) {
|
||||
if (countsEnabled && !counted) {
|
||||
if (!counted) {
|
||||
incrementReceiveErrorCounter(ex);
|
||||
}
|
||||
interceptorList.afterReceiveCompletion(null, this, ex, interceptorStack);
|
||||
@@ -185,7 +136,6 @@ public abstract class AbstractPollableChannel extends AbstractMessageChannel
|
||||
if (metricsCaptor != null) {
|
||||
buildReceiveCounter(metricsCaptor, ex).increment();
|
||||
}
|
||||
getMetrics().afterError();
|
||||
}
|
||||
|
||||
private CounterFacade buildReceiveCounter(MetricsCaptor metricsCaptor, @Nullable Exception ex) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
* Copyright 2013-2020 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.
|
||||
@@ -25,9 +25,9 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.support.channel.HeaderChannelRegistry;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -48,7 +48,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
*/
|
||||
public class DefaultHeaderChannelRegistry extends IntegrationObjectSupport
|
||||
implements HeaderChannelRegistry, Lifecycle, Runnable {
|
||||
implements HeaderChannelRegistry, ManageableLifecycle, Runnable {
|
||||
|
||||
private static final int DEFAULT_REAPER_DELAY = 60000;
|
||||
|
||||
|
||||
@@ -24,15 +24,14 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.integration.IntegrationPattern;
|
||||
import org.springframework.integration.IntegrationPatternType;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.IntegrationManagement;
|
||||
import org.springframework.integration.support.management.metrics.CounterFacade;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.integration.support.management.metrics.TimerFacade;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.PollableChannel;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* A channel implementation that essentially behaves like "/dev/null".
|
||||
@@ -45,24 +44,13 @@ import org.springframework.util.Assert;
|
||||
* @author Artyem Bilan
|
||||
*/
|
||||
@IntegrationManagedResource
|
||||
@SuppressWarnings("deprecation")
|
||||
public class NullChannel implements PollableChannel,
|
||||
org.springframework.integration.support.management.MessageChannelMetrics,
|
||||
org.springframework.integration.support.management.ConfigurableMetricsAware<
|
||||
org.springframework.integration.support.management.AbstractMessageChannelMetrics>,
|
||||
BeanNameAware, NamedComponent, IntegrationPattern {
|
||||
BeanNameAware, IntegrationManagement, IntegrationPattern {
|
||||
|
||||
private final Log logger = LogFactory.getLog(getClass());
|
||||
|
||||
private final ManagementOverrides managementOverrides = new ManagementOverrides();
|
||||
|
||||
private org.springframework.integration.support.management.AbstractMessageChannelMetrics channelMetrics
|
||||
= new org.springframework.integration.support.management.DefaultMessageChannelMetrics("nullChannel");
|
||||
|
||||
private boolean countsEnabled;
|
||||
|
||||
private boolean statsEnabled;
|
||||
|
||||
private boolean loggingEnabled = true;
|
||||
|
||||
private String beanName;
|
||||
@@ -76,8 +64,6 @@ public class NullChannel implements PollableChannel,
|
||||
@Override
|
||||
public void setBeanName(String beanName) {
|
||||
this.beanName = beanName;
|
||||
this.channelMetrics =
|
||||
new org.springframework.integration.support.management.DefaultMessageChannelMetrics(this.beanName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -118,246 +104,6 @@ public class NullChannel implements PollableChannel,
|
||||
this.metricsCaptor = registry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void configureMetrics(
|
||||
org.springframework.integration.support.management.AbstractMessageChannelMetrics metrics) {
|
||||
|
||||
Assert.notNull(metrics, "'metrics' must not be null");
|
||||
this.channelMetrics = metrics;
|
||||
this.managementOverrides.metricsConfigured = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void reset() {
|
||||
this.channelMetrics.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @param countsEnabled the countsEnabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setCountsEnabled(boolean countsEnabled) {
|
||||
this.countsEnabled = countsEnabled;
|
||||
this.managementOverrides.countsConfigured = true;
|
||||
if (!countsEnabled) {
|
||||
this.statsEnabled = false;
|
||||
this.managementOverrides.statsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return counts enabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isCountsEnabled() {
|
||||
return this.countsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @param statsEnabled the statsEnabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setStatsEnabled(boolean statsEnabled) {
|
||||
if (statsEnabled) {
|
||||
this.countsEnabled = true;
|
||||
this.managementOverrides.countsConfigured = true;
|
||||
}
|
||||
this.statsEnabled = statsEnabled;
|
||||
this.channelMetrics.setFullStatsEnabled(statsEnabled);
|
||||
this.managementOverrides.statsConfigured = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return stats enabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isStatsEnabled() {
|
||||
return this.statsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return send count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getSendCount() {
|
||||
return this.channelMetrics.getSendCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return send count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getSendCountLong() {
|
||||
return this.channelMetrics.getSendCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getSendErrorCount() {
|
||||
return this.channelMetrics.getSendErrorCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getSendErrorCountLong() {
|
||||
return this.channelMetrics.getSendErrorCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return time since last send
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getTimeSinceLastSend() {
|
||||
return this.channelMetrics.getTimeSinceLastSend();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean send rate
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanSendRate() {
|
||||
return this.channelMetrics.getMeanSendRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean error rate
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanErrorRate() {
|
||||
return this.channelMetrics.getMeanErrorRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean error ratio
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanErrorRatio() {
|
||||
return this.channelMetrics.getMeanErrorRatio();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean send duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanSendDuration() {
|
||||
return this.channelMetrics.getMeanSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return min send duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMinSendDuration() {
|
||||
return this.channelMetrics.getMinSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return max send duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMaxSendDuration() {
|
||||
return this.channelMetrics.getMaxSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return standard deviation send duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getStandardDeviationSendDuration() {
|
||||
return this.channelMetrics.getStandardDeviationSendDuration();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return statistics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public org.springframework.integration.support.management.Statistics getSendDuration() {
|
||||
return this.channelMetrics.getSendDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return statistics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public org.springframework.integration.support.management.Statistics getSendRate() {
|
||||
return this.channelMetrics.getSendRate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return statistics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public org.springframework.integration.support.management.Statistics getErrorRate() {
|
||||
return this.channelMetrics.getErrorRate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagementOverrides getOverrides() {
|
||||
return this.managementOverrides;
|
||||
@@ -373,11 +119,8 @@ public class NullChannel implements PollableChannel,
|
||||
if (this.loggingEnabled && this.logger.isDebugEnabled()) {
|
||||
this.logger.debug("message sent to null channel: " + message);
|
||||
}
|
||||
if (this.countsEnabled) {
|
||||
if (this.metricsCaptor != null) {
|
||||
sendTimer().record(0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
this.channelMetrics.afterSend(this.channelMetrics.beforeSend(), true);
|
||||
if (this.metricsCaptor != null) {
|
||||
sendTimer().record(0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -44,8 +44,7 @@ import org.springframework.util.Assert;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class QueueChannel extends AbstractPollableChannel implements QueueChannelOperations,
|
||||
org.springframework.integration.support.management.QueueChannelManagement {
|
||||
public class QueueChannel extends AbstractPollableChannel implements QueueChannelOperations {
|
||||
|
||||
private final Queue<Message<?>> queue;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.channel;
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
@@ -50,12 +51,14 @@ public interface QueueChannelOperations {
|
||||
* Obtain the current number of queued {@link Message Messages} in this channel.
|
||||
* @return The current number of queued {@link Message Messages} in this channel.
|
||||
*/
|
||||
@ManagedAttribute(description = "Queue size")
|
||||
int getQueueSize();
|
||||
|
||||
/**
|
||||
* Obtain the remaining capacity of this channel.
|
||||
* @return The remaining capacity of this channel.
|
||||
*/
|
||||
@ManagedAttribute(description = "Queue remaining capacity")
|
||||
int getRemainingCapacity();
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.support.channel.ChannelResolverUtils;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
import org.springframework.jmx.export.annotation.ManagedResource;
|
||||
@@ -43,7 +43,7 @@ import org.springframework.util.Assert;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@ManagedResource
|
||||
public class WireTap implements ChannelInterceptor, Lifecycle, VetoCapableInterceptor, BeanFactoryAware {
|
||||
public class WireTap implements ChannelInterceptor, ManageableLifecycle, VetoCapableInterceptor, BeanFactoryAware {
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(WireTap.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2019 the original author or authors.
|
||||
* Copyright 2014-2020 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,6 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.core.annotation.AliasFor;
|
||||
|
||||
/**
|
||||
* Enables default configuring of management in Spring Integration components in an existing application.
|
||||
@@ -41,83 +40,6 @@ import org.springframework.core.annotation.AliasFor;
|
||||
@Import(IntegrationManagementConfiguration.class)
|
||||
public @interface EnableIntegrationManagement {
|
||||
|
||||
/**
|
||||
* A list of simple patterns for component names for which message counts will be
|
||||
* enabled (defaults to '*'). Enables message
|
||||
* counting (`sendCount`, `errorCount`, `receiveCount`) for those components that
|
||||
* support counters (channels, message handlers, etc). This is the initial setting
|
||||
* only, individual components can have counts enabled/disabled at runtime. May be
|
||||
* overridden by an entry in {@link #statsEnabled() statsEnabled} which is additional
|
||||
* functionality over simple counts. If a pattern starts with `!`, counts are disabled
|
||||
* for matches. For components that match multiple patterns, the first pattern wins.
|
||||
* Disabling counts at runtime also disables stats.
|
||||
* Defaults to no components, unless JMX is enabled in which case, defaults to all
|
||||
* components. Overrides {@link #defaultCountsEnabled()} for matching bean names.
|
||||
* @return the patterns.
|
||||
* @deprecated in favor of 'metersEnabled'.
|
||||
*/
|
||||
@Deprecated
|
||||
@AliasFor("metersEnabled")
|
||||
String[] countsEnabled() default "*";
|
||||
|
||||
/**
|
||||
* A list of simple patterns for component names for which message counts will be
|
||||
* enabled (defaults to '*'). Enables message
|
||||
* counting (`sendCount`, `errorCount`, `receiveCount`) for those components that
|
||||
* support counters (channels, message handlers, etc). This is the initial setting
|
||||
* only, individual components can have counts enabled/disabled at runtime. May be
|
||||
* overridden by an entry in {@link #statsEnabled() statsEnabled} which is additional
|
||||
* functionality over simple counts. If a pattern starts with `!`, counts are disabled
|
||||
* for matches. For components that match multiple patterns, the first pattern wins.
|
||||
* Disabling counts at runtime also disables stats.
|
||||
* Defaults to no components, unless JMX is enabled in which case, defaults to all
|
||||
* components. Overrides {@link #defaultCountsEnabled()} for matching bean names.
|
||||
* @return the patterns.
|
||||
*/
|
||||
@AliasFor("countsEnabled")
|
||||
String[] metersEnabled() default "*";
|
||||
|
||||
/**
|
||||
* A list of simple patterns for component names for which message statistics will be
|
||||
* enabled (response times, rates etc), as well as counts (a positive match here
|
||||
* overrides {@link #countsEnabled() countsEnabled}, you can't have statistics without
|
||||
* counts). (defaults to '*'). Enables
|
||||
* statistics for those components that support statistics (channels - when sending,
|
||||
* message handlers, etc). This is the initial setting only, individual components can
|
||||
* have stats enabled/disabled at runtime. If a pattern starts with `!`, stats (and
|
||||
* counts) are disabled for matches. Note: this means that '!foo' here will disable
|
||||
* stats and counts for 'foo' even if counts are enabled for 'foo' in
|
||||
* {@link #countsEnabled() countsEnabled}. For components
|
||||
* that match multiple patterns, the first pattern wins. Enabling stats at runtime
|
||||
* also enables counts.
|
||||
* Defaults to no components, unless JMX is enabled in which case, defaults to all
|
||||
* components.
|
||||
* @return the patterns.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
String[] statsEnabled() default "*";
|
||||
|
||||
/**
|
||||
* The default setting for enabling counts when a bean name is not matched by
|
||||
* {@link #countsEnabled() countsEnabled}.
|
||||
* @return the value; false by default, or true when JMX is enabled.
|
||||
*/
|
||||
String defaultCountsEnabled() default "false";
|
||||
|
||||
/**
|
||||
* The default setting for enabling statistics when a bean name is not matched by
|
||||
* {@link #statsEnabled() statsEnabled}.
|
||||
* @return the value; false by default, or true when JMX is enabled.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
String defaultStatsEnabled() default "false";
|
||||
|
||||
/**
|
||||
* Use to disable all logging in the main message flow in framework components. When 'false', such logging will be
|
||||
* skipped, regardless of logging level. When 'true', the logging is controlled as normal by the logging
|
||||
@@ -138,15 +60,4 @@ public @interface EnableIntegrationManagement {
|
||||
*/
|
||||
String defaultLoggingEnabled() default "true";
|
||||
|
||||
/**
|
||||
* The bean name of a {@code MetricsFactory}. The {@code DefaultMetricsFactory} is used
|
||||
* if omitted.
|
||||
* @return the bean name.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
String metricsFactory() default "";
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2020 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,9 +16,6 @@
|
||||
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.beans.factory.config.BeanDefinition;
|
||||
@@ -31,7 +28,6 @@ import org.springframework.core.annotation.AnnotationAttributes;
|
||||
import org.springframework.core.env.Environment;
|
||||
import org.springframework.core.type.AnnotationMetadata;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
* {@code @Configuration} class that registers a {@link IntegrationManagementConfigurer} bean.
|
||||
@@ -64,45 +60,14 @@ public class IntegrationManagementConfiguration implements ImportAware, Environm
|
||||
"@EnableIntegrationManagement is not present on importing class " + importMetadata.getClassName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Bean(name = IntegrationManagementConfigurer.MANAGEMENT_CONFIGURER_NAME)
|
||||
@Role(BeanDefinition.ROLE_INFRASTRUCTURE)
|
||||
public IntegrationManagementConfigurer managementConfigurer() {
|
||||
IntegrationManagementConfigurer configurer = new IntegrationManagementConfigurer();
|
||||
setupCountsEnabledNamePatterns(configurer);
|
||||
setupStatsEnabledNamePatterns(configurer);
|
||||
configurer.setDefaultLoggingEnabled(
|
||||
Boolean.parseBoolean(this.environment.resolvePlaceholders(
|
||||
(String) this.attributes.get("defaultLoggingEnabled"))));
|
||||
configurer.setDefaultCountsEnabled(
|
||||
Boolean.parseBoolean(this.environment.resolvePlaceholders(
|
||||
(String) this.attributes.get("defaultCountsEnabled"))));
|
||||
configurer.setDefaultStatsEnabled(
|
||||
Boolean.parseBoolean(this.environment.resolvePlaceholders(
|
||||
(String) this.attributes.get("defaultStatsEnabled"))));
|
||||
configurer.setMetricsFactoryBeanName((String) this.attributes.get("metricsFactory"));
|
||||
return configurer;
|
||||
}
|
||||
|
||||
private void setupCountsEnabledNamePatterns(IntegrationManagementConfigurer configurer) {
|
||||
List<String> patterns = new ArrayList<>();
|
||||
String[] countsEnabled = this.attributes.getStringArray("countsEnabled");
|
||||
for (String managedComponent : countsEnabled) {
|
||||
String pattern = this.environment.resolvePlaceholders(managedComponent);
|
||||
patterns.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(pattern)));
|
||||
}
|
||||
configurer.setEnabledCountsPatterns(patterns.toArray(new String[0]));
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private void setupStatsEnabledNamePatterns(IntegrationManagementConfigurer configurer) {
|
||||
List<String> patterns = new ArrayList<>();
|
||||
String[] statsEnabled = this.attributes.getStringArray("statsEnabled");
|
||||
for (String managedComponent : statsEnabled) {
|
||||
String pattern = this.environment.resolvePlaceholders(managedComponent);
|
||||
patterns.addAll(Arrays.asList(StringUtils.commaDelimitedListToStringArray(pattern)));
|
||||
}
|
||||
configurer.setEnabledStatsPatterns(patterns.toArray(new String[0]));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,18 +16,15 @@
|
||||
|
||||
package org.springframework.integration.config;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanNameAware;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.context.ApplicationContextAware;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
@@ -35,12 +32,10 @@ import org.springframework.integration.support.management.IntegrationManagement;
|
||||
import org.springframework.integration.support.management.IntegrationManagement.ManagementOverrides;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.integration.support.management.micrometer.MicrometerMetricsCaptor;
|
||||
import org.springframework.integration.support.utils.PatternMatchUtils;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ClassUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
|
||||
/**
|
||||
@@ -55,46 +50,20 @@ import org.springframework.util.StringUtils;
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class IntegrationManagementConfigurer
|
||||
implements SmartInitializingSingleton, ApplicationContextAware, BeanNameAware,
|
||||
DestructionAwareBeanPostProcessor {
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(IntegrationManagementConfigurer.class);
|
||||
implements SmartInitializingSingleton, ApplicationContextAware, BeanNameAware, BeanPostProcessor {
|
||||
|
||||
/**
|
||||
* Bean name of tehe configurer.
|
||||
*/
|
||||
public static final String MANAGEMENT_CONFIGURER_NAME = "integrationManagementConfigurer";
|
||||
|
||||
private final Map<String, org.springframework.integration.support.management.MessageChannelMetrics>
|
||||
channelsByName = new HashMap<>();
|
||||
|
||||
private final Map<String, org.springframework.integration.support.management.MessageHandlerMetrics>
|
||||
handlersByName = new HashMap<>();
|
||||
|
||||
private final Map<String, org.springframework.integration.support.management.MessageSourceMetrics>
|
||||
sourcesByName = new HashMap<>();
|
||||
|
||||
private final Map<String,
|
||||
org.springframework.integration.support.management.MessageSourceMetricsConfigurer>
|
||||
sourceConfigurers = new HashMap<>();
|
||||
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
private String beanName;
|
||||
|
||||
private boolean defaultLoggingEnabled = true;
|
||||
|
||||
private Boolean defaultCountsEnabled = false;
|
||||
|
||||
private Boolean defaultStatsEnabled = false;
|
||||
|
||||
private org.springframework.integration.support.management.MetricsFactory metricsFactory;
|
||||
|
||||
private String metricsFactoryBeanName;
|
||||
|
||||
private String[] enabledCountsPatterns = { };
|
||||
|
||||
private String[] enabledStatsPatterns = { };
|
||||
|
||||
private volatile boolean singletonsInstantiated;
|
||||
|
||||
private MetricsCaptor metricsCaptor;
|
||||
@@ -109,115 +78,6 @@ public class IntegrationManagementConfigurer
|
||||
this.beanName = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a metrics factory.
|
||||
* Has a precedence over {@link #metricsFactoryBeanName}.
|
||||
* Defaults to {@link org.springframework.integration.support.management.DefaultMetricsFactory}.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @param metricsFactory the factory.
|
||||
* @since 4.2
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMetricsFactory(org.springframework.integration.support.management.MetricsFactory metricsFactory) {
|
||||
this.metricsFactory = metricsFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set a metrics factory bean name.
|
||||
* Is used if {@link #metricsFactory} isn't specified.
|
||||
* @param metricsFactory the factory.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @since 4.2
|
||||
*/
|
||||
@Deprecated
|
||||
public void setMetricsFactoryBeanName(String metricsFactory) {
|
||||
this.metricsFactoryBeanName = metricsFactory;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the array of simple patterns for component names for which message counts will
|
||||
* be enabled (defaults to '*').
|
||||
* Enables message counting (`sendCount`, `errorCount`, `receiveCount`)
|
||||
* for those components that support counters (channels, message handlers, etc).
|
||||
* This is the initial setting only, individual components can have counts
|
||||
* enabled/disabled at runtime. May be overridden by an entry in
|
||||
* {@link #setEnabledStatsPatterns(String[]) enabledStatsPatterns} which is additional
|
||||
* functionality over simple counts. If a pattern starts with `!`, counts are disabled
|
||||
* for matches. For components that match multiple patterns, the first pattern wins.
|
||||
* Disabling counts at runtime also disables stats.
|
||||
* @param enabledCountsPatterns the patterns.
|
||||
*/
|
||||
public void setEnabledCountsPatterns(String[] enabledCountsPatterns) {
|
||||
Assert.notEmpty(enabledCountsPatterns, "enabledCountsPatterns must not be empty");
|
||||
this.enabledCountsPatterns = Arrays.copyOf(enabledCountsPatterns, enabledCountsPatterns.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the array of simple patterns for component names for which message statistics
|
||||
* will be enabled (response times, rates etc), as well as counts (a positive match
|
||||
* here overrides {@link #setEnabledCountsPatterns(String[]) enabledCountsPatterns},
|
||||
* you can't have statistics without counts). (defaults to '*').
|
||||
* Enables statistics for those components that support statistics
|
||||
* (channels - when sending, message handlers, etc). This is the initial setting only,
|
||||
* individual components can have stats enabled/disabled at runtime. If a pattern
|
||||
* starts with `!`, stats (and counts) are disabled for matches. Note: this means that
|
||||
* '!foo' here will disable stats and counts for 'foo' even if counts are enabled for
|
||||
* 'foo' in {@link #setEnabledCountsPatterns(String[]) enabledCountsPatterns}. For
|
||||
* components that match multiple patterns, the first pattern wins. Enabling stats at
|
||||
* runtime also enables counts.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @param enabledStatsPatterns the patterns.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setEnabledStatsPatterns(String[] enabledStatsPatterns) {
|
||||
Assert.notEmpty(enabledStatsPatterns, "enabledStatsPatterns must not be empty");
|
||||
this.enabledStatsPatterns = Arrays.copyOf(enabledStatsPatterns, enabledStatsPatterns.length);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether managed components maintain message counts by default.
|
||||
* Defaults to false, unless an Integration MBean Exporter is configured.
|
||||
* @param defaultCountsEnabled true to enable.
|
||||
*/
|
||||
public void setDefaultCountsEnabled(Boolean defaultCountsEnabled) {
|
||||
this.defaultCountsEnabled = defaultCountsEnabled;
|
||||
}
|
||||
|
||||
public Boolean getDefaultCountsEnabled() {
|
||||
return this.defaultCountsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set whether managed components maintain message statistics by default.
|
||||
* Defaults to false, unless an Integration MBean Exporter is configured.
|
||||
* @param defaultStatsEnabled true to enable.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setDefaultStatsEnabled(Boolean defaultStatsEnabled) {
|
||||
this.defaultStatsEnabled = defaultStatsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if stats are enabled by default.
|
||||
* @return the stats enabled.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*/
|
||||
@Deprecated
|
||||
public Boolean getDefaultStatsEnabled() {
|
||||
return this.defaultStatsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable all logging in the normal message flow in framework components. When 'false', such logging will be
|
||||
* skipped, regardless of logging level. When 'true', the logging is controlled as normal by the logging
|
||||
@@ -254,23 +114,6 @@ public class IntegrationManagementConfigurer
|
||||
injectCaptor();
|
||||
registerComponentGauges();
|
||||
}
|
||||
if (this.metricsFactory == null && StringUtils.hasText(this.metricsFactoryBeanName)) {
|
||||
this.metricsFactory = this.applicationContext.getBean(this.metricsFactoryBeanName,
|
||||
org.springframework.integration.support.management.MetricsFactory.class);
|
||||
}
|
||||
if (this.metricsFactory == null) {
|
||||
Map<String, org.springframework.integration.support.management.MetricsFactory>
|
||||
factories = this.applicationContext
|
||||
.getBeansOfType(org.springframework.integration.support.management.MetricsFactory.class);
|
||||
if (factories.size() == 1) {
|
||||
this.metricsFactory = factories.values().iterator().next();
|
||||
}
|
||||
}
|
||||
if (this.metricsFactory == null) {
|
||||
this.metricsFactory = new org.springframework.integration.support.management.DefaultMetricsFactory();
|
||||
}
|
||||
this.sourceConfigurers.putAll(this.applicationContext.getBeansOfType(
|
||||
org.springframework.integration.support.management.MessageSourceMetricsConfigurer.class));
|
||||
Map<String, IntegrationManagement> managed = this.applicationContext
|
||||
.getBeansOfType(IntegrationManagement.class);
|
||||
for (Entry<String, IntegrationManagement> entry : managed.entrySet()) {
|
||||
@@ -279,7 +122,6 @@ public class IntegrationManagementConfigurer
|
||||
bean.setLoggingEnabled(this.defaultLoggingEnabled);
|
||||
}
|
||||
String name = entry.getKey();
|
||||
doConfigureMetrics(bean, name);
|
||||
}
|
||||
this.singletonsInstantiated = true;
|
||||
}
|
||||
@@ -302,147 +144,10 @@ public class IntegrationManagementConfigurer
|
||||
if (this.metricsCaptor != null && bean instanceof IntegrationManagement) {
|
||||
((IntegrationManagement) bean).registerMetricsCaptor(this.metricsCaptor);
|
||||
}
|
||||
return doConfigureMetrics(bean, name);
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requiresDestruction(Object bean) {
|
||||
return bean instanceof org.springframework.integration.support.management.MessageChannelMetrics ||
|
||||
bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics ||
|
||||
bean instanceof org.springframework.integration.support.management.MessageSourceMetrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void postProcessBeforeDestruction(Object bean, String nameOfBean) throws BeansException {
|
||||
if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) {
|
||||
this.channelsByName.remove(nameOfBean);
|
||||
}
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) {
|
||||
if (this.handlersByName.remove(nameOfBean) == null) {
|
||||
this.handlersByName.remove(nameOfBean + ".handler");
|
||||
}
|
||||
}
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics &&
|
||||
this.sourcesByName.remove(nameOfBean) == null) {
|
||||
|
||||
this.sourcesByName.remove(nameOfBean + ".source");
|
||||
}
|
||||
}
|
||||
|
||||
private Object doConfigureMetrics(Object bean, String name) {
|
||||
if (bean instanceof org.springframework.integration.support.management.MessageChannelMetrics) {
|
||||
configureChannelMetrics(name,
|
||||
(org.springframework.integration.support.management.MessageChannelMetrics) bean);
|
||||
}
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageHandlerMetrics) {
|
||||
configureHandlerMetrics(name,
|
||||
(org.springframework.integration.support.management.MessageHandlerMetrics) bean);
|
||||
}
|
||||
else if (bean instanceof org.springframework.integration.support.management.MessageSourceMetrics) {
|
||||
configureSourceMetrics(name,
|
||||
(org.springframework.integration.support.management.MessageSourceMetrics) bean);
|
||||
this.sourceConfigurers.values().forEach(c -> c
|
||||
.configure((org.springframework.integration.support.management.MessageSourceMetrics) bean, name));
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void configureChannelMetrics(String name,
|
||||
org.springframework.integration.support.management.MessageChannelMetrics bean) {
|
||||
|
||||
org.springframework.integration.support.management.AbstractMessageChannelMetrics metrics;
|
||||
if (bean instanceof org.springframework.integration.support.management.PollableChannelManagement) {
|
||||
metrics = this.metricsFactory.createPollableChannelMetrics(name);
|
||||
}
|
||||
else {
|
||||
metrics = this.metricsFactory.createChannelMetrics(name);
|
||||
}
|
||||
Assert.state(metrics != null, "'metrics' must not be null");
|
||||
ManagementOverrides overrides = getOverrides(bean);
|
||||
Boolean enabled = PatternMatchUtils.smartMatch(name, this.enabledCountsPatterns);
|
||||
if (enabled != null) {
|
||||
bean.setCountsEnabled(enabled);
|
||||
}
|
||||
else {
|
||||
if (!overrides.countsConfigured) {
|
||||
bean.setCountsEnabled(this.defaultCountsEnabled);
|
||||
}
|
||||
}
|
||||
enabled = PatternMatchUtils.smartMatch(name, this.enabledStatsPatterns);
|
||||
if (enabled != null) {
|
||||
bean.setStatsEnabled(enabled);
|
||||
metrics.setFullStatsEnabled(enabled);
|
||||
}
|
||||
else {
|
||||
if (!overrides.statsConfigured) {
|
||||
bean.setStatsEnabled(this.defaultStatsEnabled);
|
||||
metrics.setFullStatsEnabled(this.defaultStatsEnabled);
|
||||
}
|
||||
}
|
||||
if (bean instanceof org.springframework.integration.support.management.ConfigurableMetricsAware
|
||||
&& !overrides.metricsConfigured) {
|
||||
((org.springframework.integration.support.management.ConfigurableMetricsAware<
|
||||
org.springframework.integration.support.management.AbstractMessageChannelMetrics>) bean)
|
||||
.configureMetrics(metrics);
|
||||
}
|
||||
this.channelsByName.put(name, bean);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private void configureHandlerMetrics(String name,
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics bean) {
|
||||
org.springframework.integration.support.management.AbstractMessageHandlerMetrics metrics
|
||||
= this.metricsFactory.createHandlerMetrics(name);
|
||||
Assert.state(metrics != null, "'metrics' must not be null");
|
||||
ManagementOverrides overrides = getOverrides(bean);
|
||||
Boolean enabled = PatternMatchUtils.smartMatch(name, this.enabledCountsPatterns);
|
||||
if (enabled != null) {
|
||||
bean.setCountsEnabled(enabled);
|
||||
}
|
||||
else {
|
||||
if (!overrides.countsConfigured) {
|
||||
bean.setCountsEnabled(this.defaultCountsEnabled);
|
||||
}
|
||||
}
|
||||
enabled = PatternMatchUtils.smartMatch(name, this.enabledStatsPatterns);
|
||||
if (enabled != null) {
|
||||
bean.setStatsEnabled(enabled);
|
||||
metrics.setFullStatsEnabled(enabled);
|
||||
}
|
||||
else {
|
||||
if (!overrides.statsConfigured) {
|
||||
bean.setStatsEnabled(this.defaultStatsEnabled);
|
||||
metrics.setFullStatsEnabled(this.defaultStatsEnabled);
|
||||
}
|
||||
}
|
||||
if (bean instanceof org.springframework.integration.support.management.ConfigurableMetricsAware
|
||||
&& !overrides.metricsConfigured) {
|
||||
((org.springframework.integration.support.management.ConfigurableMetricsAware<
|
||||
org.springframework.integration.support.management.AbstractMessageHandlerMetrics>) bean)
|
||||
.configureMetrics(metrics);
|
||||
}
|
||||
|
||||
this.handlersByName.put(bean.getManagedName() != null ? bean.getManagedName() : name, bean);
|
||||
}
|
||||
|
||||
private void configureSourceMetrics(String name,
|
||||
org.springframework.integration.support.management.MessageSourceMetrics bean) {
|
||||
|
||||
Boolean enabled = PatternMatchUtils.smartMatch(name, this.enabledCountsPatterns);
|
||||
if (enabled != null) {
|
||||
bean.setCountsEnabled(enabled);
|
||||
}
|
||||
else {
|
||||
if (!getOverrides(bean).countsConfigured) {
|
||||
bean.setCountsEnabled(this.defaultCountsEnabled);
|
||||
}
|
||||
}
|
||||
this.sourcesByName.put(bean.getManagedName() != null ? bean.getManagedName() : name, bean);
|
||||
}
|
||||
|
||||
private void registerComponentGauges() {
|
||||
this.metricsCaptor.gaugeBuilder("spring.integration.channels", this,
|
||||
(c) -> this.applicationContext.getBeansOfType(MessageChannel.class).size())
|
||||
@@ -460,56 +165,6 @@ public class IntegrationManagementConfigurer
|
||||
.build();
|
||||
}
|
||||
|
||||
public String[] getChannelNames() {
|
||||
return this.channelsByName.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String[] getHandlerNames() {
|
||||
return this.handlersByName.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public String[] getSourceNames() {
|
||||
return this.sourcesByName.keySet().toArray(new String[0]);
|
||||
}
|
||||
|
||||
public org.springframework.integration.support.management.MessageChannelMetrics getChannelMetrics(String name) {
|
||||
if (this.channelsByName.containsKey(name)) {
|
||||
return this.channelsByName.get(name);
|
||||
}
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No channel found for (" + name + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public org.springframework.integration.support.management.MessageHandlerMetrics getHandlerMetrics(String name) {
|
||||
if (this.handlersByName.containsKey(name)) {
|
||||
return this.handlersByName.get(name);
|
||||
}
|
||||
if (this.handlersByName.containsKey(name + ".handler")) {
|
||||
return this.handlersByName.get(name + ".handler");
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No handler found for (" + name + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public org.springframework.integration.support.management.MessageSourceMetrics getSourceMetrics(String name) {
|
||||
if (this.sourcesByName.containsKey(name)) {
|
||||
return this.sourcesByName.get(name);
|
||||
}
|
||||
if (this.sourcesByName.containsKey(name + ".source")) {
|
||||
return this.sourcesByName.get(name + ".source");
|
||||
}
|
||||
|
||||
if (LOGGER.isDebugEnabled()) {
|
||||
LOGGER.debug("No source found for (" + name + ")");
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private static ManagementOverrides getOverrides(IntegrationManagement bean) {
|
||||
return bean.getOverrides() != null ? bean.getOverrides() : new ManagementOverrides();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2019 the original author or authors.
|
||||
* Copyright 2015-2020 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.
|
||||
@@ -46,13 +46,6 @@ public class IntegrationManagementParser extends AbstractBeanDefinitionParser {
|
||||
BeanDefinitionBuilder builder =
|
||||
BeanDefinitionBuilder.genericBeanDefinition(IntegrationManagementConfigurer.class);
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-logging-enabled");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-counts-enabled");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "default-stats-enabled");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "counts-enabled-patterns",
|
||||
"enabledCountsPatterns");
|
||||
IntegrationNamespaceUtils.setValueIfAttributeDefined(builder, element, "stats-enabled-patterns",
|
||||
"enabledStatsPatterns");
|
||||
IntegrationNamespaceUtils.setReferenceIfAttributeDefined(builder, element, "metrics-factory");
|
||||
return builder.getBeanDefinition();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2018-2019 the original author or authors.
|
||||
* Copyright 2018-2020 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,7 +16,8 @@
|
||||
|
||||
package org.springframework.integration.core;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
|
||||
/**
|
||||
* Endpoints implementing this interface can be paused/resumed. A paused endpoint might
|
||||
@@ -27,16 +28,18 @@ import org.springframework.context.Lifecycle;
|
||||
* @since 5.0.3
|
||||
*
|
||||
*/
|
||||
public interface Pausable extends Lifecycle {
|
||||
public interface Pausable extends ManageableLifecycle {
|
||||
|
||||
/**
|
||||
* Pause the endpoint.
|
||||
*/
|
||||
@ManagedOperation(description = "Pause the component")
|
||||
void pause();
|
||||
|
||||
/**
|
||||
* Resume the endpoint if paused.
|
||||
*/
|
||||
@ManagedOperation(description = "Resume the component")
|
||||
void resume();
|
||||
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.util.function.Supplier;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.support.management.ManageableSmartLifecycle;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -58,7 +58,7 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
public abstract class IntegrationFlowAdapter implements IntegrationFlow, SmartLifecycle {
|
||||
public abstract class IntegrationFlowAdapter implements IntegrationFlow, ManageableSmartLifecycle {
|
||||
|
||||
private final AtomicBoolean running = new AtomicBoolean();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.support.management.ManageableSmartLifecycle;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
/**
|
||||
@@ -65,7 +66,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
* @see org.springframework.integration.dsl.context.IntegrationFlowContext
|
||||
* @see SmartLifecycle
|
||||
*/
|
||||
public class StandardIntegrationFlow implements IntegrationFlow, SmartLifecycle {
|
||||
public class StandardIntegrationFlow implements IntegrationFlow, ManageableSmartLifecycle {
|
||||
|
||||
private final Map<Object, String> integrationComponents;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -26,6 +26,8 @@ import org.springframework.integration.context.IntegrationContextUtils;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.context.IntegrationProperties;
|
||||
import org.springframework.integration.support.SmartLifecycleRoleController;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.ManageableSmartLifecycle;
|
||||
import org.springframework.util.PatternMatchUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
@@ -44,8 +46,9 @@ import org.springframework.util.StringUtils;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@IntegrationManagedResource
|
||||
public abstract class AbstractEndpoint extends IntegrationObjectSupport
|
||||
implements SmartLifecycle, DisposableBean {
|
||||
implements ManageableSmartLifecycle, DisposableBean {
|
||||
|
||||
private boolean autoStartupSetExplicitly;
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.springframework.integration.core.MessageSource;
|
||||
import org.springframework.integration.expression.ExpressionEvalMap;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.integration.support.management.IntegrationInboundManagement;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.metrics.CounterFacade;
|
||||
import org.springframework.integration.support.management.metrics.MeterFacade;
|
||||
@@ -38,6 +39,10 @@ import org.springframework.messaging.Message;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
/**
|
||||
* Abstract message source.
|
||||
*
|
||||
* @param <T> The payload type.
|
||||
*
|
||||
* @author Mark Fisher
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gary Russell
|
||||
@@ -45,11 +50,9 @@ import org.springframework.util.CollectionUtils;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluator
|
||||
implements MessageSource<T>, org.springframework.integration.support.management.MessageSourceMetrics,
|
||||
NamedComponent, BeanNameAware {
|
||||
implements MessageSource<T>, IntegrationInboundManagement, NamedComponent, BeanNameAware {
|
||||
|
||||
private final AtomicLong messageCount = new AtomicLong();
|
||||
|
||||
@@ -65,8 +68,6 @@ public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluat
|
||||
|
||||
private String managedName;
|
||||
|
||||
private boolean countsEnabled;
|
||||
|
||||
private boolean loggingEnabled = true;
|
||||
|
||||
private MetricsCaptor metricsCaptor;
|
||||
@@ -119,17 +120,6 @@ public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluat
|
||||
return this.beanName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCountsEnabled() {
|
||||
return this.countsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountsEnabled(boolean countsEnabled) {
|
||||
this.countsEnabled = countsEnabled;
|
||||
this.managementOverrides.countsConfigured = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoggingEnabled() {
|
||||
return this.loggingEnabled;
|
||||
@@ -141,38 +131,6 @@ public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluat
|
||||
this.managementOverrides.loggingConfigured = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void reset() {
|
||||
this.messageCount.set(0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getMessageCount() {
|
||||
return (int) this.messageCount.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getMessageCountLong() {
|
||||
return this.messageCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagementOverrides getOverrides() {
|
||||
return this.managementOverrides;
|
||||
@@ -222,12 +180,10 @@ public abstract class AbstractMessageSource<T> extends AbstractExpressionEvaluat
|
||||
.copyHeaders(headers)
|
||||
.build();
|
||||
}
|
||||
if (this.countsEnabled) {
|
||||
if (this.metricsCaptor != null) {
|
||||
incrementReceiveCounter();
|
||||
}
|
||||
this.messageCount.incrementAndGet();
|
||||
if (this.metricsCaptor != null) {
|
||||
incrementReceiveCounter();
|
||||
}
|
||||
this.messageCount.incrementAndGet();
|
||||
return (Message<T>) message;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.endpoint;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
@@ -31,7 +32,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MethodInvokingMessageSource extends AbstractMessageSource<Object> implements Lifecycle {
|
||||
public class MethodInvokingMessageSource extends AbstractMessageSource<Object> implements ManageableLifecycle {
|
||||
|
||||
private volatile Object object;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,6 +24,7 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.handler.AbstractMessageProcessor;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -35,7 +36,7 @@ import org.springframework.util.Assert;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class AbstractMessageProcessingSelector
|
||||
implements MessageSelector, BeanFactoryAware, Lifecycle {
|
||||
implements MessageSelector, BeanFactoryAware, ManageableLifecycle {
|
||||
|
||||
private final MessageProcessor<Boolean> messageProcessor;
|
||||
|
||||
@@ -52,12 +53,14 @@ public abstract class AbstractMessageProcessingSelector
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
|
||||
if (this.messageProcessor instanceof BeanFactoryAware) {
|
||||
((BeanFactoryAware) this.messageProcessor).setBeanFactory(beanFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean accept(Message<?> message) {
|
||||
Object result = this.messageProcessor.processMessage(message);
|
||||
Assert.notNull(result, "result must not be null");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -25,6 +25,7 @@ import org.springframework.integration.MessageRejectedException;
|
||||
import org.springframework.integration.core.MessageSelector;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingPostProcessingMessageHandler;
|
||||
import org.springframework.integration.handler.DiscardingMessageHandler;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -45,7 +46,7 @@ import org.springframework.util.Assert;
|
||||
* @author David Liu
|
||||
*/
|
||||
public class MessageFilter extends AbstractReplyProducingPostProcessingMessageHandler
|
||||
implements DiscardingMessageHandler, Lifecycle {
|
||||
implements DiscardingMessageHandler, ManageableLifecycle {
|
||||
|
||||
private final MessageSelector selector;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -19,8 +19,8 @@ package org.springframework.integration.gateway;
|
||||
import org.springframework.beans.factory.BeanCreationException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
|
||||
@@ -31,7 +31,7 @@ import org.springframework.messaging.MessageChannel;
|
||||
*
|
||||
* @since 5.0
|
||||
*/
|
||||
public class GatewayMessageHandler extends AbstractReplyProducingMessageHandler implements Lifecycle {
|
||||
public class GatewayMessageHandler extends AbstractReplyProducingMessageHandler implements ManageableLifecycle {
|
||||
|
||||
private final GatewayProxyFactoryBean gatewayProxyFactoryBean;
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package org.springframework.integration.gateway;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import org.reactivestreams.Publisher;
|
||||
import org.reactivestreams.Subscriber;
|
||||
@@ -46,6 +45,7 @@ import org.springframework.integration.support.ErrorMessageUtils;
|
||||
import org.springframework.integration.support.MessageBuilderFactory;
|
||||
import org.springframework.integration.support.MutableMessageBuilder;
|
||||
import org.springframework.integration.support.converter.SimpleMessageConverter;
|
||||
import org.springframework.integration.support.management.IntegrationInboundManagement;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -77,7 +77,7 @@ import reactor.core.publisher.MonoProcessor;
|
||||
@IntegrationManagedResource
|
||||
public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
implements org.springframework.integration.support.management.TrackableComponent,
|
||||
org.springframework.integration.support.management.MessageSourceMetrics, IntegrationPattern {
|
||||
IntegrationInboundManagement, IntegrationPattern {
|
||||
|
||||
private static final long DEFAULT_TIMEOUT = 1000L;
|
||||
|
||||
@@ -92,8 +92,6 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
|
||||
private boolean errorOnTimeout;
|
||||
|
||||
private final AtomicLong messageCount = new AtomicLong();
|
||||
|
||||
private final ManagementOverrides managementOverrides = new ManagementOverrides();
|
||||
|
||||
private ErrorMessageStrategy errorMessageStrategy = new DefaultErrorMessageStrategy();
|
||||
@@ -114,14 +112,12 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
|
||||
private InboundMessageMapper<Object> requestMapper = new DefaultRequestMapper();
|
||||
|
||||
private boolean loggingEnabled = true;
|
||||
|
||||
private String managedType;
|
||||
|
||||
private String managedName;
|
||||
|
||||
private boolean countsEnabled;
|
||||
|
||||
private boolean loggingEnabled = true;
|
||||
|
||||
private volatile AbstractEndpoint replyMessageCorrelator;
|
||||
|
||||
private volatile boolean initialized;
|
||||
@@ -274,36 +270,6 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
this.historyWritingPostProcessor.setShouldTrack(shouldTrack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMessageCount() {
|
||||
return (int) this.messageCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessageCountLong() {
|
||||
return this.messageCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedName(String name) {
|
||||
this.managedName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagedName() {
|
||||
return this.managedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedType(String type) {
|
||||
this.managedType = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagedType() {
|
||||
return this.managedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return "gateway";
|
||||
@@ -320,17 +286,6 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
return this.loggingEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountsEnabled(boolean countsEnabled) {
|
||||
this.countsEnabled = countsEnabled;
|
||||
this.managementOverrides.countsConfigured = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCountsEnabled() {
|
||||
return this.countsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set an {@link ErrorMessageStrategy} to use to build an error message when a exception occurs.
|
||||
* Default is the {@link DefaultErrorMessageStrategy}.
|
||||
@@ -347,6 +302,26 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
return this.managementOverrides;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedType(String managedType) {
|
||||
this.managedType = managedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagedType() {
|
||||
return this.managedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedName(String managedName) {
|
||||
this.managedName = managedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagedName() {
|
||||
return this.managedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IntegrationPatternType getIntegrationPatternType() {
|
||||
return IntegrationPatternType.inbound_gateway;
|
||||
@@ -430,9 +405,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
Assert.state(channel != null,
|
||||
"send is not supported, because no request channel has been configured");
|
||||
try {
|
||||
if (this.countsEnabled) {
|
||||
this.messageCount.incrementAndGet();
|
||||
}
|
||||
// TODO Micrometer counter
|
||||
this.messagingTemplate.convertAndSend(channel, object, this.historyWritingPostProcessor);
|
||||
}
|
||||
catch (Exception e) {
|
||||
@@ -507,9 +480,7 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
Object reply;
|
||||
Message<?> requestMessage = null;
|
||||
try {
|
||||
if (this.countsEnabled) {
|
||||
this.messageCount.incrementAndGet();
|
||||
}
|
||||
// TODO Micrometer counter
|
||||
if (shouldConvert) {
|
||||
reply = this.messagingTemplate.convertSendAndReceive(channel, object, Object.class,
|
||||
this.historyWritingPostProcessor);
|
||||
@@ -675,8 +646,8 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
|
||||
return reply
|
||||
.doOnSubscribe(s -> {
|
||||
if (!error && this.countsEnabled) {
|
||||
this.messageCount.incrementAndGet();
|
||||
if (!error) {
|
||||
// TODO Micrometer counter
|
||||
}
|
||||
})
|
||||
.<Message<?>>map(replyMessage -> {
|
||||
@@ -831,12 +802,6 @@ public abstract class MessagingGatewaySupport extends AbstractEndpoint
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
this.messageCount.set(0);
|
||||
}
|
||||
|
||||
|
||||
private static class DefaultRequestMapper implements InboundMessageMapper<Object> {
|
||||
|
||||
private volatile MessageBuilderFactory messageBuilderFactory = new DefaultMessageBuilderFactory();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -28,8 +28,8 @@ public abstract class EndpointNode extends IntegrationNode {
|
||||
|
||||
private final String output;
|
||||
|
||||
protected EndpointNode(int nodeId, String name, Object nodeObject, String output, Stats stats) {
|
||||
super(nodeId, name, nodeObject, stats);
|
||||
protected EndpointNode(int nodeId, String name, Object nodeObject, String output) {
|
||||
super(nodeId, name, nodeObject);
|
||||
this.output = output;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -28,10 +28,8 @@ public class ErrorCapableEndpointNode extends EndpointNode implements ErrorCapab
|
||||
|
||||
private final String errors;
|
||||
|
||||
protected ErrorCapableEndpointNode(int nodeId, String name, Object nodeObject, String output, String errors,
|
||||
Stats stats) {
|
||||
|
||||
super(nodeId, name, nodeObject, output, stats);
|
||||
protected ErrorCapableEndpointNode(int nodeId, String name, Object nodeObject, String output, String errors) {
|
||||
super(nodeId, name, nodeObject, output);
|
||||
this.errors = errors;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -45,8 +45,6 @@ public abstract class IntegrationNode {
|
||||
|
||||
private final String nodeName;
|
||||
|
||||
private final Stats stats;
|
||||
|
||||
private final String componentType;
|
||||
|
||||
@Nullable
|
||||
@@ -59,14 +57,13 @@ public abstract class IntegrationNode {
|
||||
|
||||
private final Map<String, Object> unmodifiableProperties = Collections.unmodifiableMap(this.properties);
|
||||
|
||||
protected IntegrationNode(int nodeId, String name, Object nodeObject, Stats stats) {
|
||||
protected IntegrationNode(int nodeId, String name, Object nodeObject) {
|
||||
this.nodeId = nodeId;
|
||||
this.nodeName = name;
|
||||
this.componentType =
|
||||
nodeObject instanceof NamedComponent
|
||||
? ((NamedComponent) nodeObject).getComponentType()
|
||||
: nodeObject.getClass().getSimpleName();
|
||||
this.stats = stats;
|
||||
if (nodeObject instanceof ExpressionCapable) {
|
||||
Expression expression = ((ExpressionCapable) nodeObject).getExpression();
|
||||
if (expression != null) {
|
||||
@@ -117,10 +114,6 @@ public abstract class IntegrationNode {
|
||||
return this.integrationPatternCategory;
|
||||
}
|
||||
|
||||
public Stats getStats() {
|
||||
return this.stats.isAvailable() ? this.stats : null;
|
||||
}
|
||||
|
||||
public Map<String, Object> getProperties() {
|
||||
return this.unmodifiableProperties;
|
||||
}
|
||||
@@ -147,16 +140,4 @@ public abstract class IntegrationNode {
|
||||
}
|
||||
}
|
||||
|
||||
public static class Stats {
|
||||
|
||||
protected boolean isAvailable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public String getDeprecated() {
|
||||
return "stats are deprecated in favor of sendTimers and receiveCounters";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -36,10 +36,7 @@ public class MessageChannelNode extends IntegrationNode implements SendTimersAwa
|
||||
private Supplier<SendTimers> sendTimers;
|
||||
|
||||
public MessageChannelNode(int nodeId, String name, MessageChannel channel) {
|
||||
super(nodeId, name, channel,
|
||||
channel instanceof org.springframework.integration.support.management.MessageChannelMetrics
|
||||
? new Stats((org.springframework.integration.support.management.MessageChannelMetrics) channel)
|
||||
: new IntegrationNode.Stats());
|
||||
super(nodeId, name, channel);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -52,83 +49,4 @@ public class MessageChannelNode extends IntegrationNode implements SendTimersAwa
|
||||
this.sendTimers = timers;
|
||||
}
|
||||
|
||||
public static final class Stats extends IntegrationNode.Stats {
|
||||
|
||||
private final org.springframework.integration.support.management.MessageChannelMetrics channel;
|
||||
|
||||
Stats(org.springframework.integration.support.management.MessageChannelMetrics channel) {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailable() {
|
||||
return this.channel.isCountsEnabled();
|
||||
}
|
||||
|
||||
public boolean isCountsEnabled() {
|
||||
return this.channel.isCountsEnabled();
|
||||
}
|
||||
|
||||
public boolean isLoggingEnabled() {
|
||||
return this.channel.isLoggingEnabled();
|
||||
}
|
||||
|
||||
public long getSendCount() {
|
||||
return this.channel.getSendCountLong();
|
||||
}
|
||||
|
||||
public long getSendErrorCount() {
|
||||
return this.channel.getSendErrorCountLong();
|
||||
}
|
||||
|
||||
public double getTimeSinceLastSend() {
|
||||
return this.channel.getTimeSinceLastSend();
|
||||
}
|
||||
|
||||
public double getMeanSendRate() {
|
||||
return this.channel.getMeanSendRate();
|
||||
}
|
||||
|
||||
public double getMeanErrorRate() {
|
||||
return this.channel.getMeanErrorRate();
|
||||
}
|
||||
|
||||
public double getMeanErrorRatio() {
|
||||
return this.channel.getMeanErrorRatio();
|
||||
}
|
||||
|
||||
public double getMeanSendDuration() {
|
||||
return this.channel.getMeanSendDuration();
|
||||
}
|
||||
|
||||
public double getMinSendDuration() {
|
||||
return this.channel.getMinSendDuration();
|
||||
}
|
||||
|
||||
public double getMaxSendDuration() {
|
||||
return this.channel.getMaxSendDuration();
|
||||
}
|
||||
|
||||
public double getStandardDeviationSendDuration() {
|
||||
return this.channel.getStandardDeviationSendDuration();
|
||||
}
|
||||
|
||||
public org.springframework.integration.support.management.Statistics getSendDuration() {
|
||||
return this.channel.getSendDuration();
|
||||
}
|
||||
|
||||
public org.springframework.integration.support.management.Statistics getSendRate() {
|
||||
return this.channel.getSendRate();
|
||||
}
|
||||
|
||||
public org.springframework.integration.support.management.Statistics getErrorRate() {
|
||||
return this.channel.getErrorRate();
|
||||
}
|
||||
|
||||
public boolean isStatsEnabled() {
|
||||
return this.channel.isStatsEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -29,27 +29,7 @@ import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
public class MessageGatewayNode extends ErrorCapableEndpointNode {
|
||||
|
||||
public MessageGatewayNode(int nodeId, String name, MessagingGatewaySupport gateway, String output, String errors) {
|
||||
super(nodeId, name, gateway, output, errors, new Stats(gateway));
|
||||
}
|
||||
|
||||
|
||||
public static final class Stats extends IntegrationNode.Stats {
|
||||
|
||||
private final MessagingGatewaySupport gateway;
|
||||
|
||||
Stats(MessagingGatewaySupport gateway) {
|
||||
this.gateway = gateway;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailable() {
|
||||
return this.gateway.isCountsEnabled();
|
||||
}
|
||||
|
||||
public long getSendCount() {
|
||||
return this.gateway.getMessageCountLong();
|
||||
}
|
||||
|
||||
super(nodeId, name, gateway, output, errors);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -30,7 +30,6 @@ import org.springframework.messaging.MessageHandler;
|
||||
* @since 4.3
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MessageHandlerNode extends EndpointNode implements SendTimersAware {
|
||||
|
||||
private final String input;
|
||||
@@ -38,10 +37,7 @@ public class MessageHandlerNode extends EndpointNode implements SendTimersAware
|
||||
private Supplier<SendTimers> sendTimers;
|
||||
|
||||
public MessageHandlerNode(int nodeId, String name, MessageHandler handler, String input, String output) {
|
||||
super(nodeId, name, handler, output,
|
||||
handler instanceof org.springframework.integration.support.management.MessageHandlerMetrics
|
||||
? new Stats((org.springframework.integration.support.management.MessageHandlerMetrics) handler)
|
||||
: new IntegrationNode.Stats());
|
||||
super(nodeId, name, handler, output);
|
||||
this.input = input;
|
||||
}
|
||||
|
||||
@@ -59,64 +55,5 @@ public class MessageHandlerNode extends EndpointNode implements SendTimersAware
|
||||
this.sendTimers = timers;
|
||||
}
|
||||
|
||||
public static final class Stats extends IntegrationNode.Stats {
|
||||
|
||||
private final org.springframework.integration.support.management.MessageHandlerMetrics handler;
|
||||
|
||||
Stats(org.springframework.integration.support.management.MessageHandlerMetrics handler) {
|
||||
this.handler = handler;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailable() {
|
||||
return this.handler.isCountsEnabled();
|
||||
}
|
||||
|
||||
public boolean isLoggingEnabled() {
|
||||
return this.handler.isLoggingEnabled();
|
||||
}
|
||||
|
||||
public long getHandleCount() {
|
||||
return this.handler.getHandleCountLong();
|
||||
}
|
||||
|
||||
public long getErrorCount() {
|
||||
return this.handler.getErrorCountLong();
|
||||
}
|
||||
|
||||
public double getMeanDuration() {
|
||||
return this.handler.getMeanDuration();
|
||||
}
|
||||
|
||||
public double getMinDuration() {
|
||||
return this.handler.getMinDuration();
|
||||
}
|
||||
|
||||
public double getMaxDuration() {
|
||||
return this.handler.getMaxDuration();
|
||||
}
|
||||
|
||||
public double getStandardDeviationDuration() {
|
||||
return this.handler.getStandardDeviationDuration();
|
||||
}
|
||||
|
||||
public long getActiveCount() {
|
||||
return this.handler.getActiveCountLong();
|
||||
}
|
||||
|
||||
public org.springframework.integration.support.management.Statistics getDuration() {
|
||||
return this.handler.getDuration();
|
||||
}
|
||||
|
||||
public boolean isStatsEnabled() {
|
||||
return this.handler.isStatsEnabled();
|
||||
}
|
||||
|
||||
public boolean isCountsEnabled() {
|
||||
return this.handler.isCountsEnabled();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -29,7 +29,7 @@ import org.springframework.integration.endpoint.MessageProducerSupport;
|
||||
public class MessageProducerNode extends ErrorCapableEndpointNode {
|
||||
|
||||
public MessageProducerNode(int nodeId, String name, MessageProducerSupport producer, String output, String errors) {
|
||||
super(nodeId, name, producer, output, errors, new IntegrationNode.Stats());
|
||||
super(nodeId, name, producer, output, errors);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -30,17 +30,12 @@ import org.springframework.lang.Nullable;
|
||||
* @since 4.3
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public class MessageSourceNode extends ErrorCapableEndpointNode implements ReceiveCountersAware {
|
||||
|
||||
private Supplier<ReceiveCounters> receiveCounters;
|
||||
|
||||
public MessageSourceNode(int nodeId, String name, MessageSource<?> messageSource, String output, String errors) {
|
||||
super(nodeId, name, messageSource, output, errors,
|
||||
messageSource instanceof org.springframework.integration.support.management.MessageSourceMetrics
|
||||
? new Stats(
|
||||
(org.springframework.integration.support.management.MessageSourceMetrics) messageSource)
|
||||
: new IntegrationNode.Stats());
|
||||
super(nodeId, name, messageSource, output, errors);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -53,24 +48,5 @@ public class MessageSourceNode extends ErrorCapableEndpointNode implements Recei
|
||||
this.receiveCounters = counters;
|
||||
}
|
||||
|
||||
public static final class Stats extends IntegrationNode.Stats {
|
||||
|
||||
private final org.springframework.integration.support.management.MessageSourceMetrics source;
|
||||
|
||||
Stats(org.springframework.integration.support.management.MessageSourceMetrics source) {
|
||||
this.source = source;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isAvailable() {
|
||||
return this.source.isCountsEnabled();
|
||||
}
|
||||
|
||||
public long getMessageCount() {
|
||||
return this.source.getMessageCountLong();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -38,44 +38,30 @@ public abstract class AbstractMessageHandler extends MessageHandlerSupport
|
||||
implements MessageHandler, CoreSubscriber<Message<?>> {
|
||||
|
||||
@Override // NOSONAR
|
||||
@SuppressWarnings("deprecation")
|
||||
public void handleMessage(Message<?> message) {
|
||||
Message<?> messageToUse = message;
|
||||
Assert.notNull(messageToUse, "Message must not be null");
|
||||
if (isLoggingEnabled() && this.logger.isDebugEnabled()) {
|
||||
this.logger.debug(this + " received message: " + messageToUse);
|
||||
}
|
||||
org.springframework.integration.support.management.MetricsContext start = null;
|
||||
SampleFacade sample = null;
|
||||
MetricsCaptor metricsCaptor = getMetricsCaptor();
|
||||
if (metricsCaptor != null && isCountsEnabled()) {
|
||||
if (metricsCaptor != null) {
|
||||
sample = metricsCaptor.start();
|
||||
}
|
||||
try {
|
||||
if (shouldTrack()) {
|
||||
messageToUse = MessageHistory.write(messageToUse, this, getMessageBuilderFactory());
|
||||
}
|
||||
org.springframework.integration.support.management.AbstractMessageHandlerMetrics handlerMetrics
|
||||
= getHandlerMetrics();
|
||||
if (isCountsEnabled()) {
|
||||
start = handlerMetrics.beforeHandle();
|
||||
handleMessageInternal(messageToUse);
|
||||
if (sample != null) {
|
||||
sample.stop(sendTimer());
|
||||
}
|
||||
handlerMetrics.afterHandle(start, true);
|
||||
}
|
||||
else {
|
||||
handleMessageInternal(messageToUse);
|
||||
handleMessageInternal(messageToUse);
|
||||
if (sample != null) {
|
||||
sample.stop(sendTimer());
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
if (sample != null) {
|
||||
sample.stop(buildSendTimer(false, e.getClass().getSimpleName()));
|
||||
}
|
||||
if (isCountsEnabled()) {
|
||||
getHandlerMetrics().afterHandle(start, false);
|
||||
}
|
||||
throw IntegrationUtils.wrapInHandlingExceptionIfNecessary(messageToUse,
|
||||
() -> "error occurred in message handler [" + this + "]", e);
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -25,6 +25,7 @@ import java.util.concurrent.locks.ReentrantLock;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.IntegrationPatternType;
|
||||
import org.springframework.integration.core.MessageProducer;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
@@ -66,7 +67,7 @@ import org.springframework.util.Assert;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MessageHandlerChain extends AbstractMessageProducingHandler
|
||||
implements CompositeMessageHandler, Lifecycle {
|
||||
implements CompositeMessageHandler, ManageableLifecycle {
|
||||
|
||||
private final Object initializationMonitor = new Object();
|
||||
|
||||
|
||||
@@ -25,11 +25,11 @@ import org.springframework.integration.IntegrationPatternType;
|
||||
import org.springframework.integration.context.IntegrationObjectSupport;
|
||||
import org.springframework.integration.context.Orderable;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.IntegrationManagement;
|
||||
import org.springframework.integration.support.management.TrackableComponent;
|
||||
import org.springframework.integration.support.management.metrics.MeterFacade;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.integration.support.management.metrics.TimerFacade;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Base class for Message handling components that provides basic validation and error
|
||||
@@ -47,13 +47,9 @@ import org.springframework.util.Assert;
|
||||
* @since 5.3
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public abstract class MessageHandlerSupport extends IntegrationObjectSupport
|
||||
implements org.springframework.integration.support.management.MessageHandlerMetrics,
|
||||
org.springframework.integration.support.management.ConfigurableMetricsAware<
|
||||
org.springframework.integration.support.management.AbstractMessageHandlerMetrics>,
|
||||
TrackableComponent, Orderable, IntegrationPattern {
|
||||
implements TrackableComponent, Orderable, IntegrationManagement, IntegrationPattern {
|
||||
|
||||
private final ManagementOverrides managementOverrides = new ManagementOverrides();
|
||||
|
||||
@@ -61,19 +57,12 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport
|
||||
|
||||
private boolean shouldTrack = false;
|
||||
|
||||
private org.springframework.integration.support.management.AbstractMessageHandlerMetrics handlerMetrics
|
||||
= new org.springframework.integration.support.management.DefaultMessageHandlerMetrics();
|
||||
|
||||
private boolean countsEnabled;
|
||||
|
||||
private boolean loggingEnabled = true;
|
||||
|
||||
private MetricsCaptor metricsCaptor;
|
||||
|
||||
private int order = Ordered.LOWEST_PRECEDENCE;
|
||||
|
||||
private boolean statsEnabled;
|
||||
|
||||
private String managedName;
|
||||
|
||||
private String managedType;
|
||||
@@ -96,16 +85,6 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport
|
||||
this.metricsCaptor = metricsCaptorToRegister;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return handler metrics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
protected org.springframework.integration.support.management.AbstractMessageHandlerMetrics getHandlerMetrics() {
|
||||
return this.handlerMetrics;
|
||||
}
|
||||
|
||||
protected MetricsCaptor getMetricsCaptor() {
|
||||
return this.metricsCaptor;
|
||||
}
|
||||
@@ -134,20 +113,6 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport
|
||||
return this.shouldTrack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void configureMetrics(
|
||||
org.springframework.integration.support.management.AbstractMessageHandlerMetrics metrics) {
|
||||
|
||||
Assert.notNull(metrics, "'metrics' must not be null");
|
||||
this.handlerMetrics = metrics;
|
||||
this.managementOverrides.metricsConfigured = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagementOverrides getOverrides() {
|
||||
return this.managementOverrides;
|
||||
@@ -158,13 +123,6 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport
|
||||
return IntegrationPatternType.outbound_channel_adapter;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onInit() {
|
||||
if (this.statsEnabled) {
|
||||
this.handlerMetrics.setFullStatsEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected TimerFacade sendTimer() {
|
||||
if (this.successTimer == null) {
|
||||
this.successTimer = buildSendTimer(true, "none");
|
||||
@@ -184,210 +142,18 @@ public abstract class MessageHandlerSupport extends IntegrationObjectSupport
|
||||
return timer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void reset() {
|
||||
this.handlerMetrics.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return handle count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getHandleCountLong() {
|
||||
return this.handlerMetrics.getHandleCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return handle count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getHandleCount() {
|
||||
return this.handlerMetrics.getHandleCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getErrorCount() {
|
||||
return this.handlerMetrics.getErrorCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return error count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getErrorCountLong() {
|
||||
return this.handlerMetrics.getErrorCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return mean duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMeanDuration() {
|
||||
return this.handlerMetrics.getMeanDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return min duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMinDuration() {
|
||||
return this.handlerMetrics.getMinDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return max duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getMaxDuration() {
|
||||
return this.handlerMetrics.getMaxDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return standard deviation duration
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public double getStandardDeviationDuration() {
|
||||
return this.handlerMetrics.getStandardDeviationDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return active count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public int getActiveCount() {
|
||||
return this.handlerMetrics.getActiveCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return active count
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public long getActiveCountLong() {
|
||||
return this.handlerMetrics.getActiveCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return statistics
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public org.springframework.integration.support.management.Statistics getDuration() {
|
||||
return this.handlerMetrics.getDuration();
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @param statsEnabled the statsEnabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setStatsEnabled(boolean statsEnabled) {
|
||||
if (statsEnabled) {
|
||||
this.countsEnabled = true;
|
||||
this.managementOverrides.countsConfigured = true;
|
||||
}
|
||||
this.statsEnabled = statsEnabled;
|
||||
if (this.handlerMetrics != null) {
|
||||
this.handlerMetrics.setFullStatsEnabled(statsEnabled);
|
||||
}
|
||||
this.managementOverrides.statsConfigured = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return statsEnabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isStatsEnabled() {
|
||||
return this.statsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @param countsEnabled the countsEnabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public void setCountsEnabled(boolean countsEnabled) {
|
||||
this.countsEnabled = countsEnabled;
|
||||
this.managementOverrides.countsConfigured = true;
|
||||
if (!countsEnabled) {
|
||||
this.statsEnabled = false;
|
||||
this.managementOverrides.statsConfigured = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return countsEnabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public boolean isCountsEnabled() {
|
||||
return this.countsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedName(String managedName) {
|
||||
this.managedName = managedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagedName() {
|
||||
return this.managedName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedType(String managedType) {
|
||||
this.managedType = managedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagedType() {
|
||||
return this.managedType;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -19,7 +19,7 @@ package org.springframework.integration.handler;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessagingException;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -32,7 +32,7 @@ import org.springframework.util.Assert;
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public class MethodInvokingMessageHandler extends AbstractMessageHandler implements Lifecycle {
|
||||
public class MethodInvokingMessageHandler extends AbstractMessageHandler implements ManageableLifecycle {
|
||||
|
||||
private final MethodInvokingMessageProcessor<Object> processor;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -20,9 +20,9 @@ import java.lang.annotation.Annotation;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.handler.support.MessagingMethodInvokerHelper;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
@@ -42,7 +42,7 @@ import org.springframework.messaging.Message;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MethodInvokingMessageProcessor<T> extends AbstractMessageProcessor<T> implements Lifecycle {
|
||||
public class MethodInvokingMessageProcessor<T> extends AbstractMessageProcessor<T> implements ManageableLifecycle {
|
||||
|
||||
private final MessagingMethodInvokerHelper delegate;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2017-2019 the original author or authors.
|
||||
* Copyright 2017-2020 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.
|
||||
@@ -19,6 +19,7 @@ package org.springframework.integration.handler;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.IntegrationPattern;
|
||||
import org.springframework.integration.IntegrationPatternType;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHandler;
|
||||
import org.springframework.util.Assert;
|
||||
@@ -37,7 +38,7 @@ import org.springframework.util.Assert;
|
||||
* @since 5.0
|
||||
*/
|
||||
public class ReplyProducingMessageHandlerWrapper extends AbstractReplyProducingMessageHandler
|
||||
implements Lifecycle {
|
||||
implements ManageableLifecycle {
|
||||
|
||||
private final MessageHandler target;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,6 +24,7 @@ import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.IntegrationPattern;
|
||||
import org.springframework.integration.IntegrationPatternType;
|
||||
import org.springframework.integration.annotation.ServiceActivator;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.messaging.Message;
|
||||
|
||||
@@ -32,7 +33,7 @@ import org.springframework.messaging.Message;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandler implements Lifecycle {
|
||||
public class ServiceActivatingHandler extends AbstractReplyProducingMessageHandler implements ManageableLifecycle {
|
||||
|
||||
private final MessageProcessor<?> processor;
|
||||
|
||||
|
||||
@@ -77,6 +77,7 @@ import org.springframework.integration.support.NullAwarePayloadArgumentResolver;
|
||||
import org.springframework.integration.support.converter.ConfigurableCompositeMessageConverter;
|
||||
import org.springframework.integration.support.json.JsonObjectMapper;
|
||||
import org.springframework.integration.support.json.JsonObjectMapperProvider;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.integration.util.AbstractExpressionEvaluator;
|
||||
import org.springframework.integration.util.AnnotatedMethodFilter;
|
||||
import org.springframework.integration.util.FixedMethodFilter;
|
||||
@@ -120,7 +121,7 @@ import org.springframework.util.StringUtils;
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator implements Lifecycle {
|
||||
public class MessagingMethodInvokerHelper extends AbstractExpressionEvaluator implements ManageableLifecycle {
|
||||
|
||||
private static final String CANDIDATE_METHODS = "CANDIDATE_METHODS";
|
||||
|
||||
|
||||
@@ -31,8 +31,8 @@ import org.springframework.beans.factory.BeanFactoryUtils;
|
||||
import org.springframework.beans.factory.ListableBeanFactory;
|
||||
import org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor;
|
||||
import org.springframework.beans.factory.support.BeanDefinitionValidationException;
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
import org.springframework.integration.support.management.IntegrationManagedResource;
|
||||
import org.springframework.integration.support.management.ManageableSmartLifecycle;
|
||||
import org.springframework.integration.support.management.TrackableComponent;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
@@ -50,7 +50,8 @@ import org.springframework.util.StringUtils;
|
||||
*/
|
||||
@ManagedResource
|
||||
@IntegrationManagedResource
|
||||
public class MessageHistoryConfigurer implements SmartLifecycle, BeanFactoryAware, DestructionAwareBeanPostProcessor {
|
||||
public class MessageHistoryConfigurer implements ManageableSmartLifecycle, BeanFactoryAware,
|
||||
DestructionAwareBeanPostProcessor {
|
||||
|
||||
private static final Log LOGGER = LogFactory.getLog(MessageHistoryConfigurer.class);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,6 +24,7 @@ import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.handler.AbstractMessageProcessor;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -35,7 +36,7 @@ import org.springframework.util.Assert;
|
||||
* @since 2.0
|
||||
*/
|
||||
class AbstractMessageProcessingRouter extends AbstractMappingMessageRouter
|
||||
implements Lifecycle {
|
||||
implements ManageableLifecycle {
|
||||
|
||||
private final MessageProcessor<?> messageProcessor;
|
||||
|
||||
|
||||
@@ -19,7 +19,6 @@ package org.springframework.integration.scattergather;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.integration.IntegrationPatternType;
|
||||
import org.springframework.integration.channel.FixedSubscriberChannel;
|
||||
import org.springframework.integration.channel.QueueChannel;
|
||||
@@ -31,6 +30,7 @@ import org.springframework.integration.endpoint.EventDrivenConsumer;
|
||||
import org.springframework.integration.endpoint.PollingConsumer;
|
||||
import org.springframework.integration.endpoint.ReactiveStreamsConsumer;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
import org.springframework.messaging.MessageDeliveryException;
|
||||
@@ -53,7 +53,7 @@ import org.springframework.util.ClassUtils;
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public class ScatterGatherHandler extends AbstractReplyProducingMessageHandler implements Lifecycle {
|
||||
public class ScatterGatherHandler extends AbstractReplyProducingMessageHandler implements ManageableLifecycle {
|
||||
|
||||
private static final String GATHER_RESULT_CHANNEL = "gatherResultChannel";
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,6 +23,7 @@ import org.springframework.context.Lifecycle;
|
||||
import org.springframework.core.convert.ConversionService;
|
||||
import org.springframework.integration.handler.AbstractMessageProcessor;
|
||||
import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -35,7 +36,7 @@ import org.springframework.util.Assert;
|
||||
* @since 2.0
|
||||
*/
|
||||
abstract class AbstractMessageProcessingSplitter extends AbstractMessageSplitter
|
||||
implements Lifecycle {
|
||||
implements ManageableLifecycle {
|
||||
|
||||
private final MessageProcessor<Collection<?>> messageProcessor;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.integration.leader.DefaultCandidate;
|
||||
import org.springframework.integration.leader.event.DefaultLeaderEventPublisher;
|
||||
import org.springframework.integration.leader.event.LeaderEventPublisher;
|
||||
import org.springframework.integration.support.locks.LockRegistry;
|
||||
import org.springframework.integration.support.management.ManageableSmartLifecycle;
|
||||
import org.springframework.scheduling.concurrent.CustomizableThreadFactory;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -60,7 +61,8 @@ import org.springframework.util.Assert;
|
||||
*
|
||||
* @since 4.3.1
|
||||
*/
|
||||
public class LockRegistryLeaderInitiator implements SmartLifecycle, DisposableBean, ApplicationEventPublisherAware {
|
||||
public class LockRegistryLeaderInitiator implements ManageableSmartLifecycle, DisposableBean,
|
||||
ApplicationEventPublisherAware {
|
||||
|
||||
public static final long DEFAULT_HEART_BEAT_TIME = 500L;
|
||||
|
||||
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Abstract base class for channel metrics implementations.
|
||||
*
|
||||
* @author Gary Russell
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
**/
|
||||
@Deprecated
|
||||
public abstract class AbstractMessageChannelMetrics implements ConfigurableMetrics {
|
||||
|
||||
private static final String DEPRECATION = "deprecation";
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR - final
|
||||
|
||||
protected final String name; // NOSONAR - final
|
||||
|
||||
private volatile boolean fullStatsEnabled;
|
||||
|
||||
/**
|
||||
* Construct an instance with the provided name.
|
||||
* @param name the name.
|
||||
*/
|
||||
public AbstractMessageChannelMetrics(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* When false, simple counts are maintained; when true complete statistics
|
||||
* are maintained.
|
||||
* @param fullStatsEnabled true for complete statistics.
|
||||
*/
|
||||
public void setFullStatsEnabled(boolean fullStatsEnabled) {
|
||||
this.fullStatsEnabled = fullStatsEnabled;
|
||||
}
|
||||
|
||||
protected boolean isFullStatsEnabled() {
|
||||
return this.fullStatsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a send event.
|
||||
* @return the context to be used in a subsequent {@link #afterSend(MetricsContext, boolean)}
|
||||
* call.
|
||||
*/
|
||||
@SuppressWarnings(DEPRECATION)
|
||||
public abstract MetricsContext beforeSend();
|
||||
|
||||
/**
|
||||
* End a send event. Note that implementations typically will not validate that the
|
||||
* context is of the correct type and not null; callers should take care to ensure
|
||||
* the context is the object returned by the previous {@link #beforeSend()} call.
|
||||
* @param context the context.
|
||||
* @param result true for success, false otherwise.
|
||||
*/
|
||||
public abstract void afterSend(@SuppressWarnings(DEPRECATION) MetricsContext context, boolean result);
|
||||
|
||||
/**
|
||||
* Reset all counters/statistics.
|
||||
*/
|
||||
public abstract void reset();
|
||||
|
||||
public abstract int getSendCount();
|
||||
|
||||
public abstract long getSendCountLong();
|
||||
|
||||
public abstract int getSendErrorCount();
|
||||
|
||||
public abstract long getSendErrorCountLong();
|
||||
|
||||
public abstract double getTimeSinceLastSend();
|
||||
|
||||
public abstract double getMeanSendRate();
|
||||
|
||||
public abstract double getMeanErrorRate();
|
||||
|
||||
public abstract double getMeanErrorRatio();
|
||||
|
||||
public abstract double getMeanSendDuration();
|
||||
|
||||
public abstract double getMinSendDuration();
|
||||
|
||||
public abstract double getMaxSendDuration();
|
||||
|
||||
public abstract double getStandardDeviationSendDuration();
|
||||
|
||||
@SuppressWarnings(DEPRECATION)
|
||||
public abstract Statistics getSendDuration();
|
||||
|
||||
@SuppressWarnings(DEPRECATION)
|
||||
public abstract Statistics getSendRate();
|
||||
|
||||
@SuppressWarnings(DEPRECATION)
|
||||
public abstract Statistics getErrorRate();
|
||||
|
||||
public abstract void afterReceive();
|
||||
|
||||
public abstract void afterError();
|
||||
|
||||
public abstract int getReceiveCount();
|
||||
|
||||
public abstract long getReceiveCountLong();
|
||||
|
||||
public abstract int getReceiveErrorCount();
|
||||
|
||||
public abstract long getReceiveErrorCountLong();
|
||||
|
||||
}
|
||||
@@ -1,94 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
/**
|
||||
* Abstract base class for handler metrics implementations.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class AbstractMessageHandlerMetrics implements ConfigurableMetrics {
|
||||
|
||||
protected final Log logger = LogFactory.getLog(getClass()); // NOSONAR final
|
||||
|
||||
protected final String name; // NOSONAR final
|
||||
|
||||
private boolean fullStatsEnabled;
|
||||
|
||||
public AbstractMessageHandlerMetrics(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/**
|
||||
* When false, simple counts are maintained; when true complete statistics
|
||||
* are maintained.
|
||||
* @param fullStatsEnabled true for complete statistics.
|
||||
*/
|
||||
public void setFullStatsEnabled(boolean fullStatsEnabled) {
|
||||
this.fullStatsEnabled = fullStatsEnabled;
|
||||
}
|
||||
|
||||
protected boolean isFullStatsEnabled() {
|
||||
return this.fullStatsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Begin a handle event.
|
||||
* @return the context to be used in the {@link #afterHandle(MetricsContext, boolean)}.
|
||||
*/
|
||||
public abstract MetricsContext beforeHandle();
|
||||
|
||||
/**
|
||||
* End a handle event
|
||||
* @param context the context from the previous {@link #beforeHandle()}.
|
||||
* @param success true for success, false otherwise.
|
||||
*/
|
||||
public abstract void afterHandle(MetricsContext context, boolean success);
|
||||
|
||||
public abstract void reset();
|
||||
|
||||
public abstract long getHandleCountLong();
|
||||
|
||||
public abstract int getHandleCount();
|
||||
|
||||
public abstract int getErrorCount();
|
||||
|
||||
public abstract long getErrorCountLong();
|
||||
|
||||
public abstract double getMeanDuration();
|
||||
|
||||
public abstract double getMinDuration();
|
||||
|
||||
public abstract double getMaxDuration();
|
||||
|
||||
public abstract double getStandardDeviationDuration();
|
||||
|
||||
public abstract int getActiveCount();
|
||||
|
||||
public abstract long getActiveCountLong();
|
||||
|
||||
public abstract Statistics getDuration();
|
||||
|
||||
}
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
|
||||
/**
|
||||
* An implementation of {@link MessageChannelMetrics} that aggregates the total response
|
||||
* time over a sample, to avoid fetching the system time twice for every message.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AggregatingMessageChannelMetrics extends DefaultMessageChannelMetrics {
|
||||
|
||||
private static final int DEFAULT_SAMPLE_SIZE = 1000;
|
||||
|
||||
private final int sampleSize;
|
||||
|
||||
private long start;
|
||||
|
||||
public AggregatingMessageChannelMetrics() {
|
||||
this(null, DEFAULT_SAMPLE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance with default metrics with {@code window=10, period=1 second,
|
||||
* lapsePeriod=1 minute}.
|
||||
* @param name the name.
|
||||
* @param sampleSize the sample size over which to aggregate the duration.
|
||||
*/
|
||||
public AggregatingMessageChannelMetrics(String name, int sampleSize) {
|
||||
super(name);
|
||||
this.sampleSize = sampleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance with the supplied metrics. For proper representation of metrics, the
|
||||
* supplied sendDuration must have a {@code factor=1000000.} and the the other arguments
|
||||
* must be created with the {@code millis} constructor argument set to true.
|
||||
* @param name the name.
|
||||
* @param sendDuration an {@link ExponentialMovingAverage} for calculating the send duration.
|
||||
* @param sendErrorRate an {@link ExponentialMovingAverageRate} for calculating the send error rate.
|
||||
* @param sendSuccessRatio an {@link ExponentialMovingAverageRatio} for calculating the success ratio.
|
||||
* @param sendRate an {@link ExponentialMovingAverageRate} for calculating the send rate.
|
||||
* @param sampleSize the sample size over which to aggregate the duration.
|
||||
*/
|
||||
public AggregatingMessageChannelMetrics(String name, ExponentialMovingAverage sendDuration,
|
||||
ExponentialMovingAverageRate sendErrorRate, ExponentialMovingAverageRatio sendSuccessRatio,
|
||||
ExponentialMovingAverageRate sendRate, int sampleSize) {
|
||||
super(name, sendDuration, sendErrorRate, sendSuccessRatio, sendRate);
|
||||
this.sampleSize = sampleSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized MetricsContext beforeSend() {
|
||||
long count = this.sendCount.getAndIncrement();
|
||||
if (isFullStatsEnabled() && count % this.sampleSize == 0) {
|
||||
this.start = System.nanoTime();
|
||||
this.sendRate.increment(this.start);
|
||||
}
|
||||
return new AggregatingChannelMetricsContext(this.start, count + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSend(MetricsContext context, boolean result) {
|
||||
AggregatingChannelMetricsContext aggregatingContext = (AggregatingChannelMetricsContext) context;
|
||||
long newCount = aggregatingContext.newCount;
|
||||
if (result) {
|
||||
if (isFullStatsEnabled() && newCount % this.sampleSize == 0) {
|
||||
long now = System.nanoTime();
|
||||
this.sendSuccessRatio.success(now);
|
||||
this.sendDuration.append(now - aggregatingContext.start);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isFullStatsEnabled() && newCount % this.sampleSize == 0) {
|
||||
long now = System.nanoTime();
|
||||
this.sendSuccessRatio.failure(now);
|
||||
this.sendErrorRate.increment(now);
|
||||
}
|
||||
this.sendErrorCount.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
protected static class AggregatingChannelMetricsContext extends DefaultChannelMetricsContext {
|
||||
|
||||
protected long newCount; // NOSONAR
|
||||
|
||||
public AggregatingChannelMetricsContext(long start, long newCount) {
|
||||
super(start);
|
||||
this.newCount = newCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
|
||||
/**
|
||||
* An implementation of {@link org.springframework.integration.support.management.MessageHandlerMetrics}
|
||||
* that aggregates the total response
|
||||
* time over a sample, to avoid fetching the system time twice for every message.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class AggregatingMessageHandlerMetrics extends DefaultMessageHandlerMetrics {
|
||||
|
||||
private static final int DEFAULT_SAMPLE_SIZE = 1000;
|
||||
|
||||
private final int sampleSize;
|
||||
|
||||
private long start;
|
||||
|
||||
public AggregatingMessageHandlerMetrics() {
|
||||
this(null, DEFAULT_SAMPLE_SIZE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance with the default moving average window (10).
|
||||
* @param name the name.
|
||||
* @param sampleSize the sample size over which to aggregate the duration.
|
||||
*/
|
||||
public AggregatingMessageHandlerMetrics(String name, int sampleSize) {
|
||||
super(name);
|
||||
this.sampleSize = sampleSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance with the supplied {@link ExponentialMovingAverage} calculating
|
||||
* the duration of processing by the message handler (and any downstream synchronous
|
||||
* endpoints).
|
||||
* @param name the name.
|
||||
* @param duration an {@link ExponentialMovingAverage} for calculating the duration.
|
||||
* @param sampleSize the sample size over which to aggregate the duration.
|
||||
*/
|
||||
public AggregatingMessageHandlerMetrics(String name, ExponentialMovingAverage duration, int sampleSize) {
|
||||
super(name, duration);
|
||||
this.sampleSize = sampleSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized MetricsContext beforeHandle() {
|
||||
long count = this.handleCount.getAndIncrement();
|
||||
if (isFullStatsEnabled() && count % this.sampleSize == 0) {
|
||||
this.start = System.nanoTime();
|
||||
}
|
||||
this.activeCount.incrementAndGet();
|
||||
return new AggregatingHandlerMetricsContext(this.start, count + 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterHandle(MetricsContext context, boolean success) {
|
||||
this.activeCount.decrementAndGet();
|
||||
AggregatingHandlerMetricsContext aggregatingContext = (AggregatingHandlerMetricsContext) context;
|
||||
if (success) {
|
||||
if (isFullStatsEnabled() && aggregatingContext.newCount % this.sampleSize == 0) {
|
||||
this.duration.append(System.nanoTime() - aggregatingContext.start);
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.errorCount.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
protected static class AggregatingHandlerMetricsContext extends DefaultHandlerMetricsContext {
|
||||
|
||||
protected long newCount;
|
||||
|
||||
public AggregatingHandlerMetricsContext(long start, long newCount) {
|
||||
super(start);
|
||||
this.newCount = newCount;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
/**
|
||||
* Implementation that returns aggregating metrics.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class AggregatingMetricsFactory implements MetricsFactory {
|
||||
|
||||
private final int sampleSize;
|
||||
|
||||
/**
|
||||
* @param sampleSize the number of messages over which to aggregate the elapsed time.
|
||||
*/
|
||||
public AggregatingMetricsFactory(int sampleSize) {
|
||||
this.sampleSize = sampleSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractMessageChannelMetrics createChannelMetrics(String name) {
|
||||
return new AggregatingMessageChannelMetrics(name, this.sampleSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractMessageHandlerMetrics createHandlerMetrics(String name) {
|
||||
return new AggregatingMessageHandlerMetrics(name, this.sampleSize);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* Primary interface for channels that provide metrics.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 5.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface BaseChannelMetrics extends IntegrationStatsManagement {
|
||||
|
||||
/**
|
||||
* @return the number of successful sends
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Send Count")
|
||||
long sendCount();
|
||||
|
||||
/**
|
||||
* @return the number of failed sends (either throwing an exception or rejected by the channel)
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Send Error Count")
|
||||
long sendErrorCount();
|
||||
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @since 5.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface BaseHandlerMetrics extends IntegrationStatsManagement {
|
||||
|
||||
/**
|
||||
* @return the number of successful handler calls
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Execution Count")
|
||||
long handleCount();
|
||||
|
||||
/**
|
||||
* @return the number of failed handler calls
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Handler Error Count")
|
||||
long errorCount();
|
||||
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
/**
|
||||
* Classes implementing this interface can accept a {@link ConfigurableMetrics}.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
public interface ConfigurableMetricsAware<M extends ConfigurableMetrics> {
|
||||
|
||||
void configureMetrics(M metrics);
|
||||
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* Default implementation; use the full constructor to customize the moving averages.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Helena Edelson
|
||||
* @author Gary Russell
|
||||
* @author Ivan Krizsan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultMessageChannelMetrics extends AbstractMessageChannelMetrics {
|
||||
|
||||
public static final long ONE_SECOND_SECONDS = 1;
|
||||
|
||||
public static final long ONE_MINUTE_SECONDS = 60;
|
||||
|
||||
public static final int DEFAULT_MOVING_AVERAGE_WINDOW = 10;
|
||||
|
||||
protected final ExponentialMovingAverage sendDuration; // NOSONAR final
|
||||
|
||||
protected final ExponentialMovingAverageRate sendErrorRate; // NOSONAR final
|
||||
|
||||
protected final ExponentialMovingAverageRatio sendSuccessRatio; // NOSONAR final
|
||||
|
||||
protected final ExponentialMovingAverageRate sendRate; // NOSONAR final
|
||||
|
||||
protected final AtomicLong sendCount = new AtomicLong(); // NOSONAR final
|
||||
|
||||
protected final AtomicLong sendErrorCount = new AtomicLong(); // NOSONAR final
|
||||
|
||||
protected final AtomicLong receiveCount = new AtomicLong(); // NOSONAR final
|
||||
|
||||
protected final AtomicLong receiveErrorCount = new AtomicLong(); // NOSONAR final
|
||||
|
||||
public DefaultMessageChannelMetrics() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance with default metrics with {@code window=10, period=1 second,
|
||||
* lapsePeriod=1 minute}.
|
||||
* @param name the name.
|
||||
*/
|
||||
public DefaultMessageChannelMetrics(String name) {
|
||||
this(name, new ExponentialMovingAverage(DEFAULT_MOVING_AVERAGE_WINDOW, 1000000.),
|
||||
new ExponentialMovingAverageRate(
|
||||
ONE_SECOND_SECONDS, ONE_MINUTE_SECONDS, DEFAULT_MOVING_AVERAGE_WINDOW, true),
|
||||
new ExponentialMovingAverageRatio(
|
||||
ONE_MINUTE_SECONDS, DEFAULT_MOVING_AVERAGE_WINDOW, true),
|
||||
new ExponentialMovingAverageRate(
|
||||
ONE_SECOND_SECONDS, ONE_MINUTE_SECONDS, DEFAULT_MOVING_AVERAGE_WINDOW, true));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance with the supplied metrics. For proper representation of metrics, the
|
||||
* supplied sendDuration must have a {@code factor=1000000.} and the the other arguments
|
||||
* must be created with the {@code millis} constructor argument set to true.
|
||||
* @param name the name.
|
||||
* @param sendDuration an {@link ExponentialMovingAverage} for calculating the send duration.
|
||||
* @param sendErrorRate an {@link ExponentialMovingAverageRate} for calculating the send error rate.
|
||||
* @param sendSuccessRatio an {@link ExponentialMovingAverageRatio} for calculating the success ratio.
|
||||
* @param sendRate an {@link ExponentialMovingAverageRate} for calculating the send rate.
|
||||
* @since 4.2
|
||||
*/
|
||||
public DefaultMessageChannelMetrics(String name, ExponentialMovingAverage sendDuration,
|
||||
ExponentialMovingAverageRate sendErrorRate, ExponentialMovingAverageRatio sendSuccessRatio,
|
||||
ExponentialMovingAverageRate sendRate) {
|
||||
|
||||
super(name);
|
||||
this.sendDuration = sendDuration;
|
||||
this.sendErrorRate = sendErrorRate;
|
||||
this.sendSuccessRatio = sendSuccessRatio;
|
||||
this.sendRate = sendRate;
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug(this.sendDuration);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetricsContext beforeSend() {
|
||||
long start = 0;
|
||||
if (isFullStatsEnabled()) {
|
||||
start = System.nanoTime();
|
||||
this.sendRate.increment(start);
|
||||
}
|
||||
this.sendCount.incrementAndGet();
|
||||
return new DefaultChannelMetricsContext(start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterSend(MetricsContext context, boolean result) {
|
||||
if (result) {
|
||||
if (isFullStatsEnabled()) {
|
||||
long now = System.nanoTime();
|
||||
this.sendSuccessRatio.success(now);
|
||||
this.sendDuration.append(now - ((DefaultChannelMetricsContext) context).start);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isFullStatsEnabled()) {
|
||||
long now = System.nanoTime();
|
||||
this.sendSuccessRatio.failure(now);
|
||||
this.sendErrorRate.increment(now);
|
||||
}
|
||||
this.sendErrorCount.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void reset() {
|
||||
this.sendDuration.reset();
|
||||
this.sendErrorRate.reset();
|
||||
this.sendSuccessRatio.reset();
|
||||
this.sendRate.reset();
|
||||
this.sendCount.set(0);
|
||||
this.sendErrorCount.set(0);
|
||||
this.receiveErrorCount.set(0);
|
||||
this.receiveCount.set(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSendCount() {
|
||||
return (int) this.sendCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSendCountLong() {
|
||||
return this.sendCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSendErrorCount() {
|
||||
return (int) this.sendErrorCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getSendErrorCountLong() {
|
||||
return this.sendErrorCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTimeSinceLastSend() {
|
||||
return this.sendRate.getTimeSinceLastMeasurement();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMeanSendRate() {
|
||||
return this.sendRate.getMean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMeanErrorRate() {
|
||||
return this.sendErrorRate.getMean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMeanErrorRatio() {
|
||||
return 1 - this.sendSuccessRatio.getMean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMeanSendDuration() {
|
||||
return this.sendDuration.getMean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMinSendDuration() {
|
||||
return this.sendDuration.getMin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxSendDuration() {
|
||||
return this.sendDuration.getMax();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStandardDeviationSendDuration() {
|
||||
return this.sendDuration.getStandardDeviation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getSendDuration() {
|
||||
return this.sendDuration.getStatistics();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getSendRate() {
|
||||
return this.sendRate.getStatistics();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getErrorRate() {
|
||||
return this.sendErrorRate.getStatistics();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterReceive() {
|
||||
this.receiveCount.incrementAndGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterError() {
|
||||
this.receiveErrorCount.incrementAndGet();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReceiveCount() {
|
||||
return (int) this.receiveCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReceiveCountLong() {
|
||||
return this.receiveCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getReceiveErrorCount() {
|
||||
return (int) this.receiveErrorCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getReceiveErrorCountLong() {
|
||||
return this.receiveErrorCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("MessageChannelMonitor: [name=%s, sends=%d"
|
||||
+ (this.receiveCount.get() == 0 ? "" : this.receiveCount.get())
|
||||
+ "]", name, this.sendCount.get());
|
||||
}
|
||||
|
||||
protected static class DefaultChannelMetricsContext implements MetricsContext {
|
||||
|
||||
protected final long start; // NOSONAR
|
||||
|
||||
protected DefaultChannelMetricsContext(long start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,167 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
/**
|
||||
* Default implementation; use the full constructor to customize the moving averages.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class DefaultMessageHandlerMetrics extends AbstractMessageHandlerMetrics {
|
||||
|
||||
private static final int DEFAULT_MOVING_AVERAGE_WINDOW = 10;
|
||||
|
||||
|
||||
protected final AtomicLong activeCount = new AtomicLong(); // NOSONAR final
|
||||
|
||||
protected final AtomicLong handleCount = new AtomicLong(); // NOSONAR final
|
||||
|
||||
protected final AtomicLong errorCount = new AtomicLong(); // NOSONAR final
|
||||
|
||||
protected final ExponentialMovingAverage duration; // NOSONAR final
|
||||
|
||||
public DefaultMessageHandlerMetrics() {
|
||||
this(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance with the default moving average window (10).
|
||||
* @param name the name.
|
||||
*/
|
||||
public DefaultMessageHandlerMetrics(String name) {
|
||||
this(name, new ExponentialMovingAverage(DEFAULT_MOVING_AVERAGE_WINDOW, 1000000.));
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an instance with the supplied {@link ExponentialMovingAverage} calculating
|
||||
* the duration of processing by the message handler (and any downstream synchronous
|
||||
* endpoints).
|
||||
* @param name the name.
|
||||
* @param duration an {@link ExponentialMovingAverage} for calculating the duration.
|
||||
* @since 4.2
|
||||
*/
|
||||
public DefaultMessageHandlerMetrics(String name, ExponentialMovingAverage duration) {
|
||||
super(name);
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetricsContext beforeHandle() {
|
||||
long start = 0;
|
||||
if (isFullStatsEnabled()) {
|
||||
start = System.nanoTime();
|
||||
}
|
||||
this.handleCount.incrementAndGet();
|
||||
this.activeCount.incrementAndGet();
|
||||
return new DefaultHandlerMetricsContext(start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterHandle(MetricsContext context, boolean success) {
|
||||
this.activeCount.decrementAndGet();
|
||||
if (isFullStatsEnabled() && success) {
|
||||
this.duration.append(System.nanoTime() - ((DefaultHandlerMetricsContext) context).start);
|
||||
}
|
||||
else if (!success) {
|
||||
this.errorCount.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void reset() {
|
||||
this.duration.reset();
|
||||
this.errorCount.set(0);
|
||||
this.handleCount.set(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getHandleCountLong() {
|
||||
if (logger.isTraceEnabled()) {
|
||||
logger.trace("Getting Handle Count:" + this);
|
||||
}
|
||||
return this.handleCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHandleCount() {
|
||||
return (int) getHandleCountLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getErrorCount() {
|
||||
return (int) this.errorCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getErrorCountLong() {
|
||||
return this.errorCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMeanDuration() {
|
||||
return this.duration.getMean();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMinDuration() {
|
||||
return this.duration.getMin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getMaxDuration() {
|
||||
return this.duration.getMax();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getStandardDeviationDuration() {
|
||||
return this.duration.getStandardDeviation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getActiveCount() {
|
||||
return (int) this.activeCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getActiveCountLong() {
|
||||
return this.activeCount.get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Statistics getDuration() {
|
||||
return this.duration.getStatistics();
|
||||
}
|
||||
|
||||
protected static class DefaultHandlerMetricsContext implements MetricsContext {
|
||||
|
||||
protected final long start; // NOSONAR final
|
||||
|
||||
protected DefaultHandlerMetricsContext(long start) {
|
||||
this.start = start;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Default implementation.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public class DefaultMetricsFactory implements MetricsFactory {
|
||||
|
||||
@Override
|
||||
public AbstractMessageChannelMetrics createChannelMetrics(String name) {
|
||||
return new DefaultMessageChannelMetrics(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public AbstractMessageHandlerMetrics createHandlerMetrics(String name) {
|
||||
return new DefaultMessageHandlerMetrics(name);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,196 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cumulative statistics for a series of real numbers with higher weight given to recent data.
|
||||
* Clients call {@link #append(double)} every time there is a new measurement, and then can collect summary
|
||||
* statistics from the convenience getters (e.g. {@link #getStatistics()}). Older values are given exponentially smaller
|
||||
* 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. For performance reasons, the calculation is performed on retrieval,
|
||||
* {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the
|
||||
* sum.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class ExponentialMovingAverage {
|
||||
|
||||
private volatile long count;
|
||||
|
||||
private volatile double min = Double.MAX_VALUE;
|
||||
|
||||
private volatile double max;
|
||||
|
||||
private final Deque<Double> samples = new ArrayDeque<>();
|
||||
|
||||
private final int retention;
|
||||
|
||||
private final int window;
|
||||
|
||||
private final double factor;
|
||||
|
||||
|
||||
/**
|
||||
* Create a moving average accumulator with decay lapse window provided. Measurements older than this will have
|
||||
* smaller weight than <code>1/e</code>.
|
||||
* @param window the exponential lapse window (number of measurements)
|
||||
*/
|
||||
public ExponentialMovingAverage(int window) {
|
||||
this(window, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a moving average accumulator with decay lapse window provided. Measurements older than this will have
|
||||
* smaller weight than <code>1/e</code>.
|
||||
* @param window the exponential lapse window (number of measurements)
|
||||
* @param factor a factor by which raw values are reduced during analysis; e.g. to analyze in ms and
|
||||
* raw values are ns, set the factor to 1000000.0.
|
||||
* @since 4.2
|
||||
*/
|
||||
public ExponentialMovingAverage(int window, double factor) {
|
||||
this.window = window;
|
||||
this.retention = window * 5; // last retained value contributes just 0.5% to the sum
|
||||
this.factor = factor;
|
||||
}
|
||||
|
||||
public synchronized void reset() {
|
||||
this.count = 0;
|
||||
this.min = Double.MAX_VALUE;
|
||||
this.max = 0;
|
||||
this.samples.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new measurement to the series.
|
||||
* @param value the measurement to append
|
||||
*/
|
||||
public synchronized void append(double value) {
|
||||
if (this.samples.size() == this.retention) {
|
||||
this.samples.poll();
|
||||
}
|
||||
this.samples.add(value);
|
||||
this.count++; //NOSONAR - false positive, we're synchronized
|
||||
}
|
||||
|
||||
private Statistics calc() {
|
||||
List<Double> copy;
|
||||
long currentCount;
|
||||
synchronized (this) {
|
||||
copy = new ArrayList<Double>(this.samples);
|
||||
currentCount = this.count;
|
||||
}
|
||||
double sum = 0;
|
||||
double decay = 1 - 1. / this.window;
|
||||
double sumSquares = 0;
|
||||
double weight = 0;
|
||||
double currentMin = this.min;
|
||||
double currentMax = this.max;
|
||||
for (Double value : copy) {
|
||||
value /= this.factor;
|
||||
if (value > currentMax) {
|
||||
currentMax = value;
|
||||
}
|
||||
if (value < currentMin) {
|
||||
currentMin = value;
|
||||
}
|
||||
sum = decay * sum + value;
|
||||
sumSquares = decay * sumSquares + value * value;
|
||||
weight = decay * weight + 1;
|
||||
}
|
||||
synchronized (this) {
|
||||
if (currentMax > this.max) {
|
||||
this.max = currentMax;
|
||||
}
|
||||
if (currentMin < this.min) {
|
||||
this.min = currentMin;
|
||||
}
|
||||
}
|
||||
double mean = weight > 0 ? sum / weight : 0.;
|
||||
double var = weight > 0 ? sumSquares / weight - mean * mean : 0.;
|
||||
double standardDeviation = var > 0 ? Math.sqrt(var) : 0;
|
||||
return new Statistics(currentCount, currentMin == Double.MAX_VALUE ? 0 : currentMin, currentMax, mean, standardDeviation); //NOSONAR
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of measurements recorded
|
||||
*/
|
||||
public int getCount() {
|
||||
return (int) this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of measurements recorded
|
||||
*/
|
||||
public long getCountLong() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mean value
|
||||
*/
|
||||
public double getMean() {
|
||||
return calc().getMean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the approximate standard deviation
|
||||
*/
|
||||
public double getStandardDeviation() {
|
||||
return calc().getStandardDeviation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum value recorded (not weighted)
|
||||
*/
|
||||
public double getMax() {
|
||||
return calc().getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum value recorded (not weighted)
|
||||
*/
|
||||
public double getMin() {
|
||||
return calc().getMin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return summary statistics (count, mean, standard deviation etc.)
|
||||
*/
|
||||
public Statistics getStatistics() {
|
||||
return calc();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getStatistics().toString();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,270 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* Cumulative statistics for an event rate with higher weight given to recent data.
|
||||
* Clients call {@link #increment()} when a new event occurs, and then use convenience methods (e.g. {@link #getMean()})
|
||||
* to retrieve estimates of the rate of event arrivals and the statistics of the series. Older values are given
|
||||
* exponentially smaller weight, with a decay factor determined by a duration chosen by the client. The rate measurement
|
||||
* weights decay in two dimensions:
|
||||
* <ul>
|
||||
* <li>in time according to the lapse period supplied: <code>weight = exp((t0-t)/T)</code> where <code>t0</code> is the
|
||||
* last measurement time, <code>t</code> is the current time and <code>T</code> is the lapse period)</li>
|
||||
* <li>per measurement according to the lapse window supplied: <code>weight = exp(-i/L)</code> where <code>L</code> is
|
||||
* the lapse window and <code>i</code> is the sequence number of the measurement.</li>
|
||||
* </ul>
|
||||
* For performance reasons, the calculation is performed on retrieval,
|
||||
* {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the
|
||||
* sum.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Steven Swor
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public class ExponentialMovingAverageRate {
|
||||
|
||||
private volatile double min = Double.MAX_VALUE;
|
||||
|
||||
private volatile double max;
|
||||
|
||||
private volatile double t0;
|
||||
|
||||
private volatile long count;
|
||||
|
||||
private final double lapse;
|
||||
|
||||
private final double period;
|
||||
|
||||
private final Deque<Long> times = new ArrayDeque<>();
|
||||
|
||||
private final int retention;
|
||||
|
||||
private final int window;
|
||||
|
||||
private final double factor;
|
||||
|
||||
|
||||
/**
|
||||
* @param period the period to base the rate measurement (in seconds)
|
||||
* @param lapsePeriod the exponential lapse rate for the rate average (in seconds)
|
||||
* @param window the exponential lapse window (number of measurements)
|
||||
*/
|
||||
public ExponentialMovingAverageRate(double period, double lapsePeriod, int window) {
|
||||
this(period, lapsePeriod, window, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param period the period to base the rate measurement (in seconds)
|
||||
* @param lapsePeriod the exponential lapse rate for the rate average (in seconds)
|
||||
* @param window the exponential lapse window (number of measurements)
|
||||
* @param millis when true, analyze the data as milliseconds instead of the native nanoseconds
|
||||
* @since 4.2
|
||||
*/
|
||||
public ExponentialMovingAverageRate(double period, double lapsePeriod, int window, boolean millis) {
|
||||
this.lapse = lapsePeriod > 0 ? 0.001 / lapsePeriod : 0; // convert to milliseconds
|
||||
this.period = period * 1000; // convert to milliseconds
|
||||
this.window = window;
|
||||
this.retention = window * 5;
|
||||
this.factor = millis ? 1000000 : 1;
|
||||
this.t0 = System.nanoTime() / this.factor;
|
||||
}
|
||||
|
||||
|
||||
public synchronized void reset() {
|
||||
this.min = Double.MAX_VALUE;
|
||||
this.max = 0;
|
||||
this.count = 0;
|
||||
this.times.clear();
|
||||
this.t0 = System.nanoTime() / this.factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new event to the series.
|
||||
*/
|
||||
public synchronized void increment() {
|
||||
increment(System.nanoTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new event to the series at time t.
|
||||
* @param t a new event to the series (System.nanoTime()).
|
||||
*/
|
||||
public synchronized void increment(long t) {
|
||||
if (this.times.size() == this.retention) {
|
||||
this.times.poll();
|
||||
}
|
||||
this.times.add(t);
|
||||
this.count++; //NOSONAR - false positive, we're synchronized
|
||||
}
|
||||
|
||||
private Statistics calcStatic() {
|
||||
List<Long> copy;
|
||||
long currentCount;
|
||||
synchronized (this) {
|
||||
copy = new ArrayList<Long>(this.times);
|
||||
currentCount = this.count;
|
||||
}
|
||||
ExponentialMovingAverage rates = new ExponentialMovingAverage(this.window);
|
||||
double currentT0 = 0;
|
||||
double sum = 0;
|
||||
double weight = 0;
|
||||
double currentMin = this.min;
|
||||
double currentMax = this.max;
|
||||
int size = copy.size();
|
||||
for (Long time : copy) {
|
||||
double t = time / this.factor;
|
||||
if (size == 1) {
|
||||
currentT0 = this.t0;
|
||||
}
|
||||
else if (currentT0 == 0) {
|
||||
currentT0 = t;
|
||||
continue;
|
||||
}
|
||||
double delta = t - currentT0;
|
||||
double value = delta > 0 ? delta / this.period : 0;
|
||||
if (value > currentMax) {
|
||||
currentMax = value;
|
||||
}
|
||||
if (value < currentMin) {
|
||||
currentMin = value;
|
||||
}
|
||||
double alpha = Math.exp(-delta * this.lapse);
|
||||
currentT0 = t;
|
||||
sum = alpha * sum + value;
|
||||
weight = alpha * weight + 1;
|
||||
rates.append(sum > 0 ? weight / sum : 0);
|
||||
}
|
||||
synchronized (this) {
|
||||
if (currentMax > this.max) {
|
||||
this.max = currentMax;
|
||||
}
|
||||
if (currentMin < this.min) {
|
||||
this.min = currentMin;
|
||||
}
|
||||
}
|
||||
return new Statistics(currentCount, currentMin < Double.MAX_VALUE ? currentMin : 0, currentMax, rates.getMean(),
|
||||
rates.getStandardDeviation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of measurements recorded
|
||||
*/
|
||||
public int getCount() {
|
||||
return (int) this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of measurements recorded
|
||||
* @since 3.0
|
||||
*/
|
||||
public long getCountLong() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time in milliseconds since the last measurement
|
||||
*/
|
||||
public double getTimeSinceLastMeasurement() {
|
||||
if (this.count == 0) {
|
||||
return 0;
|
||||
}
|
||||
double currentT0 = lastTime();
|
||||
return (System.nanoTime() / this.factor - currentT0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mean value
|
||||
*/
|
||||
public double getMean() {
|
||||
return recalcMean(calcStatic());
|
||||
}
|
||||
|
||||
/**
|
||||
* Decay the mean using the current time.
|
||||
* @param staticStats the static statistics.
|
||||
* @return the new mean.
|
||||
*/
|
||||
private double recalcMean(Statistics staticStats) {
|
||||
long currentCount = this.count;
|
||||
currentCount = currentCount > this.retention ? this.retention : currentCount;
|
||||
if (currentCount == 0) {
|
||||
return 0;
|
||||
}
|
||||
double currentT0 = lastTime();
|
||||
double t = System.nanoTime() / this.factor;
|
||||
double value = t > currentT0 ? (t - currentT0) / this.period : 0;
|
||||
return currentCount / (currentCount / staticStats.getMean() + value);
|
||||
}
|
||||
|
||||
private synchronized double lastTime() {
|
||||
if (this.times.size() > 0) {
|
||||
return this.times.peekLast() / this.factor;
|
||||
}
|
||||
else {
|
||||
return this.t0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the approximate standard deviation
|
||||
*/
|
||||
public double getStandardDeviation() {
|
||||
return calcStatic().getStandardDeviation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum value recorded (not weighted)
|
||||
*/
|
||||
public double getMax() {
|
||||
double currentMin = calcStatic().getMin();
|
||||
return currentMin > 0 ? 1 / currentMin : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum value recorded (not weighted)
|
||||
*/
|
||||
public double getMin() {
|
||||
double currentMax = calcStatic().getMax();
|
||||
return currentMax > 0 ? 1 / currentMax : 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return summary statistics (count, mean, standard deviation etc.)
|
||||
*/
|
||||
public Statistics getStatistics() {
|
||||
Statistics staticStats = calcStatic();
|
||||
staticStats.setMean(recalcMean(staticStats));
|
||||
return staticStats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[%s, timeSinceLast=%f]", getStatistics(), getTimeSinceLastMeasurement());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,285 +0,0 @@
|
||||
/*
|
||||
* Copyright 2009-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Deque;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Cumulative statistics for success ratio with higher weight given to recent data.
|
||||
* Clients call {@link #success()} or {@link #failure()} when an event occurs, and the ratio of success to total events
|
||||
* is accumulated. Older values are given exponentially smaller weight, with a decay factor determined by a duration
|
||||
* chosen by the client. The rate measurement weights decay in two dimensions:
|
||||
* <ul>
|
||||
* <li>in time according to the lapse period supplied: <code>weight = exp((t0-t)/T)</code> where <code>t0</code> is the
|
||||
* last measurement time, <code>t</code> is the current time and <code>T</code> is the lapse period)</li>
|
||||
* <li>per measurement according to the lapse window supplied: <code>weight = exp(-i/L)</code> where <code>L</code> is
|
||||
* the lapse window and <code>i</code> is the sequence number of the measurement.</li>
|
||||
* </ul>
|
||||
* For performance reasons, the calculation is performed on retrieval,
|
||||
* {@code window * 5} samples are retained meaning that the earliest retained value contributes just 0.5% to the
|
||||
* sum.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Steven Swor
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class ExponentialMovingAverageRatio {
|
||||
|
||||
private volatile double t0;
|
||||
|
||||
private volatile long count;
|
||||
|
||||
private volatile double min = Double.MAX_VALUE;
|
||||
|
||||
private volatile double max;
|
||||
|
||||
private final double lapse;
|
||||
|
||||
private final Deque<Long> times = new ArrayDeque<>();
|
||||
|
||||
private final Deque<Integer> values = new ArrayDeque<>();
|
||||
|
||||
private final int retention;
|
||||
|
||||
private final int window;
|
||||
|
||||
private final double factor;
|
||||
|
||||
/**
|
||||
* @param lapsePeriod the exponential lapse rate for the rate average (in seconds)
|
||||
* @param window the exponential lapse window (number of measurements)
|
||||
*/
|
||||
public ExponentialMovingAverageRatio(double lapsePeriod, int window) {
|
||||
this(lapsePeriod, window, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param lapsePeriod the exponential lapse rate for the rate average (in seconds)
|
||||
* @param window the exponential lapse window (number of measurements)
|
||||
* @param millis when true, analyze the data as milliseconds instead of the native nanoseconds
|
||||
* @since 4.2
|
||||
*/
|
||||
public ExponentialMovingAverageRatio(double lapsePeriod, int window, boolean millis) {
|
||||
this.lapse = lapsePeriod > 0 ? 0.001 / lapsePeriod : 0; // convert to milliseconds
|
||||
this.window = window;
|
||||
this.retention = window * 5;
|
||||
this.factor = millis ? 1000000 : 1;
|
||||
this.t0 = System.nanoTime() / this.factor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Add a new event with successful outcome.
|
||||
*/
|
||||
public void success() {
|
||||
append(1, System.nanoTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new event with successful outcome at time t.
|
||||
* @param t the System.nanoTime().
|
||||
*/
|
||||
public void success(long t) {
|
||||
append(1, t);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new event with failed outcome.
|
||||
*/
|
||||
public void failure() {
|
||||
append(0, System.nanoTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a new event with failed outcome at time t.
|
||||
* @param t a new event with failed outcome in milliseconds.
|
||||
*/
|
||||
public void failure(long t) {
|
||||
append(0, t);
|
||||
}
|
||||
|
||||
public synchronized void reset() {
|
||||
this.t0 = System.nanoTime() / this.factor;
|
||||
this.times.clear();
|
||||
this.values.clear();
|
||||
this.count = 0;
|
||||
this.max = 0;
|
||||
this.min = Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
private synchronized void append(int value, long t) {
|
||||
if (this.times.size() == this.retention) {
|
||||
this.times.poll();
|
||||
this.values.poll();
|
||||
}
|
||||
this.times.add(t);
|
||||
this.values.add(value);
|
||||
this.count++; //NOSONAR - false positive, we're synchronized
|
||||
}
|
||||
|
||||
private Statistics calcStatic() {
|
||||
List<Long> copyTimes;
|
||||
List<Integer> copyValues;
|
||||
long currentCount;
|
||||
synchronized (this) {
|
||||
copyTimes = new ArrayList<Long>(this.times);
|
||||
copyValues = new ArrayList<Integer>(this.values);
|
||||
currentCount = this.count;
|
||||
}
|
||||
ExponentialMovingAverage cumulative = new ExponentialMovingAverage(this.window);
|
||||
double currentT0 = 0;
|
||||
double sum = 0;
|
||||
double weight = 0;
|
||||
double currentMin = this.min;
|
||||
double currentMax = this.max;
|
||||
int size = copyTimes.size();
|
||||
Iterator<Integer> valuesIterator = copyValues.iterator();
|
||||
for (Long time : copyTimes) {
|
||||
double t = time / this.factor;
|
||||
if (size == 1) {
|
||||
currentT0 = this.t0;
|
||||
}
|
||||
else if (currentT0 == 0) {
|
||||
currentT0 = t;
|
||||
valuesIterator.next();
|
||||
continue;
|
||||
}
|
||||
double alpha = Math.exp((currentT0 - t) * this.lapse);
|
||||
currentT0 = t;
|
||||
sum = alpha * sum + valuesIterator.next();
|
||||
weight = alpha * weight + 1;
|
||||
double value = sum / weight;
|
||||
if (value > currentMax) {
|
||||
currentMax = value;
|
||||
}
|
||||
if (value < currentMin) {
|
||||
currentMin = value;
|
||||
}
|
||||
cumulative.append(value);
|
||||
}
|
||||
synchronized (this) {
|
||||
if (currentMax > this.max) {
|
||||
this.max = currentMax;
|
||||
}
|
||||
if (currentMin < this.min) {
|
||||
this.min = currentMin;
|
||||
}
|
||||
}
|
||||
return new Statistics(currentCount, currentMin < Double.MAX_VALUE ? currentMin : 0, currentMax, cumulative.getMean(),
|
||||
cumulative.getStandardDeviation());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of measurements recorded
|
||||
*/
|
||||
public int getCount() {
|
||||
return (int) this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of measurements recorded
|
||||
*/
|
||||
public long getCountLong() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time in seconds since the last measurement
|
||||
*/
|
||||
public double getTimeSinceLastMeasurement() {
|
||||
double delta = System.nanoTime() - lastTime();
|
||||
return delta / 1000. / this.factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mean success rate
|
||||
*/
|
||||
public double getMean() {
|
||||
if (this.count == 0) {
|
||||
// Optimistic to start: success rate is 100%
|
||||
return 1;
|
||||
}
|
||||
return decayMean(calcStatic());
|
||||
}
|
||||
|
||||
/**
|
||||
* Decay the mean using the current time.
|
||||
* @param staticStats the static statistics.
|
||||
* @return the new mean.
|
||||
*/
|
||||
private double decayMean(Statistics statistics) {
|
||||
double t = System.nanoTime() / this.factor;
|
||||
double mean = statistics.getMean();
|
||||
double alpha = Math.exp((lastTime() / this.factor - t) * this.lapse);
|
||||
return alpha * mean + 1 - alpha;
|
||||
}
|
||||
|
||||
private synchronized double lastTime() {
|
||||
if (this.times.size() > 0) {
|
||||
return this.times.peekLast();
|
||||
}
|
||||
else {
|
||||
return this.t0 * this.factor;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the approximate standard deviation of the success rate measurements
|
||||
*/
|
||||
public double getStandardDeviation() {
|
||||
return calcStatic().getStandardDeviation();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the maximum value recorded of the exponential weighted average (per measurement) success rate
|
||||
*/
|
||||
public double getMax() {
|
||||
return calcStatic().getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the minimum value recorded of the exponential weighted average (per measurement) success rate
|
||||
*/
|
||||
public double getMin() {
|
||||
return calcStatic().getMin();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return summary statistics (count, mean, standard deviation etc.)
|
||||
*/
|
||||
public Statistics getStatistics() {
|
||||
Statistics staticStats = calcStatic();
|
||||
staticStats.setMean(decayMean(staticStats));
|
||||
return staticStats;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[%s, timeSinceLast=%f]", getStatistics(), getTimeSinceLastMeasurement());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
* Copyright 2020 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.
|
||||
@@ -17,14 +17,13 @@
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
/**
|
||||
* Marker interface for metrics.
|
||||
* Marker interface indicating that this {@link IntegrationManagement} component initiates
|
||||
* message flow.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
* @since 5.4
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface ConfigurableMetrics {
|
||||
public interface IntegrationInboundManagement extends IntegrationManagement {
|
||||
|
||||
}
|
||||
@@ -17,9 +17,10 @@
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
import org.springframework.beans.factory.DisposableBean;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.integration.support.management.metrics.MetricsCaptor;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
/**
|
||||
* Base interface for Integration managed components.
|
||||
@@ -28,7 +29,7 @@ import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
public interface IntegrationManagement extends DisposableBean {
|
||||
public interface IntegrationManagement extends NamedComponent, DisposableBean {
|
||||
|
||||
String METER_PREFIX = "spring.integration.";
|
||||
|
||||
@@ -36,37 +37,35 @@ public interface IntegrationManagement extends DisposableBean {
|
||||
|
||||
String RECEIVE_COUNTER_NAME = METER_PREFIX + "receive";
|
||||
|
||||
/**
|
||||
* Enable logging or not.
|
||||
* @param enabled dalse to disable.
|
||||
*/
|
||||
@ManagedAttribute(description = "Use to disable debug logging during normal message flow")
|
||||
void setLoggingEnabled(boolean enabled);
|
||||
|
||||
/**
|
||||
* Return whether logging is enabled.
|
||||
* @return true if enabled.
|
||||
*/
|
||||
@ManagedAttribute
|
||||
boolean isLoggingEnabled();
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@ManagedOperation
|
||||
void reset();
|
||||
default void setManagedName(String managedName) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @param countsEnabled the countsEnabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@ManagedAttribute(description = "Enable message counting statistics")
|
||||
void setCountsEnabled(boolean countsEnabled);
|
||||
@Nullable
|
||||
default String getManagedName() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @return counts enabled
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@ManagedAttribute
|
||||
boolean isCountsEnabled();
|
||||
default void setManagedType(String managedType) {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
default String getManagedType() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the overrides.
|
||||
@@ -84,14 +83,21 @@ public interface IntegrationManagement extends DisposableBean {
|
||||
// no op
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
default void destroy() {
|
||||
// no op
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return this {@link IntegrationManagement} as its concrete type.
|
||||
* @param <T> the type.
|
||||
* @return this.
|
||||
* @since 5.4
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
default <T> T getThisAs() {
|
||||
return (T) this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggles to inform the management configurer to not set these properties since
|
||||
@@ -104,12 +110,6 @@ public interface IntegrationManagement extends DisposableBean {
|
||||
|
||||
public boolean loggingConfigured; // NOSONAR
|
||||
|
||||
public boolean countsConfigured; // NOSONAR
|
||||
|
||||
public boolean statsConfigured; // NOSONAR
|
||||
|
||||
public boolean metricsConfigured; // NOSONAR
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,203 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
@IntegrationManagedResource
|
||||
public class LifecycleMessageHandlerMetrics implements
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics, Lifecycle,
|
||||
ConfigurableMetricsAware<AbstractMessageHandlerMetrics> {
|
||||
|
||||
private final Lifecycle lifecycle;
|
||||
|
||||
protected final org.springframework.integration.support.management.MessageHandlerMetrics delegate; // NOSONAR
|
||||
|
||||
|
||||
public LifecycleMessageHandlerMetrics(Lifecycle lifecycle,
|
||||
org.springframework.integration.support.management.MessageHandlerMetrics delegate) {
|
||||
|
||||
this.lifecycle = lifecycle;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public MessageHandlerMetrics getDelegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public void configureMetrics(AbstractMessageHandlerMetrics metrics) {
|
||||
if (this.delegate instanceof ConfigurableMetricsAware) {
|
||||
((ConfigurableMetricsAware<AbstractMessageHandlerMetrics>) this.delegate).configureMetrics(metrics);
|
||||
}
|
||||
}
|
||||
|
||||
@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 getManagedName() {
|
||||
return this.delegate.getManagedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagedType() {
|
||||
return this.delegate.getManagedType();
|
||||
}
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStatsEnabled(boolean statsEnabled) {
|
||||
this.delegate.setStatsEnabled(statsEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountsEnabled(boolean countsEnabled) {
|
||||
this.delegate.setCountsEnabled(countsEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isStatsEnabled() {
|
||||
return this.delegate.isStatsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCountsEnabled() {
|
||||
return this.delegate.isCountsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoggingEnabled(boolean enabled) {
|
||||
this.delegate.setLoggingEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoggingEnabled() {
|
||||
return this.delegate.isLoggingEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedName(String name) {
|
||||
this.delegate.setManagedName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedType(String source) {
|
||||
this.delegate.setManagedType(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagementOverrides getOverrides() {
|
||||
return this.delegate.getOverrides();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.delegate.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
|
||||
/**
|
||||
* An extension to {@link LifecycleMessageSourceMetrics} for sources that implement {@link MessageSourceManagement}.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 5.0
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LifecycleMessageSourceManagement extends LifecycleMessageSourceMetrics implements MessageSourceManagement {
|
||||
|
||||
public LifecycleMessageSourceManagement(Lifecycle lifecycle, MessageSourceManagement delegate) {
|
||||
super(lifecycle, delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxFetchSize(int maxFetchSize) {
|
||||
((MessageSourceManagement) this.delegate).setMaxFetchSize(maxFetchSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFetchSize() {
|
||||
return ((MessageSourceManagement) this.delegate).getMaxFetchSize();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
@IntegrationManagedResource
|
||||
public class LifecycleMessageSourceMetrics implements MessageSourceMetrics, Lifecycle {
|
||||
|
||||
private final Lifecycle lifecycle;
|
||||
|
||||
protected final MessageSourceMetrics delegate; // NOSONAR final
|
||||
|
||||
|
||||
public LifecycleMessageSourceMetrics(Lifecycle lifecycle, MessageSourceMetrics delegate) {
|
||||
this.lifecycle = lifecycle;
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
public MessageSourceMetrics getDelegate() {
|
||||
return this.delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ManagedOperation
|
||||
public void reset() {
|
||||
this.delegate.reset();
|
||||
}
|
||||
|
||||
@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 String getManagedName() {
|
||||
return this.delegate.getManagedName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManagedType() {
|
||||
return this.delegate.getManagedType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMessageCount() {
|
||||
return this.delegate.getMessageCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMessageCountLong() {
|
||||
return this.delegate.getMessageCountLong();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCountsEnabled(boolean countsEnabled) {
|
||||
this.delegate.setCountsEnabled(countsEnabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCountsEnabled() {
|
||||
return this.delegate.isCountsEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLoggingEnabled(boolean enabled) {
|
||||
this.delegate.setLoggingEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLoggingEnabled() {
|
||||
return this.delegate.isLoggingEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedName(String name) {
|
||||
this.delegate.setManagedName(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setManagedType(String source) {
|
||||
this.delegate.setManagedType(source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ManagementOverrides getOverrides() {
|
||||
return this.delegate.getOverrides();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroy() {
|
||||
this.delegate.destroy();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Adds {@link TrackableComponent}.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
@Deprecated
|
||||
@IntegrationManagedResource
|
||||
public class LifecycleTrackableMessageHandlerMetrics extends LifecycleMessageHandlerMetrics
|
||||
implements TrackableComponent {
|
||||
|
||||
private final TrackableComponent trackable;
|
||||
|
||||
public LifecycleTrackableMessageHandlerMetrics(Lifecycle lifecycle, MessageHandlerMetrics delegate) {
|
||||
super(lifecycle, delegate);
|
||||
Assert.isInstanceOf(TrackableComponent.class, delegate);
|
||||
this.trackable = (TrackableComponent) delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBeanName() {
|
||||
return this.trackable.getBeanName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return this.trackable.getComponentName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return this.trackable.getComponentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldTrack(boolean shouldTrack) {
|
||||
this.trackable.setShouldTrack(shouldTrack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright 2016-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
|
||||
/**
|
||||
* An extension to {@link LifecycleTrackableMessageSourceMetrics} for sources
|
||||
* that implement {@link MessageSourceManagement}.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 5.0
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class LifecycleTrackableMessageSourceManagement extends LifecycleTrackableMessageSourceMetrics
|
||||
implements MessageSourceManagement {
|
||||
|
||||
public LifecycleTrackableMessageSourceManagement(Lifecycle lifecycle, MessageSourceManagement delegate) {
|
||||
super(lifecycle, delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaxFetchSize(int maxFetchSize) {
|
||||
((MessageSourceManagement) this.delegate).setMaxFetchSize(maxFetchSize);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFetchSize() {
|
||||
return ((MessageSourceManagement) this.delegate).getMaxFetchSize();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Adds {@link TrackableComponent}.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public class LifecycleTrackableMessageSourceMetrics extends LifecycleMessageSourceMetrics
|
||||
implements TrackableComponent {
|
||||
|
||||
private final TrackableComponent trackable;
|
||||
|
||||
public LifecycleTrackableMessageSourceMetrics(Lifecycle lifecycle, MessageSourceMetrics delegate) {
|
||||
super(lifecycle, delegate);
|
||||
Assert.isInstanceOf(TrackableComponent.class, lifecycle);
|
||||
this.trackable = (TrackableComponent) lifecycle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBeanName() {
|
||||
return this.trackable.getBeanName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return this.trackable.getComponentName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return this.trackable.getComponentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldTrack(boolean shouldTrack) {
|
||||
this.trackable.setShouldTrack(shouldTrack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015-2020 the original author or authors.
|
||||
* Copyright 2020 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,24 +16,29 @@
|
||||
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedOperation;
|
||||
|
||||
/**
|
||||
* Base interface containing methods to control complete statistics gathering.
|
||||
* Makes {@link Lifecycle} methods manageable.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
* @since 5.4
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface IntegrationStatsManagement extends IntegrationManagement {
|
||||
public interface ManageableLifecycle extends Lifecycle {
|
||||
|
||||
@ManagedAttribute(description = "Enable all statistics")
|
||||
void setStatsEnabled(boolean statsEnabled);
|
||||
@ManagedOperation(description = "Start the component")
|
||||
@Override
|
||||
void start();
|
||||
|
||||
@ManagedAttribute
|
||||
boolean isStatsEnabled();
|
||||
@ManagedOperation(description = "Stop the component")
|
||||
@Override
|
||||
void stop();
|
||||
|
||||
@ManagedAttribute(description = "Is the component running?")
|
||||
@Override
|
||||
boolean isRunning();
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2019 the original author or authors.
|
||||
* Copyright 2020 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,17 +16,15 @@
|
||||
|
||||
package org.springframework.integration.support.management;
|
||||
|
||||
import org.springframework.context.SmartLifecycle;
|
||||
|
||||
/**
|
||||
* Extend {@link ManageableLifecycle} to make those methods manageable.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 5.2
|
||||
* @since 5.4
|
||||
*
|
||||
*/
|
||||
public interface BaseSourceMetrics extends IntegrationManagement {
|
||||
|
||||
/**
|
||||
* The number of successful message receptions.
|
||||
* @return the count.
|
||||
*/
|
||||
long messageCount();
|
||||
public interface ManageableSmartLifecycle extends SmartLifecycle, ManageableLifecycle {
|
||||
|
||||
}
|
||||
@@ -1,136 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
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
|
||||
* @author Gary Russell
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MessageChannelMetrics extends BaseChannelMetrics {
|
||||
|
||||
/**
|
||||
* @return the number of successful sends
|
||||
*/
|
||||
@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();
|
||||
|
||||
|
||||
@Override
|
||||
default long sendCount() {
|
||||
return 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();
|
||||
|
||||
@Override
|
||||
default long sendErrorCount() {
|
||||
return getSendErrorCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the time in milliseconds since the last send
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Channel Time Since Last Send in Milliseconds")
|
||||
double getTimeSinceLastSend();
|
||||
|
||||
/**
|
||||
* @return the mean send rate (per second)
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Channel Send Rate per Second")
|
||||
double getMeanSendRate();
|
||||
|
||||
/**
|
||||
* @return the mean error rate (per second). Errors comprise all failed sends.
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Channel Error Rate per Second")
|
||||
double getMeanErrorRate();
|
||||
|
||||
/**
|
||||
* @return the mean ratio of failed to successful sends in approximately the last minute
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Mean Channel Error Ratio per Minute")
|
||||
double getMeanErrorRatio();
|
||||
|
||||
/**
|
||||
* @return the mean send duration (milliseconds)
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Channel Send Mean Duration in Milliseconds")
|
||||
double getMeanSendDuration();
|
||||
|
||||
/**
|
||||
* @return the minimum send duration (milliseconds) since startup
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Channel Send Min Duration in Milliseconds")
|
||||
double getMinSendDuration();
|
||||
|
||||
/**
|
||||
* @return the maximum send duration (milliseconds) since startup
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Channel Send Max Duration in Milliseconds")
|
||||
double getMaxSendDuration();
|
||||
|
||||
/**
|
||||
* @return the standard deviation send duration (milliseconds)
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Channel Send Standard Deviation Duration in Milliseconds")
|
||||
double getStandardDeviationSendDuration();
|
||||
|
||||
/**
|
||||
* @return summary statistics about the send duration (milliseconds)
|
||||
*/
|
||||
Statistics getSendDuration();
|
||||
|
||||
/**
|
||||
* @return summary statistics about the send rates (per second)
|
||||
*/
|
||||
Statistics getSendRate();
|
||||
|
||||
/**
|
||||
* @return summary statistics about the error rates (per second)
|
||||
*/
|
||||
Statistics getErrorRate();
|
||||
|
||||
}
|
||||
@@ -1,113 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MessageHandlerMetrics extends BaseHandlerMetrics {
|
||||
|
||||
/**
|
||||
* @return the number of successful handler calls
|
||||
*/
|
||||
@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();
|
||||
|
||||
|
||||
@Override
|
||||
default long handleCount() {
|
||||
return 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();
|
||||
|
||||
@Override
|
||||
default long errorCount() {
|
||||
return getErrorCountLong();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the mean handler duration (milliseconds)
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Handler Mean Duration in Milliseconds")
|
||||
double getMeanDuration();
|
||||
|
||||
/**
|
||||
* @return the minimum handler duration (milliseconds)
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Handler Min Duration in Milliseconds")
|
||||
double getMinDuration();
|
||||
|
||||
/**
|
||||
* @return the maximum handler duration (milliseconds)
|
||||
*/
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "Handler Max Duration in Milliseconds")
|
||||
double getMaxDuration();
|
||||
|
||||
/**
|
||||
* @return the standard deviation handler duration (milliseconds)
|
||||
*/
|
||||
@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)
|
||||
*/
|
||||
Statistics getDuration();
|
||||
|
||||
void setManagedName(String name);
|
||||
|
||||
String getManagedName();
|
||||
|
||||
void setManagedType(String source);
|
||||
|
||||
String getManagedType();
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2019 the original author or authors.
|
||||
* Copyright 2016-2020 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.
|
||||
@@ -28,7 +28,7 @@ import org.springframework.jmx.export.annotation.ManagedAttribute;
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
@IntegrationManagedResource
|
||||
public interface MessageSourceManagement extends MessageSourceMetrics {
|
||||
public interface MessageSourceManagement {
|
||||
|
||||
/**
|
||||
* Set the maximum number of objects the source should fetch if it is necessary to
|
||||
|
||||
@@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MessageSourceMetrics extends BaseSourceMetrics {
|
||||
|
||||
/**
|
||||
* @return the number of successful message receptions.
|
||||
*/
|
||||
@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();
|
||||
|
||||
@Override
|
||||
default long messageCount() {
|
||||
return getMessageCountLong();
|
||||
}
|
||||
|
||||
void setManagedName(String name);
|
||||
|
||||
String getManagedName();
|
||||
|
||||
void setManagedType(String source);
|
||||
|
||||
String getManagedType();
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
/*
|
||||
* Copyright 2018-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
/**
|
||||
* Perform additional configuration on {@link MessageSourceMetrics}.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 5.0.2
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
@FunctionalInterface
|
||||
public interface MessageSourceMetricsConfigurer {
|
||||
|
||||
void configure(MessageSourceMetrics metrics, String beanName);
|
||||
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
/**
|
||||
* Interface representing an opaque object containing state between initiating an
|
||||
* event and concluding it.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MetricsContext {
|
||||
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
/**
|
||||
* Factories implementing this interface provide metric objects for message channels and
|
||||
* message handlers.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
@Deprecated
|
||||
public interface MetricsFactory {
|
||||
|
||||
/**
|
||||
* Factory method to create an {@link AbstractMessageChannelMetrics}.
|
||||
* @param name the name.
|
||||
* @return the metrics.
|
||||
*/
|
||||
AbstractMessageChannelMetrics createChannelMetrics(String name);
|
||||
|
||||
/**
|
||||
* Factory method to create an {@link AbstractMessageChannelMetrics} for
|
||||
* a pollable channel.
|
||||
* @param name the name.
|
||||
* @return the metrics.
|
||||
* @since 5.0.2
|
||||
*/
|
||||
default AbstractMessageChannelMetrics createPollableChannelMetrics(String name) {
|
||||
return createChannelMetrics(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory method to create an {@link AbstractMessageHandlerMetrics}.
|
||||
* @param name the name.
|
||||
* @return the metrics.
|
||||
*/
|
||||
AbstractMessageHandlerMetrics createHandlerMetrics(String name);
|
||||
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* Metrics for pollable channels.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface PollableChannelManagement extends PollableChannelMetrics {
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count")
|
||||
int getReceiveCount();
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Count")
|
||||
long getReceiveCountLong();
|
||||
|
||||
@Override
|
||||
default long receiveCount() {
|
||||
return getReceiveCountLong();
|
||||
}
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Error Count")
|
||||
int getReceiveErrorCount();
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "MessageChannel Receive Error Count")
|
||||
long getReceiveErrorCountLong();
|
||||
|
||||
@Override
|
||||
default long receiveErrorCount() {
|
||||
return getReceiveErrorCountLong();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2019-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @since 5.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface PollableChannelMetrics extends IntegrationStatsManagement {
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Receive Count")
|
||||
long receiveCount();
|
||||
|
||||
@ManagedMetric(metricType = MetricType.COUNTER, displayName = "Channel Receive Error Count")
|
||||
long receiveErrorCount();
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.jmx.export.annotation.ManagedMetric;
|
||||
import org.springframework.jmx.support.MetricType;
|
||||
|
||||
/**
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface QueueChannelManagement extends PollableChannelManagement {
|
||||
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "QueueChannel Queue Size")
|
||||
int getQueueSize();
|
||||
|
||||
@ManagedMetric(metricType = MetricType.GAUGE, displayName = "QueueChannel Remaining Capacity")
|
||||
int getRemainingCapacity();
|
||||
|
||||
}
|
||||
@@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
|
||||
/**
|
||||
* Allows Router operations to appear in the same MBean as statistics.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @since 4.2
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
@SuppressWarnings("deprecation")
|
||||
public class RouterMetrics extends LifecycleMessageHandlerMetrics implements MappingMessageRouterManagement {
|
||||
|
||||
private final MappingMessageRouterManagement router;
|
||||
|
||||
public RouterMetrics(Lifecycle lifecycle, MappingMessageRouterManagement delegate) {
|
||||
super(lifecycle, (MessageHandlerMetrics) delegate);
|
||||
this.router = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChannelMapping(String key, String channelName) {
|
||||
this.router.setChannelMapping(key, channelName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeChannelMapping(String key) {
|
||||
this.router.removeChannelMapping(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void replaceChannelMappings(Properties channelMappings) {
|
||||
this.router.replaceChannelMappings(channelMappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> getChannelMappings() {
|
||||
return this.router.getChannelMappings();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setChannelMappings(Map<String, String> channelMappings) {
|
||||
this.router.setChannelMappings(channelMappings);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<String> getDynamicChannelNames() {
|
||||
return this.router.getDynamicChannelNames();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,86 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
/**
|
||||
* Statistics.
|
||||
* @deprecated in favor of dimensional metrics via
|
||||
* {@link org.springframework.integration.support.management.metrics.MeterFacade}.
|
||||
* Built-in metrics will be removed in a future release.
|
||||
*
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @since 2.0
|
||||
*/
|
||||
@Deprecated
|
||||
public class Statistics {
|
||||
|
||||
private final long count;
|
||||
|
||||
private final double min;
|
||||
|
||||
private final double max;
|
||||
|
||||
private double mean;
|
||||
|
||||
private final double standardDeviation;
|
||||
|
||||
|
||||
public Statistics(long count, double min, double max, double mean, double standardDeviation) {
|
||||
this.count = count;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
this.mean = mean;
|
||||
this.standardDeviation = standardDeviation;
|
||||
}
|
||||
|
||||
|
||||
public int getCount() {
|
||||
return (int) this.count;
|
||||
}
|
||||
|
||||
public long getCountLong() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public double getMin() {
|
||||
return this.min;
|
||||
}
|
||||
|
||||
public double getMax() {
|
||||
return this.max;
|
||||
}
|
||||
|
||||
public double getMean() {
|
||||
return this.mean;
|
||||
}
|
||||
|
||||
public void setMean(double mean) {
|
||||
this.mean = mean;
|
||||
}
|
||||
|
||||
public double getStandardDeviation() {
|
||||
return this.standardDeviation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("[N=%d, min=%f, max=%f, mean=%f, sigma=%f]",
|
||||
this.count, this.min, this.max, getMean(), getStandardDeviation());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright 2015-2020 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
/**
|
||||
* Adds {@link TrackableComponent}.
|
||||
*
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
*
|
||||
* @since 2.0
|
||||
*
|
||||
* @deprecated in favor of Micrometer metrics.
|
||||
*/
|
||||
@Deprecated
|
||||
public class TrackableRouterMetrics extends RouterMetrics implements TrackableComponent {
|
||||
|
||||
private final TrackableComponent trackable;
|
||||
|
||||
public TrackableRouterMetrics(Lifecycle lifecycle, MappingMessageRouterManagement delegate) {
|
||||
super(lifecycle, delegate);
|
||||
Assert.isInstanceOf(TrackableComponent.class, delegate);
|
||||
this.trackable = (TrackableComponent) delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBeanName() {
|
||||
return this.trackable.getBeanName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentName() {
|
||||
return this.trackable.getComponentName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getComponentType() {
|
||||
return this.trackable.getComponentType();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setShouldTrack(boolean shouldTrack) {
|
||||
this.trackable.setShouldTrack(shouldTrack);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -25,6 +25,7 @@ import org.springframework.integration.handler.MessageProcessor;
|
||||
import org.springframework.integration.support.AbstractIntegrationMessageBuilder;
|
||||
import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
||||
import org.springframework.integration.support.MessageBuilderFactory;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.integration.support.utils.IntegrationUtils;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageHeaders;
|
||||
@@ -38,7 +39,7 @@ import org.springframework.util.ObjectUtils;
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
public abstract class AbstractMessageProcessingTransformer
|
||||
implements Transformer, BeanFactoryAware, Lifecycle {
|
||||
implements Transformer, BeanFactoryAware, ManageableLifecycle {
|
||||
|
||||
private final MessageProcessor<?> messageProcessor;
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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,6 @@ import java.util.Map;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.BeanFactoryAware;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.context.Lifecycle;
|
||||
import org.springframework.expression.EvaluationContext;
|
||||
import org.springframework.expression.Expression;
|
||||
import org.springframework.expression.spel.SpelParserConfiguration;
|
||||
@@ -34,6 +33,7 @@ import org.springframework.integration.expression.ExpressionUtils;
|
||||
import org.springframework.integration.gateway.MessagingGatewaySupport;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.DefaultMessageBuilderFactory;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.integration.transformer.support.HeaderValueMessageProcessor;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.messaging.MessageChannel;
|
||||
@@ -57,7 +57,7 @@ import org.springframework.util.ReflectionUtils;
|
||||
*
|
||||
* @since 2.1
|
||||
*/
|
||||
public class ContentEnricher extends AbstractReplyProducingMessageHandler implements Lifecycle {
|
||||
public class ContentEnricher extends AbstractReplyProducingMessageHandler implements ManageableLifecycle {
|
||||
|
||||
/**
|
||||
* Customized SpelExpressionParser to allow to specify nested properties when paren is null
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.springframework.integration.IntegrationPattern;
|
||||
import org.springframework.integration.IntegrationPatternType;
|
||||
import org.springframework.integration.handler.AbstractReplyProducingMessageHandler;
|
||||
import org.springframework.integration.support.context.NamedComponent;
|
||||
import org.springframework.integration.support.management.ManageableLifecycle;
|
||||
import org.springframework.messaging.Message;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -38,7 +39,7 @@ import org.springframework.util.Assert;
|
||||
* @author Artem Bilan
|
||||
* @author Gary Russell
|
||||
*/
|
||||
public class MessageTransformingHandler extends AbstractReplyProducingMessageHandler implements Lifecycle {
|
||||
public class MessageTransformingHandler extends AbstractReplyProducingMessageHandler implements ManageableLifecycle {
|
||||
|
||||
private final Transformer transformer;
|
||||
|
||||
|
||||
@@ -4918,69 +4918,6 @@ The list of component name patterns you want to track (e.g., tracked-components
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="default-counts-enabled" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The default value for components that don't match 'counts-enabled-patterns'.
|
||||
Defaults to false, or true when an Integration MBean Exporter is provided.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="default-stats-enabled" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
The default value for components that don't match 'stats-enabled-patterns'.
|
||||
Defaults to false, or true when an Integration MBean Exporter is provided.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="counts-enabled-patterns" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Comma separated list of simple patterns for component names for which message counts
|
||||
will be enabled (defaults to '*'). Only patterns that also match 'managed-components'
|
||||
will be considered. Enables message counting (`sendCount`, `errorCount`, `receiveCount`)
|
||||
for those components that support counters (channels, message handlers, etc).
|
||||
This is the initial setting only, individual components can have counts enabled/disabled
|
||||
at runtime. May be overridden by an entry in 'stats-enabled' which is additional
|
||||
functionality over simple counts. If a pattern starts with `!`, counts are disabled
|
||||
for matches. For components with names that match multiple patterns, the first pattern wins.
|
||||
Disabling counts at runtime also disables stats.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="stats-enabled-patterns" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:documentation>
|
||||
Comma separated list of simple patterns for component names for which message statistics
|
||||
will be enabled (response times, rates etc), as well as counts (a positive match here
|
||||
overrides `counts-enabled`, you can't have statistics without counts).
|
||||
(defaults to '*'). Only patterns that also match 'managed-components'
|
||||
will be considered. Enables statistics for those components that support
|
||||
statistics (channels - when sending, message handlers, etc).
|
||||
This is the initial setting only, individual components can have stats enabled/disabled
|
||||
at runtime. If a pattern starts with `!`, stats (and counts) are disabled
|
||||
for matches. Note: this means that '!foo' here will disable stats
|
||||
and counts for 'foo' even if counts are enabled for 'foo' in 'counts-enabled'.
|
||||
For components with names that match multiple patterns, the first pattern wins.
|
||||
Enabling stats at runtime also enables counts.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
<xsd:attribute name="metrics-factory" use="optional">
|
||||
<xsd:annotation>
|
||||
<xsd:appinfo>
|
||||
<tool:annotation kind="ref">
|
||||
<tool:expected-type
|
||||
type="org.springframework.integration.support.management.MetricsFactory"/>
|
||||
</tool:annotation>
|
||||
</xsd:appinfo>
|
||||
<xsd:documentation>
|
||||
A MetricsFactory responsible for creating objects that maintain metrics for message
|
||||
channels and message handlers.
|
||||
</xsd:documentation>
|
||||
</xsd:annotation>
|
||||
</xsd:attribute>
|
||||
</xsd:complexType>
|
||||
</xsd:element>
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ class MessageChannelReactiveUtilsTests {
|
||||
@Disabled("Backpressure is not honored")
|
||||
void testOverproducingWithSubscribableChannel() {
|
||||
DirectChannel channel = new DirectChannel();
|
||||
channel.setCountsEnabled(true);
|
||||
|
||||
Disposable.Composite compositeDisposable = Disposables.composite();
|
||||
AtomicInteger sendCount = new AtomicInteger();
|
||||
|
||||
@@ -148,15 +148,9 @@ public class ManualFlowTests {
|
||||
|
||||
assertThat(replyProducers.contains(bridgeHandler)).isTrue();
|
||||
|
||||
assertThat(this.integrationManagementConfigurer.getChannelMetrics("channel")).isNotNull();
|
||||
assertThat(this.integrationManagementConfigurer.getHandlerMetrics("bridge")).isNotNull();
|
||||
|
||||
flowRegistration.destroy();
|
||||
|
||||
assertThat(replyProducers.contains(bridgeHandler)).isFalse();
|
||||
|
||||
assertThat(this.integrationManagementConfigurer.getChannelMetrics("channel")).isNull();
|
||||
assertThat(this.integrationManagementConfigurer.getHandlerMetrics("bridge")).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2019 the original author or authors.
|
||||
* Copyright 2002-2020 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.
|
||||
@@ -73,7 +73,6 @@ public class MessagingGatewayTests {
|
||||
this.messagingGateway.setReplyChannel(this.replyChannel);
|
||||
|
||||
this.messagingGateway.setBeanFactory(this.applicationContext);
|
||||
this.messagingGateway.setCountsEnabled(true);
|
||||
this.messagingGateway.afterPropertiesSet();
|
||||
this.messagingGateway.start();
|
||||
this.applicationContext.refresh();
|
||||
@@ -93,7 +92,8 @@ public class MessagingGatewayTests {
|
||||
Mockito.when(requestChannel.send(messageMock, 1000L)).thenReturn(true);
|
||||
this.messagingGateway.send(messageMock);
|
||||
Mockito.verify(requestChannel).send(messageMock, 1000L);
|
||||
assertThat(this.messagingGateway.getMessageCount()).isEqualTo(1);
|
||||
// TODO Micrometer counter
|
||||
// assertThat(this.messagingGateway.getMessageCount()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test(expected = MessageDeliveryException.class)
|
||||
|
||||
@@ -72,8 +72,6 @@ import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.databind.module.SimpleModule;
|
||||
import com.fasterxml.jackson.databind.ser.std.NullSerializer;
|
||||
import io.micrometer.core.instrument.MeterRegistry;
|
||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
|
||||
import net.minidev.json.JSONArray;
|
||||
@@ -154,16 +152,12 @@ public class IntegrationGraphServerTests {
|
||||
|
||||
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router')]");
|
||||
String routerJson = jsonArray.toJSONString();
|
||||
assertThat(routerJson).contains("\"deprecated\":\"stats are deprecated");
|
||||
|
||||
|
||||
this.server.rebuild();
|
||||
graph = this.server.getGraph();
|
||||
baos = new ByteArrayOutputStream();
|
||||
objectMapper = new ObjectMapper();
|
||||
objectMapper.enable(SerializationFeature.INDENT_OUTPUT);
|
||||
objectMapper.registerModule(new SimpleModule().addSerializer(IntegrationNode.Stats.class,
|
||||
NullSerializer.instance));
|
||||
objectMapper.writeValue(baos, graph);
|
||||
|
||||
// System . out . println(new String(baos.toByteArray()));
|
||||
@@ -179,7 +173,6 @@ public class IntegrationGraphServerTests {
|
||||
|
||||
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router')]");
|
||||
routerJson = jsonArray.toJSONString();
|
||||
assertThat(routerJson).contains("\"stats\":null");
|
||||
assertThat(routerJson).contains("\"sendTimers\":{\"successes\":{\"count\":4");
|
||||
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'toRouter')]");
|
||||
String toRouterJson = jsonArray.toJSONString();
|
||||
|
||||
@@ -1,175 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Deque;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.assertj.core.data.Offset;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
import org.springframework.util.StopWatch;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Steven Swor
|
||||
* @author Artem Bilan
|
||||
*/
|
||||
@Ignore("Very sensitive to the time. Don't forget to test after some changes.")
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageRateTests {
|
||||
|
||||
private static final Log logger = LogFactory.getLog(ExponentialMovingAverageRateTests.class);
|
||||
|
||||
private final ExponentialMovingAverageRate history = new ExponentialMovingAverageRate(1., 10., 10, true);
|
||||
|
||||
@Test
|
||||
public void testGetCount() {
|
||||
assertThat(history.getCount()).isEqualTo(0);
|
||||
history.increment();
|
||||
assertThat(history.getCount()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetTimeSinceLastMeasurement() {
|
||||
long sleepTime = 20L;
|
||||
|
||||
// fill history with the same value.
|
||||
long now = System.nanoTime() - 2 * sleepTime * 1000000;
|
||||
for (int i = 0; i < TestUtils.getPropertyValue(history, "retention", Integer.class); i++) {
|
||||
history.increment(now);
|
||||
}
|
||||
final Deque<Long> times = TestUtils.getPropertyValue(history, "times", Deque.class);
|
||||
assertThat(times.peekFirst()).isEqualTo(Long.valueOf(now));
|
||||
assertThat(times.peekLast()).isEqualTo(Long.valueOf(now));
|
||||
|
||||
//increment just so we'll have a different value between first and last
|
||||
history.increment(System.nanoTime() - sleepTime * 1000000);
|
||||
assertThat(times.peekLast()).isNotEqualTo(times.peekFirst());
|
||||
|
||||
/*
|
||||
* We've called Thread.sleep twice with the same value in quick
|
||||
* succession. If timeSinceLastSend is pulling off the correct end of
|
||||
* the queue, then we should be closer to the sleep time than we are to
|
||||
* 2 x sleepTime, but we should definitely be greater than the sleep
|
||||
* time.
|
||||
*/
|
||||
double timeSinceLastMeasurement = history.getTimeSinceLastMeasurement();
|
||||
assertThat(timeSinceLastMeasurement > sleepTime).isTrue();
|
||||
assertThat(timeSinceLastMeasurement <= (1.5 * sleepTime)).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEarlyMean() throws Exception {
|
||||
long t0 = System.currentTimeMillis();
|
||||
assertThat(history.getMean()).isCloseTo(0, Offset.offset(0.01));
|
||||
Thread.sleep(20L);
|
||||
history.increment();
|
||||
long elapsed = System.currentTimeMillis() - t0;
|
||||
if (elapsed < 30L) {
|
||||
assertThat(history.getMean() > 10).isTrue();
|
||||
}
|
||||
else {
|
||||
logger.warn("Test took too long to verify mean");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMean() throws Exception {
|
||||
long t0 = System.currentTimeMillis();
|
||||
assertThat(history.getMean()).isCloseTo(0, Offset.offset(0.01));
|
||||
Thread.sleep(20L);
|
||||
history.increment();
|
||||
Thread.sleep(20L);
|
||||
history.increment();
|
||||
double before = history.getMean();
|
||||
Statistics statisticsBefore = history.getStatistics();
|
||||
long elapsed = System.currentTimeMillis() - t0;
|
||||
if (elapsed < 50L) {
|
||||
assertThat(before > 10).isTrue();
|
||||
Thread.sleep(20L);
|
||||
elapsed = System.currentTimeMillis() - t0;
|
||||
if (elapsed < 80L) {
|
||||
assertThat(history.getMean()).isLessThan(before);
|
||||
assertThat(history.getStatistics().getMean()).isLessThan(statisticsBefore.getMean());
|
||||
}
|
||||
else {
|
||||
logger.warn("Test took too long to verify mean");
|
||||
}
|
||||
}
|
||||
else {
|
||||
logger.warn("Test took too long to verify mean");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStandardDeviation() throws Exception {
|
||||
assertThat(history.getStandardDeviation()).isCloseTo(0, Offset.offset(0.01));
|
||||
Thread.sleep(20L);
|
||||
history.increment();
|
||||
Thread.sleep(22L);
|
||||
history.increment();
|
||||
Thread.sleep(18L);
|
||||
assertThat(history.getStandardDeviation() > 0).as("Standard deviation should be non-zero: " + history).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReset() throws Exception {
|
||||
assertThat(history.getStandardDeviation()).isCloseTo(0, Offset.offset(0.01));
|
||||
history.increment();
|
||||
Thread.sleep(30L);
|
||||
history.increment();
|
||||
assertThat(0.0).isNotEqualTo(history.getStandardDeviation());
|
||||
history.reset();
|
||||
assertThat(history.getStandardDeviation()).isCloseTo(0, Offset.offset(0.01));
|
||||
assertThat(history.getCount()).isEqualTo(0);
|
||||
assertThat(history.getTimeSinceLastMeasurement()).isCloseTo(0, Offset.offset(0.01));
|
||||
assertThat(history.getMean()).isCloseTo(0, Offset.offset(0.01));
|
||||
assertThat(history.getMin()).isCloseTo(0, Offset.offset(0.01));
|
||||
assertThat(history.getMax()).isCloseTo(0, Offset.offset(0.01));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRate() {
|
||||
ExponentialMovingAverageRate rate = new ExponentialMovingAverageRate(1, 60, 10);
|
||||
int count = 1000000;
|
||||
StopWatch watch = new StopWatch();
|
||||
watch.start();
|
||||
for (int i = 0; i < count; i++) {
|
||||
rate.increment();
|
||||
}
|
||||
watch.stop();
|
||||
double calculatedRate = count / (double) watch.getTotalTimeMillis() * 1000;
|
||||
assertThat(rate.getMean()).isEqualTo(calculatedRate, Offset.offset(4000000d));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPerf() {
|
||||
ExponentialMovingAverageRate rate = new ExponentialMovingAverageRate(1, 60, 10);
|
||||
for (int i = 0; i < 1000000; i++) {
|
||||
rate.increment();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,202 +0,0 @@
|
||||
/*
|
||||
* Copyright 2002-2019 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
|
||||
*
|
||||
* https://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.support.management;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
import java.util.Deque;
|
||||
|
||||
import org.assertj.core.data.Offset;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.integration.test.util.TestUtils;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
* @author Gary Russell
|
||||
* @author Artem Bilan
|
||||
* @author Steven Swor
|
||||
*/
|
||||
@Ignore("Very sensitive to the time. Don't forget to test after some changes.")
|
||||
@SuppressWarnings("deprecation")
|
||||
public class ExponentialMovingAverageRatioTests {
|
||||
|
||||
private final ExponentialMovingAverageRatio history = new ExponentialMovingAverageRatio(0.5, 10, true);
|
||||
|
||||
@Test
|
||||
public void testGetCount() {
|
||||
assertThat(history.getCount()).isEqualTo(0);
|
||||
history.success();
|
||||
assertThat(history.getCount()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void testGetTimeSinceLastMeasurement() {
|
||||
long sleepTime = 20L;
|
||||
// fill history with the same value.
|
||||
long now = System.nanoTime() - 2 * sleepTime * 1000000;
|
||||
for (int i = 0; i < TestUtils.getPropertyValue(history, "retention", Integer.class); i++) {
|
||||
history.success(now);
|
||||
}
|
||||
final Deque<Long> times = TestUtils.getPropertyValue(history, "times", Deque.class);
|
||||
assertThat(times.peekFirst()).isEqualTo(Long.valueOf(now));
|
||||
assertThat(times.peekLast()).isEqualTo(Long.valueOf(now));
|
||||
|
||||
//increment just so we'll have a different value between first and last
|
||||
history.success(System.nanoTime() - sleepTime * 1000000);
|
||||
assertThat(times.peekLast()).isNotEqualTo(times.peekFirst());
|
||||
|
||||
/*
|
||||
* We've called Thread.sleep twice with the same value in quick
|
||||
* succession. If timeSinceLastSend is pulling off the correct end of
|
||||
* the queue, then we should be closer to the sleep time than we are to
|
||||
* 2 x sleepTime, but we should definitely be greater than the sleep
|
||||
* time.
|
||||
*/
|
||||
double timeSinceLastMeasurement = history.getTimeSinceLastMeasurement();
|
||||
assertThat(timeSinceLastMeasurement).isGreaterThan(sleepTime / 100);
|
||||
assertThat(timeSinceLastMeasurement).isLessThanOrEqualTo(1.5 * sleepTime / 100);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEarlyMean() {
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
history.success();
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetEarlyFailure() {
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
history.failure();
|
||||
assertThat(history.getMean()).isCloseTo(0, Offset.offset(0.01));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDecayedMean() throws Exception {
|
||||
history.failure(System.nanoTime() - 200000000);
|
||||
assertThat(history.getMean()).isCloseTo(average(0, Math.exp(-0.4)), Offset.offset(0.01));
|
||||
history.success();
|
||||
history.failure();
|
||||
double mean = history.getMean();
|
||||
Statistics statistics = history.getStatistics();
|
||||
Thread.sleep(50);
|
||||
assertThat(history.getMean()).isGreaterThan(mean);
|
||||
assertThat(history.getStatistics().getMean()).isGreaterThan(statistics.getMean());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMean() {
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
history.success();
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
history.success();
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
history.success();
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMeanFailuresHighRate() {
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
history.success(); // need an extra now that we can't determine the time between the first and previous
|
||||
history.success();
|
||||
assertThat(history.getMean()).isCloseTo(average(1), Offset.offset(0.01));
|
||||
history.failure();
|
||||
assertThat(history.getMean()).isCloseTo(average(1, 0.5), Offset.offset(0.1));
|
||||
history.success();
|
||||
assertThat(history.getMean()).isCloseTo(average(1, 0.5, 0.67), Offset.offset(0.1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetMeanFailuresLowRate() {
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
history.failure(); // need an extra now that we can't determine the time between the first and previous
|
||||
history.failure();
|
||||
assertThat(history.getMean()).isCloseTo(average(0), Offset.offset(0.01));
|
||||
history.failure();
|
||||
assertThat(history.getMean()).isCloseTo(average(0, 0), Offset.offset(0.01));
|
||||
history.success();
|
||||
assertThat(history.getMean()).isCloseTo(average(0, 0, 0.33), Offset.offset(0.1));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetStandardDeviation() {
|
||||
assertThat(history.getStandardDeviation()).isCloseTo(0, Offset.offset(0.01));
|
||||
history.success();
|
||||
assertThat(history.getStandardDeviation()).isCloseTo(0, Offset.offset(1d));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testReset() {
|
||||
assertThat(history.getStandardDeviation()).isCloseTo(0, Offset.offset(0.01));
|
||||
history.success();
|
||||
history.failure();
|
||||
assertThat(history.getStandardDeviation()).isNotEqualTo(0);
|
||||
history.reset();
|
||||
assertThat(history.getStandardDeviation()).isCloseTo(0, Offset.offset(0.01));
|
||||
assertThat(history.getCount()).isEqualTo(0);
|
||||
assertThat(history.getTimeSinceLastMeasurement()).isCloseTo(0, Offset.offset(0.01));
|
||||
assertThat(history.getMean()).isCloseTo(1, Offset.offset(0.01));
|
||||
assertThat(history.getMin()).isCloseTo(0, Offset.offset(0.01));
|
||||
assertThat(history.getMax()).isCloseTo(0, Offset.offset(0.01));
|
||||
history.success();
|
||||
assertThat(history.getMin()).isCloseTo(1, Offset.offset(0.01));
|
||||
}
|
||||
|
||||
private double average(double... values) {
|
||||
int count = 0;
|
||||
double sum = 0;
|
||||
for (double d : values) {
|
||||
sum += d;
|
||||
count++;
|
||||
}
|
||||
return sum / count;
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRatio() {
|
||||
ExponentialMovingAverageRatio ratio = new ExponentialMovingAverageRatio(60, 10, true);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
if (i % 10 == 1) {
|
||||
ratio.failure();
|
||||
}
|
||||
else {
|
||||
ratio.success();
|
||||
}
|
||||
}
|
||||
assertThat(ratio.getMax()).isCloseTo(0.9, Offset.offset(0.02));
|
||||
assertThat(ratio.getMean()).isCloseTo(0.9, Offset.offset(0.03));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void testPerf() {
|
||||
ExponentialMovingAverageRatio ratio = new ExponentialMovingAverageRatio(60, 10);
|
||||
for (int i = 0; i < 100000; i++) {
|
||||
if (i % 10 == 0) {
|
||||
ratio.failure();
|
||||
}
|
||||
else {
|
||||
ratio.success();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user