Cluster Singleton Job
One job per entire cluster
- If you ever want to run a service with only one instance of your entire cluster, Cluster Singleton job is the answer
- Context Variable: job
- Running Jon Handle Variable: THIS
Example
//def API_KEY = "XXXXXXXXXXXXXX";
def API_KEY = domain.get("api_key");
def API_URL = "https://api.openweathermap.org/data/2.5/weather?q={city}&appid={api}";
while(!THIS.isStopped()){
try{
def res = rest.get(API_URL)
.routeParam("city", "New York")
.routeParam("api", API_KEY)
.asJson()
.getBody()
.toPrettyString()
;
log.info(res);
}catch(Exception ex){
log.error(ex);
}
util.sleep(10000);
}
See Also
Related REST APIs
[Create / Update Job(ref:upsertjob)
Get Job
Delete Job
Count Jobs
List Jobs
Set Job State
Count Running Jobs
List Running Jobs
Start Job
Restart Job
Count All Running Jobs
Updated over 3 years ago