1
1
package com .webank .wedatasphere .dss .orchestrator .server .job ;
2
2
3
3
import com .google .common .collect .Lists ;
4
+ import com .webank .wedatasphere .dss .appconn .scheduler .structure .orchestration .OrchestrationCreationOperation ;
5
+ import com .webank .wedatasphere .dss .appconn .scheduler .structure .orchestration .OrchestrationService ;
6
+ import com .webank .wedatasphere .dss .appconn .scheduler .structure .orchestration .ref .DSSOrchestrationContentRequestRef ;
7
+ import com .webank .wedatasphere .dss .appconn .scheduler .structure .orchestration .ref .OrchestrationResponseRef ;
4
8
import com .webank .wedatasphere .dss .common .exception .DSSErrorException ;
5
9
import com .webank .wedatasphere .dss .common .label .DSSLabel ;
6
10
import com .webank .wedatasphere .dss .common .utils .MapUtils ;
7
- import com .webank .wedatasphere .dss .orchestrator .common .entity .DSSOrchestratorCopyInfo ;
8
- import com .webank .wedatasphere .dss .orchestrator .common .entity .DSSOrchestratorInfo ;
9
- import com .webank .wedatasphere .dss .orchestrator .common .entity .DSSOrchestratorVersion ;
11
+ import com .webank .wedatasphere .dss .orchestrator .common .entity .*;
10
12
import com .webank .wedatasphere .dss .orchestrator .common .ref .OrchestratorRefConstant ;
11
13
import com .webank .wedatasphere .dss .orchestrator .core .DSSOrchestrator ;
12
14
import com .webank .wedatasphere .dss .orchestrator .core .utils .OrchestratorUtils ;
15
+ import com .webank .wedatasphere .dss .orchestrator .db .dao .OrchestratorMapper ;
13
16
import com .webank .wedatasphere .dss .orchestrator .publish .utils .OrchestrationDevelopmentOperationUtils ;
14
17
import com .webank .wedatasphere .dss .orchestrator .server .entity .vo .OrchestratorCopyVo ;
18
+ import com .webank .wedatasphere .dss .orchestrator .server .service .OrchestratorService ;
19
+ import com .webank .wedatasphere .dss .orchestrator .server .service .impl .OrchestratorFrameworkServiceImpl ;
15
20
import com .webank .wedatasphere .dss .standard .app .development .operation .RefCopyOperation ;
16
21
import com .webank .wedatasphere .dss .standard .app .development .ref .CopyRequestRef ;
17
22
import com .webank .wedatasphere .dss .standard .app .development .ref .RefJobContentResponseRef ;
@@ -33,6 +38,12 @@ public class OrchestratorCopyJob implements Runnable {
33
38
34
39
protected OrchestratorCopyEnv orchestratorCopyEnv ;
35
40
41
+ private OrchestratorFrameworkServiceImpl orchestratorFrameworkServiceImpl ;
42
+
43
+ private OrchestratorService orchestratorService ;
44
+
45
+ private OrchestratorMapper orchestratorMapper ;
46
+
36
47
private DSSOrchestratorCopyInfo orchestratorCopyInfo = new DSSOrchestratorCopyInfo (UUID .randomUUID ().toString ());
37
48
38
49
@@ -66,9 +77,10 @@ private void copyOrchestrator() {
66
77
newOrchestrator .setDesc ("copy from " + sourceOrchestrator .getName ());
67
78
newOrchestrator .setUpdateTime (null );
68
79
newOrchestrator .setUpdateUser (null );
80
+ DSSOrchestratorVersion dssOrchestratorVersion = null ;
69
81
70
82
try {
71
- doOrchestratorCopy (orchestratorCopyVo .getUsername (), orchestratorCopyVo .getWorkspace (), newOrchestrator ,
83
+ dssOrchestratorVersion = doOrchestratorCopy (orchestratorCopyVo .getUsername (), orchestratorCopyVo .getWorkspace (), newOrchestrator ,
72
84
orchestratorCopyVo .getTargetProjectName (), Lists .newArrayList (orchestratorCopyVo .getDssLabel ()), appId );
73
85
} catch (Exception e ) {
74
86
//保存错误信息
@@ -91,9 +103,37 @@ private void copyOrchestrator() {
91
103
orchestratorCopyInfo .setSuccessNode (Lists .newArrayList ("All" ));
92
104
orchestratorCopyInfo .setStatus (1 );
93
105
orchestratorCopyEnv .getOrchestratorCopyJobMapper ().updateCopyStatus (orchestratorCopyInfo );
106
+
107
+ List <DSSLabel > dssLabels = new ArrayList <>();
108
+ dssLabels .add (orchestratorCopyVo .getDssLabel ());
109
+
110
+ //2.如果调度系统要求同步创建工作流,向调度系统发送创建工作流的请求
111
+ OrchestrationResponseRef orchestrationResponseRef = orchestratorFrameworkServiceImpl .tryOrchestrationOperation (dssLabels , true , orchestratorCopyVo .getUsername (),
112
+ orchestratorCopyVo .getTargetProjectName (), orchestratorCopyVo .getWorkspace (), newOrchestrator ,
113
+ OrchestrationService ::getOrchestrationCreationOperation ,
114
+ (structureOperation , structureRequestRef ) -> ((OrchestrationCreationOperation ) structureOperation )
115
+ .createOrchestration ((DSSOrchestrationContentRequestRef ) structureRequestRef ), "create" );
116
+
117
+ try {
118
+ orchestratorService .copyOrchestrator (orchestratorCopyVo .getUsername (), orchestratorCopyVo .getWorkspace (), orchestratorCopyVo .getTargetProjectName (),
119
+ orchestratorCopyVo .getTargetProjectId (), newOrchestrator .getDesc (), newOrchestrator , dssLabels );
120
+ } catch (Exception e ) {
121
+ throw new RuntimeException ("error happened when copying orc." , e );
122
+ }
123
+
124
+ Long orchestratorId = newOrchestrator .getId ();
125
+ Long orchestratorVersionId = dssOrchestratorVersion .getId ();
126
+ //4.将工程和orchestrator的关系存储到的数据库中
127
+ if (orchestrationResponseRef != null ) {
128
+ Long refProjectId = (Long ) orchestrationResponseRef .toMap ().get ("refProjectId" );
129
+ orchestratorMapper .addOrchestratorRefOrchestration (new DSSOrchestratorRefOrchestration (orchestratorId , refProjectId , orchestrationResponseRef .getRefOrchestrationId ()));
130
+ } else {
131
+ LOGGER .info ("copy orchestration {} with orchestratorId is {}, and versionId is {}, and orchestrationResponseRef is null." , newOrchestrator .getName (), orchestratorId , orchestratorVersionId );
132
+
133
+ }
94
134
}
95
135
96
- private void doOrchestratorCopy (String userName ,
136
+ private DSSOrchestratorVersion doOrchestratorCopy (String userName ,
97
137
Workspace workspace ,
98
138
DSSOrchestratorInfo dssOrchestratorInfo ,
99
139
String projectName ,
@@ -132,6 +172,7 @@ private void doOrchestratorCopy(String userName,
132
172
orchestratorCopyEnv .getOrchestratorMapper ().addOrchestrator (dssOrchestratorInfo );
133
173
dssOrchestratorVersion .setOrchestratorId (dssOrchestratorInfo .getId ());
134
174
orchestratorCopyEnv .getOrchestratorMapper ().addOrchestratorVersion (dssOrchestratorVersion );
175
+ return dssOrchestratorVersion ;
135
176
}
136
177
137
178
@@ -158,4 +199,28 @@ public DSSOrchestratorCopyInfo getOrchestratorCopyInfo() {
158
199
public void setOrchestratorCopyInfo (DSSOrchestratorCopyInfo orchestratorCopyInfo ) {
159
200
this .orchestratorCopyInfo = orchestratorCopyInfo ;
160
201
}
202
+
203
+ public OrchestratorFrameworkServiceImpl getOrchestratorFrameworkServiceImpl () {
204
+ return orchestratorFrameworkServiceImpl ;
205
+ }
206
+
207
+ public void setOrchestratorFrameworkServiceImpl (OrchestratorFrameworkServiceImpl orchestratorFrameworkServiceImpl ) {
208
+ this .orchestratorFrameworkServiceImpl = orchestratorFrameworkServiceImpl ;
209
+ }
210
+
211
+ public OrchestratorService getOrchestratorService () {
212
+ return orchestratorService ;
213
+ }
214
+
215
+ public void setOrchestratorService (OrchestratorService orchestratorService ) {
216
+ this .orchestratorService = orchestratorService ;
217
+ }
218
+
219
+ public OrchestratorMapper getOrchestratorMapper () {
220
+ return orchestratorMapper ;
221
+ }
222
+
223
+ public void setOrchestratorMapper (OrchestratorMapper orchestratorMapper ) {
224
+ this .orchestratorMapper = orchestratorMapper ;
225
+ }
161
226
}
0 commit comments