| 1,3c1,3 |
| < commit b52671dd27d3fe35af62cf26befc36f216222548 |
| < Author: Yanjie Zhou <zhouyanjie@aliyun.com> |
| < Date: Wed Nov 11 23:09:19 2020 +0800 |
| --- |
| > commit bdecb6ccb57104efcdae0ecddb5f4829055b66e4 |
| > Author: 吴伟杰 <root496879118@me.com> |
| > Date: Fri Nov 13 15:57:14 2020 +0800 |
| 5,11c5 |
| < Update documents and examples of Spring Boot Starter (#1708) |
| < |
| < * Update documents and examples of Spring Boot Starter |
| < |
| < * Update spring-boot-starter.en.md |
| < |
| < * Update spring-namespace.*.md |
| --- |
| > Update contents about Cloud Scheduler in FAQ (#1719) |
| 13,19c7,11 |
| < diff --git a/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-boot-starter.cn.md b/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-boot-starter.cn.md |
| < index ed8e3210e..5156da93c 100644 |
| < --- a/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-boot-starter.cn.md |
| < +++ b/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-boot-starter.cn.md |
| < @@ -74,26 +74,39 @@ elasticjob: |
| < 一次性调度的作业的执行权在开发者手中,开发者可以在需要调用作业的位置注入 `OneOffJobBootstrap`, |
| < 通过 `execute()` 方法执行作业。 |
| --- |
| > diff --git a/docs/content/faq/_index.cn.md b/docs/content/faq/_index.cn.md |
| > index 8b1051a6e..ce9b54e3b 100644 |
| > --- a/docs/content/faq/_index.cn.md |
| > +++ b/docs/content/faq/_index.cn.md |
| > @@ -104,4 +104,14 @@ ElasticJob 执行任务会获取本机IP,首次可能存在获取IP较慢的 |
| 21,28c13 |
| < -**关于@DependsOn注解** |
| < - |
| < -JobBootstrap 由 Starter 动态创建,如果依赖方的实例化时间早于 Starter 创建 JobBootstrap,将无法注入 JobBootstrap 的实例。 |
| < - |
| < -也可以通过 ApplicationContext 获取 JobBootstrap 的 Bean。 |
| < - |
| < `OneOffJobBootstrap` bean 的名称通过属性 jobBootstrapBeanName 配置,注入时需要指定依赖的 bean 名称。 |
| < 具体配置请参考[配置文档](/cn/user-manual/elasticjob-lite/configuration/spring-boot-starter)。 |
| --- |
| > 打开cmd.exe并执行下面的命令: |
| 30,131c15,17 |
| < +```yaml |
| < +elasticjob: |
| < + jobs: |
| < + myOneOffJob: |
| < + jobBootstrapBeanName: myOneOffJobBean |
| < + .... |
| < +``` |
| < + |
| < ```java |
| < @RestController |
| < -@DependsOn("ElasticJobLiteAutoConfiguration") |
| < public class OneOffJobController { |
| < |
| < - @Resource(name = "manualScriptJobOneOffJobBootstrap") |
| < - private OneOffJobBootstrap manualScriptJob; |
| < - |
| < + // 通过 "@Resource" 注入 |
| < + @Resource(name = "myOneOffJobBean") |
| < + private OneOffJobBootstrap myOneOffJob; |
| < + |
| < @GetMapping("/execute") |
| < public String executeOneOffJob() { |
| < - manualScriptJob.execute(); |
| < + myOneOffJob.execute(); |
| < + return "{\"msg\":\"OK\"}"; |
| < + } |
| < + |
| < + // 通过 "@Autowired" 注入 |
| < + @Autowired |
| < + @Qualifier(name = "myOneOffJobBean") |
| < + private OneOffJobBootstrap myOneOffJob2; |
| < + |
| < + @GetMapping("/execute2") |
| < + public String executeOneOffJob2() { |
| < + myOneOffJob2.execute(); |
| < return "{\"msg\":\"OK\"}"; |
| < } |
| < } |
| < diff --git a/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-boot-starter.en.md b/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-boot-starter.en.md |
| < index 10c4399a9..47f5fcbba 100644 |
| < --- a/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-boot-starter.en.md |
| < +++ b/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-boot-starter.en.md |
| < @@ -76,26 +76,39 @@ When to execute OneOffJob is up to you. |
| < Developers can inject the `OneOffJobBootstrap` bean into where they plan to invoke. |
| < Trigger the job by invoking `execute()` method manually. |
| < |
| < -**About @DependsOn Annotation** |
| < - |
| < -JobBootstraps are created by the Starter dynamically. It's unable to inject the `JobBootstrap` beans if the beans which depends on `JobBootstrap` were instantiated earlier than the instantiation of `JobBootstrap`. |
| < - |
| < -Developers can also retrieve `JobBootstrap` beans by ApplicationContext. |
| < - |
| < The bean name of `OneOffJobBootstrap` is specified by property "jobBootstrapBeanName", |
| < Please refer to [Spring Boot Starter Configuration](/en/user-manual/elasticjob-lite/configuration/spring-boot-starter). |
| < |
| < +```yaml |
| < +elasticjob: |
| < + jobs: |
| < + myOneOffJob: |
| < + jobBootstrapBeanName: myOneOffJobBean |
| < + .... |
| < +``` |
| < + |
| < ```java |
| < @RestController |
| < -@DependsOn("ElasticJobLiteAutoConfiguration") |
| < public class OneOffJobController { |
| < - |
| < - @Resource(name = "manualScriptJobOneOffJobBootstrap") |
| < - private OneOffJobBootstrap manualScriptJob; |
| < + |
| < + // Inject via "@Resource" |
| < + @Resource(name = "myOneOffJobBean") |
| < + private OneOffJobBootstrap myOneOffJob; |
| < |
| < @GetMapping("/execute") |
| < public String executeOneOffJob() { |
| < - manualScriptJob.execute(); |
| < + myOneOffJob.execute(); |
| < + return "{\"msg\":\"OK\"}"; |
| < + } |
| < + |
| < + // Inject via "@Autowired" |
| < + @Autowired |
| < + @Qualifier(name = "myOneOffJobBean") |
| < + private OneOffJobBootstrap myOneOffJob2; |
| < + |
| < + @GetMapping("/execute2") |
| < + public String executeOneOffJob2() { |
| < + myOneOffJob2.execute(); |
| < return "{\"msg\":\"OK\"}"; |
| < } |
| < } |
| < diff --git a/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-namespace.cn.md b/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-namespace.cn.md |
| < index 8b7cf9766..09c52e71a 100644 |
| < --- a/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-namespace.cn.md |
| < +++ b/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-namespace.cn.md |
| < @@ -41,8 +41,29 @@ ElasticJob-Lite 提供自定义的 Spring 命名空间,可以与 Spring 容器 |
| < |
| < ## 作业启动 |
| < |
| < +### 定时调度 |
| --- |
| > -tar zxvf apache-shardingsphere-elasticjob-${RELEASE.VERSION}-lite-ui-bin.tar.gz |
| > \ No newline at end of file |
| > +tar zxvf apache-shardingsphere-elasticjob-${RELEASE.VERSION}-lite-ui-bin.tar.gz |
| 133,135c19 |
| < 将配置 Spring 命名空间的 xml 通过 Spring 启动,作业将自动加载。 |
| < |
| < +### 一次性调度 |
| --- |
| > +## 13. 运行 Cloud Scheduler 持续输出日志 "Elastic job: IP:PORT has leadership",不能正常运行 |
| 137,138c21 |
| < +一次性调度的作业的执行权在开发者手中,开发者可以在需要调用作业的位置注入 `OneOffJobBootstrap`, |
| < +通过 `execute()` 方法执行作业。 |
| --- |
| > +回答: |
| 140,152c23 |
| < +```xml |
| < + <bean id="oneOffJob" class="org.apache.shardingsphere.elasticjob.lite.example.job.simple.SpringSimpleJob" /> |
| < + <elasticjob:job id="oneOffJobBean" job-ref="oneOffJob" ... /> |
| < +``` |
| < +```java |
| < +public final class SpringMain { |
| < + public static void main(final String[] args) { |
| < + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:META-INF/application-context.xml"); |
| < + OneOffJobBootstrap oneOffJobBootstrap = context.getBean("oneOffJobBean", OneOffJobBootstrap.class); |
| < + oneOffJobBootstrap.execute(); |
| < + } |
| < +} |
| < +``` |
| --- |
| > +Cloud Scheduler 依赖 Mesos 库,启动时需要通过 `-Djava.library.path` 指定 Mesos 库所在目录。 |
| 154,165c25 |
| < ## 配置作业导出端口 |
| < |
| < 使用 ElasticJob-Lite 过程中可能会碰到一些分布式问题,导致作业运行不稳定。 |
| < diff --git a/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-namespace.en.md b/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-namespace.en.md |
| < index 0b6ed6ab0..9b147c3e3 100644 |
| < --- a/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-namespace.en.md |
| < +++ b/docs/content/user-manual/elasticjob-lite/usage/job-api/spring-namespace.en.md |
| < @@ -41,8 +41,30 @@ Through the way of DI (Dependency Injection), developers can easily use data sou |
| < |
| < ## Job Start |
| < |
| < +### Schedule Job |
| --- |
| > +例如,Mesos 库位于 `/usr/local/lib`,启动 Cloud Scheduler 前需要设置 `-Djava.library.path=/usr/local/lib`。 |
| 167c27,33 |
| < If the Spring container start, the `XML` that configures the Spring namespace will be loaded, and the job will be automatically started. |
| --- |
| > +Mesos 相关请参考 [Apache Mesos](https://mesos.apache.org/)。 |
| > diff --git a/docs/content/faq/_index.en.md b/docs/content/faq/_index.en.md |
| > index 50edef214..cb2df34c9 100644 |
| > --- a/docs/content/faq/_index.en.md |
| > +++ b/docs/content/faq/_index.en.md |
| > @@ -104,3 +104,13 @@ Some decompression tools may truncate the file name when decompressing the Shard |
| > Open cmd.exe and execute the following command: |
| 169c35 |
| < +### One-off Job |
| --- |
| > tar zxvf apache-shardingsphere-elasticjob-${RELEASE.VERSION}-lite-ui-bin.tar.gz |
| 171,187c37 |
| < +When to execute OneOffJob is up to you. |
| < +Developers can inject the `OneOffJobBootstrap` bean into where they plan to invoke. |
| < +Trigger the job by invoking `execute()` method manually. |
| < + |
| < +```xml |
| < + <bean id="oneOffJob" class="org.apache.shardingsphere.elasticjob.lite.example.job.simple.SpringSimpleJob" /> |
| < + <elasticjob:job id="oneOffJobBean" job-ref="oneOffJob" ... /> |
| < +``` |
| < +```java |
| < +public final class SpringMain { |
| < + public static void main(final String[] args) { |
| < + ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:META-INF/application-context.xml"); |
| < + OneOffJobBootstrap oneOffJobBootstrap = context.getBean("oneOffJobBean", OneOffJobBootstrap.class); |
| < + oneOffJobBootstrap.execute(); |
| < + } |
| < +} |
| < +``` |
| --- |
| > +## 13. Unable to startup Cloud Scheduler. Continuously output "Elastic job: IP:PORT has leadership"gg |
| 189,191c39,45 |
| < ## Job Dump |
| < |
| < Using ElasticJob may meet some distributed problem which is not easy to observe. |
| --- |
| > +Answer: |
| > + |
| > +Cloud Scheduler required Mesos native library. Specify Mesos native library path by property `-Djava.library.path`. |
| > + |
| > +For instance, Mesos native libraries are under `/usr/local/lib`, so the property `-Djava.library.path=/usr/local/lib` need to be set to start the Cloud Scheduler. |
| > + |
| > +About Apache Mesos, please refer to [Apache Mesos](https://mesos.apache.org/). |