|
26 | 26 | import org.apache.commons.lang3.SerializationUtils; |
27 | 27 | import org.apache.commons.lang3.StringUtils; |
28 | 28 | import org.apache.linkis.common.conf.CommonVars; |
| 29 | +import org.apache.linkis.manager.label.conf.LabelCommonConfig; |
29 | 30 | import org.apache.linkis.manager.label.constant.LabelKeyConstant; |
30 | 31 | import org.apache.linkis.manager.label.entity.engine.EngineType; |
31 | 32 | import org.apache.linkis.manager.label.entity.engine.EngineTypeLabel; |
@@ -145,23 +146,22 @@ public JobSubmitAction getSubmitAction(Job job) throws LinkisJobExecutionErrorEx |
145 | 146 | } |
146 | 147 |
|
147 | 148 | String stringValue = engineTypeLabel.getStringValue(); |
148 | | - // spark3开关开启,并且引擎是Spark |
149 | | - if (WORKFLOW_SPARK3_SWITCH.getValue() && EngineType.SPARK().toString().equalsIgnoreCase(engineTypeLabel.getEngineType())) { |
150 | 149 |
|
151 | | - Map<String, Object> variableMap = TaskUtils.getVariableMap(job.getParams()); |
152 | 150 |
|
153 | | - // 判断sparkVersion参数为3,则使用spark3的引擎版本,否则使用spark默认引擎版本 |
154 | | - if (MapUtils.isNotEmpty(variableMap) |
155 | | - && variableMap.get("sparkVersion") != null |
156 | | - && StringUtils.equalsIgnoreCase(variableMap.get("sparkVersion").toString().trim(), "3")) { |
157 | | - |
158 | | - EngineTypeLabel spark3EngineType = new EngineTypeLabel(); |
159 | | - spark3EngineType.setEngineType(engineTypeLabel.getEngineType()); |
160 | | - spark3EngineType.setVersion(SPARK3_ENGINE_VERSION.getValue()); |
161 | | - stringValue = spark3EngineType.getStringValue(); |
| 151 | + //TODO 当默认引擎为spark3 可以去掉此段if代码 |
| 152 | + if (EngineType.SPARK().toString().equalsIgnoreCase(engineTypeLabel.getEngineType())) { |
162 | 153 |
|
163 | | - logger.info("{} job name ,spark3 engineType stringValue is {}", job.getJobName(), stringValue); |
| 154 | + String sparkVersion = getSparkVersion(job.getParams()); |
164 | 155 |
|
| 156 | + // 判断sparkVersion参数为3,则使用spark3的引擎版本,否则使用spark默认引擎版本 |
| 157 | + if (StringUtils.isNotEmpty(sparkVersion) && |
| 158 | + StringUtils.equalsIgnoreCase(sparkVersion.trim(), "3")) { |
| 159 | + |
| 160 | + EngineTypeLabel sparkEngineType = new EngineTypeLabel(); |
| 161 | + sparkEngineType.setEngineType(engineTypeLabel.getEngineType()); |
| 162 | + sparkEngineType.setVersion(SPARK3_ENGINE_VERSION.getValue()); |
| 163 | + stringValue = sparkEngineType.getStringValue(); |
| 164 | + logger.info("{} job name ,spark engineType stringValue is {}", job.getJobName(), stringValue); |
165 | 165 | } |
166 | 166 |
|
167 | 167 | } |
@@ -282,4 +282,22 @@ private String parseRunType(String engineType, String runType, Job job) { |
282 | 282 | private void enrichParams(Job job) { |
283 | 283 | job.getRuntimeParams().put("nodeType", job.getRunType()); |
284 | 284 | } |
| 285 | + |
| 286 | + private String getSparkVersion(Map<String, Object> params) { |
| 287 | + |
| 288 | + String sparkVersion = null; |
| 289 | + |
| 290 | + if (params.get("configuration") != null) { |
| 291 | + Map<String, Object> configurationMap = (Map<String, Object>) params.get("configuration"); |
| 292 | + if (configurationMap.get("runtime") != null) { |
| 293 | + Map<String, Object> runtimeMap = (Map<String, Object>) configurationMap.get("runtime"); |
| 294 | + if (runtimeMap.get("sparkVersion") != null) { |
| 295 | + sparkVersion = (String) runtimeMap.get("sparkVersion"); |
| 296 | + } |
| 297 | + } |
| 298 | + } |
| 299 | + |
| 300 | + return sparkVersion; |
| 301 | + } |
| 302 | + |
285 | 303 | } |
0 commit comments