samz406
5 years ago
committed by
GitHub
263 changed files with 8236 additions and 636 deletions
@ -0,0 +1,23 @@
|
||||
--- |
||||
name: question |
||||
about: have a question wanted to be help |
||||
title: "[QUESTION] question title" |
||||
labels: question |
||||
assignees: '' |
||||
|
||||
--- |
||||
|
||||
*For better global communication, please give priority to using English description, thx! * |
||||
|
||||
**Describe the question** |
||||
A clear and concise description of what the question is. |
||||
|
||||
|
||||
**Which version of DolphinScheduler:** |
||||
-[1.1.0-preview] |
||||
|
||||
**Additional context** |
||||
Add any other context about the problem here. |
||||
|
||||
**Requirement or improvement |
||||
- Please describe about your requirements or improvement suggestions. |
@ -0,0 +1,17 @@
|
||||
name: CI |
||||
|
||||
on: [push] |
||||
|
||||
jobs: |
||||
build: |
||||
|
||||
runs-on: ubuntu-latest |
||||
|
||||
steps: |
||||
- uses: actions/checkout@v1 |
||||
- name: Set up JDK 1.8 |
||||
uses: actions/setup-java@v1 |
||||
with: |
||||
java-version: 1.8 |
||||
- name: Build with Maven |
||||
run: mvn apache-rat:check --file pom.xml |
@ -0,0 +1,5 @@
|
||||
logging.config=classpath:alert_logback.xml |
||||
|
||||
# server port |
||||
server.port=7789 |
||||
|
@ -0,0 +1,30 @@
|
||||
/* |
||||
* 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 cn.escheduler.common.enums; |
||||
|
||||
/** |
||||
* http check condition |
||||
*/ |
||||
public enum HttpCheckCondition { |
||||
/** |
||||
* 0 status_code_default:200 |
||||
* 1 status_code_custom |
||||
* 2 body_contains |
||||
* 3 body_not_contains |
||||
*/ |
||||
STATUS_CODE_DEFAULT,STATUS_CODE_CUSTOM, BODY_CONTAINS, BODY_NOT_CONTAINS |
||||
} |
@ -0,0 +1,31 @@
|
||||
/* |
||||
* 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 cn.escheduler.common.enums; |
||||
|
||||
/** |
||||
* http method |
||||
*/ |
||||
public enum HttpMethod { |
||||
/** |
||||
* 0 get |
||||
* 1 post |
||||
* 2 head |
||||
* 3 put |
||||
* 4 delete |
||||
*/ |
||||
GET, POST, HEAD, PUT, DELETE |
||||
} |
@ -0,0 +1,29 @@
|
||||
/* |
||||
* 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 cn.escheduler.common.enums; |
||||
|
||||
/** |
||||
* http parameters type |
||||
*/ |
||||
public enum HttpParametersType { |
||||
/** |
||||
* 0 parameter; |
||||
* 1 body; |
||||
* 2 headers; |
||||
*/ |
||||
PARAMETER,BODY,HEADERS |
||||
} |
@ -0,0 +1,125 @@
|
||||
/* |
||||
* 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 cn.escheduler.common.process; |
||||
|
||||
import cn.escheduler.common.enums.HttpParametersType; |
||||
|
||||
import java.util.Objects; |
||||
|
||||
public class HttpProperty { |
||||
/** |
||||
* key |
||||
*/ |
||||
private String prop; |
||||
|
||||
/** |
||||
* httpParametersType |
||||
*/ |
||||
private HttpParametersType httpParametersType; |
||||
|
||||
/** |
||||
* value |
||||
*/ |
||||
private String value; |
||||
|
||||
public HttpProperty() { |
||||
} |
||||
|
||||
public HttpProperty(String prop, HttpParametersType httpParametersType, String value) { |
||||
this.prop = prop; |
||||
this.httpParametersType = httpParametersType; |
||||
this.value = value; |
||||
} |
||||
|
||||
/** |
||||
* getter method |
||||
* |
||||
* @return the prop |
||||
* @see HttpProperty#prop |
||||
*/ |
||||
public String getProp() { |
||||
return prop; |
||||
} |
||||
|
||||
/** |
||||
* setter method |
||||
* |
||||
* @param prop the prop to set |
||||
* @see HttpProperty#prop |
||||
*/ |
||||
public void setProp(String prop) { |
||||
this.prop = prop; |
||||
} |
||||
|
||||
/** |
||||
* getter method |
||||
* |
||||
* @return the value |
||||
* @see HttpProperty#value |
||||
*/ |
||||
public String getValue() { |
||||
return value; |
||||
} |
||||
|
||||
/** |
||||
* setter method |
||||
* |
||||
* @param value the value to set |
||||
* @see HttpProperty#value |
||||
*/ |
||||
public void setValue(String value) { |
||||
this.value = value; |
||||
} |
||||
|
||||
public HttpParametersType getHttpParametersType() { |
||||
return httpParametersType; |
||||
} |
||||
|
||||
public void setHttpParametersType(HttpParametersType httpParametersType) { |
||||
this.httpParametersType = httpParametersType; |
||||
} |
||||
|
||||
@Override |
||||
public boolean equals(Object o) { |
||||
if (this == o) { |
||||
return true; |
||||
} |
||||
if (o == null || getClass() != o.getClass()) { |
||||
return false; |
||||
} |
||||
HttpProperty property = (HttpProperty) o; |
||||
return Objects.equals(prop, property.prop) && |
||||
Objects.equals(value, property.value); |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public int hashCode() { |
||||
return Objects.hash(prop, value); |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "HttpProperty{" + |
||||
"prop='" + prop + '\'' + |
||||
", httpParametersType=" + httpParametersType + |
||||
", value='" + value + '\'' + |
||||
'}'; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,219 @@
|
||||
/* |
||||
* 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 cn.escheduler.common.task.flink; |
||||
|
||||
import cn.escheduler.common.enums.ProgramType; |
||||
import cn.escheduler.common.process.ResourceInfo; |
||||
import cn.escheduler.common.task.AbstractParameters; |
||||
|
||||
import java.util.List; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* spark parameters |
||||
*/ |
||||
public class FlinkParameters extends AbstractParameters { |
||||
|
||||
/** |
||||
* major jar |
||||
*/ |
||||
private ResourceInfo mainJar; |
||||
|
||||
/** |
||||
* major class
|
||||
*/ |
||||
private String mainClass; |
||||
|
||||
/** |
||||
* deploy mode yarn-cluster yarn-client yarn-local |
||||
*/ |
||||
private String deployMode; |
||||
|
||||
/** |
||||
* arguments |
||||
*/ |
||||
private String mainArgs; |
||||
|
||||
/** |
||||
* slot个数 |
||||
*/ |
||||
private int slot; |
||||
|
||||
/** |
||||
*Yarn application的名字 |
||||
*/ |
||||
|
||||
private String appName; |
||||
|
||||
/** |
||||
* taskManager 数量 |
||||
*/ |
||||
private int taskManager; |
||||
|
||||
/** |
||||
* jobManagerMemory 内存大小 |
||||
*/ |
||||
private String jobManagerMemory ; |
||||
|
||||
/** |
||||
* taskManagerMemory内存大小 |
||||
*/ |
||||
private String taskManagerMemory; |
||||
|
||||
/** |
||||
* resource list |
||||
*/ |
||||
private List<ResourceInfo> resourceList; |
||||
|
||||
/** |
||||
* The YARN queue to submit to |
||||
*/ |
||||
private String queue; |
||||
|
||||
/** |
||||
* other arguments |
||||
*/ |
||||
private String others; |
||||
|
||||
/** |
||||
* program type |
||||
* 0 JAVA,1 SCALA,2 PYTHON |
||||
*/ |
||||
private ProgramType programType; |
||||
|
||||
public ResourceInfo getMainJar() { |
||||
return mainJar; |
||||
} |
||||
|
||||
public void setMainJar(ResourceInfo mainJar) { |
||||
this.mainJar = mainJar; |
||||
} |
||||
|
||||
public String getMainClass() { |
||||
return mainClass; |
||||
} |
||||
|
||||
public void setMainClass(String mainClass) { |
||||
this.mainClass = mainClass; |
||||
} |
||||
|
||||
public String getDeployMode() { |
||||
return deployMode; |
||||
} |
||||
|
||||
public void setDeployMode(String deployMode) { |
||||
this.deployMode = deployMode; |
||||
} |
||||
|
||||
public String getMainArgs() { |
||||
return mainArgs; |
||||
} |
||||
|
||||
public void setMainArgs(String mainArgs) { |
||||
this.mainArgs = mainArgs; |
||||
} |
||||
|
||||
public int getSlot() { |
||||
return slot; |
||||
} |
||||
|
||||
public void setSlot(int slot) { |
||||
this.slot = slot; |
||||
} |
||||
|
||||
public String getAppName() { |
||||
return appName; |
||||
} |
||||
|
||||
public void setAppName(String appName) { |
||||
this.appName = appName; |
||||
} |
||||
|
||||
public int getTaskManager() { |
||||
return taskManager; |
||||
} |
||||
|
||||
public void setTaskManager(int taskManager) { |
||||
this.taskManager = taskManager; |
||||
} |
||||
|
||||
public String getJobManagerMemory() { |
||||
return jobManagerMemory; |
||||
} |
||||
|
||||
public void setJobManagerMemory(String jobManagerMemory) { |
||||
this.jobManagerMemory = jobManagerMemory; |
||||
} |
||||
|
||||
public String getTaskManagerMemory() { |
||||
return taskManagerMemory; |
||||
} |
||||
|
||||
public void setTaskManagerMemory(String taskManagerMemory) { |
||||
this.taskManagerMemory = taskManagerMemory; |
||||
} |
||||
|
||||
public String getQueue() { |
||||
return queue; |
||||
} |
||||
|
||||
public void setQueue(String queue) { |
||||
this.queue = queue; |
||||
} |
||||
|
||||
public List<ResourceInfo> getResourceList() { |
||||
return resourceList; |
||||
} |
||||
|
||||
public void setResourceList(List<ResourceInfo> resourceList) { |
||||
this.resourceList = resourceList; |
||||
} |
||||
|
||||
public String getOthers() { |
||||
return others; |
||||
} |
||||
|
||||
public void setOthers(String others) { |
||||
this.others = others; |
||||
} |
||||
|
||||
public ProgramType getProgramType() { |
||||
return programType; |
||||
} |
||||
|
||||
public void setProgramType(ProgramType programType) { |
||||
this.programType = programType; |
||||
} |
||||
|
||||
@Override |
||||
public boolean checkParameters() { |
||||
return mainJar != null && programType != null; |
||||
} |
||||
|
||||
|
||||
@Override |
||||
public List<String> getResourceFilesList() { |
||||
if(resourceList !=null ) { |
||||
this.resourceList.add(mainJar); |
||||
return resourceList.stream() |
||||
.map(p -> p.getRes()).collect(Collectors.toList()); |
||||
} |
||||
return null; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,108 @@
|
||||
/* |
||||
* 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 cn.escheduler.common.task.http; |
||||
|
||||
import cn.escheduler.common.enums.HttpCheckCondition; |
||||
import cn.escheduler.common.enums.HttpMethod; |
||||
import cn.escheduler.common.process.HttpProperty; |
||||
import cn.escheduler.common.task.AbstractParameters; |
||||
import org.apache.commons.lang.StringUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* http parameter |
||||
*/ |
||||
public class HttpParameters extends AbstractParameters { |
||||
/** |
||||
* url |
||||
*/ |
||||
private String url; |
||||
|
||||
/** |
||||
* httpMethod |
||||
*/ |
||||
private HttpMethod httpMethod; |
||||
|
||||
/** |
||||
* http params |
||||
*/ |
||||
private List<HttpProperty> httpParams; |
||||
|
||||
/** |
||||
* httpCheckCondition |
||||
*/ |
||||
private HttpCheckCondition httpCheckCondition = HttpCheckCondition.STATUS_CODE_DEFAULT; |
||||
|
||||
/** |
||||
* condition |
||||
*/ |
||||
private String condition; |
||||
|
||||
|
||||
|
||||
@Override |
||||
public boolean checkParameters() { |
||||
return StringUtils.isNotEmpty(url); |
||||
} |
||||
|
||||
@Override |
||||
public List<String> getResourceFilesList() { |
||||
return new ArrayList<>(); |
||||
} |
||||
|
||||
public String getUrl() { |
||||
return url; |
||||
} |
||||
|
||||
public void setUrl(String url) { |
||||
this.url = url; |
||||
} |
||||
|
||||
public HttpMethod getHttpMethod() { |
||||
return httpMethod; |
||||
} |
||||
|
||||
public void setHttpMethod(HttpMethod httpMethod) { |
||||
this.httpMethod = httpMethod; |
||||
} |
||||
|
||||
public List<HttpProperty> getHttpParams() { |
||||
return httpParams; |
||||
} |
||||
|
||||
public void setHttpParams(List<HttpProperty> httpParams) { |
||||
this.httpParams = httpParams; |
||||
} |
||||
|
||||
public HttpCheckCondition getHttpCheckCondition() { |
||||
return httpCheckCondition; |
||||
} |
||||
|
||||
public void setHttpCheckCondition(HttpCheckCondition httpCheckCondition) { |
||||
this.httpCheckCondition = httpCheckCondition; |
||||
} |
||||
|
||||
public String getCondition() { |
||||
return condition; |
||||
} |
||||
|
||||
public void setCondition(String condition) { |
||||
this.condition = condition; |
||||
} |
||||
} |
@ -0,0 +1,124 @@
|
||||
/* |
||||
* 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 cn.escheduler.server.utils; |
||||
|
||||
|
||||
import cn.escheduler.common.Constants; |
||||
import cn.escheduler.common.enums.ProgramType; |
||||
import cn.escheduler.common.task.flink.FlinkParameters; |
||||
import org.apache.commons.lang.StringUtils; |
||||
import org.slf4j.LoggerFactory; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
|
||||
/** |
||||
* spark args utils |
||||
*/ |
||||
public class FlinkArgsUtils { |
||||
|
||||
/** |
||||
* build args |
||||
* |
||||
* @param param |
||||
* @return |
||||
*/ |
||||
private static final org.slf4j.Logger logger = LoggerFactory.getLogger(FlinkArgsUtils.class); |
||||
|
||||
public static List<String> buildArgs(FlinkParameters param) { |
||||
List<String> args = new ArrayList<>(); |
||||
String deployMode = "cluster"; |
||||
if (StringUtils.isNotEmpty(param.getDeployMode())) { |
||||
deployMode = param.getDeployMode(); |
||||
|
||||
} |
||||
if (!"local".equals(deployMode)) { |
||||
args.add(Constants.FLINK_RUN_MODE); //-m
|
||||
|
||||
args.add(Constants.FLINK_YARN_CLUSTER); //yarn-cluster
|
||||
|
||||
|
||||
if (param.getSlot() != 0) { |
||||
args.add(Constants.FLINK_YARN_SLOT); |
||||
args.add(String.format("%d", param.getSlot())); //-ys
|
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(param.getAppName())) { //-ynm
|
||||
args.add(Constants.FLINK_APP_NAME); |
||||
args.add(param.getAppName()); |
||||
} |
||||
|
||||
if (param.getTaskManager() != 0) { //-yn
|
||||
args.add(Constants.FLINK_TASK_MANAGE); |
||||
args.add(String.format("%d", param.getTaskManager())); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(param.getJobManagerMemory())) { |
||||
args.add(Constants.FLINK_JOB_MANAGE_MEM); |
||||
args.add(param.getJobManagerMemory()); //-yjm
|
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(param.getTaskManagerMemory())) { // -ytm
|
||||
args.add(Constants.FLINK_TASK_MANAGE_MEM); |
||||
args.add(param.getTaskManagerMemory()); |
||||
} |
||||
|
||||
args.add(Constants.FLINK_detach); //-d
|
||||
|
||||
|
||||
} |
||||
|
||||
if (param.getProgramType() != null) { |
||||
if (param.getProgramType() != ProgramType.PYTHON) { |
||||
if (StringUtils.isNotEmpty(param.getMainClass())) { |
||||
args.add(Constants.FLINK_MAIN_CLASS); //-c
|
||||
args.add(param.getMainClass()); //main class
|
||||
} |
||||
} |
||||
} |
||||
|
||||
if (param.getMainJar() != null) { |
||||
args.add(param.getMainJar().getRes()); |
||||
} |
||||
|
||||
if (StringUtils.isNotEmpty(param.getMainArgs())) { |
||||
args.add(param.getMainArgs()); |
||||
} |
||||
|
||||
// --files --conf --libjar ...
|
||||
if (StringUtils.isNotEmpty(param.getOthers())) { |
||||
String others = param.getOthers(); |
||||
if (!others.contains("--qu")) { |
||||
if (StringUtils.isNotEmpty(param.getQueue()) && !deployMode.equals("local")) { |
||||
args.add(Constants.FLINK_QUEUE); |
||||
args.add(param.getQueue()); |
||||
} |
||||
} |
||||
args.add(param.getOthers()); |
||||
} else if (StringUtils.isNotEmpty(param.getQueue()) && !deployMode.equals("local")) { |
||||
args.add(Constants.FLINK_QUEUE); |
||||
args.add(param.getQueue()); |
||||
|
||||
} |
||||
|
||||
|
||||
return args; |
||||
} |
||||
|
||||
|
||||
} |
@ -0,0 +1,118 @@
|
||||
/* |
||||
* 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 cn.escheduler.server.worker.task.flink; |
||||
|
||||
import cn.escheduler.common.process.Property; |
||||
import cn.escheduler.common.task.AbstractParameters; |
||||
import cn.escheduler.common.task.flink.FlinkParameters; |
||||
import cn.escheduler.common.utils.JSONUtils; |
||||
import cn.escheduler.common.utils.ParameterUtils; |
||||
import cn.escheduler.dao.model.ProcessInstance; |
||||
import cn.escheduler.server.utils.FlinkArgsUtils; |
||||
import cn.escheduler.server.utils.ParamUtils; |
||||
import cn.escheduler.server.worker.task.AbstractYarnTask; |
||||
import cn.escheduler.server.worker.task.TaskProps; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* flink task |
||||
*/ |
||||
public class FlinkTask extends AbstractYarnTask { |
||||
|
||||
/** |
||||
* flink command |
||||
*/ |
||||
private static final String FLINK_COMMAND = "flink"; |
||||
private static final String FLINK_RUN = "run"; |
||||
|
||||
/** |
||||
* flink parameters |
||||
*/ |
||||
private FlinkParameters flinkParameters; |
||||
|
||||
public FlinkTask(TaskProps props, Logger logger) { |
||||
super(props, logger); |
||||
} |
||||
|
||||
@Override |
||||
public void init() { |
||||
|
||||
logger.info("flink task params {}", taskProps.getTaskParams()); |
||||
|
||||
flinkParameters = JSONUtils.parseObject(taskProps.getTaskParams(), FlinkParameters.class); |
||||
|
||||
if (!flinkParameters.checkParameters()) { |
||||
throw new RuntimeException("flink task params is not valid"); |
||||
} |
||||
flinkParameters.setQueue(taskProps.getQueue()); |
||||
|
||||
if (StringUtils.isNotEmpty(flinkParameters.getMainArgs())) { |
||||
String args = flinkParameters.getMainArgs(); |
||||
// get process instance by task instance id
|
||||
ProcessInstance processInstance = processDao.findProcessInstanceByTaskId(taskProps.getTaskInstId()); |
||||
|
||||
/** |
||||
* combining local and global parameters |
||||
*/ |
||||
Map<String, Property> paramsMap = ParamUtils.convert(taskProps.getUserDefParamsMap(), |
||||
taskProps.getDefinedParams(), |
||||
flinkParameters.getLocalParametersMap(), |
||||
processInstance.getCmdTypeIfComplement(), |
||||
processInstance.getScheduleTime()); |
||||
|
||||
logger.info("param Map : {}", paramsMap); |
||||
if (paramsMap != null ){ |
||||
|
||||
args = ParameterUtils.convertParameterPlaceholders(args, ParamUtils.convert(paramsMap)); |
||||
logger.info("param args : {}", args); |
||||
} |
||||
flinkParameters.setMainArgs(args); |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* create command |
||||
* @return |
||||
*/ |
||||
@Override |
||||
protected String buildCommand() { |
||||
List<String> args = new ArrayList<>(); |
||||
|
||||
args.add(FLINK_COMMAND); |
||||
args.add(FLINK_RUN); |
||||
logger.info("flink task args : {}", args); |
||||
// other parameters
|
||||
args.addAll(FlinkArgsUtils.buildArgs(flinkParameters)); |
||||
|
||||
String command = ParameterUtils |
||||
.convertParameterPlaceholders(String.join(" ", args), taskProps.getDefinedParams()); |
||||
|
||||
logger.info("flink task command : {}", command); |
||||
|
||||
return command; |
||||
} |
||||
|
||||
@Override |
||||
public AbstractParameters getParameters() { |
||||
return flinkParameters; |
||||
} |
||||
} |
@ -0,0 +1,270 @@
|
||||
/* |
||||
* 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 cn.escheduler.server.worker.task.http; |
||||
|
||||
|
||||
import cn.escheduler.common.enums.HttpMethod; |
||||
import cn.escheduler.common.enums.HttpParametersType; |
||||
import cn.escheduler.common.process.HttpProperty; |
||||
import cn.escheduler.common.process.Property; |
||||
import cn.escheduler.common.task.AbstractParameters; |
||||
import cn.escheduler.common.task.http.HttpParameters; |
||||
import cn.escheduler.common.utils.Bytes; |
||||
import cn.escheduler.common.utils.DateUtils; |
||||
import cn.escheduler.common.utils.ParameterUtils; |
||||
import cn.escheduler.dao.DaoFactory; |
||||
import cn.escheduler.dao.ProcessDao; |
||||
import cn.escheduler.dao.model.ProcessInstance; |
||||
import cn.escheduler.server.utils.ParamUtils; |
||||
import cn.escheduler.server.worker.task.AbstractTask; |
||||
import cn.escheduler.server.worker.task.TaskProps; |
||||
import com.alibaba.fastjson.JSONObject; |
||||
import org.apache.commons.io.Charsets; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.apache.http.HttpEntity; |
||||
import org.apache.http.ParseException; |
||||
import org.apache.http.client.config.RequestConfig; |
||||
import org.apache.http.client.methods.CloseableHttpResponse; |
||||
import org.apache.http.client.methods.HttpUriRequest; |
||||
import org.apache.http.client.methods.RequestBuilder; |
||||
import org.apache.http.entity.StringEntity; |
||||
import org.apache.http.impl.client.CloseableHttpClient; |
||||
import org.apache.http.impl.client.HttpClientBuilder; |
||||
import org.apache.http.impl.client.HttpClients; |
||||
import org.apache.http.util.EntityUtils; |
||||
import org.slf4j.Logger; |
||||
|
||||
import java.io.IOException; |
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
import java.util.Map; |
||||
|
||||
/** |
||||
* http task |
||||
*/ |
||||
public class HttpTask extends AbstractTask { |
||||
|
||||
private HttpParameters httpParameters; |
||||
|
||||
/** |
||||
* process database access |
||||
*/ |
||||
private ProcessDao processDao; |
||||
|
||||
/** |
||||
* Convert mill seconds to second unit |
||||
*/ |
||||
protected static final int MAX_CONNECTION_MILLISECONDS = 60000; |
||||
|
||||
protected static final String APPLICATION_JSON = "application/json"; |
||||
|
||||
protected String output; |
||||
|
||||
|
||||
public HttpTask(TaskProps props, Logger logger) { |
||||
super(props, logger); |
||||
this.processDao = DaoFactory.getDaoInstance(ProcessDao.class); |
||||
} |
||||
|
||||
@Override |
||||
public void init() { |
||||
logger.info("http task params {}", taskProps.getTaskParams()); |
||||
this.httpParameters = JSONObject.parseObject(taskProps.getTaskParams(), HttpParameters.class); |
||||
|
||||
if (!httpParameters.checkParameters()) { |
||||
throw new RuntimeException("http task params is not valid"); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void handle() throws Exception { |
||||
String threadLoggerInfoName = String.format("TaskLogInfo-%s", taskProps.getTaskAppId()); |
||||
Thread.currentThread().setName(threadLoggerInfoName); |
||||
|
||||
long startTime = System.currentTimeMillis(); |
||||
String statusCode = null; |
||||
String body = null; |
||||
try(CloseableHttpClient client = createHttpClient()) { |
||||
try(CloseableHttpResponse response = sendRequest(client)) { |
||||
statusCode = String.valueOf(getStatusCode(response)); |
||||
body = getResponseBody(response); |
||||
exitStatusCode = validResponse(body, statusCode); |
||||
long costTime = System.currentTimeMillis() - startTime; |
||||
logger.info("startTime: {}, httpUrl: {}, httpMethod: {}, costTime : {}Millisecond, statusCode : {}, body : {}, log : {}", |
||||
DateUtils.format2Readable(startTime), httpParameters.getUrl(),httpParameters.getHttpMethod(), costTime, statusCode, body, output); |
||||
}catch (Exception e) { |
||||
appendMessage(e.toString()); |
||||
exitStatusCode = -1; |
||||
logger.error("httpUrl[" + httpParameters.getUrl() + "] connection failed:"+output, e); |
||||
} |
||||
} catch (Exception e) { |
||||
appendMessage(e.toString()); |
||||
exitStatusCode = -1; |
||||
logger.error("httpUrl[" + httpParameters.getUrl() + "] connection failed:"+output, e); |
||||
} |
||||
} |
||||
|
||||
protected CloseableHttpResponse sendRequest(CloseableHttpClient client) throws IOException { |
||||
RequestBuilder builder = createRequestBuilder(); |
||||
ProcessInstance processInstance = processDao.findProcessInstanceByTaskId(taskProps.getTaskInstId()); |
||||
|
||||
Map<String, Property> paramsMap = ParamUtils.convert(taskProps.getUserDefParamsMap(), |
||||
taskProps.getDefinedParams(), |
||||
httpParameters.getLocalParametersMap(), |
||||
processInstance.getCmdTypeIfComplement(), |
||||
processInstance.getScheduleTime()); |
||||
List<HttpProperty> httpPropertyList = new ArrayList<>(); |
||||
if(httpParameters.getHttpParams() != null && httpParameters.getHttpParams().size() > 0){ |
||||
for (HttpProperty httpProperty: httpParameters.getHttpParams()) { |
||||
String jsonObject = JSONObject.toJSONString(httpProperty); |
||||
String params = ParameterUtils.convertParameterPlaceholders(jsonObject,ParamUtils.convert(paramsMap)); |
||||
logger.info("http request params:{}",params); |
||||
httpPropertyList.add(JSONObject.parseObject(params,HttpProperty.class)); |
||||
} |
||||
} |
||||
addRequestParams(builder,httpPropertyList); |
||||
HttpUriRequest request = builder.setUri(httpParameters.getUrl()).build(); |
||||
setHeaders(request,httpPropertyList); |
||||
return client.execute(request); |
||||
} |
||||
|
||||
protected String getResponseBody(CloseableHttpResponse httpResponse) throws ParseException, IOException { |
||||
if (httpResponse == null) { |
||||
return null; |
||||
} |
||||
HttpEntity entity = httpResponse.getEntity(); |
||||
if (entity == null) { |
||||
return null; |
||||
} |
||||
String webPage = EntityUtils.toString(entity, Bytes.UTF8_ENCODING); |
||||
return webPage; |
||||
} |
||||
|
||||
protected int getStatusCode(CloseableHttpResponse httpResponse) { |
||||
int status = httpResponse.getStatusLine().getStatusCode(); |
||||
return status; |
||||
} |
||||
|
||||
protected int validResponse(String body, String statusCode){ |
||||
int exitStatusCode = 0; |
||||
switch (httpParameters.getHttpCheckCondition()) { |
||||
case BODY_CONTAINS: |
||||
if (StringUtils.isEmpty(body) || !body.contains(httpParameters.getCondition())) { |
||||
appendMessage(httpParameters.getUrl() + " doesn contain " |
||||
+ httpParameters.getCondition()); |
||||
exitStatusCode = -1; |
||||
} |
||||
break; |
||||
case BODY_NOT_CONTAINS: |
||||
if (StringUtils.isEmpty(body) || body.contains(httpParameters.getCondition())) { |
||||
appendMessage(httpParameters.getUrl() + " contains " |
||||
+ httpParameters.getCondition()); |
||||
exitStatusCode = -1; |
||||
} |
||||
break; |
||||
case STATUS_CODE_CUSTOM: |
||||
if (!statusCode.equals(httpParameters.getCondition())) { |
||||
appendMessage(httpParameters.getUrl() + " statuscode: " + statusCode + ", Must be: " + httpParameters.getCondition()); |
||||
exitStatusCode = -1; |
||||
} |
||||
break; |
||||
default: |
||||
if (!"200".equals(statusCode)) { |
||||
appendMessage(httpParameters.getUrl() + " statuscode: " + statusCode + ", Must be: 200"); |
||||
exitStatusCode = -1; |
||||
} |
||||
break; |
||||
} |
||||
return exitStatusCode; |
||||
} |
||||
|
||||
public String getOutput() { |
||||
return output; |
||||
} |
||||
|
||||
protected void appendMessage(String message) { |
||||
if (output == null) { |
||||
output = ""; |
||||
} |
||||
if (message != null && !message.trim().isEmpty()) { |
||||
output += message; |
||||
} |
||||
} |
||||
|
||||
protected void addRequestParams(RequestBuilder builder,List<HttpProperty> httpPropertyList) { |
||||
if(httpPropertyList != null && httpPropertyList.size() > 0){ |
||||
JSONObject jsonParam = new JSONObject(); |
||||
for (HttpProperty property: httpPropertyList){ |
||||
if(property.getHttpParametersType() != null){ |
||||
if (property.getHttpParametersType().equals(HttpParametersType.PARAMETER)){ |
||||
builder.addParameter(property.getProp(), property.getValue()); |
||||
}else if(property.getHttpParametersType().equals(HttpParametersType.BODY)){ |
||||
jsonParam.put(property.getProp(), property.getValue()); |
||||
} |
||||
} |
||||
} |
||||
StringEntity postingString = new StringEntity(jsonParam.toString(), Charsets.UTF_8); |
||||
postingString.setContentEncoding(Bytes.UTF8_ENCODING); |
||||
postingString.setContentType(APPLICATION_JSON); |
||||
builder.setEntity(postingString); |
||||
} |
||||
} |
||||
|
||||
protected void setHeaders(HttpUriRequest request,List<HttpProperty> httpPropertyList) { |
||||
if(httpPropertyList != null && httpPropertyList.size() > 0){ |
||||
for (HttpProperty property: httpPropertyList){ |
||||
if(property.getHttpParametersType() != null) { |
||||
if (property.getHttpParametersType().equals(HttpParametersType.HEADERS)) { |
||||
request.addHeader(property.getProp(), property.getValue()); |
||||
} |
||||
} |
||||
} |
||||
} |
||||
} |
||||
|
||||
protected CloseableHttpClient createHttpClient() { |
||||
final RequestConfig requestConfig = requestConfig(); |
||||
HttpClientBuilder httpClientBuilder; |
||||
httpClientBuilder = HttpClients.custom().setDefaultRequestConfig(requestConfig); |
||||
return httpClientBuilder.build(); |
||||
} |
||||
|
||||
private RequestConfig requestConfig() { |
||||
return RequestConfig.custom().setSocketTimeout(MAX_CONNECTION_MILLISECONDS).setConnectTimeout(MAX_CONNECTION_MILLISECONDS).build(); |
||||
} |
||||
|
||||
protected RequestBuilder createRequestBuilder() { |
||||
if (httpParameters.getHttpMethod().equals(HttpMethod.GET)) { |
||||
return RequestBuilder.get(); |
||||
} else if (httpParameters.getHttpMethod().equals(HttpMethod.POST)) { |
||||
return RequestBuilder.post(); |
||||
} else if (httpParameters.getHttpMethod().equals(HttpMethod.HEAD)) { |
||||
return RequestBuilder.head(); |
||||
} else if (httpParameters.getHttpMethod().equals(HttpMethod.PUT)) { |
||||
return RequestBuilder.put(); |
||||
} else if (httpParameters.getHttpMethod().equals(HttpMethod.DELETE)) { |
||||
return RequestBuilder.delete(); |
||||
} else { |
||||
return null; |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public AbstractParameters getParameters() { |
||||
return this.httpParameters; |
||||
} |
||||
} |
@ -1,4 +1,4 @@
|
||||
logging.config=classpath:master_logback.xml |
||||
logging.config=classpath:worker_logback.xml |
||||
|
||||
# server port |
||||
server.port=7788 |
||||
|
File diff suppressed because one or more lines are too long
@ -1 +1,17 @@
|
||||
/* |
||||
* 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. |
||||
*/ |
||||
Not found |
File diff suppressed because one or more lines are too long
@ -0,0 +1,242 @@
|
||||
/* |
||||
* 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 class="user-def-params-model"> |
||||
<div class="select-listpp" |
||||
v-for="(item,$index) in httpParamsList" |
||||
:key="item.id" |
||||
@click="_getIndex($index)"> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
type="text" |
||||
v-model="httpParamsList[$index].prop" |
||||
:placeholder="$t('prop(required)')" |
||||
@on-blur="_verifProp()" |
||||
:style="inputStyle"> |
||||
</x-input> |
||||
<x-select |
||||
@change="_handlePositionChanged" |
||||
v-model="httpParamsList[$index].httpParametersType" |
||||
:placeholder="$t('Http Parameters Position')" |
||||
:disabled="isDetails" |
||||
:style="inputStyle" |
||||
> |
||||
<x-option |
||||
v-for="position in positionList" |
||||
:key="position.code" |
||||
:value="position.id" |
||||
:label="position.code"> |
||||
</x-option> |
||||
</x-select> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
type="text" |
||||
v-model="httpParamsList[$index].value" |
||||
:placeholder="$t('value(required)')" |
||||
@on-blur="_handleValue()" |
||||
:style="inputStyle"> |
||||
</x-input> |
||||
<span class="lt-add"> |
||||
<a href="javascript:" style="color:red;" @click="!isDetails && _removeUdp($index)" > |
||||
<i class="iconfont" :class="_isDetails" data-toggle="tooltip" :title="$t('delete')" ></i> |
||||
</a> |
||||
</span> |
||||
<span class="add" v-if="$index === (httpParamsList.length - 1)"> |
||||
<a href="javascript:" @click="!isDetails && _addUdp()" > |
||||
<i class="iconfont" :class="_isDetails" data-toggle="tooltip" :title="$t('Add')"></i> |
||||
</a> |
||||
</span> |
||||
</div> |
||||
<span class="add-dp" v-if="!httpParamsList.length"> |
||||
<a href="javascript:" @click="!isDetails && _addUdp()" > |
||||
<i class="iconfont" :class="_isDetails" data-toggle="tooltip" :title="$t('Add')"></i> |
||||
</a> |
||||
</span> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import _ from 'lodash' |
||||
import i18n from '@/module/i18n' |
||||
import { positionList } from './commcon' |
||||
import disabledState from '@/module/mixin/disabledState' |
||||
export default { |
||||
name: 'http-params', |
||||
data () { |
||||
return { |
||||
// Increased data |
||||
httpParamsList: [], |
||||
// Current execution index |
||||
httpParamsIndex: null, |
||||
// 参数位置的下拉框 |
||||
positionList:positionList |
||||
} |
||||
}, |
||||
mixins: [disabledState], |
||||
props: { |
||||
udpList: Array, |
||||
// hide direct/type |
||||
hide: { |
||||
type: Boolean, |
||||
default: true |
||||
} |
||||
}, |
||||
methods: { |
||||
/** |
||||
* Current index |
||||
*/ |
||||
_getIndex (index) { |
||||
this.httpParamsIndex = index |
||||
}, |
||||
/** |
||||
* 获取参数位置 |
||||
*/ |
||||
_handlePositionChanged () { |
||||
this._verifProp('value') |
||||
}, |
||||
/** |
||||
* delete item |
||||
*/ |
||||
_removeUdp (index) { |
||||
this.httpParamsList.splice(index, 1) |
||||
this._verifProp('value') |
||||
}, |
||||
/** |
||||
* add |
||||
*/ |
||||
_addUdp () { |
||||
this.httpParamsList.push({ |
||||
prop: '', |
||||
httpParametersType: 'PARAMETER', |
||||
value: '' |
||||
}) |
||||
}, |
||||
/** |
||||
* blur verification |
||||
*/ |
||||
_handleValue () { |
||||
this._verifValue('value') |
||||
}, |
||||
/** |
||||
* Verify that the value exists or is empty |
||||
*/ |
||||
_verifProp (type) { |
||||
let arr = [] |
||||
let flag = true |
||||
_.map(this.httpParamsList, v => { |
||||
arr.push(v.prop) |
||||
if (!v.prop) { |
||||
flag = false |
||||
} |
||||
if(v.value === ''){ |
||||
this.$message.warning(`${i18n.$t('value is empty')}`) |
||||
return false |
||||
} |
||||
}) |
||||
if (!flag) { |
||||
if (!type) { |
||||
this.$message.warning(`${i18n.$t('prop is empty')}`) |
||||
} |
||||
return false |
||||
} |
||||
let newArr = _.cloneDeep(_.uniqWith(arr, _.isEqual)) |
||||
if (newArr.length !== arr.length) { |
||||
if (!type) { |
||||
this.$message.warning(`${i18n.$t('prop is repeat')}`) |
||||
} |
||||
return false |
||||
} |
||||
this.$emit('on-http-params', _.cloneDeep(this.httpParamsList)) |
||||
return true |
||||
}, |
||||
_verifValue (type) { |
||||
let arr = [] |
||||
let flag = true |
||||
_.map(this.httpParamsList, v => { |
||||
arr.push(v.value) |
||||
if (!v.value) { |
||||
flag = false |
||||
} |
||||
}) |
||||
if (!flag) { |
||||
this.$message.warning(`${i18n.$t('value is empty')}`) |
||||
return false |
||||
} |
||||
this.$emit('on-http-params', _.cloneDeep(this.httpParamsList)) |
||||
return true |
||||
} |
||||
}, |
||||
watch: { |
||||
// Monitor data changes |
||||
udpList () { |
||||
this.httpParamsList = this.udpList |
||||
} |
||||
}, |
||||
created () { |
||||
this.httpParamsList = this.udpList |
||||
}, |
||||
computed: { |
||||
inputStyle () { |
||||
return "width:30%" |
||||
} |
||||
}, |
||||
mounted () { |
||||
}, |
||||
components: { } |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" rel="stylesheet/scss"> |
||||
.user-def-params-model { |
||||
.select-listpp { |
||||
margin-bottom: 6px; |
||||
.lt-add { |
||||
padding-left: 4px; |
||||
a { |
||||
.iconfont { |
||||
font-size: 18px; |
||||
vertical-align: middle; |
||||
margin-bottom: -2px; |
||||
display: inline-block; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
.add { |
||||
a { |
||||
color: #000; |
||||
.iconfont { |
||||
font-size: 18px; |
||||
vertical-align: middle; |
||||
display: inline-block; |
||||
margin-top: 1px; |
||||
} |
||||
} |
||||
} |
||||
.add-dp{ |
||||
a { |
||||
color: #0097e0; |
||||
.iconfont { |
||||
font-size: 18px; |
||||
vertical-align: middle; |
||||
display: inline-block; |
||||
margin-top: 2px; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
||||
|
@ -0,0 +1,389 @@
|
||||
<template> |
||||
<div class="flink-model"> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Program Type')}}</div> |
||||
<div slot="content"> |
||||
<x-select |
||||
style="width: 130px;" |
||||
v-model="programType" |
||||
:disabled="isDetails"> |
||||
<x-option |
||||
v-for="city in programTypeList" |
||||
:key="city.code" |
||||
:value="city.code" |
||||
:label="city.code"> |
||||
</x-option> |
||||
</x-select> |
||||
</div> |
||||
</m-list-box> |
||||
|
||||
<m-list-box v-if="programType !== 'PYTHON'"> |
||||
<div slot="text">{{$t('Main class')}}</div> |
||||
<div slot="content"> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
type="input" |
||||
v-model="mainClass" |
||||
:placeholder="$t('Please enter main class')" |
||||
autocomplete="off"> |
||||
</x-input> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Main jar package')}}</div> |
||||
<div slot="content"> |
||||
<x-select |
||||
style="width: 100%;" |
||||
:placeholder="$t('Please enter main jar package')" |
||||
v-model="mainJar" |
||||
filterable |
||||
:disabled="isDetails"> |
||||
<x-option |
||||
v-for="city in mainJarList" |
||||
:key="city.code" |
||||
:value="city.code" |
||||
:label="city.code"> |
||||
</x-option> |
||||
</x-select> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Deploy Mode')}}</div> |
||||
<div slot="content"> |
||||
<x-radio-group v-model="deployMode"> |
||||
<x-radio :label="'cluster'" :disabled="isDetails"></x-radio> |
||||
<x-radio :label="'local'" :disabled="isDetails"></x-radio> |
||||
</x-radio-group> |
||||
</div> |
||||
</m-list-box> |
||||
<div class="list-box-4p"> |
||||
<div class="clearfix list"> |
||||
<span class="sp1">{{$t('slot')}}</span> |
||||
<span class="sp2"> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
type="input" |
||||
v-model="slot" |
||||
:placeholder="$t('Please enter driver core number')" |
||||
style="width: 200px;" |
||||
autocomplete="off"> |
||||
</x-input> |
||||
</span> |
||||
<span class="sp1 sp3">{{$t('taskManager')}}</span> |
||||
<span class="sp2"> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
type="input" |
||||
v-model="taskManager" |
||||
:placeholder="$t('Please enter driver memory use')" |
||||
style="width: 186px;" |
||||
autocomplete="off"> |
||||
</x-input> |
||||
</span> |
||||
</div> |
||||
<div class="clearfix list"> |
||||
<span class="sp1">{{$t('jobManagerMemory')}}</span> |
||||
<span class="sp2"> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
type="input" |
||||
v-model="jobManagerMemory" |
||||
:placeholder="$t('Please enter the number of Executor')" |
||||
style="width: 200px;" |
||||
autocomplete="off"> |
||||
</x-input> |
||||
</span> |
||||
<span class="sp1 sp3">{{$t('taskManagerMemory')}}</span> |
||||
<span class="sp2"> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
type="input" |
||||
v-model="taskManagerMemory" |
||||
:placeholder="$t('Please enter the Executor memory')" |
||||
style="width: 186px;" |
||||
autocomplete="off"> |
||||
</x-input> |
||||
</span> |
||||
</div> |
||||
|
||||
</div> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Command-line parameters')}}</div> |
||||
<div slot="content"> |
||||
<x-input |
||||
:autosize="{minRows:2}" |
||||
:disabled="isDetails" |
||||
type="textarea" |
||||
v-model="mainArgs" |
||||
:placeholder="$t('Please enter Command-line parameters')" |
||||
autocomplete="off"> |
||||
</x-input> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Other parameters')}}</div> |
||||
<div slot="content"> |
||||
<x-input |
||||
:disabled="isDetails" |
||||
:autosize="{minRows:2}" |
||||
type="textarea" |
||||
v-model="others" |
||||
:placeholder="$t('Please enter other parameters')"> |
||||
</x-input> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Resources')}}</div> |
||||
<div slot="content"> |
||||
<m-resources |
||||
ref="refResources" |
||||
@on-resourcesData="_onResourcesData" |
||||
:resource-list="resourceList"> |
||||
</m-resources> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Custom Parameters')}}</div> |
||||
<div slot="content"> |
||||
<m-local-params |
||||
ref="refLocalParams" |
||||
@on-local-params="_onLocalParams" |
||||
:udp-list="localParams" |
||||
:hide="false"> |
||||
</m-local-params> |
||||
</div> |
||||
</m-list-box> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import _ from 'lodash' |
||||
import i18n from '@/module/i18n' |
||||
import mLocalParams from './_source/localParams' |
||||
import mListBox from './_source/listBox' |
||||
import mResources from './_source/resources' |
||||
import disabledState from '@/module/mixin/disabledState' |
||||
|
||||
export default { |
||||
name: 'flink', |
||||
data () { |
||||
return { |
||||
// Main function class |
||||
mainClass: '', |
||||
// Master jar package |
||||
mainJar: null, |
||||
// Master jar package(List) |
||||
mainJarList: [], |
||||
// Deployment method |
||||
deployMode: 'cluster', |
||||
// Resource(list) |
||||
resourceList: [], |
||||
// Custom function |
||||
localParams: [], |
||||
// Driver Number of cores |
||||
slot: 1, |
||||
// Driver Number of memory |
||||
taskManager: '2', |
||||
// Executor Number |
||||
jobManagerMemory: '1G', |
||||
// Executor Number of memory |
||||
taskManagerMemory: '2G', |
||||
// Executor Number of cores |
||||
executorCores: 2, |
||||
// Command line argument |
||||
mainArgs: '', |
||||
// Other parameters |
||||
others: '', |
||||
// Program type |
||||
programType: 'SCALA', |
||||
// Program type(List) |
||||
programTypeList: [{ code: 'JAVA' }, { code: 'SCALA' }, { code: 'PYTHON' }] |
||||
} |
||||
}, |
||||
props: { |
||||
backfillItem: Object |
||||
}, |
||||
mixins: [disabledState], |
||||
methods: { |
||||
/** |
||||
* return localParams |
||||
*/ |
||||
_onLocalParams (a) { |
||||
this.localParams = a |
||||
}, |
||||
/** |
||||
* return resourceList |
||||
*/ |
||||
_onResourcesData (a) { |
||||
this.resourceList = a |
||||
}, |
||||
/** |
||||
* verification |
||||
*/ |
||||
_verification () { |
||||
if (this.programType !== 'PYTHON' && !this.mainClass) { |
||||
this.$message.warning(`${i18n.$t('Please enter main class')}`) |
||||
return false |
||||
} |
||||
|
||||
|
||||
if (!this.mainJar) { |
||||
this.$message.warning(`${i18n.$t('Please enter main jar package')}`) |
||||
return false |
||||
} |
||||
|
||||
if (!this.jobManagerMemory) { |
||||
this.$message.warning(`${i18n.$t('Please enter the number of Executor')}`) |
||||
return false |
||||
} |
||||
|
||||
if (!Number.isInteger(parseInt(this.jobManagerMemory))) { |
||||
this.$message.warning(`${i18n.$t('The number of Executors should be a positive integer')}`) |
||||
return false |
||||
} |
||||
|
||||
if (!this.taskManagerMemory) { |
||||
this.$message.warning(`${i18n.$t('Please enter the Executor memory')}`) |
||||
return false |
||||
} |
||||
|
||||
if (!this.taskManagerMemory) { |
||||
this.$message.warning(`${i18n.$t('Please enter the Executor memory')}`) |
||||
return false |
||||
} |
||||
|
||||
if (!_.isNumber(parseInt(this.taskManagerMemory))) { |
||||
this.$message.warning(`${i18n.$t('Memory should be a positive integer')}`) |
||||
return false |
||||
} |
||||
|
||||
if (!this.executorCores) { |
||||
this.$message.warning(`${i18n.$t('Please enter ExecutorPlease enter Executor core number')}`) |
||||
return false |
||||
} |
||||
|
||||
if (!Number.isInteger(parseInt(this.executorCores))) { |
||||
this.$message.warning(`${i18n.$t('Core number should be positive integer')}`) |
||||
return false |
||||
} |
||||
|
||||
if (!this.$refs.refResources._verifResources()) { |
||||
return false |
||||
} |
||||
|
||||
// localParams Subcomponent verification |
||||
if (!this.$refs.refLocalParams._verifProp()) { |
||||
return false |
||||
} |
||||
|
||||
// storage |
||||
this.$emit('on-params', { |
||||
mainClass: this.mainClass, |
||||
mainJar: { |
||||
res: this.mainJar |
||||
}, |
||||
deployMode: this.deployMode, |
||||
resourceList: this.resourceList, |
||||
localParams: this.localParams, |
||||
slot: this.slot, |
||||
taskManager: this.taskManager, |
||||
jobManagerMemory: this.jobManagerMemory, |
||||
taskManagerMemory: this.taskManagerMemory, |
||||
executorCores: this.executorCores, |
||||
mainArgs: this.mainArgs, |
||||
others: this.others, |
||||
programType: this.programType |
||||
}) |
||||
return true |
||||
}, |
||||
/** |
||||
* get resources list |
||||
*/ |
||||
_getResourcesList () { |
||||
return new Promise((resolve, reject) => { |
||||
let isJar = (alias) => { |
||||
return alias.substring(alias.lastIndexOf('.') + 1, alias.length) !== 'jar' |
||||
} |
||||
this.mainJarList = _.map(_.cloneDeep(this.store.state.dag.resourcesListS), v => { |
||||
return { |
||||
id: v.id, |
||||
code: v.alias, |
||||
disabled: isJar(v.alias) |
||||
} |
||||
}) |
||||
resolve() |
||||
}) |
||||
} |
||||
}, |
||||
watch: { |
||||
// Listening type |
||||
programType (type) { |
||||
if (type === 'PYTHON') { |
||||
this.mainClass = '' |
||||
} |
||||
} |
||||
}, |
||||
created () { |
||||
this._getResourcesList().then(() => { |
||||
let o = this.backfillItem |
||||
|
||||
// Non-null objects represent backfill |
||||
if (!_.isEmpty(o)) { |
||||
this.mainClass = o.params.mainClass || '' |
||||
this.mainJar = o.params.mainJar.res || '' |
||||
this.deployMode = o.params.deployMode || '' |
||||
this.slot = o.params.slot || 1 |
||||
this.taskManager = o.params.taskManager || '2' |
||||
this.jobManagerMemory = o.params.jobManagerMemory || '1G' |
||||
this.taskManagerMemory = o.params.taskManagerMemory || '2G' |
||||
|
||||
this.mainArgs = o.params.mainArgs || '' |
||||
this.others = o.params.others |
||||
this.programType = o.params.programType || 'SCALA' |
||||
|
||||
// backfill resourceList |
||||
let resourceList = o.params.resourceList || [] |
||||
if (resourceList.length) { |
||||
this.resourceList = resourceList |
||||
} |
||||
|
||||
// backfill localParams |
||||
let localParams = o.params.localParams || [] |
||||
if (localParams.length) { |
||||
this.localParams = localParams |
||||
} |
||||
} |
||||
}) |
||||
}, |
||||
mounted () { |
||||
|
||||
}, |
||||
components: { mLocalParams, mListBox, mResources } |
||||
} |
||||
</script> |
||||
|
||||
<style lang="scss" rel="stylesheet/scss"> |
||||
.flink-model { |
||||
.list-box-4p { |
||||
.list { |
||||
margin-bottom: 14px; |
||||
.sp1 { |
||||
float: left; |
||||
width: 112px; |
||||
text-align: right; |
||||
margin-right: 10px; |
||||
font-size: 14px; |
||||
color: #777; |
||||
display: inline-block; |
||||
padding-top: 6px; |
||||
} |
||||
.sp2 { |
||||
float: left; |
||||
margin-right: 4px; |
||||
} |
||||
.sp3 { |
||||
width: 176px; |
||||
} |
||||
} |
||||
} |
||||
} |
||||
</style> |
@ -0,0 +1,191 @@
|
||||
/* |
||||
* 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 class="http-model"> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Http Url')}}</div> |
||||
<div slot="content"> |
||||
<x-input |
||||
:autosize="{minRows:2}" |
||||
:disabled="isDetails" |
||||
type="textarea" |
||||
v-model="url" |
||||
:placeholder="$t('Please Enter Http Url')" |
||||
autocomplete="off"> |
||||
</x-input> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Http Method')}}</div> |
||||
<div slot="content"> |
||||
<x-select |
||||
style="width: 150px;" |
||||
v-model="httpMethod" |
||||
:disabled="isDetails"> |
||||
<x-option |
||||
v-for="city in httpMethodList" |
||||
:key="city.code" |
||||
:value="city.code" |
||||
:label="city.code"> |
||||
</x-option> |
||||
</x-select> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Http Parameters')}}</div> |
||||
<div slot="content"> |
||||
<m-http-params |
||||
ref="refHttpParams" |
||||
@on-http-params="_onHttpParams" |
||||
:udp-list="httpParams" |
||||
:hide="false"> |
||||
</m-http-params> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Http Check Condition')}}</div> |
||||
<div slot="content"> |
||||
<x-select |
||||
style="width: 150px;" |
||||
v-model="httpCheckCondition" |
||||
:disabled="isDetails"> |
||||
<x-option |
||||
v-for="city in httpCheckConditionList" |
||||
:key="city.code" |
||||
:value="city.code" |
||||
:label="city.value"> |
||||
</x-option> |
||||
</x-select> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Http Condition')}}</div> |
||||
<div slot="content"> |
||||
<x-input |
||||
:autosize="{minRows:2}" |
||||
:disabled="isDetails" |
||||
type="textarea" |
||||
v-model="condition" |
||||
:placeholder="$t('Please Enter Http Condition')" |
||||
autocomplete="off"> |
||||
</x-input> |
||||
</div> |
||||
</m-list-box> |
||||
<m-list-box> |
||||
<div slot="text">{{$t('Custom Parameters')}}</div> |
||||
<div slot="content"> |
||||
<m-local-params |
||||
ref="refLocalParams" |
||||
@on-local-params="_onLocalParams" |
||||
:udp-list="localParams" |
||||
:hide="false"> |
||||
</m-local-params> |
||||
</div> |
||||
</m-list-box> |
||||
</div> |
||||
</template> |
||||
<script> |
||||
import _ from 'lodash' |
||||
import i18n from '@/module/i18n' |
||||
import mLocalParams from './_source/localParams' |
||||
import mHttpParams from './_source/httpParams' |
||||
import mListBox from './_source/listBox' |
||||
import disabledState from '@/module/mixin/disabledState' |
||||
export default { |
||||
name: 'http', |
||||
data () { |
||||
return { |
||||
url: '', |
||||
condition: '', |
||||
localParams: [], |
||||
httpParams: [], |
||||
httpMethod: 'GET', |
||||
httpMethodList: [{ code: 'GET' }, { code: 'POST' }, { code: 'HEAD' }, { code: 'PUT' }, { code: 'DELETE' }], |
||||
httpCheckCondition: 'STATUS_CODE_DEFAULT', |
||||
httpCheckConditionList: [{ code: 'STATUS_CODE_DEFAULT',value:'默认响应码200' }, { code: 'STATUS_CODE_CUSTOM',value:'自定义响应码' }, { code: 'BODY_CONTAINS',value:'内容包含' }, { code: 'BODY_NOT_CONTAINS',value:'内容不包含' }] |
||||
} |
||||
}, |
||||
props: { |
||||
backfillItem: Object |
||||
}, |
||||
mixins: [disabledState], |
||||
methods: { |
||||
/** |
||||
* return localParams |
||||
*/ |
||||
_onLocalParams (a) { |
||||
this.localParams = a |
||||
}, |
||||
_onHttpParams (a) { |
||||
this.httpParams = a |
||||
}, |
||||
/** |
||||
* verification |
||||
*/ |
||||
_verification () { |
||||
if (!this.url) { |
||||
this.$message.warning(`${i18n.$t('Please Enter Http Url')}`) |
||||
return false |
||||
} |
||||
// localParams Subcomponent verification |
||||
if (!this.$refs.refLocalParams._verifProp()) { |
||||
return false |
||||
} |
||||
if (!this.$refs.refHttpParams._verifProp()) { |
||||
return false |
||||
} |
||||
if (!this.$refs.refHttpParams._verifValue()) { |
||||
return false |
||||
} |
||||
// storage |
||||
this.$emit('on-params', { |
||||
localParams: this.localParams, |
||||
httpParams: this.httpParams, |
||||
url: this.url, |
||||
httpMethod: this.httpMethod, |
||||
httpCheckCondition: this.httpCheckCondition, |
||||
condition: this.condition |
||||
}) |
||||
return true |
||||
} |
||||
}, |
||||
watch: { |
||||
}, |
||||
created () { |
||||
let o = this.backfillItem |
||||
// Non-null objects represent backfill |
||||
if (!_.isEmpty(o)) { |
||||
this.url = o.params.url || '' |
||||
this.httpMethod = o.params.httpMethod || 'GET' |
||||
this.httpCheckCondition = o.params.httpCheckCondition || 'DEFAULT' |
||||
this.condition = o.params.condition || '' |
||||
// backfill localParams |
||||
let localParams = o.params.localParams || [] |
||||
if (localParams.length) { |
||||
this.localParams = localParams |
||||
} |
||||
let httpParams = o.params.httpParams || [] |
||||
if (httpParams.length) { |
||||
this.httpParams = httpParams |
||||
} |
||||
} |
||||
}, |
||||
mounted () { |
||||
}, |
||||
components: { mLocalParams, mHttpParams, mListBox } |
||||
} |
||||
</script> |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue