private void initialize (String jobId, String taskId, JSONObject jobConfig, JSONObject responses) { this.jobId = jobId; this.taskId = taskId; this.responses = responses; this.payloadType = LGConstants.LG_PAYLOAD_TYPE_ADAPTERRESPONSE; // always adapter response by default this.requests = LGPayload.empty_nodes_edges(); this.setJobConfig(jobConfig); }
/** */ private String getStatusHelper(LGJob lg) { if (null == lg) { return null; } return lg.getStatusString(lg.getStatus()); }
public List<JSONObject> getRequestNodesAndEdges() { return getNodesAndEdges(this.getRequests()); }
/** * Updates an LGJob's history field and updates the jobHistory entry in mongodb * @param job LGJob * @param history LGJobHistory */ public static void updateJobHistory(LGJob job, LGJobHistory history) { open(); job.addHistory(history); JSONObject jHistory = history.toJson(); MONGO_DB_STORE.appendToList("jobs", job.getJobId(), "jobHistory", jHistory); }
public Boolean maxGraphActivity(LGJob job, String taskId) { if(MAX_GRAPH_SIZE <= 0)//ignore for MAX_GRAPH_SIZE <=0 return false; Boolean errorCheck = false; // Check to see if GraphActivity exceeds threshold; if so, issue STOP command for this job int graphActivity = JobManager.getJob(job.getJobId()).getGraphActivity(); if (graphActivity > MAX_GRAPH_SIZE && MAX_GRAPH_SIZE > 0) { //ignore for MAX_GRAPH_SIZE <=0 JobManager.setStatus(job, LGJob.STATUS_STOPPED, "Exceeded MAX_GRAPH_SIZE", true); String msg = "job:"+job.getJobId()+" GraphActivity:"+graphActivity+" exceeds the MAX_GRAPH_SIZE:" + MAX_GRAPH_SIZE; log.warn(msg); LGTask task = JobManager.getTask(taskId); LGJobError error = new LGJobError(job.getJobId(), taskId, "Job Error", task.getAdapterId(), msg); JobManager.updateMaxGraphSizeErrorsForJob(job.getJobId(), error); errorCheck = true; } return errorCheck; }
/** */ public static JSONArray getErrorsHelper(LGJob lg) { if (null == lg) { return null; } List<LGJobError> errors = lg.getJobErrors(); JSONArray result = new JSONArray(); for(LGJobError l: errors) { JSONObject rl = l.toJson(); result.put(rl); } return result; }
/** */ private JSONArray getHistoryHelper(LGJob lg) { List<LGJobHistory> history = lg.getJobHistory(); JSONArray result = new JSONArray(); for(LGJobHistory l: history) { JSONObject rl = l.toJson(); result.put(rl); } return result; }
public LGPayload(String jobId, String taskId, JSONObject jobConfig) { initialize(jobId, taskId, jobConfig, LGPayload.empty_nodes_edges()); }
public List<JSONObject> getResponseNodesAndEdges() { return getNodesAndEdges(this.getResponses()); }
public String getStatusString() { return getStatusString(this.getStatus());} public String getAuxInfo() { return this.extraParams;}
private void readObject(java.io.ObjectInputStream in) throws IOException { this.jobId = in.readUTF(); this.taskId= in.readUTF(); this.requests = readNodesAndEdges(in); this.responses = readNodesAndEdges(in); this.jobConfig = readJSONObject(in); this.payloadType = in.readUTF(); }
/** */ public String toString() { StringBuilder sb = new StringBuilder(); sb.append("Cmd ").append(this.getCmdString()); sb.append(" id :").append(this.jobId); sb.append(" ttl:").append(this.ttl); sb.append(" priority:").append(this.priority); sb.append(" payload:").append(this.seedPayload.toString()); sb.append(" adapters:").append(adapterList.toString()); return sb.toString(); }
public LGPayload(String jobId, String taskId, JSONObject jobConfig, JSONObject responses) { initialize(jobId, taskId, jobConfig, responses); }
@Override public String toString() { return this.toJsonString(); }
public void delTaskId() { this.setTaskId("");}
/** * @return String in JSONObject format */ public String toJsonString() { return this.toJson().toString(); }
private JSONObject readJSONObject(java.io.ObjectInputStream in) throws IOException { String str = readString(in); JSONObject jObject = new JSONObject(str); return jObject; }
public LGPayload(JSONObject jobConfig) { String jobId = ""; if (jobConfig.has("job_id")) { jobId = jobConfig.getString("job_id"); } initialize(jobId, "", jobConfig, LGPayload.empty_nodes_edges()); }