Kerwin
3 years ago
committed by
GitHub
31 changed files with 1440 additions and 22 deletions
@ -0,0 +1,313 @@
|
||||
/* |
||||
* 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.spi.utils; |
||||
|
||||
import org.apache.commons.beanutils.BeanMap; |
||||
|
||||
import java.util.*; |
||||
import java.util.function.Function; |
||||
import java.util.stream.Collectors; |
||||
|
||||
/** |
||||
* Provides utility methods and decorators for {@link Collection} instances. |
||||
* <p> |
||||
* Various utility methods might put the input objects into a Set/Map/Bag. In case |
||||
* the input objects override {@link Object#equals(Object)}, it is mandatory that |
||||
* the general contract of the {@link Object#hashCode()} method is maintained. |
||||
* <p> |
||||
* NOTE: From 4.0, method parameters will take {@link Iterable} objects when possible. |
||||
* |
||||
* @version $Id: CollectionUtils.java 1686855 2015-06-22 13:00:27Z tn $ |
||||
* @since 1.0 |
||||
*/ |
||||
public class CollectionUtils { |
||||
|
||||
private CollectionUtils() { |
||||
throw new UnsupportedOperationException("Construct CollectionUtils"); |
||||
} |
||||
|
||||
/** |
||||
* The load factor used when none specified in constructor. |
||||
*/ |
||||
static final float DEFAULT_LOAD_FACTOR = 0.75f; |
||||
|
||||
/** |
||||
* Returns a new {@link Collection} containing <i>a</i> minus a subset of |
||||
* <i>b</i>. Only the elements of <i>b</i> that satisfy the predicate |
||||
* condition, <i>p</i> are subtracted from <i>a</i>. |
||||
* |
||||
* <p>The cardinality of each element <i>e</i> in the returned {@link Collection} |
||||
* that satisfies the predicate condition will be the cardinality of <i>e</i> in <i>a</i> |
||||
* minus the cardinality of <i>e</i> in <i>b</i>, or zero, whichever is greater.</p> |
||||
* <p>The cardinality of each element <i>e</i> in the returned {@link Collection} that does <b>not</b> |
||||
* satisfy the predicate condition will be equal to the cardinality of <i>e</i> in <i>a</i>.</p> |
||||
* |
||||
* @param a the collection to subtract from, must not be null |
||||
* @param b the collection to subtract, must not be null |
||||
* @param <T> T |
||||
* @return a new collection with the results |
||||
* @see Collection#removeAll |
||||
*/ |
||||
public static <T> Collection<T> subtract(Set<T> a, Set<T> b) { |
||||
return org.apache.commons.collections4.CollectionUtils.subtract(a, b); |
||||
} |
||||
|
||||
public static boolean isNotEmpty(Collection coll) { |
||||
return !isEmpty(coll); |
||||
} |
||||
|
||||
public static boolean isEmpty(Collection coll) { |
||||
return coll == null || coll.isEmpty(); |
||||
} |
||||
|
||||
/** |
||||
* String to map |
||||
* |
||||
* @param str string |
||||
* @param separator separator |
||||
* @return string to map |
||||
*/ |
||||
public static Map<String, String> stringToMap(String str, String separator) { |
||||
return stringToMap(str, separator, ""); |
||||
} |
||||
|
||||
/** |
||||
* String to map |
||||
* |
||||
* @param str string |
||||
* @param separator separator |
||||
* @param keyPrefix prefix |
||||
* @return string to map |
||||
*/ |
||||
public static Map<String, String> stringToMap(String str, String separator, String keyPrefix) { |
||||
|
||||
Map<String, String> emptyMap = new HashMap<>(0); |
||||
if (StringUtils.isEmpty(str)) { |
||||
return emptyMap; |
||||
} |
||||
if (StringUtils.isEmpty(separator)) { |
||||
return emptyMap; |
||||
} |
||||
String[] strings = str.split(separator); |
||||
int initialCapacity = (int)(strings.length / DEFAULT_LOAD_FACTOR) + 1; |
||||
Map<String, String> map = new HashMap<>(initialCapacity); |
||||
for (int i = 0; i < strings.length; i++) { |
||||
String[] strArray = strings[i].split("="); |
||||
if (strArray.length != 2) { |
||||
return emptyMap; |
||||
} |
||||
//strArray[0] KEY strArray[1] VALUE
|
||||
if (StringUtils.isEmpty(keyPrefix)) { |
||||
map.put(strArray[0], strArray[1]); |
||||
} else { |
||||
map.put(keyPrefix + strArray[0], strArray[1]); |
||||
} |
||||
} |
||||
return map; |
||||
} |
||||
|
||||
/** |
||||
* Transform item in collection |
||||
* |
||||
* @param collection origin collection |
||||
* @param transformFunc transform function |
||||
* @param <R> origin item type |
||||
* @param <T> target type |
||||
* @return transform list |
||||
*/ |
||||
public static <R, T> List<T> transformToList(Collection<R> collection, Function<R, T> transformFunc) { |
||||
if (isEmpty(collection)) { |
||||
return new ArrayList<>(); |
||||
} |
||||
return collection.stream().map(transformFunc).collect(Collectors.toList()); |
||||
} |
||||
|
||||
/** |
||||
* Collect collection to map |
||||
* |
||||
* @param collection origin collection |
||||
* @param keyTransformFunction key transform function |
||||
* @param <K> target k type |
||||
* @param <V> value |
||||
* @return map |
||||
*/ |
||||
public static <K, V> Map<K, V> collectionToMap(Collection<V> collection, Function<V, K> keyTransformFunction) { |
||||
if (isEmpty(collection)) { |
||||
return new HashMap<>(); |
||||
} |
||||
return collection.stream().collect(Collectors.toMap(keyTransformFunction, Function.identity())); |
||||
} |
||||
|
||||
/** |
||||
* Helper class to easily access cardinality properties of two collections. |
||||
* |
||||
* @param <O> the element type |
||||
*/ |
||||
private static class CardinalityHelper<O> { |
||||
|
||||
/** |
||||
* Contains the cardinality for each object in collection A. |
||||
*/ |
||||
final Map<O, Integer> cardinalityA; |
||||
|
||||
/** |
||||
* Contains the cardinality for each object in collection B. |
||||
*/ |
||||
final Map<O, Integer> cardinalityB; |
||||
|
||||
/** |
||||
* Create a new CardinalityHelper for two collections. |
||||
* |
||||
* @param a the first collection |
||||
* @param b the second collection |
||||
*/ |
||||
public CardinalityHelper(final Iterable<? extends O> a, final Iterable<? extends O> b) { |
||||
cardinalityA = CollectionUtils.getCardinalityMap(a); |
||||
cardinalityB = CollectionUtils.getCardinalityMap(b); |
||||
} |
||||
|
||||
/** |
||||
* Returns the frequency of this object in collection A. |
||||
* |
||||
* @param obj the object |
||||
* @return the frequency of the object in collection A |
||||
*/ |
||||
public int freqA(final Object obj) { |
||||
return getFreq(obj, cardinalityA); |
||||
} |
||||
|
||||
/** |
||||
* Returns the frequency of this object in collection B. |
||||
* |
||||
* @param obj the object |
||||
* @return the frequency of the object in collection B |
||||
*/ |
||||
public int freqB(final Object obj) { |
||||
return getFreq(obj, cardinalityB); |
||||
} |
||||
|
||||
private int getFreq(final Object obj, final Map<?, Integer> freqMap) { |
||||
final Integer count = freqMap.get(obj); |
||||
if (count != null) { |
||||
return count; |
||||
} |
||||
return 0; |
||||
} |
||||
} |
||||
|
||||
/** |
||||
* returns {@code true} iff the given {@link Collection}s contain |
||||
* exactly the same elements with exactly the same cardinalities. |
||||
* |
||||
* @param a the first collection |
||||
* @param b the second collection |
||||
* @return Returns true iff the given Collections contain exactly the same elements with exactly the same cardinalities. |
||||
* That is, iff the cardinality of e in a is equal to the cardinality of e in b, for each element e in a or b. |
||||
*/ |
||||
public static boolean equalLists(Collection<?> a, Collection<?> b) { |
||||
if (a == null && b == null) { |
||||
return true; |
||||
} |
||||
|
||||
if (a == null || b == null) { |
||||
return false; |
||||
} |
||||
|
||||
return isEqualCollection(a, b); |
||||
} |
||||
|
||||
/** |
||||
* Returns {@code true} iff the given {@link Collection}s contain |
||||
* exactly the same elements with exactly the same cardinalities. |
||||
* <p> |
||||
* That is, iff the cardinality of <i>e</i> in <i>a</i> is |
||||
* equal to the cardinality of <i>e</i> in <i>b</i>, |
||||
* for each element <i>e</i> in <i>a</i> or <i>b</i>. |
||||
* |
||||
* @param a the first collection, must not be null |
||||
* @param b the second collection, must not be null |
||||
* @return <code>true</code> iff the collections contain the same elements with the same cardinalities. |
||||
*/ |
||||
public static boolean isEqualCollection(final Collection<?> a, final Collection<?> b) { |
||||
if (a.size() != b.size()) { |
||||
return false; |
||||
} |
||||
final CardinalityHelper<Object> helper = new CardinalityHelper<>(a, b); |
||||
if (helper.cardinalityA.size() != helper.cardinalityB.size()) { |
||||
return false; |
||||
} |
||||
for (final Object obj : helper.cardinalityA.keySet()) { |
||||
if (helper.freqA(obj) != helper.freqB(obj)) { |
||||
return false; |
||||
} |
||||
} |
||||
return true; |
||||
} |
||||
|
||||
/** |
||||
* Returns a {@link Map} mapping each unique element in the given |
||||
* {@link Collection} to an {@link Integer} representing the number |
||||
* of occurrences of that element in the {@link Collection}. |
||||
* <p> |
||||
* Only those elements present in the collection will appear as |
||||
* keys in the map. |
||||
* |
||||
* @param <O> the type of object in the returned {@link Map}. This is a super type of O |
||||
* @param coll the collection to get the cardinality map for, must not be null |
||||
* @return the populated cardinality map |
||||
*/ |
||||
public static <O> Map<O, Integer> getCardinalityMap(final Iterable<? extends O> coll) { |
||||
final Map<O, Integer> count = new HashMap<>(); |
||||
for (final O obj : coll) { |
||||
count.put(obj, count.getOrDefault(obj, 0) + 1); |
||||
} |
||||
return count; |
||||
} |
||||
|
||||
/** |
||||
* Removes certain attributes of each object in the list |
||||
* |
||||
* @param originList origin list |
||||
* @param exclusionSet exclusion set |
||||
* @param <T> T |
||||
* @return removes certain attributes of each object in the list |
||||
*/ |
||||
public static <T extends Object> List<Map<String, Object>> getListByExclusion(List<T> originList, Set<String> exclusionSet) { |
||||
List<Map<String, Object>> instanceList = new ArrayList<>(); |
||||
if (exclusionSet == null) { |
||||
exclusionSet = new HashSet<>(); |
||||
} |
||||
if (originList == null) { |
||||
return instanceList; |
||||
} |
||||
Map<String, Object> instanceMap; |
||||
for (T instance : originList) { |
||||
BeanMap beanMap = new BeanMap(instance); |
||||
instanceMap = new LinkedHashMap<>(16, 0.75f, true); |
||||
for (Map.Entry<Object, Object> entry : beanMap.entrySet()) { |
||||
if (exclusionSet.contains(entry.getKey())) { |
||||
continue; |
||||
} |
||||
instanceMap.put((String) entry.getKey(), entry.getValue()); |
||||
} |
||||
instanceList.add(instanceMap); |
||||
} |
||||
return instanceList; |
||||
} |
||||
|
||||
} |
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>dolphinscheduler-task-plugin</artifactId> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<version>1.3.6-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>dolphinscheduler-task-datax</artifactId> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-spi</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-task-api</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
|
||||
|
||||
</project> |
@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>dolphinscheduler-task-plugin</artifactId> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<version>1.3.6-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>dolphinscheduler-task-http</artifactId> |
||||
<packaging>dolphinscheduler-plugin</packaging> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-spi</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-task-api</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
<build> |
||||
<finalName>dolphinscheduler-task-http-${project.version}</finalName> |
||||
</build> |
||||
</project> |
@ -0,0 +1,32 @@
|
||||
/* |
||||
* 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.plugin.task.http; |
||||
|
||||
/** |
||||
* 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,32 @@
|
||||
/* |
||||
* 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.plugin.task.http; |
||||
|
||||
/** |
||||
* http method |
||||
*/ |
||||
public enum HttpMethod { |
||||
/** |
||||
* 0 get |
||||
* 1 post |
||||
* 2 head |
||||
* 3 put |
||||
* 4 delete |
||||
*/ |
||||
GET, POST, HEAD, PUT, DELETE |
||||
} |
@ -0,0 +1,134 @@
|
||||
/* |
||||
* 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.plugin.task.http; |
||||
|
||||
import org.apache.dolphinscheduler.spi.task.AbstractParameters; |
||||
import org.apache.dolphinscheduler.spi.task.ResourceInfo; |
||||
import org.apache.dolphinscheduler.spi.utils.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; |
||||
|
||||
|
||||
/** |
||||
* Connect Timeout |
||||
* Unit: ms |
||||
*/ |
||||
private int connectTimeout ; |
||||
|
||||
/** |
||||
* Socket Timeout |
||||
* Unit: ms |
||||
*/ |
||||
private int socketTimeout ; |
||||
|
||||
@Override |
||||
public boolean checkParameters() { |
||||
return StringUtils.isNotEmpty(url); |
||||
} |
||||
|
||||
@Override |
||||
public List<ResourceInfo> 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; |
||||
} |
||||
|
||||
public int getConnectTimeout() { |
||||
return connectTimeout; |
||||
} |
||||
|
||||
public void setConnectTimeout(int connectTimeout) { |
||||
this.connectTimeout = connectTimeout; |
||||
} |
||||
|
||||
public int getSocketTimeout() { |
||||
return socketTimeout; |
||||
} |
||||
|
||||
public void setSocketTimeout(int socketTimeout) { |
||||
this.socketTimeout = socketTimeout; |
||||
} |
||||
} |
@ -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 org.apache.dolphinscheduler.plugin.task.http; |
||||
|
||||
/** |
||||
* http parameters type |
||||
*/ |
||||
public enum HttpParametersType { |
||||
/** |
||||
* 0 parameter; |
||||
* 1 body; |
||||
* 2 headers; |
||||
*/ |
||||
PARAMETER,BODY,HEADERS |
||||
} |
@ -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 org.apache.dolphinscheduler.plugin.task.http; |
||||
|
||||
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,47 @@
|
||||
package org.apache.dolphinscheduler.plugin.task.http; |
||||
|
||||
import org.apache.dolphinscheduler.spi.task.AbstractParameters; |
||||
import org.apache.dolphinscheduler.spi.task.AbstractTask; |
||||
import org.apache.dolphinscheduler.spi.task.TaskRequest; |
||||
import org.apache.dolphinscheduler.spi.utils.JSONUtils; |
||||
import org.slf4j.Logger; |
||||
|
||||
public class HttpTask extends AbstractTask { |
||||
|
||||
/** |
||||
* taskExecutionContext |
||||
*/ |
||||
private TaskRequest taskExecutionContext; |
||||
|
||||
private HttpParameters httpParameters; |
||||
|
||||
/** |
||||
* constructor |
||||
* |
||||
* @param taskExecutionContext taskExecutionContext |
||||
* @param logger logger |
||||
*/ |
||||
public HttpTask(TaskRequest taskExecutionContext, Logger logger) { |
||||
super(taskExecutionContext, logger); |
||||
} |
||||
|
||||
@Override |
||||
public void init() { |
||||
logger.info("http task params {}", taskExecutionContext.getTaskParams()); |
||||
this.httpParameters = JSONUtils.parseObject(taskExecutionContext.getTaskParams(), HttpParameters.class); |
||||
|
||||
if (!httpParameters.checkParameters()) { |
||||
throw new RuntimeException("http task params is not valid"); |
||||
} |
||||
} |
||||
|
||||
@Override |
||||
public void handle() throws Exception { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public AbstractParameters getParameters() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,4 @@
|
||||
package org.apache.dolphinscheduler.plugin.task.http; |
||||
|
||||
public class HttpTaskChannel { |
||||
} |
@ -0,0 +1,24 @@
|
||||
package org.apache.dolphinscheduler.plugin.task.http; |
||||
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams; |
||||
import org.apache.dolphinscheduler.spi.task.TaskChannel; |
||||
import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class HttpTaskChannelFactory implements TaskChannelFactory { |
||||
@Override |
||||
public String getName() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public List<PluginParams> getParams() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public TaskChannel create() { |
||||
return null; |
||||
} |
||||
} |
@ -0,0 +1,13 @@
|
||||
package org.apache.dolphinscheduler.plugin.task.http; |
||||
|
||||
import com.google.common.collect.ImmutableList; |
||||
import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin; |
||||
import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; |
||||
|
||||
public class HttpTaskPlugin implements DolphinSchedulerPlugin { |
||||
|
||||
@Override |
||||
public Iterable<TaskChannelFactory> getTaskChannelFactorys() { |
||||
return ImmutableList.of(new HttpTaskChannelFactory()); |
||||
} |
||||
} |
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>dolphinscheduler-task-plugin</artifactId> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<version>1.3.6-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>dolphinscheduler-task-mr</artifactId> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-spi</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-task-api</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
</project> |
@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>dolphinscheduler-task-plugin</artifactId> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<version>1.3.6-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>dolphinscheduler-task-procedure</artifactId> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-spi</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-task-api</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
|
||||
</project> |
@ -0,0 +1,37 @@
|
||||
/* |
||||
* 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.plugin.task.spark; |
||||
|
||||
import org.apache.dolphinscheduler.spi.task.AbstractTask; |
||||
import org.apache.dolphinscheduler.spi.task.TaskChannel; |
||||
import org.apache.dolphinscheduler.spi.task.TaskRequest; |
||||
|
||||
import org.slf4j.Logger; |
||||
|
||||
public class SparkTaskChannel implements TaskChannel { |
||||
|
||||
@Override |
||||
public void cancelApplication(boolean status) { |
||||
|
||||
} |
||||
|
||||
@Override |
||||
public AbstractTask createTask(TaskRequest taskRequest, Logger logger) { |
||||
return new SparkTask(taskRequest, logger); |
||||
} |
||||
} |
@ -0,0 +1,41 @@
|
||||
/* |
||||
* 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.plugin.task.spark; |
||||
|
||||
import org.apache.dolphinscheduler.spi.params.base.PluginParams; |
||||
import org.apache.dolphinscheduler.spi.task.TaskChannel; |
||||
import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; |
||||
|
||||
import java.util.List; |
||||
|
||||
public class SparkTaskChannelFanctory implements TaskChannelFactory { |
||||
@Override |
||||
public String getName() { |
||||
return "SPARK"; |
||||
} |
||||
|
||||
@Override |
||||
public List<PluginParams> getParams() { |
||||
return null; |
||||
} |
||||
|
||||
@Override |
||||
public TaskChannel create() { |
||||
return new SparkTaskChannel(); |
||||
} |
||||
} |
@ -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 org.apache.dolphinscheduler.plugin.task.spark; |
||||
|
||||
import org.apache.dolphinscheduler.spi.DolphinSchedulerPlugin; |
||||
import org.apache.dolphinscheduler.spi.task.TaskChannelFactory; |
||||
|
||||
import com.google.common.collect.ImmutableList; |
||||
|
||||
public class SparkTaskPlugin implements DolphinSchedulerPlugin { |
||||
|
||||
@Override |
||||
public Iterable<TaskChannelFactory> getTaskChannelFactorys() { |
||||
return ImmutableList.of(new SparkTaskChannelFanctory()); |
||||
} |
||||
} |
@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>dolphinscheduler-task-plugin</artifactId> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<version>1.3.6-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>dolphinscheduler-task-sql</artifactId> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-spi</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-task-api</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
|
||||
|
||||
</project> |
@ -0,0 +1,44 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?> |
||||
<!-- |
||||
~ 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. |
||||
--> |
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" |
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" |
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> |
||||
<parent> |
||||
<artifactId>dolphinscheduler-task-plugin</artifactId> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<version>1.3.6-SNAPSHOT</version> |
||||
</parent> |
||||
<modelVersion>4.0.0</modelVersion> |
||||
|
||||
<artifactId>dolphinscheduler-task-sqoop</artifactId> |
||||
|
||||
<dependencies> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-spi</artifactId> |
||||
<scope>provided</scope> |
||||
</dependency> |
||||
<dependency> |
||||
<groupId>org.apache.dolphinscheduler</groupId> |
||||
<artifactId>dolphinscheduler-task-api</artifactId> |
||||
<version>${project.version}</version> |
||||
</dependency> |
||||
|
||||
</dependencies> |
||||
|
||||
</project> |
Loading…
Reference in new issue