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); }
public static void feedCoordinator(int sleep, int times, ArrayList<String> approvedAdapters, JSONArray nodes) throws Exception { String jobId; SubmitToRabbitMQ submit = new SubmitToRabbitMQ(); for (int i = 0; i != times; i++) { LGPayload lgp = new LGPayload(); lgp.addResponseNodes(nodes); JSONObject jobConfig = new JSONObject(); jobConfig.put("depth","6"); lgp.setJobConfig(jobConfig); submit.sendNewJobToCommandController(approvedAdapters, lgp); if (sleep > 0) { Thread.sleep(sleep); // ~500 requests/sec } } submit.close(); }
public static void feedCoordinator(int sleep, int times, ArrayList<String> approvedAdapters, JSONObject node) throws Exception { String jobId; SubmitToRabbitMQ submit = new SubmitToRabbitMQ(); for (int i = 0; i != times; i++) { LGPayload lgp = new LGPayload(); lgp.addResponseNode(node); JSONObject jobConfig = new JSONObject(); jobConfig.put("depth","6"); lgp.setJobConfig(jobConfig); submit.sendNewJobToCommandController(approvedAdapters, lgp); if (sleep > 0) { Thread.sleep(sleep); // ~500 requests/sec } } submit.close(); }
/** * See api/Job.java for complete description * @param jobId String for job ID * @param taskId String for task ID * @throws Exception when failing to send retry. */ public void sendRetry(String jobId, String taskId) throws Exception { openConnections(); ArrayList approvedAdapters = new ArrayList<String>(); LGPayload cmdPayload = new LGPayload(jobId); JSONObject jobConfig = new JSONObject(); JSONArray tasks = new JSONArray(); // So in the future we can support a list of taskIds if (!taskId.equals("")) { tasks.put(taskId); } jobConfig.put("tasks", tasks); cmdPayload.setJobConfig(jobConfig); LGCommand cmd = new LGCommand(LGCommand.COMMAND_TYPE_RETRY_FAILED_TASKS, jobId, 100, 255, approvedAdapters, cmdPayload); channel.basicPublish( "" //exchange , LGConstants.LEMONGRENADE_COORDINATORCMD //routing key , new AMQP.BasicProperties.Builder().priority(LGConstants.QUEUE_PRIORITY_COMMAND).build() , cmd.toByteArray()); }
/** * See api/Job.java for complete description * @param jobId String job ID * @param reason String reason for reset * */ public void sendReset(String jobId, String reason) throws Exception { openConnections(); ArrayList approvedAdapters = new ArrayList<String>(); LGPayload cmdPayload = new LGPayload(jobId); JSONObject jobConfig = new JSONObject(); jobConfig.put(LGConstants.LG_RESET_REASON, reason); cmdPayload.setJobConfig(jobConfig); LGCommand cmd = new LGCommand(LGCommand.COMMAND_TYPE_RESET, jobId, 100, 255, approvedAdapters, cmdPayload); channel.basicPublish("", LGConstants.LEMONGRENADE_COORDINATORCMD , new AMQP.BasicProperties.Builder().priority(LGConstants.QUEUE_PRIORITY_COMMAND).build() , cmd.toByteArray()); }