-
Notifications
You must be signed in to change notification settings - Fork 339
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #15726 from cdapio/CDAP-21061-wrap-plugin-methods
[CDAP-21061] Wrap exceptions from process stage to throw WrappedStageException and add WrappedBatchAutoJoiner
- Loading branch information
Showing
3 changed files
with
95 additions
and
1 deletion.
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
78 changes: 78 additions & 0 deletions
78
...tl/cdap-etl-core/src/main/java/io/cdap/cdap/etl/common/plugin/WrappedBatchAutoJoiner.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,78 @@ | ||
/* | ||
* Copyright © 2024 Cask Data, Inc. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
|
||
package io.cdap.cdap.etl.common.plugin; | ||
|
||
import io.cdap.cdap.etl.api.MultiInputPipelineConfigurer; | ||
import io.cdap.cdap.etl.api.batch.BatchAutoJoiner; | ||
import io.cdap.cdap.etl.api.batch.BatchJoinerContext; | ||
import io.cdap.cdap.etl.api.join.AutoJoinerContext; | ||
import io.cdap.cdap.etl.api.join.JoinDefinition; | ||
import java.util.concurrent.Callable; | ||
import javax.annotation.Nullable; | ||
|
||
/** | ||
* Wrapper around {@link BatchAutoJoiner} that makes sure logging, classloading, and other pipeline | ||
* capabilities are set up correctly. | ||
* | ||
*/ | ||
public class WrappedBatchAutoJoiner extends BatchAutoJoiner | ||
implements PluginWrapper<BatchAutoJoiner> { | ||
|
||
private final BatchAutoJoiner joiner; | ||
private final Caller caller; | ||
|
||
public WrappedBatchAutoJoiner(BatchAutoJoiner joiner, Caller caller) { | ||
this.joiner = joiner; | ||
this.caller = caller; | ||
} | ||
|
||
|
||
@Override | ||
public void configurePipeline(MultiInputPipelineConfigurer multiInputPipelineConfigurer) { | ||
caller.callUnchecked((Callable<Void>) () -> { | ||
joiner.configurePipeline(multiInputPipelineConfigurer); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public void prepareRun(BatchJoinerContext context) throws Exception { | ||
caller.call((Callable<Void>) () -> { | ||
joiner.prepareRun(context); | ||
return null; | ||
}); | ||
} | ||
|
||
@Override | ||
public void onRunFinish(boolean succeeded, BatchJoinerContext context) { | ||
caller.callUnchecked((Callable<Void>) () -> { | ||
joiner.onRunFinish(succeeded, context); | ||
return null; | ||
}); | ||
} | ||
|
||
@Nullable | ||
@Override | ||
public JoinDefinition define(AutoJoinerContext context) { | ||
return caller.callUnchecked(() -> joiner.define(context)); | ||
} | ||
|
||
@Override | ||
public BatchAutoJoiner getWrapped() { | ||
return joiner; | ||
} | ||
} |
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