Skip to content

Commit

Permalink
[HUDI-2799] Fix the classloader of flink write task (apache#4042)
Browse files Browse the repository at this point in the history
  • Loading branch information
danny0405 committed Nov 22, 2021
1 parent 2533a9c commit 8281cbf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ public BulkInsertWriteFunction(Configuration config, RowType rowType) {

@Override
public void open(Configuration parameters) throws IOException {
// always use the user classloader
Thread.currentThread().setContextClassLoader(getRuntimeContext().getUserCodeClassLoader());
this.taskID = getRuntimeContext().getIndexOfThisSubtask();
this.metaClient = StreamerUtil.createMetaClient(this.config);
this.writeClient = StreamerUtil.createWriteClient(this.config, getRuntimeContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ public AbstractStreamWriteFunction(Configuration config) {

@Override
public void initializeState(FunctionInitializationContext context) throws Exception {
// always use the user classloader
Thread.currentThread().setContextClassLoader(getRuntimeContext().getUserCodeClassLoader());
this.taskID = getRuntimeContext().getIndexOfThisSubtask();
this.metaClient = StreamerUtil.createMetaClient(this.config);
this.writeClient = StreamerUtil.createWriteClient(this.config, getRuntimeContext());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ public CompactFunction(Configuration conf) {

@Override
public void open(Configuration parameters) throws Exception {
// always use the user classloader
Thread.currentThread().setContextClassLoader(getRuntimeContext().getUserCodeClassLoader());
this.taskID = getRuntimeContext().getIndexOfThisSubtask();
this.writeClient = StreamerUtil.createWriteClient(conf, getRuntimeContext());
if (this.asyncCompaction) {
Expand Down

0 comments on commit 8281cbf

Please sign in to comment.