2323import com .qlangtech .tis .exec .AbstractExecContext ;
2424import com .qlangtech .tis .exec .impl .DataXPipelineExecContext ;
2525import com .qlangtech .tis .exec .impl .WorkflowExecContext ;
26+ import com .qlangtech .tis .fullbuild .indexbuild .IRemoteTaskPostTrigger ;
27+ import com .qlangtech .tis .fullbuild .indexbuild .IRemoteTaskPreviousTrigger ;
2628import com .qlangtech .tis .fullbuild .indexbuild .IRemoteTaskTrigger ;
2729import com .qlangtech .tis .fullbuild .phasestatus .impl .JoinPhaseStatus ;
2830import com .qlangtech .tis .job .common .JobCommon ;
3335import com .tis .hadoop .rpc .StatusRpcClientFactory ;
3436import com .tis .hadoop .rpc .StatusRpcClientFactory .AssembleSvcCompsite ;
3537import org .apache .commons .lang3 .StringUtils ;
38+ import org .apache .commons .lang3 .tuple .Pair ;
3639import org .slf4j .Logger ;
3740import org .slf4j .LoggerFactory ;
3841
@@ -73,9 +76,9 @@ public static void main(String[] args) throws Exception {
7376 AssembleSvcCompsite .statusRpc = (statusRpc );
7477
7578 final String lifecycleHookName = args [3 ];
76- // final ISelectedTab tab = new DefaultTab(args[4]);
77- final EntityName entity = EntityName . parse (args [4 ]);
78- if (StringUtils .isEmpty (entity . getTabName () )) {
79+ // final ISelectedTab tab = new DefaultTab(args[4]);
80+ final String entity = (args [4 ]);
81+ if (StringUtils .isEmpty (entity )) {
7982 throw new IllegalStateException ("param table name can not be empty" );
8083 }
8184
@@ -94,53 +97,54 @@ public static void main(String[] args) throws Exception {
9497 }
9598
9699
97- IRemoteTaskTrigger hookTrigger = null ;
100+ // IRemoteTaskTrigger hookTrigger = null;
98101 try {
99102 IDataxProcessor dataxProcessor = DataxProcessor .load (null , resType , dataXName );
100103 IDataxReader reader = dataxProcessor .getReader (null );
101- ISelectedTab tab = reader .getSelectedTab (entity . getTableName () );
104+ ISelectedTab tab = reader .getSelectedTab (entity );
102105 IDataXBatchPost batchPost =
103106 IDataxWriter .castBatchPost (Objects .requireNonNull (dataxProcessor .getWriter (null ), "dataXName" +
104107 ":" + dataXName + " relevant dataXWriter can not be null" ));
105108 // final EntityName tabEntity = batchPost.parseEntity(tab);
106- AbstractExecContext execContext = null ;
107- switch (resType ) {
108- case DataApp :
109- execContext = new DataXPipelineExecContext (dataXName , execEpochMilli ) {
110- @ Override
111- public IDataxProcessor getProcessor () {
112- return dataxProcessor ;
113- }
114- };
115- break ;
116- case DataFlow :
117- execContext = new WorkflowExecContext (null , execEpochMilli ) {
118- @ Override
119- public IDataxProcessor getProcessor () {
120- return dataxProcessor ;
121- }
122- };
123- break ;
124- default :
125- throw new IllegalStateException ("illegal resType:" + resType );
126- }
109+
110+ final AbstractExecContext execContext = createExecContext (execEpochMilli , dataxProcessor );
127111
128112 // execContext.setResType(resType);
129113
130- if (IDataXBatchPost .KEY_POST .equalsIgnoreCase (lifecycleHookName )) {
131- hookTrigger = batchPost .createPostTask (
132- execContext , entity , tab , dataxProcessor .getDataxCfgFileNames (null , Optional .empty ()));
133- } else if (IDataXBatchPost .KEY_PREP .equalsIgnoreCase (lifecycleHookName )) {
134- hookTrigger = batchPost .createPreExecuteTask (execContext , entity , tab );
135- } else {
136- throw new IllegalArgumentException ("illegal lifecycleHookName:" + lifecycleHookName );
137- }
138- if (!StringUtils .equals (hookTrigger .getTaskName (), jobName )) {
139- logger .warn ("hookTrigger.getTaskName:{} is not equal with jobName:{}" , hookTrigger .getTaskName (),
140- jobName );
141- }
142- Objects .requireNonNull (hookTrigger , "hookTrigger can not be null" );
143- hookTrigger .run ();
114+ IDataXBatchPost .process (dataxProcessor , tab , (batchPostTask , entryName ) -> {
115+ IRemoteTaskTrigger hookTrigger = null ;
116+ if (IDataXBatchPost .KEY_POST .equalsIgnoreCase (lifecycleHookName )) {
117+ hookTrigger = batchPost .createPostTask (
118+ execContext , entryName , tab , dataxProcessor .getDataxCfgFileNames (null , Optional .empty ()));
119+ } else if (IDataXBatchPost .KEY_PREP .equalsIgnoreCase (lifecycleHookName )) {
120+ hookTrigger = batchPost .createPreExecuteTask (execContext , entryName , tab );
121+ } else {
122+ throw new IllegalArgumentException ("illegal lifecycleHookName:" + lifecycleHookName );
123+ }
124+ if (!StringUtils .equals (hookTrigger .getTaskName (), jobName )) {
125+ logger .warn ("hookTrigger.getTaskName:{} is not equal with jobName:{}" , hookTrigger .getTaskName (),
126+ jobName );
127+ }
128+ Objects .requireNonNull (hookTrigger , "hookTrigger can not be null" );
129+ hookTrigger .run ();
130+ return null ;
131+ });
132+
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();
144148 } catch (Throwable e ) {
145149 logger .error (e .getMessage (), e );
146150 try {
@@ -185,5 +189,32 @@ public IDataxProcessor getProcessor() {
185189 System .exit (0 );
186190 }
187191
192+ private static AbstractExecContext createExecContext (long execEpochMilli , IDataxProcessor dataxProcessor ) {
193+ AbstractExecContext execContext ;
194+ StoreResourceType resType = dataxProcessor .getResType ();
195+ String dataXName = dataxProcessor .identityValue ();
196+ switch (resType ) {
197+ case DataApp :
198+ execContext = new DataXPipelineExecContext (dataXName , execEpochMilli ) {
199+ @ Override
200+ public IDataxProcessor getProcessor () {
201+ return dataxProcessor ;
202+ }
203+ };
204+ break ;
205+ case DataFlow :
206+ execContext = new WorkflowExecContext (null , execEpochMilli ) {
207+ @ Override
208+ public IDataxProcessor getProcessor () {
209+ return dataxProcessor ;
210+ }
211+ };
212+ break ;
213+ default :
214+ throw new IllegalStateException ("illegal resType:" + resType );
215+ }
216+ return execContext ;
217+ }
218+
188219
189220}
0 commit comments