dailidong
5 years ago
128 changed files with 2193 additions and 976 deletions
@ -1,49 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.api; |
||||
|
||||
import org.apache.dolphinscheduler.alert.AlertServer; |
||||
import org.apache.dolphinscheduler.server.master.MasterServer; |
||||
import org.apache.dolphinscheduler.server.rpc.LoggerServer; |
||||
import org.apache.dolphinscheduler.server.worker.WorkerServer; |
||||
import org.springframework.boot.autoconfigure.SpringBootApplication; |
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
||||
import org.springframework.boot.web.servlet.ServletComponentScan; |
||||
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer; |
||||
import org.springframework.context.annotation.ComponentScan; |
||||
import org.springframework.context.annotation.Import; |
||||
import springfox.documentation.swagger2.annotations.EnableSwagger2; |
||||
|
||||
@SpringBootApplication |
||||
@ConditionalOnProperty(prefix = "server", name = "is-combined-server", havingValue = "true") |
||||
@ServletComponentScan |
||||
@ComponentScan("org.apache.dolphinscheduler") |
||||
@Import({MasterServer.class, WorkerServer.class}) |
||||
@EnableSwagger2 |
||||
public class CombinedApplicationServer extends SpringBootServletInitializer { |
||||
|
||||
public static void main(String[] args) throws Exception { |
||||
|
||||
ApiApplicationServer.main(args); |
||||
|
||||
LoggerServer server = new LoggerServer(); |
||||
server.start(); |
||||
|
||||
AlertServer alertServer = AlertServer.getInstance(); |
||||
alertServer.start(); |
||||
} |
||||
} |
@ -0,0 +1,247 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.api.dto; |
||||
|
||||
/** |
||||
* ProcessMeta |
||||
*/ |
||||
public class ProcessMeta { |
||||
|
||||
/** |
||||
* project name |
||||
*/ |
||||
private String projectName; |
||||
|
||||
/** |
||||
* process definition name |
||||
*/ |
||||
private String processDefinitionName; |
||||
|
||||
/** |
||||
* processs definition json |
||||
*/ |
||||
private String processDefinitionJson; |
||||
|
||||
/** |
||||
* process definition desc |
||||
*/ |
||||
private String processDefinitionDescription; |
||||
|
||||
/** |
||||
* process definition locations |
||||
*/ |
||||
private String processDefinitionLocations; |
||||
|
||||
/** |
||||
* process definition connects |
||||
*/ |
||||
private String processDefinitionConnects; |
||||
|
||||
/** |
||||
* warning type |
||||
*/ |
||||
private String scheduleWarningType; |
||||
|
||||
/** |
||||
* warning group id |
||||
*/ |
||||
private Integer scheduleWarningGroupId; |
||||
|
||||
/** |
||||
* warning group name |
||||
*/ |
||||
private String scheduleWarningGroupName; |
||||
|
||||
/** |
||||
* start time |
||||
*/ |
||||
private String scheduleStartTime; |
||||
|
||||
/** |
||||
* end time |
||||
*/ |
||||
private String scheduleEndTime; |
||||
|
||||
/** |
||||
* crontab |
||||
*/ |
||||
private String scheduleCrontab; |
||||
|
||||
/** |
||||
* failure strategy |
||||
*/ |
||||
private String scheduleFailureStrategy; |
||||
|
||||
/** |
||||
* release state |
||||
*/ |
||||
private String scheduleReleaseState; |
||||
|
||||
/** |
||||
* process instance priority |
||||
*/ |
||||
private String scheduleProcessInstancePriority; |
||||
|
||||
/** |
||||
* worker group id |
||||
*/ |
||||
private Integer scheduleWorkerGroupId; |
||||
|
||||
/** |
||||
* worker group name |
||||
*/ |
||||
private String scheduleWorkerGroupName; |
||||
|
||||
public ProcessMeta() { |
||||
} |
||||
|
||||
public String getProjectName() { |
||||
return projectName; |
||||
} |
||||
|
||||
public void setProjectName(String projectName) { |
||||
this.projectName = projectName; |
||||
} |
||||
|
||||
public String getProcessDefinitionName() { |
||||
return processDefinitionName; |
||||
} |
||||
|
||||
public void setProcessDefinitionName(String processDefinitionName) { |
||||
this.processDefinitionName = processDefinitionName; |
||||
} |
||||
|
||||
public String getProcessDefinitionJson() { |
||||
return processDefinitionJson; |
||||
} |
||||
|
||||
public void setProcessDefinitionJson(String processDefinitionJson) { |
||||
this.processDefinitionJson = processDefinitionJson; |
||||
} |
||||
|
||||
public String getProcessDefinitionDescription() { |
||||
return processDefinitionDescription; |
||||
} |
||||
|
||||
public void setProcessDefinitionDescription(String processDefinitionDescription) { |
||||
this.processDefinitionDescription = processDefinitionDescription; |
||||
} |
||||
|
||||
public String getProcessDefinitionLocations() { |
||||
return processDefinitionLocations; |
||||
} |
||||
|
||||
public void setProcessDefinitionLocations(String processDefinitionLocations) { |
||||
this.processDefinitionLocations = processDefinitionLocations; |
||||
} |
||||
|
||||
public String getProcessDefinitionConnects() { |
||||
return processDefinitionConnects; |
||||
} |
||||
|
||||
public void setProcessDefinitionConnects(String processDefinitionConnects) { |
||||
this.processDefinitionConnects = processDefinitionConnects; |
||||
} |
||||
|
||||
public String getScheduleWarningType() { |
||||
return scheduleWarningType; |
||||
} |
||||
|
||||
public void setScheduleWarningType(String scheduleWarningType) { |
||||
this.scheduleWarningType = scheduleWarningType; |
||||
} |
||||
|
||||
public Integer getScheduleWarningGroupId() { |
||||
return scheduleWarningGroupId; |
||||
} |
||||
|
||||
public void setScheduleWarningGroupId(int scheduleWarningGroupId) { |
||||
this.scheduleWarningGroupId = scheduleWarningGroupId; |
||||
} |
||||
|
||||
public String getScheduleWarningGroupName() { |
||||
return scheduleWarningGroupName; |
||||
} |
||||
|
||||
public void setScheduleWarningGroupName(String scheduleWarningGroupName) { |
||||
this.scheduleWarningGroupName = scheduleWarningGroupName; |
||||
} |
||||
|
||||
public String getScheduleStartTime() { |
||||
return scheduleStartTime; |
||||
} |
||||
|
||||
public void setScheduleStartTime(String scheduleStartTime) { |
||||
this.scheduleStartTime = scheduleStartTime; |
||||
} |
||||
|
||||
public String getScheduleEndTime() { |
||||
return scheduleEndTime; |
||||
} |
||||
|
||||
public void setScheduleEndTime(String scheduleEndTime) { |
||||
this.scheduleEndTime = scheduleEndTime; |
||||
} |
||||
|
||||
public String getScheduleCrontab() { |
||||
return scheduleCrontab; |
||||
} |
||||
|
||||
public void setScheduleCrontab(String scheduleCrontab) { |
||||
this.scheduleCrontab = scheduleCrontab; |
||||
} |
||||
|
||||
public String getScheduleFailureStrategy() { |
||||
return scheduleFailureStrategy; |
||||
} |
||||
|
||||
public void setScheduleFailureStrategy(String scheduleFailureStrategy) { |
||||
this.scheduleFailureStrategy = scheduleFailureStrategy; |
||||
} |
||||
|
||||
public String getScheduleReleaseState() { |
||||
return scheduleReleaseState; |
||||
} |
||||
|
||||
public void setScheduleReleaseState(String scheduleReleaseState) { |
||||
this.scheduleReleaseState = scheduleReleaseState; |
||||
} |
||||
|
||||
public String getScheduleProcessInstancePriority() { |
||||
return scheduleProcessInstancePriority; |
||||
} |
||||
|
||||
public void setScheduleProcessInstancePriority(String scheduleProcessInstancePriority) { |
||||
this.scheduleProcessInstancePriority = scheduleProcessInstancePriority; |
||||
} |
||||
|
||||
public Integer getScheduleWorkerGroupId() { |
||||
return scheduleWorkerGroupId; |
||||
} |
||||
|
||||
public void setScheduleWorkerGroupId(int scheduleWorkerGroupId) { |
||||
this.scheduleWorkerGroupId = scheduleWorkerGroupId; |
||||
} |
||||
|
||||
public String getScheduleWorkerGroupName() { |
||||
return scheduleWorkerGroupName; |
||||
} |
||||
|
||||
public void setScheduleWorkerGroupName(String scheduleWorkerGroupName) { |
||||
this.scheduleWorkerGroupName = scheduleWorkerGroupName; |
||||
} |
||||
} |
@ -0,0 +1,83 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.api.utils.exportprocess; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import org.apache.dolphinscheduler.common.enums.TaskType; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.dao.entity.DataSource; |
||||
import org.apache.dolphinscheduler.dao.mapper.DataSourceMapper; |
||||
import org.springframework.beans.factory.InitializingBean; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* task node add datasource param strategy |
||||
*/ |
||||
@Service |
||||
public class DataSourceParam implements ProcessAddTaskParam, InitializingBean { |
||||
|
||||
@Autowired |
||||
private DataSourceMapper dataSourceMapper; |
||||
|
||||
/** |
||||
* add datasource params |
||||
* @param taskNode task node json object |
||||
* @return task node json object |
||||
*/ |
||||
@Override |
||||
public JSONObject addExportSpecialParam(JSONObject taskNode) { |
||||
// add sqlParameters
|
||||
JSONObject sqlParameters = JSONUtils.parseObject(taskNode.getString("params")); |
||||
DataSource dataSource = dataSourceMapper.selectById((Integer) sqlParameters.get("datasource")); |
||||
if (null != dataSource) { |
||||
sqlParameters.put("datasourceName", dataSource.getName()); |
||||
} |
||||
taskNode.put("params", sqlParameters); |
||||
|
||||
return taskNode; |
||||
} |
||||
|
||||
/** |
||||
* import process add datasource params |
||||
* @param taskNode task node json object |
||||
* @return task node json object |
||||
*/ |
||||
@Override |
||||
public JSONObject addImportSpecialParam(JSONObject taskNode) { |
||||
JSONObject sqlParameters = JSONUtils.parseObject(taskNode.getString("params")); |
||||
List<DataSource> dataSources = dataSourceMapper.queryDataSourceByName(sqlParameters.getString("datasourceName")); |
||||
if (!dataSources.isEmpty()) { |
||||
DataSource dataSource = dataSources.get(0); |
||||
sqlParameters.put("datasource", dataSource.getId()); |
||||
} |
||||
taskNode.put("params", sqlParameters); |
||||
return taskNode; |
||||
} |
||||
|
||||
|
||||
/** |
||||
* put datasource strategy |
||||
*/ |
||||
@Override |
||||
public void afterPropertiesSet() { |
||||
TaskNodeParamFactory.register(TaskType.SQL.name(), this); |
||||
TaskNodeParamFactory.register(TaskType.PROCEDURE.name(), this); |
||||
} |
||||
} |
@ -0,0 +1,112 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.api.utils.exportprocess; |
||||
|
||||
import com.alibaba.fastjson.JSONArray; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import org.apache.dolphinscheduler.common.enums.TaskType; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.dao.entity.ProcessDefinition; |
||||
import org.apache.dolphinscheduler.dao.entity.Project; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProcessDefinitionMapper; |
||||
import org.apache.dolphinscheduler.dao.mapper.ProjectMapper; |
||||
import org.springframework.beans.factory.InitializingBean; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Service; |
||||
|
||||
/** |
||||
* task node add dependent param strategy |
||||
*/ |
||||
@Service |
||||
public class DependentParam implements ProcessAddTaskParam, InitializingBean { |
||||
|
||||
|
||||
@Autowired |
||||
ProcessDefinitionMapper processDefineMapper; |
||||
|
||||
@Autowired |
||||
ProjectMapper projectMapper; |
||||
|
||||
/** |
||||
* add dependent param |
||||
* @param taskNode task node json object |
||||
* @return task node json object |
||||
*/ |
||||
@Override |
||||
public JSONObject addExportSpecialParam(JSONObject taskNode) { |
||||
// add dependent param
|
||||
JSONObject dependentParameters = JSONUtils.parseObject(taskNode.getString("dependence")); |
||||
|
||||
if (null != dependentParameters) { |
||||
JSONArray dependTaskList = (JSONArray) dependentParameters.get("dependTaskList"); |
||||
for (int j = 0; j < dependTaskList.size(); j++) { |
||||
JSONObject dependentTaskModel = dependTaskList.getJSONObject(j); |
||||
JSONArray dependItemList = (JSONArray) dependentTaskModel.get("dependItemList"); |
||||
for (int k = 0; k < dependItemList.size(); k++) { |
||||
JSONObject dependentItem = dependItemList.getJSONObject(k); |
||||
int definitionId = dependentItem.getInteger("definitionId"); |
||||
ProcessDefinition definition = processDefineMapper.queryByDefineId(definitionId); |
||||
if (null != definition) { |
||||
dependentItem.put("projectName", definition.getProjectName()); |
||||
dependentItem.put("definitionName", definition.getName()); |
||||
} |
||||
} |
||||
} |
||||
taskNode.put("dependence", dependentParameters); |
||||
} |
||||
|
||||
return taskNode; |
||||
} |
||||
|
||||
/** |
||||
* import process add dependent param |
||||
* @param taskNode task node json object |
||||
* @return |
||||
*/ |
||||
@Override |
||||
public JSONObject addImportSpecialParam(JSONObject taskNode) { |
||||
JSONObject dependentParameters = JSONUtils.parseObject(taskNode.getString("dependence")); |
||||
if(dependentParameters != null){ |
||||
JSONArray dependTaskList = (JSONArray) dependentParameters.get("dependTaskList"); |
||||
for (int h = 0; h < dependTaskList.size(); h++) { |
||||
JSONObject dependentTaskModel = dependTaskList.getJSONObject(h); |
||||
JSONArray dependItemList = (JSONArray) dependentTaskModel.get("dependItemList"); |
||||
for (int k = 0; k < dependItemList.size(); k++) { |
||||
JSONObject dependentItem = dependItemList.getJSONObject(k); |
||||
Project dependentItemProject = projectMapper.queryByName(dependentItem.getString("projectName")); |
||||
if(dependentItemProject != null){ |
||||
ProcessDefinition definition = processDefineMapper.queryByDefineName(dependentItemProject.getId(),dependentItem.getString("definitionName")); |
||||
if(definition != null){ |
||||
dependentItem.put("projectId",dependentItemProject.getId()); |
||||
dependentItem.put("definitionId",definition.getId()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
taskNode.put("dependence", dependentParameters); |
||||
} |
||||
return taskNode; |
||||
} |
||||
|
||||
/** |
||||
* put dependent strategy |
||||
*/ |
||||
@Override |
||||
public void afterPropertiesSet() { |
||||
TaskNodeParamFactory.register(TaskType.DEPENDENT.name(), this); |
||||
} |
||||
} |
@ -0,0 +1,39 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.api.utils.exportprocess; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
|
||||
/** |
||||
* ProcessAddTaskParam |
||||
*/ |
||||
public interface ProcessAddTaskParam { |
||||
|
||||
/** |
||||
* add export task special param: sql task dependent task |
||||
* @param taskNode task node json object |
||||
* @return task node json object |
||||
*/ |
||||
JSONObject addExportSpecialParam(JSONObject taskNode); |
||||
|
||||
/** |
||||
* add task special param: sql task dependent task |
||||
* @param taskNode task node json object |
||||
* @return task node json object |
||||
*/ |
||||
JSONObject addImportSpecialParam(JSONObject taskNode); |
||||
} |
@ -0,0 +1,38 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.api.utils.exportprocess; |
||||
|
||||
import java.util.Map; |
||||
import java.util.concurrent.ConcurrentHashMap; |
||||
|
||||
/** |
||||
* task node param factory |
||||
*/ |
||||
public class TaskNodeParamFactory { |
||||
|
||||
private static Map<String, ProcessAddTaskParam> taskServices = new ConcurrentHashMap<>(); |
||||
|
||||
public static ProcessAddTaskParam getByTaskType(String taskType){ |
||||
return taskServices.get(taskType); |
||||
} |
||||
|
||||
static void register(String taskType, ProcessAddTaskParam addSpecialTaskParam){ |
||||
if (null != taskType) { |
||||
taskServices.put(taskType, addSpecialTaskParam); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,86 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.api.utils.exportprocess; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import org.apache.dolphinscheduler.api.ApiApplicationServer; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.common.utils.StringUtils; |
||||
import org.json.JSONException; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.skyscreamer.jsonassert.JSONAssert; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
||||
/** |
||||
* DataSourceParamTest |
||||
*/ |
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest(classes = ApiApplicationServer.class) |
||||
public class DataSourceParamTest { |
||||
|
||||
@Test |
||||
public void testAddExportDependentSpecialParam() throws JSONException { |
||||
|
||||
String sqlJson = "{\"type\":\"SQL\",\"id\":\"tasks-27297\",\"name\":\"sql\"," + |
||||
"\"params\":{\"type\":\"MYSQL\",\"datasource\":1,\"sql\":\"select * from test\"," + |
||||
"\"udfs\":\"\",\"sqlType\":\"1\",\"title\":\"\",\"receivers\":\"\",\"receiversCc\":\"\",\"showType\":\"TABLE\"" + |
||||
",\"localParams\":[],\"connParams\":\"\"," + |
||||
"\"preStatements\":[],\"postStatements\":[]}," + |
||||
"\"description\":\"\",\"runFlag\":\"NORMAL\",\"dependence\":{},\"maxRetryTimes\":\"0\"," + |
||||
"\"retryInterval\":\"1\",\"timeout\":{\"strategy\":\"\"," + |
||||
"\"enable\":false},\"taskInstancePriority\":\"MEDIUM\",\"workerGroupId\":-1," + |
||||
"\"preTasks\":[\"dependent\"]}"; |
||||
|
||||
|
||||
JSONObject taskNode = JSONUtils.parseObject(sqlJson); |
||||
if (StringUtils.isNotEmpty(taskNode.getString("type"))) { |
||||
String taskType = taskNode.getString("type"); |
||||
|
||||
ProcessAddTaskParam addTaskParam = TaskNodeParamFactory.getByTaskType(taskType); |
||||
|
||||
JSONObject sql = addTaskParam.addExportSpecialParam(taskNode); |
||||
|
||||
JSONAssert.assertEquals(taskNode.toString(), sql.toString(), false); |
||||
} |
||||
} |
||||
|
||||
@Test |
||||
public void testAddImportDependentSpecialParam() throws JSONException { |
||||
String sqlJson = "{\"workerGroupId\":-1,\"description\":\"\",\"runFlag\":\"NORMAL\"," + |
||||
"\"type\":\"SQL\",\"params\":{\"postStatements\":[]," + |
||||
"\"connParams\":\"\",\"receiversCc\":\"\",\"udfs\":\"\"," + |
||||
"\"type\":\"MYSQL\",\"title\":\"\",\"sql\":\"show tables\",\"" + |
||||
"preStatements\":[],\"sqlType\":\"1\",\"receivers\":\"\",\"datasource\":1," + |
||||
"\"showType\":\"TABLE\",\"localParams\":[],\"datasourceName\":\"dsmetadata\"},\"timeout\"" + |
||||
":{\"enable\":false,\"strategy\":\"\"},\"maxRetryTimes\":\"0\"," + |
||||
"\"taskInstancePriority\":\"MEDIUM\",\"name\":\"mysql\",\"dependence\":{}," + |
||||
"\"retryInterval\":\"1\",\"preTasks\":[\"dependent\"],\"id\":\"tasks-8745\"}"; |
||||
|
||||
JSONObject taskNode = JSONUtils.parseObject(sqlJson); |
||||
if (StringUtils.isNotEmpty(taskNode.getString("type"))) { |
||||
String taskType = taskNode.getString("type"); |
||||
|
||||
ProcessAddTaskParam addTaskParam = TaskNodeParamFactory.getByTaskType(taskType); |
||||
|
||||
JSONObject sql = addTaskParam.addImportSpecialParam(taskNode); |
||||
|
||||
JSONAssert.assertEquals(taskNode.toString(), sql.toString(), false); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,112 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
package org.apache.dolphinscheduler.api.utils.exportprocess; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import org.apache.dolphinscheduler.api.ApiApplicationServer; |
||||
import org.apache.dolphinscheduler.common.utils.JSONUtils; |
||||
import org.apache.dolphinscheduler.common.utils.StringUtils; |
||||
import org.json.JSONException; |
||||
import org.junit.Test; |
||||
import org.junit.runner.RunWith; |
||||
import org.skyscreamer.jsonassert.JSONAssert; |
||||
import org.springframework.boot.test.context.SpringBootTest; |
||||
import org.springframework.test.context.junit4.SpringRunner; |
||||
|
||||
/** |
||||
* DependentParamTest |
||||
*/ |
||||
@RunWith(SpringRunner.class) |
||||
@SpringBootTest(classes = ApiApplicationServer.class) |
||||
public class DependentParamTest { |
||||
|
||||
|
||||
@Test |
||||
public void testAddExportDependentSpecialParam() throws JSONException { |
||||
String dependentJson = "{\"type\":\"DEPENDENT\",\"id\":\"tasks-33787\"," + |
||||
"\"name\":\"dependent\",\"params\":{},\"description\":\"\",\"runFlag\":\"NORMAL\"," + |
||||
"\"dependence\":{\"relation\":\"AND\",\"dependTaskList\":[{\"relation\":\"AND\"," + |
||||
"\"dependItemList\":[{\"projectId\":2,\"definitionId\":46,\"depTasks\":\"ALL\"," + |
||||
"\"cycle\":\"day\",\"dateValue\":\"today\"}]}]}}"; |
||||
|
||||
JSONObject taskNode = JSONUtils.parseObject(dependentJson); |
||||
if (StringUtils.isNotEmpty(taskNode.getString("type"))) { |
||||
String taskType = taskNode.getString("type"); |
||||
|
||||
ProcessAddTaskParam addTaskParam = TaskNodeParamFactory.getByTaskType(taskType); |
||||
|
||||
JSONObject dependent = addTaskParam.addExportSpecialParam(taskNode); |
||||
|
||||
JSONAssert.assertEquals(taskNode.toString(), dependent.toString(), false); |
||||
} |
||||
|
||||
String dependentEmpty = "{\"type\":\"DEPENDENT\",\"id\":\"tasks-33787\"," + |
||||
"\"name\":\"dependent\",\"params\":{},\"description\":\"\",\"runFlag\":\"NORMAL\"}"; |
||||
|
||||
JSONObject taskEmpty = JSONUtils.parseObject(dependentEmpty); |
||||
if (StringUtils.isNotEmpty(taskEmpty.getString("type"))) { |
||||
String taskType = taskEmpty.getString("type"); |
||||
|
||||
ProcessAddTaskParam addTaskParam = TaskNodeParamFactory.getByTaskType(taskType); |
||||
|
||||
JSONObject dependent = addTaskParam.addImportSpecialParam(taskEmpty); |
||||
|
||||
JSONAssert.assertEquals(taskEmpty.toString(), dependent.toString(), false); |
||||
} |
||||
|
||||
} |
||||
|
||||
@Test |
||||
public void testAddImportDependentSpecialParam() throws JSONException { |
||||
String dependentJson = "{\"workerGroupId\":-1,\"description\":\"\",\"runFlag\":\"NORMAL\"" + |
||||
",\"type\":\"DEPENDENT\",\"params\":{},\"timeout\":{\"enable\":false," + |
||||
"\"strategy\":\"\"},\"maxRetryTimes\":\"0\",\"taskInstancePriority\":\"MEDIUM\"" + |
||||
",\"name\":\"dependent\"," + |
||||
"\"dependence\":{\"dependTaskList\":[{\"dependItemList\":[{\"dateValue\":\"today\"," + |
||||
"\"definitionName\":\"shell-1\",\"depTasks\":\"shell-1\",\"projectName\":\"test\"," + |
||||
"\"projectId\":1,\"cycle\":\"day\",\"definitionId\":7}],\"relation\":\"AND\"}]," + |
||||
"\"relation\":\"AND\"},\"retryInterval\":\"1\",\"preTasks\":[],\"id\":\"tasks-55485\"}"; |
||||
|
||||
JSONObject taskNode = JSONUtils.parseObject(dependentJson); |
||||
if (StringUtils.isNotEmpty(taskNode.getString("type"))) { |
||||
String taskType = taskNode.getString("type"); |
||||
|
||||
ProcessAddTaskParam addTaskParam = TaskNodeParamFactory.getByTaskType(taskType); |
||||
|
||||
JSONObject dependent = addTaskParam.addImportSpecialParam(taskNode); |
||||
|
||||
JSONAssert.assertEquals(taskNode.toString(), dependent.toString(), false); |
||||
} |
||||
|
||||
String dependentEmpty = "{\"workerGroupId\":-1,\"description\":\"\",\"runFlag\":\"NORMAL\"" + |
||||
",\"type\":\"DEPENDENT\",\"params\":{},\"timeout\":{\"enable\":false," + |
||||
"\"strategy\":\"\"},\"maxRetryTimes\":\"0\",\"taskInstancePriority\":\"MEDIUM\"" + |
||||
",\"name\":\"dependent\",\"retryInterval\":\"1\",\"preTasks\":[],\"id\":\"tasks-55485\"}"; |
||||
|
||||
JSONObject taskNodeEmpty = JSONUtils.parseObject(dependentEmpty); |
||||
if (StringUtils.isNotEmpty(taskNodeEmpty.getString("type"))) { |
||||
String taskType = taskNodeEmpty.getString("type"); |
||||
|
||||
ProcessAddTaskParam addTaskParam = TaskNodeParamFactory.getByTaskType(taskType); |
||||
|
||||
JSONObject dependent = addTaskParam.addImportSpecialParam(taskNode); |
||||
|
||||
JSONAssert.assertEquals(taskNodeEmpty.toString(), dependent.toString(), false); |
||||
} |
||||
|
||||
} |
||||
} |
@ -1,22 +0,0 @@
|
||||
# |
||||
# Licensed to the Apache Software Foundation (ASF) under one or more |
||||
# contributor license agreements. See the NOTICE file distributed with |
||||
# this work for additional information regarding copyright ownership. |
||||
# The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
# (the "License"); you may not use this file except in compliance with |
||||
# the License. You may obtain a copy of the License at |
||||
# |
||||
# http://www.apache.org/licenses/LICENSE-2.0 |
||||
# |
||||
# Unless required by applicable law or agreed to in writing, software |
||||
# distributed under the License is distributed on an "AS IS" BASIS, |
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
# See the License for the specific language governing permissions and |
||||
# limitations under the License. |
||||
# |
||||
|
||||
masters=ark0,ark1 |
||||
workers=ark2,ark3,ark4 |
||||
alertServer=ark3 |
||||
apiServers=ark1 |
||||
sshPort=22 |
@ -0,0 +1,8 @@
|
||||
{ |
||||
"presets": [["env", { "modules": false }]], |
||||
"env": { |
||||
"test": { |
||||
"presets": [["env", { "targets": { "node": "current" } }]] |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,55 @@
|
||||
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
import { mount } from '@vue/test-utils' |
||||
import Counter from '../src/components/Counter.vue' |
||||
|
||||
describe("Counter.vue", () => { |
||||
it("渲染Counter组件", () => { |
||||
const wrapper = mount(Counter) |
||||
expect(wrapper.element).toMatchSnapshot() |
||||
}) |
||||
|
||||
it("初始化之为0", () => { |
||||
const wrapper = mount(Counter) |
||||
expect(wrapper.vm.count).toEqual(0) |
||||
}) |
||||
|
||||
it("加1", () => { |
||||
const wrapper = mount(Counter) |
||||
wrapper.vm.inc() |
||||
expect(wrapper.vm.count).toEqual(1) |
||||
}) |
||||
|
||||
it("减1", () => { |
||||
const wrapper = mount(Counter) |
||||
wrapper.vm.dec() |
||||
expect(wrapper.vm.count).toEqual(-1) |
||||
}) |
||||
|
||||
it("重置", () => { |
||||
const wrapper = mount(Counter) |
||||
wrapper.vm.reset() |
||||
expect(wrapper.vm.count).toEqual(0) |
||||
}) |
||||
|
||||
it("因数为10加1操作", () => { |
||||
const wrapper = mount(Counter, { propsData: { factor: 10 } }) |
||||
wrapper.vm.inc() |
||||
expect(wrapper.vm.computedCount).toEqual(10) |
||||
}) |
||||
}) |
@ -0,0 +1,43 @@
|
||||
{ |
||||
"name": "testjest", |
||||
"description": "jest", |
||||
"version": "1.0.0", |
||||
"author": "xiangcaibiao", |
||||
"private": true, |
||||
"scripts": { |
||||
"test": "jest --coverage" |
||||
}, |
||||
"dependencies": { |
||||
"vue": "^2.4.4" |
||||
}, |
||||
"jest": { |
||||
"moduleFileExtensions": [ |
||||
"js", |
||||
"vue" |
||||
], |
||||
"moduleNameMapper": { |
||||
"^@/(.*)$": "<rootDir>/src/$1" |
||||
}, |
||||
"transform": { |
||||
"^.+\\.js$": "<rootDir>/_test_/node_modules/babel-jest", |
||||
".*\\.(vue)$": "<rootDir>/_test_/node_modules/vue-jest" |
||||
}, |
||||
"snapshotSerializers": [ |
||||
"<rootDir>/_test_/node_modules/jest-serializer-vue" |
||||
], |
||||
"collectCoverage": true, |
||||
"collectCoverageFrom": [ |
||||
"src/**/*.{js,vue}", |
||||
"!**/node_modules/**" |
||||
], |
||||
"rootDir": "../" |
||||
}, |
||||
"devDependencies": { |
||||
"@vue/test-utils": "^1.0.0-beta.30", |
||||
"babel-jest": "^24.9.0", |
||||
"babel-preset-env": "^1.7.0", |
||||
"jest": "^24.9.0", |
||||
"jest-serializer-vue": "^2.0.2", |
||||
"vue-jest": "^3.0.5" |
||||
} |
||||
} |
@ -0,0 +1,34 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
import { shallowMount } from '@vue/test-utils' |
||||
import Message from '../src/components/Message.vue' |
||||
|
||||
describe('Message', () => { |
||||
it('renders props.msg when passed', () => { |
||||
const msg = 'new message' |
||||
const wrapper = shallowMount(Message, { |
||||
propsData: { msg } |
||||
}) |
||||
expect(wrapper.text()).toBe(msg) |
||||
}) |
||||
|
||||
it('renders default message if not passed a prop', () => { |
||||
const defaultMessage = 'default message' |
||||
const wrapper = shallowMount(Message) |
||||
expect(wrapper.text()).toBe(defaultMessage) |
||||
}) |
||||
}) |
@ -1,100 +0,0 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
|
||||
const webpack = require('webpack') |
||||
const merge = require('webpack-merge') |
||||
const { baseConfig } = require('./config') |
||||
const ExtractTextPlugin = require('extract-text-webpack-plugin') |
||||
|
||||
const config = merge.smart(baseConfig, { |
||||
devtool: 'inline-source-map', |
||||
output: { |
||||
filename: 'js/[name].js' |
||||
}, |
||||
module: { |
||||
rules: [ |
||||
{ |
||||
test: /\.vue$/, |
||||
loader: 'vue-loader', |
||||
options: { |
||||
hotReload: true // Open hot overload
|
||||
} |
||||
}, |
||||
{ |
||||
test: /\.css$/, |
||||
loader: ExtractTextPlugin.extract({ |
||||
use: [ |
||||
'css-loader', |
||||
{ |
||||
loader: 'postcss-loader', |
||||
options: { |
||||
plugins: (loader) => [ |
||||
require('autoprefixer')({ |
||||
overrideBrowserslist: [ |
||||
"Android 4.1", |
||||
"iOS 7.1", |
||||
"Chrome > 31", |
||||
"ff > 31", |
||||
"ie >= 8" |
||||
] |
||||
}), |
||||
require('cssnano') |
||||
] |
||||
} |
||||
} |
||||
], |
||||
fallback: ['vue-style-loader'] |
||||
}) |
||||
}, |
||||
{ |
||||
test: /\.scss$/, |
||||
loader: ExtractTextPlugin.extract({ |
||||
use: [ |
||||
'css-loader', |
||||
'sass-loader', |
||||
{ |
||||
loader: 'postcss-loader', |
||||
options: { |
||||
plugins: (loader) => [ |
||||
require('autoprefixer')({ |
||||
overrideBrowserslist: [ |
||||
"Android 4.1", |
||||
"iOS 7.1", |
||||
"Chrome > 31", |
||||
"ff > 31", |
||||
"ie >= 8" |
||||
] |
||||
}), |
||||
require('cssnano') |
||||
] |
||||
} |
||||
} |
||||
], |
||||
fallback: ['vue-style-loader'] |
||||
}) |
||||
} |
||||
] |
||||
}, |
||||
externals: '', |
||||
plugins: [ |
||||
new webpack.HotModuleReplacementPlugin(), |
||||
new ExtractTextPlugin({ filename: 'css/[name].css', allChunks: true }), |
||||
new webpack.optimize.OccurrenceOrderPlugin() |
||||
] |
||||
}) |
||||
|
||||
module.exports = config |
@ -0,0 +1,53 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
<template> |
||||
<div> |
||||
<div>{{ computedCount }}</div> |
||||
<button @click="inc">加</button> |
||||
<button @click="dec">减</button> |
||||
<button @click="reset">重置</button> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
export default { |
||||
props: { |
||||
factor: { type: Number, default: 1 } |
||||
}, |
||||
data() { |
||||
return { |
||||
count: 0 |
||||
}; |
||||
}, |
||||
methods: { |
||||
inc() { |
||||
this.count++; |
||||
}, |
||||
dec() { |
||||
this.count--; |
||||
}, |
||||
reset() { |
||||
this.count = 0; |
||||
} |
||||
}, |
||||
computed: { |
||||
computedCount: function() { |
||||
return this.count * this.factor; |
||||
} |
||||
} |
||||
}; |
||||
</script> |
@ -0,0 +1,28 @@
|
||||
/* |
||||
* Licensed to the Apache Software Foundation (ASF) under one or more |
||||
* contributor license agreements. See the NOTICE file distributed with |
||||
* this work for additional information regarding copyright ownership. |
||||
* The ASF licenses this file to You under the Apache License, Version 2.0 |
||||
* (the "License"); you may not use this file except in compliance with |
||||
* the License. You may obtain a copy of the License at |
||||
* |
||||
* http://www.apache.org/licenses/LICENSE-2.0 |
||||
* |
||||
* Unless required by applicable law or agreed to in writing, software |
||||
* distributed under the License is distributed on an "AS IS" BASIS, |
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||
* See the License for the specific language governing permissions and |
||||
* limitations under the License. |
||||
*/ |
||||
<template> |
||||
<h1> {{ msg || 'default message' }}</h1> |
||||
</template> |
||||
|
||||
<script> |
||||
export default { |
||||
name: 'message', |
||||
props: [ |
||||
'msg' |
||||
] |
||||
} |
||||
</script> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue