18 package org.ensembl.hive;
22 import org.slf4j.Logger;
23 import org.slf4j.LoggerFactory;
25 import com.fasterxml.jackson.core.JsonProcessingException;
26 import com.fasterxml.jackson.databind.ObjectMapper;
36 private final transient ObjectMapper mapper =
new ObjectMapper();
38 private final Logger log = LoggerFactory.getLogger(this.getClass());
40 private static final String INPUT_ID_KEY =
"input_id";
42 private static final String DB_ID_KEY =
"dbID";
44 private static final String RETRY_COUNT_KEY =
"retry_count";
46 private static final String PARAMETERS_KEY =
"parameters";
49 private final int retryCount;
50 private final int dbID;
51 private final String inputId;
53 private boolean autoflow =
true;
54 private boolean lethalForWorker =
false;
55 private boolean transientError =
true;
56 private boolean complete =
false;
58 public Job(Map<String, Object> jobParams) {
59 log.debug(
"Building job with params with "+String.valueOf(jobParams.get(PARAMETERS_KEY)));
61 (Map<String, Object>) (jobParams.get(PARAMETERS_KEY)));;
62 this.retryCount = Double.valueOf(
63 jobParams.get(RETRY_COUNT_KEY).toString()).intValue();
64 this.dbID = Double.valueOf(jobParams.get(DB_ID_KEY).toString())
66 this.inputId = (String) (jobParams.get(INPUT_ID_KEY));
72 this.parameters = parameters;
73 this.retryCount = retryCount;
75 this.inputId = inputId;
99 this.autoflow = autoflow;
103 return lethalForWorker;
107 this.lethalForWorker = lethalForWorker;
111 return transientError;
115 this.transientError = transientError;
120 return mapper.writeValueAsString(
this);
121 }
catch (JsonProcessingException e) {
122 throw new RuntimeException(
"Could not write job as JSON", e);
131 this.complete = complete;