Examples of MJob


Examples of org.apache.sqoop.model.MJob

    MConnection connection = getClient().newConnection("generic-jdbc-connector");
    fillConnectionForm(connection);
    createConnection(connection);

    // Job creation
    MJob job = getClient().newJob(connection.getPersistenceId(), MJob.Type.IMPORT);

    // Connector values
    MFormList forms = job.getConnectorPart();
    forms.getStringInput("table.tableName").setValue(provider.escapeTableName(getTableName()));
    forms.getStringInput("table.partitionColumn").setValue(provider.escapeColumnName("id"));
    // Framework values
    fillOutputForm(job, StorageType.HDFS, OutputFormat.TEXT_FILE);
    createJob(job);
View Full Code Here

Examples of org.apache.sqoop.model.MJob

    fillConnectionForm(connection);

    createConnection(connection);

    // Job creation
    MJob job = getClient().newJob(connection.getPersistenceId(), MJob.Type.IMPORT);

    // Connector values
    MFormList forms = job.getConnectorPart();
    forms.getStringInput("table.tableName").setValue(provider.escapeTableName(getTableName()));
    forms.getStringInput("table.partitionColumn").setValue(provider.escapeColumnName("id"));
    forms.getStringInput("table.columns").setValue(provider.escapeColumnName("id") + "," + provider.escapeColumnName("country"));
    // Framework values
    fillOutputForm(job, StorageType.HDFS, OutputFormat.TEXT_FILE);
    createJob(job);

    MSubmission submission = getClient().startSubmission(job.getPersistenceId());
    assertTrue(submission.getStatus().isRunning());

    // Wait until the job finish - this active waiting will be removed once
    // Sqoop client API will get blocking support.
    do {
      Thread.sleep(5000);
      submission = getClient().getSubmissionStatus(job.getPersistenceId());
    } while(submission.getStatus().isRunning());

    // Assert correct output
    assertMapreduceOutput(
      "1,'USA'",
View Full Code Here

Examples of org.apache.sqoop.model.MJob

    MConnection connection = getClient().newConnection("generic-jdbc-connector");
    fillConnectionForm(connection);
    createConnection(connection);

    // Job creation
    MJob job = getClient().newJob(connection.getPersistenceId(),
      MJob.Type.EXPORT);

    // Connector values
    MFormList forms = job.getConnectorPart();
    forms.getStringInput("table.tableName").setValue(
      provider.escapeTableName(getTableName()));
    forms.getStringInput("table.stageTableName").setValue(
      provider.escapeTableName(stageTableName));
    fillInputForm(job);
View Full Code Here

Examples of org.apache.sqoop.model.MJob

    MConnection connection = getClient().newConnection("generic-jdbc-connector");
    fillConnectionForm(connection);
    createConnection(connection);

    // Job creation
    MJob job = getClient().newJob(connection.getPersistenceId(), MJob.Type.IMPORT);

    // Connector values
    MFormList forms = job.getConnectorPart();
    forms.getStringInput("table.tableName").setValue(provider.escapeTableName(getTableName()));
    forms.getStringInput("table.partitionColumn").setValue(provider.escapeColumnName(partitionColumn));
    // Framework values
    fillOutputForm(job, StorageType.HDFS, OutputFormat.TEXT_FILE);
    forms = job.getFrameworkPart();
    forms.getIntegerInput("throttling.extractors").setValue(extractors);
    createJob(job);

    runJob(job);
View Full Code Here

Examples of org.apache.sqoop.model.MJob

public class TestJobBean {
  @Test
  public void testSerialization() throws ParseException {
    Date created = new Date();
    Date updated = new Date();
    MJob job = getJob("ahoj", MJob.Type.IMPORT);
    job.setName("The big job");
    job.setPersistenceId(666);
    job.setCreationDate(created);
    job.setLastUpdateDate(updated);
    job.setEnabled(false);

    // Fill some data at the beginning
    MStringInput input = (MStringInput) job.getConnectorPart().getForms()
      .get(0).getInputs().get(0);
    input.setValue("Hi there!");

    // Serialize it to JSON object
    JobBean bean = new JobBean(job);
    JSONObject json = bean.extract(false);

    // "Move" it across network in text form
    String string = json.toJSONString();

    // Retrieved transferred object
    JSONObject retrievedJson = (JSONObject)JSONValue.parseWithException(string);
    JobBean retrievedBean = new JobBean();
    retrievedBean.restore(retrievedJson);
    MJob target = retrievedBean.getJobs().get(0);

    // Check id and name
    assertEquals(666, target.getPersistenceId());
    assertEquals(MJob.Type.IMPORT, target.getType());
    assertEquals("The big job", target.getName());
    assertEquals(created, target.getCreationDate());
    assertEquals(updated, target.getLastUpdateDate());
    assertEquals(false, target.getEnabled());

    // Test that value was correctly moved
    MStringInput targetInput = (MStringInput) target.getConnectorPart()
      .getForms().get(0).getInputs().get(0);
    assertEquals("Hi there!", targetInput.getValue());
  }
View Full Code Here

Examples of org.apache.sqoop.model.MJob

                           getFramework().getConnectionForms()
    );
  }

  public static MJob getJob(String name, MJob.Type type) {
    return new MJob(1, 1,
                    type,
                    getConnector(name).getJobForms(type),
                    getFramework().getJobForms(type)
    );
  }
View Full Code Here

Examples of org.apache.sqoop.model.MJob

      throw new SqoopException(ServerError.SERVER_0003,
        "Expected one job metadata but got " + jobs.size());
    }

    // Job object
    MJob job = jobs.get(0);

    // Verify that user is not trying to spoof us
    MJobForms connectorForms
      = ConnectorManager.getConnectorMetadata(job.getConnectorId())
      .getJobForms(job.getType());
    MJobForms frameworkForms = FrameworkManager.getFramework()
      .getJobForms(job.getType());

    if(!connectorForms.equals(job.getConnectorPart())
      || !frameworkForms.equals(job.getFrameworkPart())) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Detected incorrect form structure");
    }

    // Responsible connector for this session
    SqoopConnector connector =
      ConnectorManager.getConnector(job.getConnectorId());

    // Get validator objects
    Validator connectorValidator = connector.getValidator();
    Validator frameworkValidator = FrameworkManager.getValidator();

    // We need translate forms to configuration objects
    Object connectorConfig = ClassUtils.instantiate(
      connector.getJobConfigurationClass(job.getType()));
    Object frameworkConfig = ClassUtils.instantiate(
      FrameworkManager.getJobConfigurationClass(job.getType()));

    FormUtils.fromForms(job.getConnectorPart().getForms(), connectorConfig);
    FormUtils.fromForms(job.getFrameworkPart().getForms(), frameworkConfig);

    // Validate both parts
    Validation connectorValidation =
      connectorValidator.validateJob(job.getType(), connectorConfig);
    Validation frameworkValidation =
      frameworkValidator.validateJob(job.getType(), frameworkConfig);

    Status finalStatus = Status.getWorstStatus(connectorValidation.getStatus(),
      frameworkValidation.getStatus());

    // Return back validations in all cases
    ValidationBean outputBean =
      new ValidationBean(connectorValidation, frameworkValidation);

    // If we're good enough let's perform the action
    if(finalStatus.canProceed()) {
      if(update) {
        RepositoryManager.getRepository().updateJob(job);
      } else {
        RepositoryManager.getRepository().createJob(job);
        outputBean.setId(job.getPersistenceId());
      }

    }

    return outputBean;
View Full Code Here

Examples of org.apache.sqoop.model.MJob

        }
      }
    } else {
      long jid = Long.valueOf(sjid);

      MJob job = repository.findJob(jid);
      long connectorId = job.getConnectorId();

      bean = new JobBean(job);

      bean.addConnectorBundle(connectorId,
        ConnectorManager.getResourceBundle(connectorId, locale));
View Full Code Here

Examples of org.apache.sqoop.model.MJob

        loadForms(connectorConnForms, connectorJobForms,
          formConnectorFetchStmt, inputFetchStmt, 2);
        loadForms(frameworkConnForms, frameworkJobForms,
          formFrameworkFetchStmt, inputFetchStmt, 2);

        MJob job = new MJob(connectorId, connectionId, type,
          new MJobForms(type, connectorJobForms.get(type)),
          new MJobForms(type, frameworkJobForms.get(type)));

        job.setPersistenceId(id);
        job.setName(name);

        jobs.add(job);
      }
    } finally {
      closeResultSets(rsJob);
View Full Code Here

Examples of org.apache.sqoop.model.MJob

    assertCountForTable("SQOOP.SQ_JOB", 0);
    assertCountForTable("SQOOP.SQ_JOB_INPUT", 0);
  }

  public MJob getJob() {
    return new MJob(1, 1, MJob.Type.IMPORT,
      handler.findConnector("A",
        getDerbyConnection()).getJobForms(MJob.Type.IMPORT
      ),
      handler.findFramework(
        getDerbyConnection()).getJobForms(MJob.Type.IMPORT
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.