This is an automated email from the ASF dual-hosted git repository.

zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob.git


The following commit(s) were added to refs/heads/master by this push:
     new a21a63e  Support HTTP job (#1339) (#1345)
a21a63e is described below

commit a21a63ef5fcc5ec3f8b7507bfc87187abc478010
Author: Tboy <[email protected]>
AuthorDate: Mon Aug 10 20:19:20 2020 +0800

    Support HTTP job (#1339) (#1345)
---
 .../{ => elasticjob-http-executor}/pom.xml         |  32 +++---
 .../elasticjob/http/executor/HttpJobExecutor.java  | 121 ++++++++++++++++++++
 .../elasticjob/http/pojo/HttpParam.java            |  41 +++++++
 .../elasticjob/http/props/HttpJobProperties.java   |  59 ++++++++++
 ...sphere.elasticjob.executor.item.JobItemExecutor |  18 +++
 .../http/executor/HttpJobExecutorTest.java         | 125 +++++++++++++++++++++
 .../elasticjob-executor-type/pom.xml               |   4 +-
 .../infra/exception/JobExecutionException.java     |  34 ++++++
 elasticjob-lite/elasticjob-lite-core/pom.xml       |   5 +
 .../elasticjob/lite/example/JavaMain.java          |   9 ++
 10 files changed, 428 insertions(+), 20 deletions(-)

diff --git a/elasticjob-executor/elasticjob-executor-type/pom.xml 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/pom.xml
similarity index 64%
copy from elasticjob-executor/elasticjob-executor-type/pom.xml
copy to 
elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/pom.xml
index b1119a3..d5020c0 100644
--- a/elasticjob-executor/elasticjob-executor-type/pom.xml
+++ 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/pom.xml
@@ -8,7 +8,7 @@
   ~ 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.
@@ -16,39 +16,33 @@
   ~ 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";>
+<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";>
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.shardingsphere.elasticjob</groupId>
-        <artifactId>elasticjob-executor</artifactId>
+        <artifactId>elasticjob-executor-type</artifactId>
         <version>3.0.0-beta-SNAPSHOT</version>
     </parent>
-    <artifactId>elasticjob-executor-type</artifactId>
-    <packaging>pom</packaging>
+    <artifactId>elasticjob-http-executor</artifactId>
     <name>${project.artifactId}</name>
     
-    <modules>
-        <module>elasticjob-simple-executor</module>
-        <module>elasticjob-dataflow-executor</module>
-        <module>elasticjob-script-executor</module>
-    </modules>
-    
     <dependencies>
         <dependency>
+            <groupId>org.apache.shardingsphere.elasticjob</groupId>
+            <artifactId>elasticjob-executor-kernel</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        
+        <dependency>
             <groupId>org.projectlombok</groupId>
             <artifactId>lombok</artifactId>
         </dependency>
+        
         <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
         </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.mockito</groupId>
-            <artifactId>mockito-inline</artifactId>
-        </dependency>
     </dependencies>
 </project>
diff --git 
a/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutor.java
 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutor.java
new file mode 100644
index 0000000..1833f7b
--- /dev/null
+++ 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutor.java
@@ -0,0 +1,121 @@
+/*
+ * 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.shardingsphere.elasticjob.http.executor;
+
+import com.google.common.base.Strings;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shardingsphere.elasticjob.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.api.ShardingContext;
+import org.apache.shardingsphere.elasticjob.executor.JobFacade;
+import 
org.apache.shardingsphere.elasticjob.executor.item.impl.TypedJobItemExecutor;
+import org.apache.shardingsphere.elasticjob.http.pojo.HttpParam;
+import org.apache.shardingsphere.elasticjob.http.props.HttpJobProperties;
+import 
org.apache.shardingsphere.elasticjob.infra.exception.JobConfigurationException;
+import 
org.apache.shardingsphere.elasticjob.infra.exception.JobExecutionException;
+import org.apache.shardingsphere.elasticjob.infra.json.GsonFactory;
+
+import java.io.BufferedReader;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import java.nio.charset.StandardCharsets;
+import java.util.Properties;
+
+/**
+ * Http job executor.
+ */
+@Slf4j
+public final class HttpJobExecutor implements TypedJobItemExecutor {
+    
+    @Override
+    public void process(final ElasticJob elasticJob, final JobConfiguration 
jobConfig, final JobFacade jobFacade, final ShardingContext shardingContext) {
+        HttpParam httpParam = getHttpParam(jobConfig.getProps());
+        HttpURLConnection connection = null;
+        BufferedReader bufferedReader = null;
+        try {
+            URL url = new URL(httpParam.getUrl());
+            connection = (HttpURLConnection) url.openConnection();
+            connection.setRequestMethod(httpParam.getMethod());
+            connection.setDoOutput(true);
+            connection.setConnectTimeout(httpParam.getConnectTimeout());
+            connection.setReadTimeout(httpParam.getReadTimeout());
+            if (!Strings.isNullOrEmpty(httpParam.getContentType())) {
+                connection.setRequestProperty("Content-Type", 
httpParam.getContentType());
+            }
+            connection.connect();
+            String data = httpParam.getData();
+            if (!Strings.isNullOrEmpty(data)) {
+                StringBuilder builder = new StringBuilder(data);
+                
builder.append("&").append(HttpJobProperties.TRANSPARENT_SHARDING_CONTEXT_KEY);
+                
builder.append("=").append(GsonFactory.getGson().toJson(shardingContext));
+                data = builder.toString();
+                DataOutputStream dataOutputStream = new 
DataOutputStream(connection.getOutputStream());
+                dataOutputStream.write(data.getBytes(StandardCharsets.UTF_8));
+                dataOutputStream.flush();
+                dataOutputStream.close();
+            }
+            int code = connection.getResponseCode();
+            if (code != 200) {
+                throw new JobExecutionException("Http job %s executed with 
response code %d", jobConfig.getJobName(), code);
+            }
+            bufferedReader = new BufferedReader(new 
InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
+            StringBuilder result = new StringBuilder();
+            String line;
+            while ((line = bufferedReader.readLine()) != null) {
+                result.append(line);
+            }
+            log.debug("http job execute result : {}", result.toString());
+        } catch (final IOException ex) {
+            throw new JobExecutionException(ex);
+        } finally {
+            try {
+                if (null != bufferedReader) {
+                    bufferedReader.close();
+                }
+                if (null != connection) {
+                    connection.disconnect();
+                }
+            } catch (final IOException ignore) {
+            }
+        }
+    }
+    
+    private HttpParam getHttpParam(final Properties props) {
+        String url = props.getProperty(HttpJobProperties.URI_KEY);
+        if (Strings.isNullOrEmpty(url)) {
+            throw new JobConfigurationException("Cannot find http url, job is 
not executed.");
+        }
+        String method = props.getProperty(HttpJobProperties.METHOD_KEY);
+        if (Strings.isNullOrEmpty(method)) {
+            throw new JobConfigurationException("Cannot find http method, job 
is not executed.");
+        }
+        String data = props.getProperty(HttpJobProperties.DATA_KEY);
+        int connectTimeout = 
Integer.parseInt(props.getProperty(HttpJobProperties.CONNECT_TIMEOUT_KEY, 
"3000"));
+        int readTimeout = 
Integer.parseInt(props.getProperty(HttpJobProperties.READ_TIMEOUT_KEY, "5000"));
+        String contentType = 
props.getProperty(HttpJobProperties.CONTENT_TYPE_KEY);
+        return new HttpParam(url, method, data, connectTimeout, readTimeout, 
contentType);
+    }
+    
+    @Override
+    public String getType() {
+        return "HTTP";
+    }
+}
diff --git 
a/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/pojo/HttpParam.java
 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/pojo/HttpParam.java
new file mode 100644
index 0000000..6ad4c83
--- /dev/null
+++ 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/pojo/HttpParam.java
@@ -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.shardingsphere.elasticjob.http.pojo;
+
+import lombok.Getter;
+import lombok.RequiredArgsConstructor;
+
+/**
+ * Http job param.
+ */
+@RequiredArgsConstructor
+@Getter
+public final class HttpParam {
+    
+    private final String url;
+    
+    private final String method;
+    
+    private final String data;
+    
+    private final int connectTimeout;
+    
+    private final int readTimeout;
+    
+    private final String contentType;
+}
diff --git 
a/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/props/HttpJobProperties.java
 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/props/HttpJobProperties.java
new file mode 100644
index 0000000..27bcf5f
--- /dev/null
+++ 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/java/org/apache/shardingsphere/elasticjob/http/props/HttpJobProperties.java
@@ -0,0 +1,59 @@
+/*
+ * 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.shardingsphere.elasticjob.http.props;
+
+/**
+ * Http job properties.
+ */
+public final class HttpJobProperties {
+    
+    /**
+     * Http request uri.
+     */
+    public static final String URI_KEY = "http.uri";
+    
+    /**
+     * Http request method.
+     */
+    public static final String METHOD_KEY = "http.method";
+    
+    /**
+     * Http request data.
+     */
+    public static final String DATA_KEY = "http.data";
+    
+    /**
+     * Http connect timeout.
+     */
+    public static final String CONNECT_TIMEOUT_KEY = "http.connect.timeout";
+    
+    /**
+     * Http read timeout.
+     */
+    public static final String READ_TIMEOUT_KEY = "http.read.timeout";
+    
+    /**
+     * Http content type.
+     */
+    public static final String CONTENT_TYPE_KEY = "http.content.type";
+    
+    /**
+     * Http transparent sharding context.
+     */
+    public static final String TRANSPARENT_SHARDING_CONTEXT_KEY = 
"shardingContext";
+}
diff --git 
a/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.executor.item.JobItemExecutor
 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.executor.item.JobItemExecutor
new file mode 100644
index 0000000..27fa4a3
--- /dev/null
+++ 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/main/resources/META-INF/services/org.apache.shardingsphere.elasticjob.executor.item.JobItemExecutor
@@ -0,0 +1,18 @@
+#
+# 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.
+#
+
+org.apache.shardingsphere.elasticjob.http.executor.HttpJobExecutor
diff --git 
a/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/test/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutorTest.java
 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/test/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutorTest.java
new file mode 100644
index 0000000..da5982e
--- /dev/null
+++ 
b/elasticjob-executor/elasticjob-executor-type/elasticjob-http-executor/src/test/java/org/apache/shardingsphere/elasticjob/http/executor/HttpJobExecutorTest.java
@@ -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 org.apache.shardingsphere.elasticjob.http.executor;
+
+import org.apache.shardingsphere.elasticjob.api.ElasticJob;
+import org.apache.shardingsphere.elasticjob.api.JobConfiguration;
+import org.apache.shardingsphere.elasticjob.api.ShardingContext;
+import org.apache.shardingsphere.elasticjob.executor.JobFacade;
+import org.apache.shardingsphere.elasticjob.http.props.HttpJobProperties;
+import 
org.apache.shardingsphere.elasticjob.infra.exception.JobConfigurationException;
+import 
org.apache.shardingsphere.elasticjob.infra.exception.JobExecutionException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
+
+import java.util.Properties;
+
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.mockito.Mockito.when;
+
+@RunWith(MockitoJUnitRunner.class)
+public final class HttpJobExecutorTest {
+    
+    @Mock
+    private ElasticJob elasticJob;
+    
+    @Mock
+    private JobConfiguration jobConfig;
+    
+    @Mock
+    private JobFacade jobFacade;
+    
+    @Mock
+    private Properties properties;
+    
+    @Mock
+    private ShardingContext shardingContext;
+    
+    private HttpJobExecutor jobExecutor;
+    
+    @Before
+    public void setUp() {
+        when(jobConfig.getProps()).thenReturn(properties);
+        jobExecutor = new HttpJobExecutor();
+    }
+    
+    @Test(expected = JobConfigurationException.class)
+    public void assertUrlEmpty() {
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn("");
+        jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext);
+    }
+    
+    @Test(expected = JobConfigurationException.class)
+    public void assertMethodEmpty() {
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn("https://github.com";);
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("");
+        jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext);
+    }
+    
+    @Test(expected = JobExecutionException.class)
+    public void assertProcessWithoutSuccessCode() {
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn("https://github.com/apache/shardingsphere-elasticjob2";);
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("GET");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.DATA_KEY)).thenReturn("");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.CONNECT_TIMEOUT_KEY, 
"3000")).thenReturn("4000");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.READ_TIMEOUT_KEY, 
"5000")).thenReturn("5000");
+        jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext);
+    }
+    
+    @Test
+    public void assertProcessWithGet() {
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn("https://github.com";);
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("GET");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.DATA_KEY)).thenReturn("");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.CONNECT_TIMEOUT_KEY, 
"3000")).thenReturn("4000");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.READ_TIMEOUT_KEY, 
"5000")).thenReturn("5000");
+        jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext);
+    }
+    
+    @Test
+    public void assertProcessWithPost() {
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn("http://www.baidu.com";);
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("POST");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.DATA_KEY)).thenReturn("login=test&password=123");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.CONNECT_TIMEOUT_KEY, 
"3000")).thenReturn("4000");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.READ_TIMEOUT_KEY, 
"5000")).thenReturn("5000");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.CONTENT_TYPE_KEY)).thenReturn("application/x-www-form-urlencoded");
+        jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext);
+    }
+    
+    @Test(expected = JobExecutionException.class)
+    public void assertProcessWithIOException() {
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.URI_KEY)).thenReturn("http://www.baidu.com";);
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.METHOD_KEY)).thenReturn("POST");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.DATA_KEY)).thenReturn("login=test&password=123");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.CONNECT_TIMEOUT_KEY, 
"3000")).thenReturn("1");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.READ_TIMEOUT_KEY, 
"5000")).thenReturn("1");
+        
when(jobConfig.getProps().getProperty(HttpJobProperties.CONTENT_TYPE_KEY)).thenReturn("application/x-www-form-urlencoded");
+        jobExecutor.process(elasticJob, jobConfig, jobFacade, shardingContext);
+    }
+    
+    @Test
+    public void assertGetType() {
+        assertThat(jobExecutor.getType(), is("HTTP"));
+    }
+    
+}
diff --git a/elasticjob-executor/elasticjob-executor-type/pom.xml 
b/elasticjob-executor/elasticjob-executor-type/pom.xml
index b1119a3..fc4c8cf 100644
--- a/elasticjob-executor/elasticjob-executor-type/pom.xml
+++ b/elasticjob-executor/elasticjob-executor-type/pom.xml
@@ -16,7 +16,8 @@
   ~ 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";>
+<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";>
     <modelVersion>4.0.0</modelVersion>
     <parent>
         <groupId>org.apache.shardingsphere.elasticjob</groupId>
@@ -31,6 +32,7 @@
         <module>elasticjob-simple-executor</module>
         <module>elasticjob-dataflow-executor</module>
         <module>elasticjob-script-executor</module>
+        <module>elasticjob-http-executor</module>
     </modules>
     
     <dependencies>
diff --git 
a/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/JobExecutionException.java
 
b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/JobExecutionException.java
new file mode 100644
index 0000000..931bf10
--- /dev/null
+++ 
b/elasticjob-infra/elasticjob-infra-common/src/main/java/org/apache/shardingsphere/elasticjob/infra/exception/JobExecutionException.java
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.infra.exception;
+
+/**
+ * Job execution exception.
+ */
+public final class JobExecutionException extends RuntimeException {
+    
+    private static final long serialVersionUID = 1L;
+    
+    public JobExecutionException(final String errorMessage, final Object... 
args) {
+        super(String.format(errorMessage, args));
+    }
+    
+    public JobExecutionException(final Throwable cause) {
+        super(cause);
+    }
+}
diff --git a/elasticjob-lite/elasticjob-lite-core/pom.xml 
b/elasticjob-lite/elasticjob-lite-core/pom.xml
index 623fd7d..fd48d02 100644
--- a/elasticjob-lite/elasticjob-lite-core/pom.xml
+++ b/elasticjob-lite/elasticjob-lite-core/pom.xml
@@ -58,6 +58,11 @@
         </dependency>
         <dependency>
             <groupId>org.apache.shardingsphere.elasticjob</groupId>
+            <artifactId>elasticjob-http-executor</artifactId>
+            <version>${project.parent.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.shardingsphere.elasticjob</groupId>
             <artifactId>elasticjob-tracing-rdb</artifactId>
             <version>${project.parent.version}</version>
         </dependency>
diff --git 
a/examples/elasticjob-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
 
b/examples/elasticjob-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
index b93b79d..9478ea4 100644
--- 
a/examples/elasticjob-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
+++ 
b/examples/elasticjob-example-lite-java/src/main/java/org/apache/shardingsphere/elasticjob/lite/example/JavaMain.java
@@ -62,6 +62,7 @@ public final class JavaMain {
         EmbedZookeeperServer.start(EMBED_ZOOKEEPER_PORT);
         CoordinatorRegistryCenter regCenter = setUpRegistryCenter();
         TracingConfiguration<DataSource> tracingConfig = new 
TracingConfiguration<>("RDB", setUpEventTraceDataSource());
+        setUpHttpJob(regCenter, tracingConfig);
         setUpSimpleJob(regCenter, tracingConfig);
         setUpDataflowJob(regCenter, tracingConfig);
         setUpScriptJob(regCenter, tracingConfig);
@@ -83,6 +84,14 @@ public final class JavaMain {
         return result;
     }
     
+    private static void setUpHttpJob(final CoordinatorRegistryCenter 
regCenter, final TracingConfiguration<DataSource> tracingConfig) {
+        new ScheduleJobBootstrap(regCenter, "HTTP", 
JobConfiguration.newBuilder("javaHttpJob", 3)
+                .setProperty(HttpJobProperties.URI_KEY, "https://github.com";)
+                .setProperty(HttpJobProperties.METHOD_KEY, "GET")
+                .cron("0/5 * * * * 
?").shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").build(), 
tracingConfig).schedule();
+        
+    }
+    
     private static void setUpSimpleJob(final CoordinatorRegistryCenter 
regCenter, final TracingConfiguration<DataSource> tracingConfig) {
         new ScheduleJobBootstrap(regCenter, new JavaSimpleJob(), 
JobConfiguration.newBuilder("javaSimpleJob", 3)
                 .cron("0/5 * * * * 
?").shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").build(), 
tracingConfig).schedule();

Reply via email to