Java Code Examples for org.apache.sqoop.model.MJob#setName()
The following examples show how to use
org.apache.sqoop.model.MJob#setName() .
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: ConfigFiller.java From sqoop-on-spark with Apache License 2.0 | 6 votes |
/** * Fill job object based on user input. * * @param reader Associated console reader object * @param job Job that user is suppose to fill in * @param fromConfigBundle Connector resource bundle * @param driverConfigBundle Driver config resource bundle * @return True if we filled all inputs, false if user has stopped processing * @throws IOException */ public static boolean fillJobWithBundle(ConsoleReader reader, MJob job, ResourceBundle fromConfigBundle, ResourceBundle toConfigBundle, ResourceBundle driverConfigBundle) throws IOException { job.setName(getName(reader, job.getName())); return fillJobConfigWithBundle(reader, job.getJobConfig(Direction.FROM).getConfigs(), fromConfigBundle, job.getJobConfig(Direction.TO).getConfigs(), toConfigBundle, job.getDriverConfig().getConfigs(), driverConfigBundle); }
Example 2
Source File: TestJobHandling.java From sqoop-on-spark with Apache License 2.0 | 5 votes |
@Test(expectedExceptions=SqoopException.class) public void testCreateDuplicateJob() throws Exception { // Duplicate jobs MJob job = getJob(); fillJob(job); job.setName("test"); handler.createJob(job, getDerbyDatabaseConnection()); assertEquals(1, job.getPersistenceId()); job.setPersistenceId(MJob.PERSISTANCE_ID_DEFAULT); handler.createJob(job, getDerbyDatabaseConnection()); }
Example 3
Source File: ConfigFiller.java From sqoop-on-spark with Apache License 2.0 | 5 votes |
/** * Fill job object based on CLI options. * * @param line Associated console reader object * @param job Job that user is suppose to fill in * @return True if we filled all inputs, false if user has stopped processing * @throws IOException */ public static boolean fillJob(CommandLine line, MJob job) throws IOException { job.setName(line.getOptionValue("name")); return fillJobConfig(line, job.getJobConfig(Direction.FROM).getConfigs(), job.getJobConfig(Direction.TO).getConfigs(), job.getDriverConfig().getConfigs()); }
Example 4
Source File: JobBean.java From sqoop-on-spark with Apache License 2.0 | 5 votes |
private MJob restoreJob(Object obj) { JSONObject object = (JSONObject) obj; long fromConnectorId = (Long) object.get(FROM_CONNECTOR_ID); long toConnectorId = (Long) object.get(TO_CONNECTOR_ID); long fromConnectionId = (Long) object.get(FROM_LINK_ID); long toConnectionId = (Long) object.get(TO_LINK_ID); JSONArray fromConfigJson = (JSONArray) object.get(FROM_CONFIG_VALUES); JSONArray toConfigJson = (JSONArray) object.get(TO_CONFIG_VALUES); JSONArray driverConfigJson = (JSONArray) object.get(DRIVER_CONFIG_VALUES); List<MConfig> fromConfig = restoreConfigList(fromConfigJson); List<MConfig> toConfig = restoreConfigList(toConfigJson); List<MConfig> driverConfig = restoreConfigList(driverConfigJson); MJob job = new MJob( fromConnectorId, toConnectorId, fromConnectionId, toConnectionId, new MFromConfig(fromConfig), new MToConfig(toConfig), new MDriverConfig(driverConfig) ); job.setPersistenceId((Long) object.get(ID)); job.setName((String) object.get(NAME)); job.setEnabled((Boolean) object.get(ENABLED)); job.setCreationUser((String) object.get(CREATION_USER)); job.setCreationDate(new Date((Long) object.get(CREATION_DATE))); job.setLastUpdateUser((String) object.get(UPDATE_USER)); job.setLastUpdateDate(new Date((Long) object.get(UPDATE_DATE))); return job; }
Example 5
Source File: BeanTestUtil.java From sqoop-on-spark with Apache License 2.0 | 5 votes |
public static MJob createJob(String connectorName, String jobName, Long jobId, Date created, Date updated) { MJob job = BeanTestUtil.getJob(connectorName); job.setName(jobName); job.setPersistenceId(jobId); job.setCreationDate(created); job.setLastUpdateDate(updated); job.setEnabled(false); return job; }
Example 6
Source File: TestJobHandling.java From sqoop-on-spark with Apache License 2.0 | 4 votes |
@Test public void testUpdateJob() throws Exception { loadJobsForLatestVersion(); assertCountForTable("SQOOP.SQ_JOB", 4); assertCountForTable("SQOOP.SQ_JOB_INPUT", 24); MJob job = handler.findJob(1, derbyConnection); List<MConfig> configs; configs = job.getJobConfig(Direction.FROM).getConfigs(); ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated"); Map<String, String> newFromMap = new HashMap<String, String>(); newFromMap.put("1F", "foo"); newFromMap.put("2F", "bar"); ((MMapInput)configs.get(0).getInputs().get(1)).setValue(newFromMap); configs = job.getJobConfig(Direction.TO).getConfigs(); ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated"); Map<String, String> newToMap = new HashMap<String, String>(); newToMap.put("1T", "foo"); newToMap.put("2T", "bar"); ((MMapInput)configs.get(0).getInputs().get(1)).setValue(newToMap); configs = job.getDriverConfig().getConfigs(); ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated"); ((MMapInput)configs.get(0).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Updated"); ((MMapInput)configs.get(1).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value job.setName("name"); handler.updateJob(job, derbyConnection); assertEquals(1, job.getPersistenceId()); assertCountForTable("SQOOP.SQ_JOB", 4); assertCountForTable("SQOOP.SQ_JOB_INPUT", 28); MJob retrieved = handler.findJob(1, derbyConnection); assertEquals("name", retrieved.getName()); configs = job.getJobConfig(Direction.FROM).getConfigs(); assertEquals(2, configs.size()); assertEquals("Updated", configs.get(0).getInputs().get(0).getValue()); assertEquals(newFromMap, configs.get(0).getInputs().get(1).getValue()); configs = job.getJobConfig(Direction.TO).getConfigs(); assertEquals(2, configs.size()); assertEquals("Updated", configs.get(0).getInputs().get(0).getValue()); assertEquals(newToMap, configs.get(0).getInputs().get(1).getValue()); configs = retrieved.getDriverConfig().getConfigs(); assertEquals(2, configs.size()); assertEquals("Updated", configs.get(0).getInputs().get(0).getValue()); assertNotNull(configs.get(0).getInputs().get(1).getValue()); assertEquals(((Map) configs.get(0).getInputs().get(1).getValue()).size(), 0); }
Example 7
Source File: TestJobHandling.java From sqoop-on-spark with Apache License 2.0 | 4 votes |
@Test public void testUpdateJob() throws Exception { Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB")), 2); Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB_INPUT")), 12); MJob job = handler.findJob(1, provider.getConnection()); List<MConfig> configs; configs = job.getJobConfig(Direction.FROM).getConfigs(); ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated"); ((MMapInput)configs.get(0).getInputs().get(1)).setValue(null); configs = job.getJobConfig(Direction.TO).getConfigs(); ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated"); ((MMapInput)configs.get(0).getInputs().get(1)).setValue(null); configs = job.getDriverConfig().getConfigs(); ((MStringInput)configs.get(0).getInputs().get(0)).setValue("Updated"); ((MMapInput)configs.get(0).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value ((MStringInput)configs.get(1).getInputs().get(0)).setValue("Updated"); ((MMapInput)configs.get(1).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value job.setName("name"); handler.updateJob(job, provider.getConnection()); assertEquals(1, job.getPersistenceId()); Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB")), 2); Assert.assertEquals(provider.rowCount(new TableName("SQOOP", "SQ_JOB_INPUT")), 14); MJob retrieved = handler.findJob(1, provider.getConnection()); assertEquals("name", retrieved.getName()); configs = job.getJobConfig(Direction.FROM).getConfigs(); assertEquals(2, configs.size()); assertEquals("Updated", configs.get(0).getInputs().get(0).getValue()); assertNull(configs.get(0).getInputs().get(1).getValue()); configs = job.getJobConfig(Direction.TO).getConfigs(); assertEquals(2, configs.size()); assertEquals("Updated", configs.get(0).getInputs().get(0).getValue()); assertNull(configs.get(0).getInputs().get(1).getValue()); configs = retrieved.getDriverConfig().getConfigs(); assertEquals(2, configs.size()); assertEquals("Updated", configs.get(0).getInputs().get(0).getValue()); assertNotNull(configs.get(0).getInputs().get(1).getValue()); assertEquals(((Map)configs.get(0).getInputs().get(1).getValue()).size(), 0); }
Example 8
Source File: CommonRepositoryHandler.java From sqoop-on-spark with Apache License 2.0 | 4 votes |
private List<MJob> loadJobs(PreparedStatement stmt, Connection conn) throws SQLException { List<MJob> jobs = new ArrayList<MJob>(); ResultSet rsJob = null; PreparedStatement fromConfigFetchStmt = null; PreparedStatement toConfigFetchStmt = null; PreparedStatement driverConfigfetchStmt = null; PreparedStatement jobInputFetchStmt = null; try { rsJob = stmt.executeQuery(); // Note: Job does not hold a explicit reference to the driver since every // job has the same driver long driverId = this.findDriver(MDriver.DRIVER_NAME, conn).getPersistenceId(); fromConfigFetchStmt = conn.prepareStatement(crudQueries.getStmtSelectConfigForConfigurable()); toConfigFetchStmt = conn.prepareStatement(crudQueries.getStmtSelectConfigForConfigurable()); driverConfigfetchStmt = conn.prepareStatement(crudQueries.getStmtSelectConfigForConfigurable()); jobInputFetchStmt = conn.prepareStatement(crudQueries.getStmtFetchJobInput()); while(rsJob.next()) { long fromConnectorId = rsJob.getLong(1); long toConnectorId = rsJob.getLong(2); long id = rsJob.getLong(3); String name = rsJob.getString(4); long fromLinkId = rsJob.getLong(5); long toLinkId = rsJob.getLong(6); boolean enabled = rsJob.getBoolean(7); String createBy = rsJob.getString(8); Date creationDate = rsJob.getTimestamp(9); String updateBy = rsJob.getString(10); Date lastUpdateDate = rsJob.getTimestamp(11); fromConfigFetchStmt.setLong(1, fromConnectorId); toConfigFetchStmt.setLong(1,toConnectorId); driverConfigfetchStmt.setLong(1, driverId); jobInputFetchStmt.setLong(1, id); jobInputFetchStmt.setLong(3, id); // FROM entity configs List<MConfig> fromConnectorLinkConfig = new ArrayList<MConfig>(); List<MConfig> fromConnectorFromJobConfig = new ArrayList<MConfig>(); List<MConfig> fromConnectorToJobConfig = new ArrayList<MConfig>(); loadConnectorConfigs(fromConnectorLinkConfig, fromConnectorFromJobConfig, fromConnectorToJobConfig, fromConfigFetchStmt, jobInputFetchStmt, 2, conn); // TO entity configs List<MConfig> toConnectorLinkConfig = new ArrayList<MConfig>(); List<MConfig> toConnectorFromJobConfig = new ArrayList<MConfig>(); List<MConfig> toConnectorToJobConfig = new ArrayList<MConfig>(); List<MConfig> driverConfig = new ArrayList<MConfig>(); loadConnectorConfigs(toConnectorLinkConfig, toConnectorFromJobConfig, toConnectorToJobConfig, toConfigFetchStmt, jobInputFetchStmt, 2, conn); loadDriverConfigs(driverConfig, driverConfigfetchStmt, jobInputFetchStmt, 2, conn); MJob job = new MJob( fromConnectorId, toConnectorId, fromLinkId, toLinkId, new MFromConfig(fromConnectorFromJobConfig), new MToConfig(toConnectorToJobConfig), new MDriverConfig(driverConfig)); job.setPersistenceId(id); job.setName(name); job.setCreationUser(createBy); job.setCreationDate(creationDate); job.setLastUpdateUser(updateBy); job.setLastUpdateDate(lastUpdateDate); job.setEnabled(enabled); jobs.add(job); } } finally { closeResultSets(rsJob); closeStatements(fromConfigFetchStmt, toConfigFetchStmt, driverConfigfetchStmt, jobInputFetchStmt); } return jobs; }