forked from apache/beam
-
Notifications
You must be signed in to change notification settings - Fork 5
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
LISAMZA-36419: support offspring #110
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a36ca80
LISAMZA-36419: support offspring in beam flink
MabelYC 6ce82ff
invoke pipelineOptionsFactory in proxy as function
MabelYC 92985dd
add comments
MabelYC 7a92297
add comments
MabelYC 6c4ce40
fix tests
MabelYC 1b95e8d
trigger checks
MabelYC 2054424
address comments
MabelYC 0697a3f
address comments
MabelYC 969501b
address comments
MabelYC bbace76
trigger checks
MabelYC 33df868
address comments
MabelYC 8896257
address comments
MabelYC File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
43 changes: 43 additions & 0 deletions
43
...java/core/src/main/java/org/apache/beam/sdk/options/CustomPipelineOptionsInitializer.java
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 |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.apache.beam.sdk.options; | ||
|
||
import java.util.Iterator; | ||
import java.util.ServiceLoader; | ||
import org.apache.beam.vendor.guava.v26_0_jre.com.google.common.collect.Iterators; | ||
import org.checkerframework.checker.initialization.qual.Initialized; | ||
import org.checkerframework.checker.nullness.qual.Nullable; | ||
|
||
|
||
/** | ||
* Interface to support offspring wire-in for Li: if input class is a | ||
* customized pipelineOptions created by an offspring factory, | ||
* the pipelineOptions will be initialized. | ||
* | ||
*/ | ||
@SuppressWarnings("rawtypes") | ||
public interface CustomPipelineOptionsInitializer<T> { | ||
void init(T pipelineOptions, Class<T> clazz); | ||
|
||
/** | ||
* Inject the implementation for the interface | ||
* <p>Usage: | ||
* | ||
* <pre>{@code | ||
* @AutoService(CustomPipelineOptionsInitializer.Registrar.class) | ||
* public static class Registrar implements CustomPipelineOptions.Registrar { | ||
* @Override | ||
* public CustomPipelineOptions create() { | ||
* return new CustomPipelineOptions(); | ||
* } | ||
* }</pre> | ||
*/ | ||
interface Registrar { | ||
CustomPipelineOptionsInitializer create(); | ||
} | ||
|
||
|
||
static @Initialized @Nullable CustomPipelineOptionsInitializer get() { | ||
final Iterator<CustomPipelineOptionsInitializer.Registrar> | ||
initializer = ServiceLoader.load(CustomPipelineOptionsInitializer.Registrar.class).iterator(); | ||
return initializer.hasNext() ? Iterators.getOnlyElement(initializer).create() : null; | ||
} | ||
} |
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
Oops, something went wrong.
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.
how will the Registrar be used?
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.
In the implementation, we will have a class annotated as AutoService(CustomePipelineOptionsInitializer.Registrar.class). It returns an instance of the implementation, so beam will know which implementation to use during runtime
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.
Got it. Can you add an example of usage in the javadoc?
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.
Updated