You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ch...@apache.org on 2020/07/14 18:06:38 UTC

[flink] branch release-1.11 updated (1ee85e3 -> 60cf377)

This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a change to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git.


    from 1ee85e3  [hotfix][docs] Fix table example code
     new 5c73b0c  [FLINK-18573][metrics][influxdb] Fix services directory name
     new 60cf377  [FLINK-18573][metrics] Add test for loading reporters via service loader

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../metrics/util/MetricReporterTestUtils.java      | 51 ++++++++++++++++++++++
 flink-metrics/flink-metrics-datadog/pom.xml        |  8 ++++
 .../datadog/DatadogHttpReporterFactoryTest.java    | 18 ++++----
 flink-metrics/flink-metrics-graphite/pom.xml       | 16 +++++++
 .../graphite/GraphiteReporterFactoryTest.java      | 25 +++++------
 ...he.flink.metrics.reporter.MetricReporterFactory |  0
 .../influxdb/InfluxdbReporterFactoryTest.java      | 25 +++++------
 .../flink/metrics/jmx/JMXReporterFactoryTest.java  |  6 +++
 .../metrics/statsd/StatsDReporterFactoryTest.java  | 25 +++++------
 9 files changed, 123 insertions(+), 51 deletions(-)
 create mode 100644 flink-metrics/flink-metrics-core/src/test/java/org/apache/flink/metrics/util/MetricReporterTestUtils.java
 copy flink-streaming-java/src/test/java/org/apache/flink/streaming/util/EvenOddOutputSelector.java => flink-metrics/flink-metrics-datadog/src/test/java/org/apache/flink/metrics/datadog/DatadogHttpReporterFactoryTest.java (65%)
 copy flink-tests/src/test/java/org/apache/flink/test/checkpointing/utils/IntType.java => flink-metrics/flink-metrics-graphite/src/test/java/org/apache/flink/metrics/graphite/GraphiteReporterFactoryTest.java (65%)
 rename flink-metrics/flink-metrics-influxdb/src/main/resources/META-INF/{service => services}/org.apache.flink.metrics.reporter.MetricReporterFactory (100%)
 copy flink-tests/src/test/java/org/apache/flink/test/checkpointing/utils/IntType.java => flink-metrics/flink-metrics-influxdb/src/test/java/org/apache/flink/metrics/influxdb/InfluxdbReporterFactoryTest.java (65%)
 copy flink-tests/src/test/java/org/apache/flink/test/checkpointing/utils/IntType.java => flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterFactoryTest.java (66%)


[flink] 01/02: [FLINK-18573][metrics][influxdb] Fix services directory name

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 5c73b0c4a1b50d1b2b3a6a3a3637677a143e598f
Author: Yun Tang <my...@live.com>
AuthorDate: Mon Jul 13 18:36:53 2020 +0800

    [FLINK-18573][metrics][influxdb] Fix services directory name
---
 .../org.apache.flink.metrics.reporter.MetricReporterFactory               | 0
 1 file changed, 0 insertions(+), 0 deletions(-)

diff --git a/flink-metrics/flink-metrics-influxdb/src/main/resources/META-INF/service/org.apache.flink.metrics.reporter.MetricReporterFactory b/flink-metrics/flink-metrics-influxdb/src/main/resources/META-INF/services/org.apache.flink.metrics.reporter.MetricReporterFactory
similarity index 100%
rename from flink-metrics/flink-metrics-influxdb/src/main/resources/META-INF/service/org.apache.flink.metrics.reporter.MetricReporterFactory
rename to flink-metrics/flink-metrics-influxdb/src/main/resources/META-INF/services/org.apache.flink.metrics.reporter.MetricReporterFactory


[flink] 02/02: [FLINK-18573][metrics] Add test for loading reporters via service loader

Posted by ch...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

chesnay pushed a commit to branch release-1.11
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 60cf377b01595f257992d8d30d1b236d0f6f0103
Author: Yun Tang <my...@live.com>
AuthorDate: Tue Jul 14 20:01:52 2020 +0200

    [FLINK-18573][metrics] Add test for loading reporters via service loader
---
 .../metrics/util/MetricReporterTestUtils.java      | 51 ++++++++++++++++++++++
 flink-metrics/flink-metrics-datadog/pom.xml        |  8 ++++
 .../datadog/DatadogHttpReporterFactoryTest.java    | 35 +++++++++++++++
 flink-metrics/flink-metrics-graphite/pom.xml       | 16 +++++++
 .../graphite/GraphiteReporterFactoryTest.java      | 35 +++++++++++++++
 .../influxdb/InfluxdbReporterFactoryTest.java      | 35 +++++++++++++++
 .../flink/metrics/jmx/JMXReporterFactoryTest.java  |  6 +++
 .../metrics/statsd/StatsDReporterFactoryTest.java  | 35 +++++++++++++++
 8 files changed, 221 insertions(+)

diff --git a/flink-metrics/flink-metrics-core/src/test/java/org/apache/flink/metrics/util/MetricReporterTestUtils.java b/flink-metrics/flink-metrics-core/src/test/java/org/apache/flink/metrics/util/MetricReporterTestUtils.java
new file mode 100644
index 0000000..93a988d
--- /dev/null
+++ b/flink-metrics/flink-metrics-core/src/test/java/org/apache/flink/metrics/util/MetricReporterTestUtils.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.metrics.util;
+
+import org.apache.flink.metrics.reporter.MetricReporterFactory;
+
+import java.util.ServiceLoader;
+import java.util.Set;
+import java.util.stream.Collectors;
+import java.util.stream.StreamSupport;
+
+import static org.hamcrest.Matchers.hasItem;
+import static org.junit.Assert.assertThat;
+
+/**
+ * Test utils for metric reporters.
+ */
+public class MetricReporterTestUtils {
+
+	/**
+	 * Verifies that the given {@link MetricReporterFactory} class can be loaded by the {@link ServiceLoader}.
+	 *
+	 * <p>Essentially, this verifies that the {@code META-INF/services/org.apache.flink.metrics.reporter.MetricReporterFactory}
+	 * file exists and contains the expected factory class references.
+	 *
+	 * @param clazz class to load
+	 */
+	public static void testMetricReporterSetupViaSPI(final Class<? extends MetricReporterFactory> clazz) {
+		final Set<Class<? extends MetricReporterFactory>> loadedFactories = StreamSupport
+			.stream(ServiceLoader.load(MetricReporterFactory.class).spliterator(), false)
+			.map(MetricReporterFactory::getClass)
+			.collect(Collectors.toSet());
+		assertThat(loadedFactories , hasItem(clazz));
+	}
+}
diff --git a/flink-metrics/flink-metrics-datadog/pom.xml b/flink-metrics/flink-metrics-datadog/pom.xml
index 6cdf64a..8e619da 100644
--- a/flink-metrics/flink-metrics-datadog/pom.xml
+++ b/flink-metrics/flink-metrics-datadog/pom.xml
@@ -64,6 +64,14 @@ under the License.
 			<artifactId>flink-test-utils-junit</artifactId>
 			<version>${project.version}</version>
 		</dependency>
+
+		<dependency>
+			<groupId>org.apache.flink</groupId>
+			<artifactId>flink-metrics-core</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+			<type>test-jar</type>
+		</dependency>
 	</dependencies>
 
 	<build>
diff --git a/flink-metrics/flink-metrics-datadog/src/test/java/org/apache/flink/metrics/datadog/DatadogHttpReporterFactoryTest.java b/flink-metrics/flink-metrics-datadog/src/test/java/org/apache/flink/metrics/datadog/DatadogHttpReporterFactoryTest.java
new file mode 100644
index 0000000..e4f5d3b
--- /dev/null
+++ b/flink-metrics/flink-metrics-datadog/src/test/java/org/apache/flink/metrics/datadog/DatadogHttpReporterFactoryTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.metrics.datadog;
+
+import org.apache.flink.metrics.util.MetricReporterTestUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+/**
+ * Tests for the {@link DatadogHttpReporterFactory}.
+ */
+public class DatadogHttpReporterFactoryTest extends TestLogger {
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		MetricReporterTestUtils.testMetricReporterSetupViaSPI(DatadogHttpReporterFactory.class);
+	}
+}
diff --git a/flink-metrics/flink-metrics-graphite/pom.xml b/flink-metrics/flink-metrics-graphite/pom.xml
index e530c6f..e22b727 100644
--- a/flink-metrics/flink-metrics-graphite/pom.xml
+++ b/flink-metrics/flink-metrics-graphite/pom.xml
@@ -64,6 +64,22 @@ under the License.
 			<artifactId>metrics-graphite</artifactId>
 			<version>${dropwizard.version}</version>
 		</dependency>
+
+		<!-- test dependencies -->
+
+		<dependency>
+			<groupId>org.apache.flink</groupId>
+			<artifactId>flink-test-utils-junit</artifactId>
+			<version>${project.version}</version>
+		</dependency>
+
+		<dependency>
+			<groupId>org.apache.flink</groupId>
+			<artifactId>flink-metrics-core</artifactId>
+			<version>${project.version}</version>
+			<scope>test</scope>
+			<type>test-jar</type>
+		</dependency>
 	</dependencies>
 
 	<build>
diff --git a/flink-metrics/flink-metrics-graphite/src/test/java/org/apache/flink/metrics/graphite/GraphiteReporterFactoryTest.java b/flink-metrics/flink-metrics-graphite/src/test/java/org/apache/flink/metrics/graphite/GraphiteReporterFactoryTest.java
new file mode 100644
index 0000000..b361c82
--- /dev/null
+++ b/flink-metrics/flink-metrics-graphite/src/test/java/org/apache/flink/metrics/graphite/GraphiteReporterFactoryTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.metrics.graphite;
+
+import org.apache.flink.metrics.util.MetricReporterTestUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+/**
+ * Tests for loading {@link GraphiteReporterFactory}.
+ */
+public class GraphiteReporterFactoryTest extends TestLogger {
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		MetricReporterTestUtils.testMetricReporterSetupViaSPI(GraphiteReporterFactory.class);
+	}
+}
diff --git a/flink-metrics/flink-metrics-influxdb/src/test/java/org/apache/flink/metrics/influxdb/InfluxdbReporterFactoryTest.java b/flink-metrics/flink-metrics-influxdb/src/test/java/org/apache/flink/metrics/influxdb/InfluxdbReporterFactoryTest.java
new file mode 100644
index 0000000..8706a88
--- /dev/null
+++ b/flink-metrics/flink-metrics-influxdb/src/test/java/org/apache/flink/metrics/influxdb/InfluxdbReporterFactoryTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.metrics.influxdb;
+
+import org.apache.flink.metrics.util.MetricReporterTestUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+/**
+ * Tests for the {@link InfluxdbReporterFactory}.
+ */
+public class InfluxdbReporterFactoryTest extends TestLogger {
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		MetricReporterTestUtils.testMetricReporterSetupViaSPI(InfluxdbReporterFactory.class);
+	}
+}
diff --git a/flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterFactoryTest.java b/flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterFactoryTest.java
index 0f96435..fe9623b 100644
--- a/flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterFactoryTest.java
+++ b/flink-metrics/flink-metrics-jmx/src/test/java/org/apache/flink/metrics/jmx/JMXReporterFactoryTest.java
@@ -17,6 +17,7 @@
 
 package org.apache.flink.metrics.jmx;
 
+import org.apache.flink.metrics.util.MetricReporterTestUtils;
 import org.apache.flink.util.TestLogger;
 
 import org.junit.Assert;
@@ -61,4 +62,9 @@ public class JMXReporterFactoryTest extends TestLogger {
 			metricReporter.close();
 		}
 	}
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		MetricReporterTestUtils.testMetricReporterSetupViaSPI(JMXReporterFactory.class);
+	}
 }
diff --git a/flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterFactoryTest.java b/flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterFactoryTest.java
new file mode 100644
index 0000000..8a37c66
--- /dev/null
+++ b/flink-metrics/flink-metrics-statsd/src/test/java/org/apache/flink/metrics/statsd/StatsDReporterFactoryTest.java
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.metrics.statsd;
+
+import org.apache.flink.metrics.util.MetricReporterTestUtils;
+import org.apache.flink.util.TestLogger;
+
+import org.junit.Test;
+
+/**
+ * Tests for the {@link StatsDReporterFactory}.
+ */
+public class StatsDReporterFactoryTest extends TestLogger {
+
+	@Test
+	public void testMetricReporterSetupViaSPI() {
+		MetricReporterTestUtils.testMetricReporterSetupViaSPI(StatsDReporterFactory.class);
+	}
+}