Skip to content

Commit 87e81b2

Browse files
committed
add taskId to AsbstractExecContext
1 parent 0039011 commit 87e81b2

5 files changed

Lines changed: 295 additions & 37 deletions

File tree

tis-datax/executor/tis-datax-executor/src/main/java/com/qlangtech/tis/datax/DataxPrePostExecutor.java

Lines changed: 14 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,14 @@
2323
import com.qlangtech.tis.exec.AbstractExecContext;
2424
import com.qlangtech.tis.exec.impl.DataXPipelineExecContext;
2525
import com.qlangtech.tis.exec.impl.WorkflowExecContext;
26-
import com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskPostTrigger;
27-
import com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskPreviousTrigger;
2826
import com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskTrigger;
2927
import com.qlangtech.tis.fullbuild.phasestatus.impl.JoinPhaseStatus;
3028
import com.qlangtech.tis.job.common.JobCommon;
31-
import com.qlangtech.tis.plugin.ds.DefaultTab;
3229
import com.qlangtech.tis.plugin.ds.ISelectedTab;
33-
import com.qlangtech.tis.sql.parser.tuple.creator.EntityName;
3430
import com.tis.hadoop.rpc.RpcServiceReference;
3531
import com.tis.hadoop.rpc.StatusRpcClientFactory;
3632
import com.tis.hadoop.rpc.StatusRpcClientFactory.AssembleSvcCompsite;
3733
import org.apache.commons.lang3.StringUtils;
38-
import org.apache.commons.lang3.tuple.Pair;
3934
import org.slf4j.Logger;
4035
import org.slf4j.LoggerFactory;
4136

@@ -61,10 +56,10 @@ public class DataxPrePostExecutor {
6156
*/
6257
public static void main(String[] args) throws Exception {
6358
if (args.length != 9) {
64-
throw new IllegalArgumentException("args length must be 8,but now is " + String.join(",", args));
59+
throw new IllegalArgumentException("args length must be 9,but now is " + String.join(",", args));
6560
}
66-
Integer jobId = Integer.parseInt(args[0]);
67-
String dataXName = args[1];
61+
final Integer taskId = Integer.parseInt(args[0]);
62+
String pipelineName = args[1];
6863
String incrStateCollectAddress = args[2];
6964
if (StringUtils.isEmpty(incrStateCollectAddress)) {
7065
throw new IllegalArgumentException("arg 'incrStateCollectAddress' can not be null");
@@ -90,25 +85,25 @@ public static void main(String[] args) throws Exception {
9085
final long execEpochMilli = Long.parseLong(args[7]);
9186

9287

93-
JobCommon.setMDC(jobId, dataXName);
88+
JobCommon.setMDC(taskId, pipelineName);
9489

95-
if (StringUtils.isEmpty(dataXName)) {
90+
if (StringUtils.isEmpty(pipelineName)) {
9691
throw new IllegalArgumentException("arg 'dataXName' can not be null");
9792
}
9893

9994

10095
// IRemoteTaskTrigger hookTrigger = null;
10196
try {
102-
IDataxProcessor dataxProcessor = DataxProcessor.load(null, resType, dataXName);
97+
IDataxProcessor dataxProcessor = DataxProcessor.load(null, resType, pipelineName);
10398
IDataxReader reader = dataxProcessor.getReader(null);
10499
ISelectedTab tab = reader.getSelectedTab(entity);
105100
IDataXBatchPost batchPost =
106101
IDataxWriter.castBatchPost(Objects.requireNonNull(dataxProcessor.getWriter(null), "dataXName" +
107-
":" + dataXName + " relevant dataXWriter can not be null"));
102+
":" + pipelineName + " relevant dataXWriter can not be null"));
108103
// final EntityName tabEntity = batchPost.parseEntity(tab);
109104

110-
final AbstractExecContext execContext = createExecContext(execEpochMilli, dataxProcessor);
111-
105+
final AbstractExecContext execContext = createExecContext(taskId, execEpochMilli, dataxProcessor);
106+
//execContext.getTaskId()
112107
// execContext.setResType(resType);
113108

114109
IDataXBatchPost.process(dataxProcessor, tab, (batchPostTask, entryName) -> {
@@ -130,21 +125,6 @@ public static void main(String[] args) throws Exception {
130125
return null;
131126
});
132127

133-
134-
// if (IDataXBatchPost.KEY_POST.equalsIgnoreCase(lifecycleHookName)) {
135-
// hookTrigger = batchPost.createPostTask(
136-
// execContext, entity, tab, dataxProcessor.getDataxCfgFileNames(null, Optional.empty()));
137-
// } else if (IDataXBatchPost.KEY_PREP.equalsIgnoreCase(lifecycleHookName)) {
138-
// hookTrigger = batchPost.createPreExecuteTask(execContext, entity, tab);
139-
// } else {
140-
// throw new IllegalArgumentException("illegal lifecycleHookName:" + lifecycleHookName);
141-
// }
142-
// if (!StringUtils.equals(hookTrigger.getTaskName(), jobName)) {
143-
// logger.warn("hookTrigger.getTaskName:{} is not equal with jobName:{}", hookTrigger.getTaskName(),
144-
// jobName);
145-
// }
146-
// Objects.requireNonNull(hookTrigger, "hookTrigger can not be null");
147-
// hookTrigger.run();
148128
} catch (Throwable e) {
149129
logger.error(e.getMessage(), e);
150130
try {
@@ -158,9 +138,9 @@ public static void main(String[] args) throws Exception {
158138
joinStatus.setFaild(true);
159139
joinStatus.setComplete(true);
160140
joinStatus.setStart();
161-
statusRpc.reportJoinStatus(jobId, joinStatus);
141+
statusRpc.reportJoinStatus(taskId, joinStatus);
162142
} else if (IDataXBatchPost.KEY_PREP.equalsIgnoreCase(lifecycleHookName)) {
163-
statusRpc.reportDumpJobStatus(true, true, false, jobId, jobName, -1, -1);
143+
statusRpc.reportDumpJobStatus(true, true, false, taskId, jobName, -1, -1);
164144
} else {
165145
throw new IllegalArgumentException("illegal lifecycleHookName:" + lifecycleHookName);
166146
}
@@ -185,11 +165,11 @@ public static void main(String[] args) throws Exception {
185165
// } catch (Throwable e) {
186166
// }
187167
}
188-
logger.info("dataX:" + dataXName + ",taskid:" + jobId + " finished");
168+
logger.info("dataX:" + pipelineName + ",taskid:" + taskId + " finished");
189169
System.exit(0);
190170
}
191171

192-
private static AbstractExecContext createExecContext(long execEpochMilli, IDataxProcessor dataxProcessor) {
172+
private static AbstractExecContext createExecContext(Integer taskId, long execEpochMilli, IDataxProcessor dataxProcessor) {
193173
AbstractExecContext execContext;
194174
StoreResourceType resType = dataxProcessor.getResType();
195175
String dataXName = dataxProcessor.identityValue();
@@ -213,6 +193,7 @@ public IDataxProcessor getProcessor() {
213193
default:
214194
throw new IllegalStateException("illegal resType:" + resType);
215195
}
196+
execContext.setAttribute(JobCommon.KEY_TASK_ID, Objects.requireNonNull(taskId));
216197
return execContext;
217198
}
218199

tis-datax/executor/tis-datax-executor/src/main/java/com/qlangtech/tis/datax/executor/BasicTISTableDumpProcessor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import com.qlangtech.tis.exec.ExecChainContextUtils;
3636
import com.qlangtech.tis.exec.IExecChainContext;
3737
import com.qlangtech.tis.fullbuild.indexbuild.IRemoteTaskTrigger;
38+
import com.qlangtech.tis.job.common.JobCommon;
3839
import com.qlangtech.tis.job.common.JobParams;
3940
import com.qlangtech.tis.offline.DataxUtils;
4041
import com.qlangtech.tis.plugin.PluginAndCfgSnapshotLocalCache;
@@ -164,6 +165,9 @@ public void processPostTask(ITaskExecutorContext context) {
164165

165166
execContext.setSpecifiedLocalLoggerPath(context.getSpecifiedLocalLoggerPath());
166167
execContext.setDisableGrpcRemoteServerConnect(context.isDisableGrpcRemoteServerConnect());
168+
// execContext.setAttribute(JobCommon.KEY_TASK_ID, Objects.requireNonNull(taskId, "taskId can not be null"));
169+
170+
167171
/**
168172
* 同步必要的配置及tpi资源到本地
169173
*/

0 commit comments

Comments
 (0)