Skip to content

Commit a9cc08d

Browse files
committed
!!!Just For Test: add examples
1 parent cd99ee6 commit a9cc08d

File tree

5 files changed

+196
-0
lines changed

5 files changed

+196
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Licensed to the Apache Software Foundation (ASF) under one
4+
~ or more contributor license agreements. See the NOTICE file
5+
~ distributed with this work for additional information
6+
~ regarding copyright ownership. The ASF licenses this file
7+
~ to you under the Apache License, Version 2.0 (the
8+
~ "License"); you may not use this file except in compliance
9+
~ with the License. You may obtain a copy of the License at
10+
~
11+
~ http://www.apache.org/licenses/LICENSE-2.0
12+
~
13+
~ Unless required by applicable law or agreed to in writing, software
14+
~ distributed under the License is distributed on an "AS IS" BASIS,
15+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
~ See the License for the specific language governing permissions and
17+
~ limitations under the License.
18+
-->
19+
20+
<project xmlns="http://maven.apache.org/POM/4.0.0"
21+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
22+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
23+
<parent>
24+
<artifactId>flink-process-function-parent</artifactId>
25+
<groupId>org.apache.flink</groupId>
26+
<version>1.20-SNAPSHOT</version>
27+
</parent>
28+
<modelVersion>4.0.0</modelVersion>
29+
30+
<artifactId>flink-process-cuntion-example</artifactId>
31+
32+
<properties>
33+
<maven.compiler.source>8</maven.compiler.source>
34+
<maven.compiler.target>8</maven.compiler.target>
35+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
36+
</properties>
37+
38+
<packaging>jar</packaging>
39+
40+
<dependencies>
41+
<dependency>
42+
<groupId>org.apache.flink</groupId>
43+
<artifactId>flink-streaming-java</artifactId>
44+
<version>${project.version}</version>
45+
</dependency>
46+
47+
<dependency>
48+
<groupId>org.apache.flink</groupId>
49+
<artifactId>flink-process-function-api</artifactId>
50+
<version>${project.version}</version>
51+
</dependency>
52+
53+
<dependency>
54+
<groupId>org.apache.flink</groupId>
55+
<artifactId>flink-process-function</artifactId>
56+
<version>${project.version}</version>
57+
</dependency>
58+
59+
<dependency>
60+
<groupId>org.apache.flink</groupId>
61+
<artifactId>flink-clients</artifactId>
62+
<version>${project.version}</version>
63+
</dependency>
64+
65+
66+
<!-- Add a logging Framework, to make the examples produce -->
67+
<!-- logs when executing in the IDE -->
68+
69+
<dependency>
70+
<groupId>org.apache.logging.log4j</groupId>
71+
<artifactId>log4j-slf4j-impl</artifactId>
72+
<scope>compile</scope>
73+
</dependency>
74+
75+
<dependency>
76+
<groupId>org.apache.logging.log4j</groupId>
77+
<artifactId>log4j-api</artifactId>
78+
<scope>compile</scope>
79+
</dependency>
80+
81+
<dependency>
82+
<groupId>org.apache.logging.log4j</groupId>
83+
<artifactId>log4j-core</artifactId>
84+
<scope>compile</scope>
85+
</dependency>
86+
87+
</dependencies>
88+
89+
</project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import org.apache.flink.api.connector.v2.SinkUtils;
20+
import org.apache.flink.api.connector.v2.SourceUtils;
21+
import org.apache.flink.process.api.ExecutionEnvironment;
22+
import org.apache.flink.process.api.common.Collector;
23+
import org.apache.flink.process.api.context.RuntimeContext;
24+
import org.apache.flink.process.api.function.OneInputStreamProcessFunction;
25+
import org.apache.flink.process.api.stream.NonKeyedPartitionStream;
26+
import org.apache.flink.streaming.api.functions.sink.PrintSink;
27+
28+
import java.util.Arrays;
29+
30+
public class Test {
31+
public static void main(String[] args) throws Exception {
32+
ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment();
33+
NonKeyedPartitionStream<String> source =
34+
env.fromSource(SourceUtils.fromData(Arrays.asList("a", "b", "c")), "source");
35+
NonKeyedPartitionStream<String> map =
36+
source.process(
37+
new OneInputStreamProcessFunction<String, String>() {
38+
@Override
39+
public void processRecord(
40+
String record, Collector<String> output, RuntimeContext ctx)
41+
throws Exception {
42+
System.out.println(record);
43+
output.collect(record + "!!!");
44+
}
45+
});
46+
47+
PrintSink<String> sink = new PrintSink<>();
48+
map.toSink(SinkUtils.wrapSink(sink));
49+
50+
env.execute("test job");
51+
}
52+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
################################################################################
2+
# Licensed to the Apache Software Foundation (ASF) under one
3+
# or more contributor license agreements. See the NOTICE file
4+
# distributed with this work for additional information
5+
# regarding copyright ownership. The ASF licenses this file
6+
# to you under the Apache License, Version 2.0 (the
7+
# "License"); you may not use this file except in compliance
8+
# with the License. You may obtain a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS,
14+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
# See the License for the specific language governing permissions and
16+
# limitations under the License.
17+
################################################################################
18+
19+
rootLogger.level = INFO
20+
rootLogger.appenderRef.console.ref = ConsoleAppender
21+
22+
appender.console.name = ConsoleAppender
23+
appender.console.type = CONSOLE
24+
appender.console.layout.type = PatternLayout
25+
appender.console.layout.pattern = %d{yyyy-MM-dd HH:mm:ss,SSS} %-5p %-60c %x - %m%n
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<!--
2+
~ Licensed to the Apache Software Foundation (ASF) under one
3+
~ or more contributor license agreements. See the NOTICE file
4+
~ distributed with this work for additional information
5+
~ regarding copyright ownership. The ASF licenses this file
6+
~ to you under the Apache License, Version 2.0 (the
7+
~ "License"); you may not use this file except in compliance
8+
~ with the License. You may obtain a copy of the License at
9+
~
10+
~ http://www.apache.org/licenses/LICENSE-2.0
11+
~
12+
~ Unless required by applicable law or agreed to in writing, software
13+
~ distributed under the License is distributed on an "AS IS" BASIS,
14+
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
~ See the License for the specific language governing permissions and
16+
~ limitations under the License.
17+
-->
18+
19+
<configuration>
20+
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
21+
<encoder>
22+
<pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{60} %X{sourceThread} - %msg%n</pattern>
23+
</encoder>
24+
</appender>
25+
26+
<root level="INFO">
27+
<appender-ref ref="STDOUT"/>
28+
</root>
29+
</configuration>

Diff for: flink-process-function-parent/pom.xml

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ under the License.
3535
<modules>
3636
<module>flink-process-function</module>
3737
<module>flink-process-function-api</module>
38+
<module>flink-process-function-example</module>
3839
</modules>
3940

4041
</project>

0 commit comments

Comments
 (0)