-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[FLINK-6177] Add support for "Distributed Cache" in streaming applica… #3741
Closed
zohar-mizrahi
wants to merge
4
commits into
apache:release-1.2.0-rc3
from
zohar-mizrahi:python-streaming-distributed-cache
Closed
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
03684e8
[FLINK-6177] Add support for "Distributed Cache" in streaming applica…
7e6374f
[FLINK-6177] Apply suggested fixes from a review
8606faf
[FLINK-6177] Combine the streaming & batch distributed cache tests an…
fa74b64
[FLINK-6177] Add missing file cache functions to the scala StreamExec…
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,6 +24,7 @@ | |
import org.apache.flink.api.common.ExecutionConfig; | ||
import org.apache.flink.api.common.InvalidProgramException; | ||
import org.apache.flink.api.common.JobExecutionResult; | ||
import org.apache.flink.api.common.cache.DistributedCache; | ||
import org.apache.flink.api.common.functions.InvalidTypesException; | ||
import org.apache.flink.api.common.functions.StoppableFunction; | ||
import org.apache.flink.api.common.io.FileInputFormat; | ||
|
@@ -36,6 +37,7 @@ | |
import org.apache.flink.api.java.ClosureCleaner; | ||
import org.apache.flink.api.java.ExecutionEnvironment; | ||
import org.apache.flink.api.java.io.TextInputFormat; | ||
import org.apache.flink.api.java.tuple.Tuple2; | ||
import org.apache.flink.api.java.tuple.Tuple3; | ||
import org.apache.flink.api.java.typeutils.MissingTypeInfo; | ||
import org.apache.flink.api.java.typeutils.PojoTypeInfo; | ||
|
@@ -134,6 +136,8 @@ public abstract class StreamExecutionEnvironment { | |
/** The time characteristic used by the data streams */ | ||
private TimeCharacteristic timeCharacteristic = DEFAULT_TIME_CHARACTERISTIC; | ||
|
||
protected final List<Tuple2<String, DistributedCache.DistributedCacheEntry>> cacheFile = new ArrayList<>(); | ||
|
||
|
||
// -------------------------------------------------------------------------------------------- | ||
// Constructor and Properties | ||
|
@@ -146,6 +150,13 @@ public ExecutionConfig getConfig() { | |
return config; | ||
} | ||
|
||
/** | ||
* Get the list of cached files that were registered for distribution among the task managers | ||
*/ | ||
public List<Tuple2<String, DistributedCache.DistributedCacheEntry>> getCacheFile() { | ||
return cacheFile; | ||
} | ||
|
||
/** | ||
* Sets the parallelism for operations executed through this environment. | ||
* Setting a parallelism of x here will cause all operators (such as map, | ||
|
@@ -1642,11 +1653,11 @@ public static LocalStreamEnvironment createLocalEnvironment(int parallelism, Con | |
/** | ||
* Creates a {@link LocalStreamEnvironment} for local program execution that also starts the | ||
* web monitoring UI. | ||
* | ||
* | ||
* <p>The local execution environment will run the program in a multi-threaded fashion in | ||
* the same JVM as the environment was created in. It will use the parallelism specified in the | ||
* parameter. | ||
* | ||
* | ||
* <p>If the configuration key 'jobmanager.web.port' was set in the configuration, that particular | ||
* port will be used for the web UI. Otherwise, the default port (8081) will be used. | ||
*/ | ||
|
@@ -1776,8 +1787,45 @@ public static void setDefaultLocalParallelism(int parallelism) { | |
protected static void initializeContextEnvironment(StreamExecutionEnvironmentFactory ctx) { | ||
contextEnvironmentFactory = ctx; | ||
} | ||
|
||
protected static void resetContextEnvironment() { | ||
contextEnvironmentFactory = null; | ||
} | ||
|
||
/** | ||
* Registers a file at the distributed cache under the given name. The file will be accessible | ||
* from any user-defined function in the (distributed) runtime under a local path. Files | ||
* may be local files (as long as all relevant workers have access to it), or files in a distributed file system. | ||
* The runtime will copy the files temporarily to a local cache, if needed. | ||
* <p> | ||
* The {@link org.apache.flink.api.common.functions.RuntimeContext} can be obtained inside UDFs via | ||
* {@link org.apache.flink.api.common.functions.RichFunction#getRuntimeContext()} and provides access | ||
* {@link org.apache.flink.api.common.cache.DistributedCache} via | ||
* {@link org.apache.flink.api.common.functions.RuntimeContext#getDistributedCache()}. | ||
* | ||
* @param filePath The path of the file, as a URI (e.g. "file:///some/path" or "hdfs://host:port/and/path") | ||
* @param name The name under which the file is registered. | ||
*/ | ||
public void registerCachedFile(String filePath, String name){ | ||
registerCachedFile(filePath, name, false); | ||
} | ||
|
||
/** | ||
* Registers a file at the distributed cache under the given name. The file will be accessible | ||
* from any user-defined function in the (distributed) runtime under a local path. Files | ||
* may be local files (as long as all relevant workers have access to it), or files in a distributed file system. | ||
* The runtime will copy the files temporarily to a local cache, if needed. | ||
* <p> | ||
* The {@link org.apache.flink.api.common.functions.RuntimeContext} can be obtained inside UDFs via | ||
* {@link org.apache.flink.api.common.functions.RichFunction#getRuntimeContext()} and provides access | ||
* {@link org.apache.flink.api.common.cache.DistributedCache} via | ||
* {@link org.apache.flink.api.common.functions.RuntimeContext#getDistributedCache()}. | ||
* | ||
* @param filePath The path of the file, as a URI (e.g. "file:///some/path" or "hdfs://host:port/and/path") | ||
* @param name The name under which the file is registered. | ||
* @param executable flag indicating whether the file should be executable | ||
*/ | ||
public void registerCachedFile(String filePath, String name, boolean executable){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing space before |
||
this.cacheFile.add(new Tuple2<>(name, new DistributedCache.DistributedCacheEntry(filePath, executable))); | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
missing space before
{
.