You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/07/15 06:29:17 UTC

[shardingsphere-elasticjob] branch master updated: Update quick start (#1066)

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 70c0f4a   Update quick start (#1066)
70c0f4a is described below

commit 70c0f4a751bc9f9844901f0f7867b5d9da8a83a3
Author: Liang Zhang <te...@163.com>
AuthorDate: Wed Jul 15 14:29:12 2020 +0800

     Update quick start (#1066)
    
    * Update structure of quick start
    
    * Add elasticjob-cloud quick start
    
    * update lite cn
    
    * update lite en
    
    * update cloud cn
    
    * update cloud en
---
 docs/content/quick-start/_index.cn.md           | 112 +-----------------------
 docs/content/quick-start/_index.en.md           |   2 +-
 docs/content/quick-start/elasticjob-cloud.cn.md |  70 +++++++++++++++
 docs/content/quick-start/elasticjob-cloud.en.md |  70 +++++++++++++++
 docs/content/quick-start/elasticjob-lite.cn.md  |  67 ++++++++++++++
 docs/content/quick-start/elasticjob-lite.en.md  |  67 ++++++++++++++
 6 files changed, 276 insertions(+), 112 deletions(-)

diff --git a/docs/content/quick-start/_index.cn.md b/docs/content/quick-start/_index.cn.md
index bf48c01..bae7073 100644
--- a/docs/content/quick-start/_index.cn.md
+++ b/docs/content/quick-start/_index.cn.md
@@ -5,114 +5,4 @@ weight = 2
 chapter = true
 +++
 
-## 1. 使用 API 配置启动
-
-### 引入 maven 依赖
-
-```xml
-<dependency>
-    <groupId>org.apache.shardingsphere.elasticjob</groupId>
-    <artifactId>elasticjob-lite-core</artifactId>
-    <version>${latest.release.version}</version>
-</dependency>
-```
-
-### 作业开发
-
-```java
-public class MyElasticJob implements SimpleJob {
-    
-    @Override
-    public void execute(ShardingContext context) {
-        switch (context.getShardingItem()) {
-            case 0: 
-                // do something by sharding item 0
-                break;
-            case 1: 
-                // do something by sharding item 1
-                break;
-            case 2: 
-                // do something by sharding item 2
-                break;
-            // case n: ...
-        }
-    }
-}
-```
-
-### 作业配置
-
-```java
-    // 定义作业核心配置
-    JobCoreConfiguration simpleCoreConfig = JobCoreConfiguration.newBuilder("demoSimpleJob", "0/15 * * * * ?", 10).build();
-    // 定义 SIMPLE 类型配置
-    SimpleJobConfiguration simpleJobConfig = new SimpleJobConfiguration(simpleCoreConfig, SimpleDemoJob.class.getCanonicalName());
-    // 定义作业根配置
-    JobConfiguration jobConfig = JobConfiguration.newBuilder(simpleJobConfig).build();
-```
-
-### 启动作业
-
-```java
-public class JobDemo {
-    
-    public static void main(String[] args) {
-        new JobScheduler(createRegistryCenter(), createJobConfiguration()).init();
-    }
-    
-    private static CoordinatorRegistryCenter createRegistryCenter() {
-        CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration("zk_host:2181", "elastic-job-demo"));
-        regCenter.init();
-        return regCenter;
-    }
-    
-    private static JobConfiguration createJobConfiguration() {
-        // 创建作业配置
-        // ...
-    }
-}
-```
-
-## 2. 使用 Spring 配置启动
-
-```xml
-<dependency>
-    <groupId>org.apache.shardingsphere.elasticjob</groupId>
-    <artifactId>elasticjob-lite-spring</artifactId>
-    <version>${latest.release.version}</version>
-</dependency>
-```
-
-### 作业开发
-
-同使用 API 配置中作业开发
-
-### 作业配置
-
-```xml
-<?xml version="1.0" encoding="UTF-8"?>
-<beans xmlns="http://www.springframework.org/schema/beans"
-       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:elasticjob="http://shardingsphere.apache.org/schema/elasticjob"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans
-                           http://www.springframework.org/schema/beans/spring-beans.xsd
-                           http://shardingsphere.apache.org/schema/elasticjob
-                           http://shardingsphere.apache.org/schema/elasticjob/elasticjob.xsd
-                           ">
-    <!--配置作业注册中心 -->
-    <elasticjob:zookeeper id="regCenter" server-lists="yourhost:2181" namespace="elastic-job" base-sleep-time-milliseconds="1000" max-sleep-time-milliseconds="3000" max-retries="3" />
-   
-    <!--配置任务监控 -->
-    <elasticjob:monitor id="monitor1" registry-center-ref="regCenter" monitor-port="9999" />    
-
-    <!--配置作业类 -->
-    <bean id="simpleJob" class="xxx.MyElasticJob" />
-    
-    <!--配置作业 -->
-    <elasticjob:simple id="oneOffElasticJob" job-ref="simpleJob" registry-center-ref="regCenter" reconcile-interval-minutes="10" cron="0/10 * * * * ?" sharding-total-count="3" sharding-item-parameters="0=A,1=B,2=C" />
-</beans>
-```
-
-### 启动作业
-
-将配置 Spring 命名空间的 xml 通过 Spring 启动,作业将自动加载。
+本章节以尽量短的时间,为使用者提供最简单的 ElasticJob 的快速入门。
\ No newline at end of file
diff --git a/docs/content/quick-start/_index.en.md b/docs/content/quick-start/_index.en.md
index 10f8fe5..b2f198a 100644
--- a/docs/content/quick-start/_index.en.md
+++ b/docs/content/quick-start/_index.en.md
@@ -5,4 +5,4 @@ weight = 2
 chapter = true
 +++
 
-TODO
+In shortest time, this chapter provides users with a simplest quick start with ElasticJob.
diff --git a/docs/content/quick-start/elasticjob-cloud.cn.md b/docs/content/quick-start/elasticjob-cloud.cn.md
new file mode 100644
index 0000000..c2f60fa
--- /dev/null
+++ b/docs/content/quick-start/elasticjob-cloud.cn.md
@@ -0,0 +1,70 @@
++++
+pre = "<b>2.2. </b>"
+title = "ElasticJob Cloud"
+weight = 2
+chapter = true
++++
+
+## 引入 maven 依赖
+
+```xml
+<dependency>
+    <groupId>org.apache.shardingsphere.elasticjob</groupId>
+    <artifactId>elasticjob-cloud-executor</artifactId>
+    <version>${latest.release.version}</version>
+</dependency>
+```
+
+## 作业开发
+
+```java
+public class MyJob implements SimpleJob {
+    
+    @Override
+    public void execute(ShardingContext context) {
+        switch (context.getShardingItem()) {
+            case 0: 
+                // do something by sharding item 0
+                break;
+            case 1: 
+                // do something by sharding item 1
+                break;
+            case 2: 
+                // do something by sharding item 2
+                break;
+            // case n: ...
+        }
+    }
+}
+```
+
+## 作业启动
+
+需定义 `Main` 方法并调用 `JobBootstrap.execute()`,例子如下:
+
+```java
+public class MyJobDemo {
+    
+    public static void main(final String[] args) {
+        JobBootstrap.execute(new MyJob());
+    }
+}
+```
+
+## 作业打包
+
+```bash
+tar -cvf my-job.tar.gz my-job
+```
+
+## 作业发布
+
+```bash
+curl -l -H "Content-type: application/json" -X POST -d '{"appName":"foo_app","appURL":"http://app_host:8080/my-job.tar.gz","cpuCount":0.1,"memoryMB":64.0,"bootstrapScript":"bin/start.sh","appCacheEnable":true,"eventTraceSamplingCount":0}' http://elasticjob_cloud_host:8899/api/app
+```
+
+## 作业调度
+
+```bash
+curl -l -H "Content-type: application/json" -X POST -d '{"jobName":"foo_job","appName":"foo_app","jobExecutionType":"TRANSIENT","cron":"0/5 * * * * ?","shardingTotalCount":3,"cpuCount":0.1,"memoryMB":64.0}' http://elasticjob_cloud_host:8899/api/job/register
+```
diff --git a/docs/content/quick-start/elasticjob-cloud.en.md b/docs/content/quick-start/elasticjob-cloud.en.md
new file mode 100644
index 0000000..3f8ba1d
--- /dev/null
+++ b/docs/content/quick-start/elasticjob-cloud.en.md
@@ -0,0 +1,70 @@
++++
+pre = "<b>2.2. </b>"
+title = "ElasticJob Cloud"
+weight = 2
+chapter = true
++++
+
+## Import Maven Dependency
+
+```xml
+<dependency>
+    <groupId>org.apache.shardingsphere.elasticjob</groupId>
+    <artifactId>elasticjob-cloud-executor</artifactId>
+    <version>${latest.release.version}</version>
+</dependency>
+```
+
+## Develop Job Details
+
+```java
+public class MyJob implements SimpleJob {
+    
+    @Override
+    public void execute(ShardingContext context) {
+        switch (context.getShardingItem()) {
+            case 0: 
+                // do something by sharding item 0
+                break;
+            case 1: 
+                // do something by sharding item 1
+                break;
+            case 2: 
+                // do something by sharding item 2
+                break;
+            // case n: ...
+        }
+    }
+}
+```
+
+## Develop Job Bootstrap
+
+Define `Main` method and call `JobBootstrap.execute()`, example as follow:
+
+```java
+public class MyJobDemo {
+    
+    public static void main(final String[] args) {
+        JobBootstrap.execute(new MyJob());
+    }
+}
+```
+
+## Pack Job
+
+```bash
+tar -cvf my-job.tar.gz my-job
+```
+
+## Publish Job
+
+```bash
+curl -l -H "Content-type: application/json" -X POST -d '{"appName":"foo_app","appURL":"http://app_host:8080/my-job.tar.gz","cpuCount":0.1,"memoryMB":64.0,"bootstrapScript":"bin/start.sh","appCacheEnable":true,"eventTraceSamplingCount":0}' http://elasticjob_cloud_host:8899/api/app
+```
+
+## Schedule Job
+
+```bash
+curl -l -H "Content-type: application/json" -X POST -d '{"jobName":"foo_job","appName":"foo_app","jobExecutionType":"TRANSIENT","cron":"0/5 * * * * ?","shardingTotalCount":3,"cpuCount":0.1,"memoryMB":64.0}' http://elasticjob_cloud_host:8899/api/job/register
+```
diff --git a/docs/content/quick-start/elasticjob-lite.cn.md b/docs/content/quick-start/elasticjob-lite.cn.md
new file mode 100644
index 0000000..02e6fa9
--- /dev/null
+++ b/docs/content/quick-start/elasticjob-lite.cn.md
@@ -0,0 +1,67 @@
++++
+pre = "<b>2.1. </b>"
+title = "ElasticJob Lite"
+weight = 1
+chapter = true
++++
+
+## 引入 maven 依赖
+
+```xml
+<dependency>
+    <groupId>org.apache.shardingsphere.elasticjob</groupId>
+    <artifactId>elasticjob-lite-core</artifactId>
+    <version>${latest.release.version}</version>
+</dependency>
+```
+
+## 作业开发
+
+```java
+public class MyJob implements SimpleJob {
+    
+    @Override
+    public void execute(ShardingContext context) {
+        switch (context.getShardingItem()) {
+            case 0: 
+                // do something by sharding item 0
+                break;
+            case 1: 
+                // do something by sharding item 1
+                break;
+            case 2: 
+                // do something by sharding item 2
+                break;
+            // case n: ...
+        }
+    }
+}
+```
+
+## 作业配置
+
+```java
+    JobConfiguration jobConfig = JobConfiguration.newBuilder("MyJob", 3).cron("0/5 * * * * ?").shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").build();
+```
+
+## 作业调度
+
+```java
+public class MyJobDemo {
+    
+    public static void main(String[] args) {
+        new ScheduleJobBootstrap(createRegistryCenter(), new MyJob(), createJobConfiguration()).schedule();
+    }
+    
+    private static CoordinatorRegistryCenter createRegistryCenter() {
+        CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration("zk_host:2181", "my-job"));
+        regCenter.init();
+        return regCenter;
+    }
+    
+    private static JobConfiguration createJobConfiguration() {
+        // 创建作业配置
+        // ...
+    }
+}
+```
diff --git a/docs/content/quick-start/elasticjob-lite.en.md b/docs/content/quick-start/elasticjob-lite.en.md
new file mode 100644
index 0000000..f66f218
--- /dev/null
+++ b/docs/content/quick-start/elasticjob-lite.en.md
@@ -0,0 +1,67 @@
++++
+pre = "<b>2.1. </b>"
+title = "ElasticJob Lite"
+weight = 1
+chapter = true
++++
+
+## Import Maven Dependency
+
+```xml
+<dependency>
+    <groupId>org.apache.shardingsphere.elasticjob</groupId>
+    <artifactId>elasticjob-lite-core</artifactId>
+    <version>${latest.release.version}</version>
+</dependency>
+```
+
+## Develop Job
+
+```java
+public class MyJob implements SimpleJob {
+    
+    @Override
+    public void execute(ShardingContext context) {
+        switch (context.getShardingItem()) {
+            case 0: 
+                // do something by sharding item 0
+                break;
+            case 1: 
+                // do something by sharding item 1
+                break;
+            case 2: 
+                // do something by sharding item 2
+                break;
+            // case n: ...
+        }
+    }
+}
+```
+
+## Configure Job
+
+```java
+    JobConfiguration jobConfig = JobConfiguration.newBuilder("MyJob", 3).cron("0/5 * * * * ?").shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").build();
+```
+
+## Schedule Job
+
+```java
+public class MyJobDemo {
+    
+    public static void main(String[] args) {
+        new ScheduleJobBootstrap(createRegistryCenter(), new MyJob(), createJobConfiguration()).schedule();
+    }
+    
+    private static CoordinatorRegistryCenter createRegistryCenter() {
+        CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new ZookeeperConfiguration("zk_host:2181", "my-job"));
+        regCenter.init();
+        return regCenter;
+    }
+    
+    private static JobConfiguration createJobConfiguration() {
+        // create job configuration
+        // ...
+    }
+}
+```