import org.apache.shardingsphere.elasticjob.api.ShardingContext;
import org.apache.shardingsphere.elasticjob.simple.job.SimpleJob;
public class MyLogSimpleJob implements SimpleJob {
@Override
public void execute(final ShardingContext shardingContext) {
// Do what you want.
}
}
import icu.wwj.elasticjob.example.job.MyLogSimpleJob;
import org.apache.shardingsphere.elasticjob.cloud.api.JobBootstrap;
public class Main {
public static void main(String[] args) {
JobBootstrap.execute(new MyLogSimpleJob());
}
}
See example.
kubectl apply -f https://raw.githubusercontent.com/TeslaCN/elasticjob-kubernetes/main/example/k8s/transient/elasticjob.yaml
apiVersion: icu.wwj.elasticjob/v1alpha1
kind: ElasticJob
metadata:
name: hello-transient-job
namespace: elasticjob-cloud
spec:
template:
metadata:
labels:
app: elasticjob
spec:
restartPolicy: OnFailure
containers:
- name: job-container
imagePullPolicy: IfNotPresent
image: teslacn/elasticjob-kubernetes-example:latest
jobExecutionType: TRANSIENT
shardingTotalCount: 3
shardingItemParameters:
1: a
2: b
0: c
jobParameter: 'common parameter'
# Transient job only support minute level cron. The second expression would be ignored.
cron: '0 * * * * ?'
misfire: true
description: ''
props:
a: b
disabled: false
ElasticJob on Kubernetes vs ElasticJob Cloud 3.0 (Mesos)
ElasticJob concept |
ElasticJob Kubernetes |
ElasticJob Mesos |
API |
CRD elasticjobs.icu.wwj.elasticjob |
Restful API |
Scheduler |
ElasticJob Operator |
base on Mesos Scheduler & Executor |
Application |
An Image |
A Tarball |
Kubernetes resource:
Job Execution Type |
DAEMON |
TRANSIENT |
ElasticJob with CRON |
✅ StatefulSet |
✅ CronJob |
ElasticJob without CRON |
❌ StatefulSet |
✅ Job |
-
✅ means supported
-
❌ means unsupported for now