Java Code Examples for org.codehaus.jettison.json.JSONObject#getJSONObject()

The following examples show how to use org.codehaus.jettison.json.JSONObject#getJSONObject() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestHsWebServicesJobsQuery.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobsQueryFinishTimeBeginNegative() throws JSONException,
    Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs")
      .queryParam("finishedTimeBegin", String.valueOf(-1000))
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject msg = response.getEntity(JSONObject.class);
  JSONObject exception = msg.getJSONObject("RemoteException");
  assertEquals("incorrect number of elements", 3, exception.length());
  String message = exception.getString("message");
  String type = exception.getString("exception");
  String classname = exception.getString("javaClassName");
  WebServicesTestUtils.checkStringMatch("exception message",
      "java.lang.Exception: finishedTimeBegin must be greater than 0",
      message);
  WebServicesTestUtils.checkStringMatch("exception type",
      "BadRequestException", type);
  WebServicesTestUtils.checkStringMatch("exception classname",
      "org.apache.hadoop.yarn.webapp.BadRequestException", classname);
}
 
Example 2
Source File: TestHsWebServicesTasks.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testTasks() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);
    ClientResponse response = r.path("ws").path("v1").path("history")
        .path("mapreduce").path("jobs").path(jobId).path("tasks")
        .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject tasks = json.getJSONObject("tasks");
    JSONArray arr = tasks.getJSONArray("task");
    assertEquals("incorrect number of elements", 2, arr.length());

    verifyHsTask(arr, jobsMap.get(id), null);
  }
}
 
Example 3
Source File: TestHsWebServicesJobsQuery.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobsQueryFinishTimeEndInvalidformat() throws JSONException,
    Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs").queryParam("finishedTimeEnd", "efsd")
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject msg = response.getEntity(JSONObject.class);
  JSONObject exception = msg.getJSONObject("RemoteException");
  assertEquals("incorrect number of elements", 3, exception.length());
  String message = exception.getString("message");
  String type = exception.getString("exception");
  String classname = exception.getString("javaClassName");
  WebServicesTestUtils
      .checkStringMatch(
          "exception message",
          "java.lang.Exception: Invalid number format: For input string: \"efsd\"",
          message);
  WebServicesTestUtils.checkStringMatch("exception type",
      "BadRequestException", type);
  WebServicesTestUtils.checkStringMatch("exception classname",
      "org.apache.hadoop.yarn.webapp.BadRequestException", classname);
}
 
Example 4
Source File: TestAHSWebServices.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testAppsQuery() throws Exception {
  WebResource r = resource();
  ClientResponse response =
      r.path("ws").path("v1").path("applicationhistory").path("apps")
        .queryParam("state", YarnApplicationState.FINISHED.toString())
        .queryParam("user.name", USERS[round])
        .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject apps = json.getJSONObject("apps");
  assertEquals("incorrect number of elements", 1, apps.length());
  JSONArray array = apps.getJSONArray("app");
  assertEquals("incorrect number of elements", 5, array.length());
}
 
Example 5
Source File: TestHsWebServicesJobsQuery.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobsQueryStartTimeEnd() throws JSONException, Exception {
  WebResource r = resource();
  // the mockJobs start time is the current time - some random amount
  Long now = System.currentTimeMillis();
  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs")
      .queryParam("startedTimeEnd", String.valueOf(now))
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject jobs = json.getJSONObject("jobs");
  JSONArray arr = jobs.getJSONArray("job");
  assertEquals("incorrect number of elements", 3, arr.length());
}
 
Example 6
Source File: TestAMWebServicesJobs.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobIdInvalidDefault() throws JSONException, Exception {
  WebResource r = resource();

  try {
    r.path("ws").path("v1").path("mapreduce").path("jobs").path("job_foo")
        .get(JSONObject.class);
    fail("should have thrown exception on invalid uri");
  } catch (UniformInterfaceException ue) {
    ClientResponse response = ue.getResponse();
    assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject msg = response.getEntity(JSONObject.class);
    JSONObject exception = msg.getJSONObject("RemoteException");
    assertEquals("incorrect number of elements", 3, exception.length());
    String message = exception.getString("message");
    String type = exception.getString("exception");
    String classname = exception.getString("javaClassName");
    verifyJobIdInvalid(message, type, classname);
  }
}
 
Example 7
Source File: TestRMWebServicesApps.java    From big-c with Apache License 2.0 6 votes vote down vote up
public void testAppsHelper(String path, RMApp app, String media)
    throws JSONException, Exception {
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path(path).accept(media).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject apps = json.getJSONObject("apps");
  assertEquals("incorrect number of elements", 1, apps.length());
  JSONArray array = apps.getJSONArray("app");
  assertEquals("incorrect number of elements", 1, array.length());
  verifyAppInfo(array.getJSONObject(0), app);

}
 
Example 8
Source File: TestRMWebServicesApps.java    From hadoop with Apache License 2.0 6 votes vote down vote up
public void testAppsHelper(String path, RMApp app, String media)
    throws JSONException, Exception {
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("cluster")
      .path(path).accept(media).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject apps = json.getJSONObject("apps");
  assertEquals("incorrect number of elements", 1, apps.length());
  JSONArray array = apps.getJSONArray("app");
  assertEquals("incorrect number of elements", 1, array.length());
  verifyAppInfo(array.getJSONObject(0), app);

}
 
Example 9
Source File: TestAMWebServicesJobs.java    From hadoop with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobIdNonExist() throws JSONException, Exception {
  WebResource r = resource();

  try {
    r.path("ws").path("v1").path("mapreduce").path("jobs")
        .path("job_0_1234").get(JSONObject.class);
    fail("should have thrown exception on invalid uri");
  } catch (UniformInterfaceException ue) {
    ClientResponse response = ue.getResponse();
    assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject msg = response.getEntity(JSONObject.class);
    JSONObject exception = msg.getJSONObject("RemoteException");
    assertEquals("incorrect number of elements", 3, exception.length());
    String message = exception.getString("message");
    String type = exception.getString("exception");
    String classname = exception.getString("javaClassName");
    WebServicesTestUtils.checkStringMatch("exception message",
        "java.lang.Exception: job, job_0_1234, is not found", message);
    WebServicesTestUtils.checkStringMatch("exception type",
        "NotFoundException", type);
    WebServicesTestUtils.checkStringMatch("exception classname",
        "org.apache.hadoop.yarn.webapp.NotFoundException", classname);
  }
}
 
Example 10
Source File: TestHsWebServicesJobsQuery.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobsQueryLimitInvalid() throws JSONException, Exception {
  WebResource r = resource();

  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs").queryParam("limit", "-1")
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);

  assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject msg = response.getEntity(JSONObject.class);
  JSONObject exception = msg.getJSONObject("RemoteException");
  assertEquals("incorrect number of elements", 3, exception.length());
  String message = exception.getString("message");
  String type = exception.getString("exception");
  String classname = exception.getString("javaClassName");
  WebServicesTestUtils.checkStringMatch("exception message",
      "java.lang.Exception: limit value must be greater then 0", message);
  WebServicesTestUtils.checkStringMatch("exception type",
      "BadRequestException", type);
  WebServicesTestUtils.checkStringMatch("exception classname",
      "org.apache.hadoop.yarn.webapp.BadRequestException", classname);
}
 
Example 11
Source File: TestHsWebServicesJobs.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobs() throws JSONException, Exception {
  WebResource r = resource();
  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs").accept(MediaType.APPLICATION_JSON)
      .get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject jobs = json.getJSONObject("jobs");
  JSONArray arr = jobs.getJSONArray("job");
  assertEquals("incorrect number of elements", 1, arr.length());
  JSONObject info = arr.getJSONObject(0);
  Job job = appContext.getPartialJob(MRApps.toJobID(info.getString("id")));
  VerifyJobsUtils.verifyHsJobPartial(info, job);

}
 
Example 12
Source File: TestAMWebServicesJobs.java    From big-c with Apache License 2.0 6 votes vote down vote up
@Test
public void testJobAttempts() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);

    ClientResponse response = r.path("ws").path("v1")
        .path("mapreduce").path("jobs").path(jobId).path("jobattempts")
        .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
    JSONObject json = response.getEntity(JSONObject.class);
    assertEquals("incorrect number of elements", 1, json.length());
    JSONObject info = json.getJSONObject("jobAttempts");
    verifyJobAttempts(info, jobsMap.get(id));
  }
}
 
Example 13
Source File: TestNMWebServices.java    From big-c with Apache License 2.0 6 votes vote down vote up
public void verifyNodeInfo(JSONObject json) throws JSONException, Exception {
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject info = json.getJSONObject("nodeInfo");
  assertEquals("incorrect number of elements", 16, info.length());
  verifyNodeInfoGeneric(info.getString("id"), info.getString("healthReport"),
      info.getLong("totalVmemAllocatedContainersMB"),
      info.getLong("totalPmemAllocatedContainersMB"),
      info.getLong("totalVCoresAllocatedContainers"),
      info.getBoolean("vmemCheckEnabled"),
      info.getBoolean("pmemCheckEnabled"),
      info.getLong("lastNodeUpdateTime"), info.getBoolean("nodeHealthy"),
      info.getString("nodeHostName"), info.getString("hadoopVersionBuiltOn"),
      info.getString("hadoopBuildVersion"), info.getString("hadoopVersion"),
      info.getString("nodeManagerVersionBuiltOn"),
      info.getString("nodeManagerBuildVersion"),
      info.getString("nodeManagerVersion"));

}
 
Example 14
Source File: TestHsWebServicesAttempts.java    From hadoop with Apache License 2.0 5 votes vote down vote up
private void testTaskAttemptIdErrorGeneric(String attid, String error)
    throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();

  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);

    for (Task task : jobsMap.get(id).getTasks().values()) {
      String tid = MRApps.toString(task.getID());

      try {
        r.path("ws").path("v1").path("history").path("mapreduce")
            .path("jobs").path(jobId).path("tasks").path(tid)
            .path("attempts").path(attid).accept(MediaType.APPLICATION_JSON)
            .get(JSONObject.class);
        fail("should have thrown exception on invalid uri");
      } catch (UniformInterfaceException ue) {
        ClientResponse response = ue.getResponse();
        assertEquals(Status.NOT_FOUND, response.getClientResponseStatus());
        assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject msg = response.getEntity(JSONObject.class);
        JSONObject exception = msg.getJSONObject("RemoteException");
        assertEquals("incorrect number of elements", 3, exception.length());
        String message = exception.getString("message");
        String type = exception.getString("exception");
        String classname = exception.getString("javaClassName");
        WebServicesTestUtils.checkStringMatch("exception message", error,
            message);
        WebServicesTestUtils.checkStringMatch("exception type",
            "NotFoundException", type);
        WebServicesTestUtils.checkStringMatch("exception classname",
            "org.apache.hadoop.yarn.webapp.NotFoundException", classname);
      }
    }
  }
}
 
Example 15
Source File: TestAMWebServicesAttempts.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testTaskAttemptIdCounters() throws JSONException, Exception {
  WebResource r = resource();
  Map<JobId, Job> jobsMap = appContext.getAllJobs();

  for (JobId id : jobsMap.keySet()) {
    String jobId = MRApps.toString(id);

    for (Task task : jobsMap.get(id).getTasks().values()) {
      String tid = MRApps.toString(task.getID());

      for (TaskAttempt att : task.getAttempts().values()) {
        TaskAttemptId attemptid = att.getID();
        String attid = MRApps.toString(attemptid);

        ClientResponse response = r.path("ws").path("v1").path("mapreduce")
            .path("jobs").path(jobId).path("tasks").path(tid)
            .path("attempts").path(attid).path("counters")
            .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
        assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
        JSONObject json = response.getEntity(JSONObject.class);
        assertEquals("incorrect number of elements", 1, json.length());
        JSONObject info = json.getJSONObject("jobTaskAttemptCounters");
        verifyAMJobTaskAttemptCounters(info, att);
      }
    }
  }
}
 
Example 16
Source File: TestHsWebServicesJobsQuery.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Test
public void testJobsQueryFinishTimeBeginEnd() throws JSONException, Exception {
  WebResource r = resource();

  Map<JobId, Job> jobsMap = appContext.getAllJobs();
  int size = jobsMap.size();
  // figure out the mid end time - we expect atleast 3 jobs
  ArrayList<Long> finishTime = new ArrayList<Long>(size);
  for (Map.Entry<JobId, Job> entry : jobsMap.entrySet()) {
    finishTime.add(entry.getValue().getReport().getFinishTime());
  }
  Collections.sort(finishTime);

  assertTrue("Error we must have atleast 3 jobs", size >= 3);
  long midFinishTime = finishTime.get(size - 2);

  ClientResponse response = r.path("ws").path("v1").path("history")
      .path("mapreduce").path("jobs")
      .queryParam("finishedTimeBegin", String.valueOf(40000))
      .queryParam("finishedTimeEnd", String.valueOf(midFinishTime))
      .accept(MediaType.APPLICATION_JSON).get(ClientResponse.class);
  assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());
  JSONObject json = response.getEntity(JSONObject.class);
  assertEquals("incorrect number of elements", 1, json.length());
  JSONObject jobs = json.getJSONObject("jobs");
  JSONArray arr = jobs.getJSONArray("job");
  assertEquals("incorrect number of elements", size - 1, arr.length());
}
 
Example 17
Source File: AtlasClient.java    From incubator-atlas with Apache License 2.0 5 votes vote down vote up
public JSONObject getOutputGraph(String datasetName) throws AtlasServiceException {
    JSONObject response = callAPIWithBodyAndParams(API.NAME_LINEAGE_OUTPUTS_GRAPH, null, datasetName, "/outputs/graph");
    try {
        return response.getJSONObject(AtlasClient.RESULTS);
    } catch (JSONException e) {
        throw new AtlasServiceException(e);
    }
}
 
Example 18
Source File: TestRMWebServicesNodes.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Test
public void testNodesQueryStateInvalid() throws JSONException, Exception {
  WebResource r = resource();
  rm.registerNode("h1:1234", 5120);
  rm.registerNode("h2:1235", 5121);

  try {
    r.path("ws").path("v1").path("cluster").path("nodes")
        .queryParam("states", "BOGUSSTATE").accept(MediaType.APPLICATION_JSON)
        .get(JSONObject.class);

    fail("should have thrown exception querying invalid state");
  } catch (UniformInterfaceException ue) {
    ClientResponse response = ue.getResponse();

    assertEquals(Status.BAD_REQUEST, response.getClientResponseStatus());
    assertEquals(MediaType.APPLICATION_JSON_TYPE, response.getType());

    JSONObject msg = response.getEntity(JSONObject.class);
    JSONObject exception = msg.getJSONObject("RemoteException");
    assertEquals("incorrect number of elements", 3, exception.length());
    String message = exception.getString("message");
    String type = exception.getString("exception");
    String classname = exception.getString("javaClassName");
    WebServicesTestUtils
        .checkStringContains(
            "exception message",
            "org.apache.hadoop.yarn.api.records.NodeState.BOGUSSTATE",
            message);
    WebServicesTestUtils.checkStringMatch("exception type",
        "IllegalArgumentException", type);
    WebServicesTestUtils.checkStringMatch("exception classname",
        "java.lang.IllegalArgumentException", classname);

  } finally {
    rm.stop();
  }
}
 
Example 19
Source File: TestHistoryEventJsonConversion.java    From tez with Apache License 2.0 4 votes vote down vote up
@Test(timeout = 5000)
public void testConvertVertexReconfigureDoneEvent() throws JSONException {
  TezVertexID vId = TezVertexID.getInstance(
      TezDAGID.getInstance(
          ApplicationId.newInstance(1l, 1), 1), 1);
  Map<String, EdgeProperty> edgeMgrs =
      new HashMap<String, EdgeProperty>();
  
  edgeMgrs.put("a", EdgeProperty.create(EdgeManagerPluginDescriptor.create("a.class")
      .setHistoryText("text"), DataSourceType.PERSISTED, SchedulingType.SEQUENTIAL,
      OutputDescriptor.create("Out"), InputDescriptor.create("In")));
  VertexConfigurationDoneEvent event = new VertexConfigurationDoneEvent(vId, 0L, 1, null,
      edgeMgrs, null, true);

  JSONObject jsonObject = HistoryEventJsonConversion.convertToJson(event);
  Assert.assertNotNull(jsonObject);
  Assert.assertEquals(vId.toString(), jsonObject.getString(ATSConstants.ENTITY));
  Assert.assertEquals(ATSConstants.TEZ_VERTEX_ID, jsonObject.get(ATSConstants.ENTITY_TYPE));

  JSONArray events = jsonObject.getJSONArray(ATSConstants.EVENTS);
  Assert.assertEquals(1, events.length());

  JSONObject evt = events.getJSONObject(0);
  Assert.assertEquals(HistoryEventType.VERTEX_CONFIGURE_DONE.name(),
      evt.getString(ATSConstants.EVENT_TYPE));

  JSONObject evtInfo = evt.getJSONObject(ATSConstants.EVENT_INFO);
  Assert.assertEquals(1, evtInfo.getInt(ATSConstants.NUM_TASKS));
  Assert.assertNotNull(evtInfo.getJSONObject(ATSConstants.UPDATED_EDGE_MANAGERS));

  JSONObject updatedEdgeMgrs = evtInfo.getJSONObject(ATSConstants.UPDATED_EDGE_MANAGERS);
  Assert.assertEquals(1, updatedEdgeMgrs.length());
  Assert.assertNotNull(updatedEdgeMgrs.getJSONObject("a"));
  JSONObject updatedEdgeMgr = updatedEdgeMgrs.getJSONObject("a");

  Assert.assertEquals(DataMovementType.CUSTOM.name(),
      updatedEdgeMgr.getString(DAGUtils.DATA_MOVEMENT_TYPE_KEY));
  Assert.assertEquals("In", updatedEdgeMgr.getString(DAGUtils.EDGE_DESTINATION_CLASS_KEY));
  Assert.assertEquals("a.class", updatedEdgeMgr.getString(DAGUtils.EDGE_MANAGER_CLASS_KEY));

}
 
Example 20
Source File: ExecuteSparkInteractive.java    From nifi with Apache License 2.0 4 votes vote down vote up
@Override
public void onTrigger(ProcessContext context, final ProcessSession session) throws ProcessException {

    FlowFile flowFile = session.get();
    if (flowFile == null) {
        return;
    }

    final ComponentLog log = getLogger();
    final LivySessionService livySessionService = context.getProperty(LIVY_CONTROLLER_SERVICE).asControllerService(LivySessionService.class);
    final Map<String, String> livyController;
    try {
        livyController = livySessionService.getSession();
        if (livyController == null || livyController.isEmpty()) {
            log.debug("No Spark session available (yet), routing flowfile to wait");
            session.transfer(flowFile, REL_WAIT);
            context.yield();
            return;
        }
    } catch (SessionManagerException sme) {
        log.error("Error opening spark session, routing flowfile to wait", sme);
        session.transfer(flowFile, REL_WAIT);
        context.yield();
        return;
    }
    final long statusCheckInterval = context.getProperty(STATUS_CHECK_INTERVAL).evaluateAttributeExpressions(flowFile).asTimePeriod(TimeUnit.MILLISECONDS);
    Charset charset = Charset.forName(context.getProperty(CHARSET).evaluateAttributeExpressions(flowFile).getValue());

    String sessionId = livyController.get("sessionId");
    String livyUrl = livyController.get("livyUrl");
    String code = context.getProperty(CODE).evaluateAttributeExpressions(flowFile).getValue();
    if (StringUtils.isEmpty(code)) {
        try (InputStream inputStream = session.read(flowFile)) {
            // If no code was provided, assume it is in the content of the incoming flow file
            code = IOUtils.toString(inputStream, charset);
        } catch (IOException ioe) {
            log.error("Error reading input flowfile, penalizing and routing to failure", new Object[]{flowFile, ioe.getMessage()}, ioe);
            flowFile = session.penalize(flowFile);
            session.transfer(flowFile, REL_FAILURE);
            return;
        }
    }

    code = StringEscapeUtils.escapeJson(code);
    String payload = "{\"code\":\"" + code + "\"}";
    try {
        final JSONObject result = submitAndHandleJob(livyUrl, livySessionService, sessionId, payload, statusCheckInterval);
        log.debug("ExecuteSparkInteractive Result of Job Submit: " + result);
        if (result == null) {
            session.transfer(flowFile, REL_FAILURE);
        } else {
            try {
                final JSONObject output = result.getJSONObject("data");
                flowFile = session.write(flowFile, out -> out.write(output.toString().getBytes(charset)));
                flowFile = session.putAttribute(flowFile, CoreAttributes.MIME_TYPE.key(), LivySessionService.APPLICATION_JSON);
                session.transfer(flowFile, REL_SUCCESS);
            } catch (JSONException je) {
                // The result doesn't contain the data, just send the output object as the flow file content to failure (after penalizing)
                log.error("Spark Session returned an error, sending the output JSON object as the flow file content to failure (after penalizing)");
                flowFile = session.write(flowFile, out -> out.write(result.toString().getBytes(charset)));
                flowFile = session.putAttribute(flowFile, CoreAttributes.MIME_TYPE.key(), LivySessionService.APPLICATION_JSON);
                flowFile = session.penalize(flowFile);
                session.transfer(flowFile, REL_FAILURE);
            }
        }
    } catch (IOException | SessionManagerException e) {
        log.error("Failure processing flowfile {} due to {}, penalizing and routing to failure", new Object[]{flowFile, e.getMessage()}, e);
        flowFile = session.penalize(flowFile);
        session.transfer(flowFile, REL_FAILURE);
    }
}