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:05:37 UTC

[flink] branch master updated (c5cbd0e -> c3e0d45)

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

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


    from c5cbd0e  [hotfix][docs] Fix table example code
     new 49d3cab  [FLINK-18573][metrics][influxdb] Fix services directory name
     new c3e0d45  [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] 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 master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit c3e0d450c82ea8246a7f0abab3a1f86a0f53de7d
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 49ba309..b520fa7 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 eb95d7f..bcd78a2 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);
+	}
+}


[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 master
in repository https://gitbox.apache.org/repos/asf/flink.git

commit 49d3cabb8ae53900138fc1a2f5178dbec46ce378
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