You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@flink.apache.org by ga...@apache.org on 2019/08/05 09:34:40 UTC
[flink] 01/04: [hotfix][tests] Extract class InfiniteIntegerSource
This is an automated email from the ASF dual-hosted git repository.
gary pushed a commit to branch release-1.9
in repository https://gitbox.apache.org/repos/asf/flink.git
commit 95fc88b6f899f4b95cea8a6d55708681f6a7fd6e
Author: Gary Yao <ga...@apache.org>
AuthorDate: Tue Jul 30 17:38:38 2019 +0200
[hotfix][tests] Extract class InfiniteIntegerSource
---
.../classloading/jar/CustomKvStateProgram.java | 22 +---------
.../flink/test/util/InfiniteIntegerSource.java | 47 ++++++++++++++++++++++
2 files changed, 48 insertions(+), 21 deletions(-)
diff --git a/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CustomKvStateProgram.java b/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CustomKvStateProgram.java
index da33447..d1952cc 100644
--- a/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CustomKvStateProgram.java
+++ b/flink-tests/src/test/java/org/apache/flink/test/classloading/jar/CustomKvStateProgram.java
@@ -29,7 +29,7 @@ import org.apache.flink.configuration.Configuration;
import org.apache.flink.runtime.state.filesystem.FsStateBackend;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
-import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
+import org.apache.flink.test.util.InfiniteIntegerSource;
import org.apache.flink.util.Collector;
import java.util.concurrent.ThreadLocalRandom;
@@ -76,26 +76,6 @@ public class CustomKvStateProgram {
env.execute();
}
- private static class InfiniteIntegerSource implements ParallelSourceFunction<Integer> {
- private static final long serialVersionUID = -7517574288730066280L;
- private volatile boolean running = true;
-
- @Override
- public void run(SourceContext<Integer> ctx) throws Exception {
- int counter = 0;
- while (running) {
- synchronized (ctx.getCheckpointLock()) {
- ctx.collect(counter++);
- }
- }
- }
-
- @Override
- public void cancel() {
- running = false;
- }
- }
-
private static class ReducingStateFlatMap extends RichFlatMapFunction<Tuple2<Integer, Integer>, Integer> {
private static final long serialVersionUID = -5939722892793950253L;
diff --git a/flink-tests/src/test/java/org/apache/flink/test/util/InfiniteIntegerSource.java b/flink-tests/src/test/java/org/apache/flink/test/util/InfiniteIntegerSource.java
new file mode 100644
index 0000000..e4b2e98
--- /dev/null
+++ b/flink-tests/src/test/java/org/apache/flink/test/util/InfiniteIntegerSource.java
@@ -0,0 +1,47 @@
+/*
+ * 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.test.util;
+
+import org.apache.flink.streaming.api.functions.source.ParallelSourceFunction;
+
+/**
+ * Source that emits an integers indefinitely.
+ */
+public class InfiniteIntegerSource implements ParallelSourceFunction<Integer> {
+
+ private static final long serialVersionUID = 1L;
+
+ private volatile boolean running = true;
+
+ @Override
+ public void run(SourceContext<Integer> ctx) throws Exception {
+ int counter = 0;
+ while (running) {
+ synchronized (ctx.getCheckpointLock()) {
+ ctx.collect(counter++);
+ }
+ }
+ }
+
+ @Override
+ public void cancel() {
+ running = false;
+ }
+}