Skip to content
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

[Improve][Doris] Add a jobId to the doris label to distinguish between tasks #4839

Merged
merged 1 commit into from
May 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import org.apache.seatunnel.shade.com.typesafe.config.Config;

import org.apache.seatunnel.api.common.JobContext;
import org.apache.seatunnel.api.common.PrepareFailException;
import org.apache.seatunnel.api.common.SeaTunnelAPIErrorCode;
import org.apache.seatunnel.api.serialization.Serializer;
Expand Down Expand Up @@ -54,6 +55,7 @@ public class DorisSink

private Config pluginConfig;
private SeaTunnelRowType seaTunnelRowType;
private String jobId;

@Override
public String getPluginName() {
Expand All @@ -78,6 +80,11 @@ public void prepare(Config pluginConfig) throws PrepareFailException {
}
}

@Override
public void setJobContext(JobContext jobContext) {
this.jobId = jobContext.getJobId();
}

@Override
public void setTypeInfo(SeaTunnelRowType seaTunnelRowType) {
this.seaTunnelRowType = seaTunnelRowType;
Expand All @@ -93,7 +100,7 @@ public SinkWriter<SeaTunnelRow, DorisCommitInfo, DorisSinkState> createWriter(
SinkWriter.Context context) throws IOException {
DorisSinkWriter dorisSinkWriter =
new DorisSinkWriter(
context, Collections.emptyList(), seaTunnelRowType, pluginConfig);
context, Collections.emptyList(), seaTunnelRowType, pluginConfig, jobId);
dorisSinkWriter.initializeLoad(Collections.emptyList());
return dorisSinkWriter;
}
Expand All @@ -102,7 +109,7 @@ public SinkWriter<SeaTunnelRow, DorisCommitInfo, DorisSinkState> createWriter(
public SinkWriter<SeaTunnelRow, DorisCommitInfo, DorisSinkState> restoreWriter(
SinkWriter.Context context, List<DorisSinkState> states) throws IOException {
DorisSinkWriter dorisWriter =
new DorisSinkWriter(context, states, seaTunnelRowType, pluginConfig);
new DorisSinkWriter(context, states, seaTunnelRowType, pluginConfig, jobId);
dorisWriter.initializeLoad(states);
return dorisWriter;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,15 @@ public DorisSinkWriter(
SinkWriter.Context context,
List<DorisSinkState> state,
SeaTunnelRowType seaTunnelRowType,
Config pluginConfig) {
Config pluginConfig,
String jobId) {
this.dorisConfig = DorisConfig.loadConfig(pluginConfig);
this.lastCheckpointId = state.size() != 0 ? state.get(0).getCheckpointId() : 0;
log.info("restore checkpointId {}", lastCheckpointId);
log.info("labelPrefix " + dorisConfig.getLabelPrefix());
this.dorisSinkState = new DorisSinkState(dorisConfig.getLabelPrefix(), lastCheckpointId);
this.labelPrefix = dorisConfig.getLabelPrefix() + "_" + context.getIndexOfSubtask();
this.labelPrefix =
dorisConfig.getLabelPrefix() + "_" + jobId + "_" + context.getIndexOfSubtask();
this.labelGenerator = new LabelGenerator(labelPrefix, dorisConfig.getEnable2PC());
this.scheduledExecutorService =
new ScheduledThreadPoolExecutor(
Expand Down