コード例 #1
0
  @Test
  public void testCreateJobSubmission() {

    HttpEventContext testCtx = new HttpEventContext();
    testCtx.setUsername("testUser");
    MSubmission jobSubmission = jobManager.createJobSubmission(testCtx, 1234L);
    assertEquals(jobSubmission.getCreationUser(), "testUser");
    assertEquals(jobSubmission.getLastUpdateUser(), "testUser");
  }
コード例 #2
0
ファイル: ConnectorTestCase.java プロジェクト: gbecares/Sqoop
  /**
   * Run job with given jid.
   *
   * @param jid Job id
   * @throws Exception
   */
  protected void executeJob(String jobName) throws Exception {
    MSubmission finalSubmission = getClient().startJob(jobName, DEFAULT_SUBMISSION_CALLBACKS, 100);

    if (finalSubmission.getStatus().isFailure()) {
      LOG.error("Submission has failed: " + finalSubmission.getError().getErrorSummary());
      LOG.error("Corresponding error details: " + finalSubmission.getError().getErrorDetails());
    }
    assertEquals(
        finalSubmission.getStatus(),
        SubmissionStatus.SUCCEEDED,
        "Submission finished with error: " + finalSubmission.getError().getErrorSummary());
  }
コード例 #3
0
  @SuppressWarnings("unchecked")
  private JSONObject extractSubmission(MSubmission submission) {
    JSONObject object = new JSONObject();

    object.put(JOB, submission.getJobId());
    object.put(JOB_ID, submission.getJobId());
    object.put(STATUS, submission.getStatus().name());
    object.put(PROGRESS, submission.getProgress());

    if (submission.getCreationUser() != null) {
      object.put(CREATION_USER, submission.getCreationUser());
    }
    if (submission.getCreationDate() != null) {
      object.put(CREATION_DATE, submission.getCreationDate().getTime());
    }
    if (submission.getLastUpdateUser() != null) {
      object.put(LAST_UPDATE_USER, submission.getLastUpdateUser());
    }
    if (submission.getLastUpdateDate() != null) {
      object.put(LAST_UPDATE_DATE, submission.getLastUpdateDate().getTime());
    }
    if (submission.getExternalJobId() != null) {
      object.put(EXTERNAL_ID, submission.getExternalJobId());
    }
    if (submission.getExternalLink() != null) {
      object.put(EXTERNAL_LINK, submission.getExternalLink());
    }
    if (submission.getError().getErrorSummary() != null) {
      object.put(ERROR_SUMMARY, submission.getError().getErrorSummary());
    }
    if (submission.getError().getErrorDetails() != null) {
      object.put(ERROR_DETAILS, submission.getError().getErrorDetails());
    }
    if (submission.getCounters() != null) {
      object.put(COUNTERS, extractCounters(submission.getCounters()));
    }
    if (submission.getFromSchema() != null) {
      object.put(FROM_SCHEMA, extractSchema(submission.getFromSchema()));
    }
    if (submission.getToSchema() != null) {
      object.put(TO_SCHEMA, extractSchema(submission.getToSchema()));
    }
    return object;
  }
コード例 #4
0
  private MSubmission restoreSubmission(Object obj) {
    JSONObject object = (JSONObject) obj;
    MSubmission submission = new MSubmission();
    Long jobId = (Long) object.get(JOB_ID);
    if (jobId == null) {
      jobId = (Long) object.get(JOB);
    }
    submission.setJobId(jobId);
    submission.setStatus(SubmissionStatus.valueOf((String) object.get(STATUS)));
    submission.setProgress((Double) object.get(PROGRESS));

    if (object.containsKey(CREATION_USER)) {
      submission.setCreationUser((String) object.get(CREATION_USER));
    }
    if (object.containsKey(CREATION_DATE)) {
      submission.setCreationDate(new Date((Long) object.get(CREATION_DATE)));
    }
    if (object.containsKey(LAST_UPDATE_USER)) {
      submission.setLastUpdateUser((String) object.get(LAST_UPDATE_USER));
    }
    if (object.containsKey(LAST_UPDATE_DATE)) {
      submission.setLastUpdateDate(new Date((Long) object.get(LAST_UPDATE_DATE)));
    }
    if (object.containsKey(EXTERNAL_ID)) {
      submission.setExternalJobId((String) object.get(EXTERNAL_ID));
    }
    if (object.containsKey(EXTERNAL_LINK)) {
      submission.setExternalLink((String) object.get(EXTERNAL_LINK));
    }
    if (object.containsKey(ERROR_SUMMARY)) {
      submission.getError().setErrorSummary((String) object.get(ERROR_SUMMARY));
    }
    if (object.containsKey(ERROR_DETAILS)) {
      submission.getError().setErrorDetails((String) object.get(ERROR_DETAILS));
    }
    if (object.containsKey(COUNTERS)) {
      submission.setCounters(restoreCounters((JSONObject) object.get(COUNTERS)));
    }

    if (object.containsKey(FROM_SCHEMA)) {
      submission.setFromSchema(restoreSchema((JSONObject) object.get(FROM_SCHEMA)));
    }
    if (object.containsKey(TO_SCHEMA)) {
      submission.setToSchema(restoreSchema((JSONObject) object.get(TO_SCHEMA)));
    }
    return submission;
  }