@Test public void runPropertiesAreCorrectlySetup() { ScheduledTime t = new ScheduledTime("2013-11-26T17:23Z"); SlotID id = new SlotID(new WorkflowID("test"), t); ObjectNode defaults = Util.newObjectNode(); defaults.put("foo", "bar"); defaults.put("uses-variables", "${year}-${month}-${day}-${hour}-${year}"); defaults.put("another-one", "${year}-${month}-${day}T${hour}:${minute}:${second}.${millisecond}Z"); Properties runProperties = makeOozieExternalService().setupRunProperties(defaults, id); Assert.assertEquals("bar", runProperties.getProperty("foo")); Assert.assertEquals("2013-11-26-17-2013", runProperties.getProperty("uses-variables")); Assert.assertEquals("2013-11-26T17:23:00.000Z", runProperties.getProperty("another-one")); Assert.assertEquals("2013", runProperties.getProperty(OozieExternalService.YEAR_PROP)); Assert.assertEquals("11", runProperties.getProperty(OozieExternalService.MONTH_PROP)); Assert.assertEquals("26", runProperties.getProperty(OozieExternalService.DAY_PROP)); Assert.assertEquals("17", runProperties.getProperty(OozieExternalService.HOUR_PROP)); Assert.assertEquals("23", runProperties.getProperty(OozieExternalService.MINUTE_PROP)); Assert.assertEquals("00", runProperties.getProperty(OozieExternalService.SECOND_PROP)); Assert.assertEquals("test@2013-11-26T17:23Z", runProperties.getProperty(OozieExternalService.WORKFLOW_NAME_PROP)); }
Properties setupRunProperties(ObjectNode defaults, SlotID id) { ScheduledTime t = id.getScheduledTime(); Properties runProperties = setupDefaultProperties(defaults, t); ScheduledTimeFormatter formatter = new ScheduledTimeFormatter(); runProperties.setProperty(YEAR_PROP, formatter.formatYear(t)); runProperties.setProperty(MONTH_PROP, formatter.formatMonth(t)); runProperties.setProperty(DAY_PROP, formatter.formatDay(t)); runProperties.setProperty(HOUR_PROP, formatter.formatHour(t)); runProperties.setProperty(MINUTE_PROP, formatter.formatMinute(t)); runProperties.setProperty(SECOND_PROP, formatter.formatSecond(t)); runProperties.setProperty(WORKFLOW_NAME_PROP, getWorkflowName(id, formatter)); return runProperties; }
OozieExternalService implements ExternalService { Properties setupRunProperties(ObjectNode defaults, SlotID id) { ScheduledTime t = id.getScheduledTime(); Properties runProperties = setupDefaultProperties(defaults, t); ScheduledTimeFormatter formatter = new ScheduledTimeFormatter(); runProperties.setProperty(YEAR_PROP, formatter.formatYear(t)); runProperties.setProperty(MONTH_PROP, formatter.formatMonth(t)); runProperties.setProperty(DAY_PROP, formatter.formatDay(t)); runProperties.setProperty(HOUR_PROP, formatter.formatHour(t)); runProperties.setProperty(MINUTE_PROP, formatter.formatMinute(t)); runProperties.setProperty(SECOND_PROP, formatter.formatSecond(t)); runProperties.setProperty(WORKFLOW_NAME_PROP, getWorkflowName(id, formatter)); return runProperties; } }
OozieExternalService implements ExternalService { Properties setupRunProperties(ObjectNode defaults, SlotID id) { ScheduledTime t = id.getScheduledTime(); Properties runProperties = setupDefaultProperties(defaults, t); ScheduledTimeFormatter formatter = new ScheduledTimeFormatter(); runProperties.setProperty(YEAR_PROP, formatter.formatYear(t)); runProperties.setProperty(MONTH_PROP, formatter.formatMonth(t)); runProperties.setProperty(DAY_PROP, formatter.formatDay(t)); runProperties.setProperty(HOUR_PROP, formatter.formatHour(t)); runProperties.setProperty(MINUTE_PROP, formatter.formatMinute(t)); runProperties.setProperty(SECOND_PROP, formatter.formatSecond(t)); runProperties.setProperty(WORKFLOW_NAME_PROP, getWorkflowName(id, formatter)); return runProperties; } OozieExternalService(String oozieURL, PropertiesGenerator gen); }
OozieExternalService implements ExternalService { Properties setupRunProperties(ObjectNode defaults, SlotID id) { ScheduledTime t = id.getScheduledTime(); Properties runProperties = setupDefaultProperties(defaults, t); ScheduledTimeFormatter formatter = new ScheduledTimeFormatter(); runProperties.setProperty(YEAR_PROP, formatter.formatYear(t)); runProperties.setProperty(MONTH_PROP, formatter.formatMonth(t)); runProperties.setProperty(DAY_PROP, formatter.formatDay(t)); runProperties.setProperty(HOUR_PROP, formatter.formatHour(t)); runProperties.setProperty(MINUTE_PROP, formatter.formatMinute(t)); runProperties.setProperty(SECOND_PROP, formatter.formatSecond(t)); runProperties.setProperty(WORKFLOW_NAME_PROP, getWorkflowName(id, formatter)); return runProperties; } OozieExternalService(String oozieURL, PropertiesGenerator gen); @Override String submit(SlotID id); ObjectNode getProperties(SlotID id); @Override void start(SlotID unused, String externalID); @Override void kill(SlotID unused, String externalID); @Override ExternalStatus getStatus(SlotID unused, String jobId); String getOozieURL(); }
OozieExternalService implements ExternalService { Properties setupRunProperties(ObjectNode defaults, SlotID id) { ScheduledTime t = id.getScheduledTime(); Properties runProperties = setupDefaultProperties(defaults, t); ScheduledTimeFormatter formatter = new ScheduledTimeFormatter(); runProperties.setProperty(YEAR_PROP, formatter.formatYear(t)); runProperties.setProperty(MONTH_PROP, formatter.formatMonth(t)); runProperties.setProperty(DAY_PROP, formatter.formatDay(t)); runProperties.setProperty(HOUR_PROP, formatter.formatHour(t)); runProperties.setProperty(MINUTE_PROP, formatter.formatMinute(t)); runProperties.setProperty(SECOND_PROP, formatter.formatSecond(t)); runProperties.setProperty(WORKFLOW_NAME_PROP, getWorkflowName(id, formatter)); return runProperties; } OozieExternalService(String oozieURL, PropertiesGenerator gen); @Override String submit(SlotID id); ObjectNode getProperties(SlotID id); @Override void start(SlotID unused, String externalID); @Override void kill(SlotID unused, String externalID); @Override ExternalStatus getStatus(SlotID unused, String jobId); String getOozieURL(); static final String YEAR_PROP; static final String MONTH_PROP; static final String DAY_PROP; static final String HOUR_PROP; static final String MINUTE_PROP; static final String SECOND_PROP; static final String WORKFLOW_NAME_PROP; }