Java Code Examples for org.apache.flink.streaming.api.environment.StreamExecutionEnvironment#registerCachedFile()
The following examples show how to use
org.apache.flink.streaming.api.environment.StreamExecutionEnvironment#registerCachedFile() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: YarnTestCacheJob.java From flink with Apache License 2.0 | 6 votes |
public static JobGraph getDistributedCacheJobGraph(File testDirectory) { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); final String cacheFilePath = Thread.currentThread().getContextClassLoader() .getResource("cache.properties").getFile(); env.registerCachedFile(testDirectory.getAbsolutePath(), TEST_DIRECTORY_NAME); env.registerCachedFile(cacheFilePath, "cacheFile", false); env.addSource(new GenericSourceFunction(LIST, TypeInformation.of(String.class))) .setParallelism(1) .map(new MapperFunction(), TypeInformation.of(String.class)) .setParallelism(1) .addSink(new DiscardingSink<String>()) .setParallelism(1); return env.getStreamGraph().getJobGraph(); }
Example 2
Source File: DistributedCacheTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testStreamingDistributedCache() throws Exception { String textPath = createTempFile("count.txt", DATA); StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.registerCachedFile(textPath, "cache_test"); env.readTextFile(textPath).flatMap(new WordChecker()); env.execute(); }
Example 3
Source File: DistributedCacheDfsTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testDistributeFileViaDFS() throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.registerCachedFile(testFile.toString(), "test_data", false); env.registerCachedFile(testDir.toString(), "test_dir", false); env.fromElements(1) .map(new TestMapFunction()) .addSink(new DiscardingSink<>()); env.execute("Distributed Cache Via Blob Test Program"); }
Example 4
Source File: DistributedCacheViaBlobTestProgram.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { final ParameterTool params = ParameterTool.fromArgs(args); final Path inputFile = Paths.get(params.getRequired("inputFile")); final Path inputDir = Paths.get(params.getRequired("inputDir")); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.registerCachedFile(inputFile.toString(), "test_data", false); env.registerCachedFile(inputDir.toString(), "test_dir", false); final Path containedFile; try (Stream<Path> files = Files.list(inputDir)) { containedFile = files.findAny().orElseThrow(() -> new RuntimeException("Input directory must not be empty.")); } env.fromElements(1) .map(new TestMapFunction( inputFile.toAbsolutePath().toString(), Files.size(inputFile), inputDir.toAbsolutePath().toString(), containedFile.getFileName().toString())) .writeAsText(params.getRequired("output"), FileSystem.WriteMode.OVERWRITE); env.execute("Distributed Cache Via Blob Test Program"); }
Example 5
Source File: DistributedCacheTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testStreamingDistributedCache() throws Exception { String textPath = createTempFile("count.txt", DATA); StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.registerCachedFile(textPath, "cache_test"); env.readTextFile(textPath).flatMap(new WordChecker()); env.execute(); }
Example 6
Source File: DistributedCacheDfsTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDistributeFileViaDFS() throws Exception { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.registerCachedFile(testFile.toString(), "test_data", false); env.registerCachedFile(testDir.toString(), "test_dir", false); env.fromElements(1) .map(new TestMapFunction()) .addSink(new DiscardingSink<>()); env.execute("Distributed Cache Via Blob Test Program"); }
Example 7
Source File: DistributedCacheViaBlobTestProgram.java From flink with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { final ParameterTool params = ParameterTool.fromArgs(args); final Path inputFile = Paths.get(params.getRequired("inputFile")); final Path inputDir = Paths.get(params.getRequired("inputDir")); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.registerCachedFile(inputFile.toString(), "test_data", false); env.registerCachedFile(inputDir.toString(), "test_dir", false); final Path containedFile; try (Stream<Path> files = Files.list(inputDir)) { containedFile = files.findAny().orElseThrow(() -> new RuntimeException("Input directory must not be empty.")); } env.fromElements(1) .map(new TestMapFunction( inputFile.toAbsolutePath().toString(), Files.size(inputFile), inputDir.toAbsolutePath().toString(), containedFile.getFileName().toString())) .writeAsText(params.getRequired("output"), FileSystem.WriteMode.OVERWRITE); env.execute("Distributed Cache Via Blob Test Program"); }
Example 8
Source File: DistributedCacheTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testStreamingDistributedCache() throws Exception { String textPath = createTempFile("count.txt", DATA); StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.registerCachedFile(textPath, "cache_test"); env.readTextFile(textPath).flatMap(new WordChecker()); env.execute(); }
Example 9
Source File: DistributedCacheDfsTest.java From flink with Apache License 2.0 | 5 votes |
private StreamExecutionEnvironment createJobWithRegisteredCachedFiles() { final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.registerCachedFile(testFile.toString(), "test_data", false); env.registerCachedFile(testDir.toString(), "test_dir", false); env.fromElements(1) .map(new TestMapFunction()) .addSink(new DiscardingSink<>()); return env; }
Example 10
Source File: DistributedCacheViaBlobTestProgram.java From flink with Apache License 2.0 | 5 votes |
public static void main(String[] args) throws Exception { final ParameterTool params = ParameterTool.fromArgs(args); final Path inputFile = Paths.get(params.getRequired("inputFile")); final Path inputDir = Paths.get(params.getRequired("inputDir")); final StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(); env.setParallelism(1); env.registerCachedFile(inputFile.toString(), "test_data", false); env.registerCachedFile(inputDir.toString(), "test_dir", false); final Path containedFile; try (Stream<Path> files = Files.list(inputDir)) { containedFile = files.findAny().orElseThrow(() -> new RuntimeException("Input directory must not be empty.")); } env.fromElements(1) .map(new TestMapFunction( inputFile.toAbsolutePath().toString(), Files.size(inputFile), inputDir.toAbsolutePath().toString(), containedFile.getFileName().toString())) .writeAsText(params.getRequired("output"), FileSystem.WriteMode.OVERWRITE); env.execute("Distributed Cache Via Blob Test Program"); }