Beispiel #1
0
  public JSONObject toJSON() throws JSONException {
    JSONObject jplan = new JSONObject();

    jplan.put("flags", jobFlags.toString());

    JSONArray jans = new JSONArray();
    for (IActivity an : activityNodes.values()) {
      JSONObject jan = new JSONObject();
      jan.put("id", an.getActivityId().toString());
      jan.put("java-class", an.getClass().getName());
      jan.put("operator-id", an.getActivityId().getOperatorDescriptorId().toString());

      List<IConnectorDescriptor> inputs = getActivityInputConnectorDescriptors(an.getActivityId());
      if (inputs != null) {
        JSONArray jInputs = new JSONArray();
        for (int i = 0; i < inputs.size(); ++i) {
          JSONObject jInput = new JSONObject();
          jInput.put("input-port", i);
          jInput.put("connector-id", inputs.get(i).getConnectorId().toString());
          jInputs.put(jInput);
        }
        jan.put("inputs", jInputs);
      }

      List<IConnectorDescriptor> outputs =
          getActivityOutputConnectorDescriptors(an.getActivityId());
      if (outputs != null) {
        JSONArray jOutputs = new JSONArray();
        for (int i = 0; i < outputs.size(); ++i) {
          JSONObject jOutput = new JSONObject();
          jOutput.put("output-port", i);
          jOutput.put("connector-id", outputs.get(i).getConnectorId().toString());
          jOutputs.put(jOutput);
        }
        jan.put("outputs", jOutputs);
      }

      Set<ActivityId> blockers = getBlocked2BlockerMap().get(an.getActivityId());
      if (blockers != null) {
        JSONArray jDeps = new JSONArray();
        for (ActivityId blocker : blockers) {
          jDeps.put(blocker.toString());
        }
        jan.put("depends-on", jDeps);
      }
      jans.put(jan);
    }
    jplan.put("activities", jans);

    return jplan;
  }
Beispiel #2
0
 public List<IConnectorDescriptor> getActivityOutputConnectorDescriptors(ActivityId hanId) {
   List<Integer> outputIndexes = activityOutputMap.get(hanId);
   if (outputIndexes == null) {
     return null;
   }
   OperatorDescriptorId ownerId = hanId.getOperatorDescriptorId();
   List<IConnectorDescriptor> outputs = new ArrayList<IConnectorDescriptor>();
   for (Integer i : outputIndexes) {
     outputs.add(jobSpec.getOutputConnectorDescriptor(ownerId, i));
   }
   return outputs;
 }
Beispiel #3
0
 public RecordDescriptor getActivityOutputRecordDescriptor(ActivityId hanId, int outputIndex) {
   int opOutputIndex = getActivityOutputMap().get(hanId).get(outputIndex);
   return jobSpec.getOperatorOutputRecordDescriptor(
       hanId.getOperatorDescriptorId(), opOutputIndex);
 }