Add remaining deprecations for legacy metrics

- add a module to suppress legacy metrics from the Integration Graph
- move graph tests package to match src/main

Fix missed deprecation and checkstyle.

More deprecations and remove GraphLegacyStatsNullModule.

* Revert GRAPH_VERSION.
* Fix JavaDocs warnings
* Fix `MBeanExporterParserTests`
This commit is contained in:
Gary Russell
2020-04-21 17:44:05 -04:00
committed by Artem Bilan
parent b06322787e
commit c2babe4ba2
46 changed files with 642 additions and 553 deletions

View File

@@ -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.
@@ -19,6 +19,7 @@ package org.springframework.integration.channel;
import static org.assertj.core.api.Assertions.assertThat;
import java.time.Duration;
import java.util.concurrent.atomic.AtomicInteger;
import org.junit.jupiter.api.Test;
@@ -73,6 +74,7 @@ class MessageChannelReactiveUtilsTests {
channel.setCountsEnabled(true);
Disposable.Composite compositeDisposable = Disposables.composite();
AtomicInteger sendCount = new AtomicInteger();
try {
int initialRequest = 10;
StepVerifier.create(MessageChannelReactiveUtils.toPublisher(channel), initialRequest)
@@ -83,6 +85,7 @@ class MessageChannelReactiveUtilsTests {
while (true) {
if (channel.getSubscriberCount() > 0) {
channel.send(new GenericMessage<>("foo"));
sendCount.incrementAndGet();
}
}
})
@@ -96,7 +99,7 @@ class MessageChannelReactiveUtilsTests {
compositeDisposable.dispose();
}
assertThat(channel.getMetrics().getSendCountLong())
assertThat(sendCount.get())
.as("produced")
.isLessThanOrEqualTo(Queues.SMALL_BUFFER_SIZE);
}

View File

@@ -442,13 +442,7 @@ public class IntegrationFlowTests {
@Test
public void testNullChannelInTheEndOfFlow() {
this.nullChannel.setCountsEnabled(true);
this.flowWithNullChannelInput.send(new GenericMessage<>("foo"));
assertThat(this.nullChannel.getSendCount()).isEqualTo(1);
this.nullChannel.setCountsEnabled(false);
}
@Autowired
@@ -461,13 +455,7 @@ public class IntegrationFlowTests {
@Test
public void testLocalNullChannel() {
this.localNullChannel.setCountsEnabled(true);
this.flowWithLocalNullChannelInput.send(new GenericMessage<>("foo"));
assertThat(this.localNullChannel.getSendCount()).isEqualTo(1);
assertThat(this.localNullChannel).isNotSameAs(this.nullChannel);
}

View File

@@ -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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.springframework.integration.support.management.graph;
package org.springframework.integration.graph;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatIllegalStateException;
@@ -53,8 +53,6 @@ import org.springframework.integration.endpoint.AbstractMessageSource;
import org.springframework.integration.endpoint.EventDrivenConsumer;
import org.springframework.integration.endpoint.MessageProducerSupport;
import org.springframework.integration.endpoint.PollingConsumer;
import org.springframework.integration.graph.Graph;
import org.springframework.integration.graph.IntegrationGraphServer;
import org.springframework.integration.json.JsonPathUtils;
import org.springframework.integration.router.ExpressionEvaluatingRouter;
import org.springframework.integration.router.HeaderValueRouter;
@@ -74,6 +72,8 @@ 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;
@@ -152,10 +152,18 @@ public class IntegrationGraphServerTests {
this.testSource.receive();
this.expressionRouterInput.send(MessageBuilder.withPayload("foo").setHeader("foo", "fizChannel").build());
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()));
@@ -170,8 +178,8 @@ public class IntegrationGraphServerTests {
assertThat(links.size()).isEqualTo(37);
jsonArray = JsonPathUtils.evaluate(baos.toByteArray(), "$..nodes[?(@.name == 'router')]");
String routerJson = jsonArray.toJSONString();
assertThat(routerJson).contains("\"deprecated\":\"stats are deprecated");
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();
@@ -253,7 +261,7 @@ public class IntegrationGraphServerTests {
@EnableIntegration
@EnableIntegrationManagement
@IntegrationComponentScan
@ImportResource("org/springframework/integration/support/management/graph/integration-graph-context.xml")
@ImportResource("org/springframework/integration/graph/integration-graph-context.xml")
public static class Config {
@Bean

View File

@@ -1,71 +0,0 @@
/*
* Copyright 2017-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 org.junit.Test;
import org.springframework.integration.channel.QueueChannel;
import org.springframework.integration.support.MessageBuilder;
import org.springframework.messaging.Message;
/**
* @author Ivan Krizsan
* @author Artem Bilan
*/
public class DefaultMessageChannelMetricsTests {
protected static final int MESSAGE_COUNT = 10;
protected static final long SEND_TIMEOUT = 1;
@Test
public void errorCountWithCountsEnabledOnlySuccessTest() {
final QueueChannel theMessageChannel = new QueueChannel();
theMessageChannel.setCountsEnabled(true);
for (int i = 0; i < MESSAGE_COUNT; i++) {
Message<String> theInputMessage =
MessageBuilder.withPayload(Integer.toString(i)).build();
theMessageChannel.send(theInputMessage, SEND_TIMEOUT);
}
assertThat(theMessageChannel.getSendCount()).as("Message count should match number of sent messages")
.isEqualTo(MESSAGE_COUNT);
assertThat(theMessageChannel.getSendErrorCount()).as("Error count should indicate no errors").isEqualTo(0);
}
@Test
public void errorCountWithCountsEnabledHalfErrorsTest() {
Message<String> theInputMessage;
final QueueChannel theMessageChannel = new QueueChannel(MESSAGE_COUNT / 2);
theMessageChannel.setCountsEnabled(true);
for (int i = 0; i < MESSAGE_COUNT; i++) {
theInputMessage = MessageBuilder.withPayload(Integer.toString(i)).build();
theMessageChannel.send(theInputMessage, SEND_TIMEOUT);
}
assertThat(theMessageChannel.getSendCount()).as("Message count should match number of sent messages")
.isEqualTo(MESSAGE_COUNT);
assertThat(theMessageChannel.getSendErrorCount()).as("Error count should indicate errors half the messages")
.isEqualTo(MESSAGE_COUNT / 2);
}
}

View File

@@ -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.
@@ -37,7 +37,6 @@ import org.springframework.integration.config.IntegrationManagementConfigurer;
import org.springframework.integration.endpoint.AbstractMessageSource;
import org.springframework.integration.handler.AbstractMessageHandler;
import org.springframework.integration.router.RecipientListRouter;
import org.springframework.integration.test.util.TestUtils;
import org.springframework.messaging.MessageChannel;
/**
@@ -94,8 +93,6 @@ public class IntegrationManagementConfigurerTests {
AbstractMessageChannel channel = ctx.getBean("channel", AbstractMessageChannel.class);
assertThat(channel.isCountsEnabled()).isTrue();
assertThat(channel.isStatsEnabled()).isTrue();
assertThat(TestUtils.getPropertyValue(channel, "channelMetrics"))
.isInstanceOf(DefaultMessageChannelMetrics.class);
channel = ctx.getBean("loggingOffChannel", AbstractMessageChannel.class);
assertThat(channel.isLoggingEnabled()).isFalse();
ctx.close();