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 556a3a3 Translate java-api.en.md (#1126)
556a3a3 is described below
commit 556a3a333fca1d823e5c29755c0e4b594b23a9ca
Author: 于玉桔 <[email protected]>
AuthorDate: Sat Jul 18 13:34:46 2020 +0800
Translate java-api.en.md (#1126)
---
.../elasticjob-lite/usage/job-api/java-api.en.md | 65 +++++++++++++++++++++-
1 file changed, 64 insertions(+), 1 deletion(-)
diff --git
a/docs/content/user-manual/elasticjob-lite/usage/job-api/java-api.en.md
b/docs/content/user-manual/elasticjob-lite/usage/job-api/java-api.en.md
index a9876e7..140479c 100644
--- a/docs/content/user-manual/elasticjob-lite/usage/job-api/java-api.en.md
+++ b/docs/content/user-manual/elasticjob-lite/usage/job-api/java-api.en.md
@@ -4,4 +4,67 @@ weight = 2
chapter = true
+++
-TODO
+## Job configuration
+
+ElasticJob-Lite uses the builder mode to create job configuration objects.
+The code example is as follows:
+
+```java
+ JobConfiguration jobConfig = JobConfiguration.newBuilder("myJob",
3).cron("0/5 * * * *
?").shardingItemParameters("0=Beijing,1=Shanghai,2=Guangzhou").build();
+```
+
+## Job start
+
+ElasticJob-Lite scheduler is divided into two types: timed scheduling and
one-time scheduling.
+Each scheduler needs three parameters: registry configuration, job object (or
job type), and job configuration when it starts.
+
+### Timed scheduling
+
+```java
+public class JobDemo {
+
+ public static void main(String[] args) {
+ // Class-based Scheduling Jobs
+ new ScheduleJobBootstrap(createRegistryCenter(), new MyJob(),
createJobConfiguration()).schedule();
+ // Type-based Scheduling Jobs
+ new ScheduleJobBootstrap(createRegistryCenter(), "MY_TYPE",
createJobConfiguration()).schedule();
+ }
+
+ private static CoordinatorRegistryCenter createRegistryCenter() {
+ CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new
ZookeeperConfiguration("zk_host:2181", "elastic-job-demo"));
+ regCenter.init();
+ return regCenter;
+ }
+
+ private static JobConfiguration createJobConfiguration() {
+ // Create job configuration
+ ...
+ }
+}
+```
+
+### One-time scheduling
+
+```java
+public class JobDemo {
+
+ public static void main(String[] args) {
+ OneOffJobBootstrap jobBootstrap = new
OneOffJobBootstrap(createRegistryCenter(), new MyJob(),
createJobConfiguration());
+ // One-time scheduling can be called multiple times
+ jobBootstrap.execute();
+ jobBootstrap.execute();
+ jobBootstrap.execute();
+ }
+
+ private static CoordinatorRegistryCenter createRegistryCenter() {
+ CoordinatorRegistryCenter regCenter = new ZookeeperRegistryCenter(new
ZookeeperConfiguration("zk_host:2181", "elastic-job-demo"));
+ regCenter.init();
+ return regCenter;
+ }
+
+ private static JobConfiguration createJobConfiguration() {
+ // Create job configuration
+ ...
+ }
+}
+```
\ No newline at end of file