Created
January 30, 2017 17:08
-
-
Save GEOFBOT/084397bac7878b3547b7ffed662d930d to your computer and use it in GitHub Desktop.
Multiple Flink jobs in one file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.github.geofbot; | |
import org.apache.commons.cli.*; | |
import org.apache.commons.collections.CollectionUtils; | |
import org.apache.flink.api.common.functions.*; | |
import org.apache.flink.api.common.operators.Order; | |
import org.apache.flink.api.java.DataSet; | |
import org.apache.flink.api.java.ExecutionEnvironment; | |
import org.apache.flink.api.java.aggregation.Aggregations; | |
import org.apache.flink.api.java.operators.IterativeDataSet; | |
import org.apache.flink.api.java.tuple.Tuple2; | |
import org.apache.flink.api.java.tuple.Tuple3; | |
import org.apache.flink.api.java.tuple.Tuple4; | |
import org.apache.flink.api.java.utils.DataSetUtils; | |
import org.apache.flink.core.fs.FileSystem; | |
import org.apache.flink.util.Collector; | |
import java.io.File; | |
import java.util.ArrayList; | |
import java.util.List; | |
import java.util.Random; | |
import static java.lang.Math.round; | |
/** | |
* Experiment file | |
*/ | |
public class Experiment { | |
// | |
// Program | |
// | |
public static void main(String[] args) throws Exception { | |
// Initialize the Flink environment. | |
final ExecutionEnvironment env = ExecutionEnvironment.getExecutionEnvironment(); | |
// Read in the input data. | |
DataSet<Tuple2<Integer, Integer>> e = env.fromElements( | |
new Tuple2<>(0, 1), | |
new Tuple2<>(1, 2), | |
new Tuple2<>(2, 3), | |
new Tuple2<>(2, 10) | |
); | |
e = e.groupBy(0).aggregate(Aggregations.SUM, 1); | |
e.writeAsCsv("/tmp/e1", FileSystem.WriteMode.OVERWRITE); | |
env.execute(); | |
final ExecutionEnvironment env2 = ExecutionEnvironment.getExecutionEnvironment(); | |
DataSet<Tuple2<Integer, Integer>> f = env2.readCsvFile("/tmp/e1") | |
.types(Integer.class, Integer.class); | |
f = f.first(2); | |
f.writeAsCsv("/tmp/f1", FileSystem.WriteMode.OVERWRITE); | |
env2.execute(); | |
} | |
} |
@Johny-Ch Sorry, I'm not sure if this file ever worked. I made it a long time ago for my own testing
No worries will update here If I'm able to figure it out. Thank you for the prompt response.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Tried this and only the first job is executing and don't see the second job. Any inputs?