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-6606] Create checkpoint hook with user classloader #3933
Conversation
EronWright
commented
May 17, 2017
- wrap calls to MasterTriggerRestoreHook (and its factory) such that the user classloader is applied
- wrap calls to MasterTriggerRestoreHook (and its factory) such that the user classloader is applied
I haven't worked on this part of the code before, but I believe this code is +1 to merge. |
Thanks for your contribution @EronWright. I'm not quite sure whether I understand which problem we are trying to solve here. I think by deserializing the But I might be overlooking something here. Maybe you can give me some more details about the PR. |
@tillrohrmann the issue is with code that uses the thread's context classloader (TCCL), that may execute in Looking at other areas in Flink where usercode is called, I see that the TCCL is consistently set. For example, see InputFormatVertex, ExecutionJobVertex, and Task. |
Till and I had an offline discussion about this.
|
That's the sort of workaround that Android apps are forced to use. Why not continue the practice of setting the TCCL in transitions from system to user code? |
Lets see what Till says. Till's proposal (so get the CL via the class) keeps our code straightforward, but users have to know it. |
I agree with @EronWright that it would be nice to offer all user code the a similar environment. This will become especially important if a I'm wondering whether to follow the approach of the |
public String getIdentifier() { | ||
Thread thread = Thread.currentThread(); | ||
ClassLoader originalClassLoader = thread.getContextClassLoader(); | ||
thread.setContextClassLoader(userClassLoader); |
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.
Maybe we can move the setContextClassLoader
into the try
body. Just to be on the safe side that whenever something happens we will reset the original class loader.
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.
I disagee with that approach due to lack of symmetry. The try..finally idiom is typically written as:
open();
try { ... } finally { close(); }
In other words, the close statement is needed only if the open statement completes.
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.
True.
Originally I pursued the path suggested by @tillrohrmann of setting the TCCL at the sites where the hook is invoked, but found that the classloader wasn't readily available. I found it more expedient to create a wrapper that eagerly captured the classloader. This also improved testability. |
Yes that is true. Thanks for your work and the clarification @EronWright. Merging this PR. |
…Hook - wrap calls to MasterTriggerRestoreHook (and its factory) such that the user classloader is applied This closes #3933.