/** * Retrieve the FlowStatus with the given key * @param key flow status id key containing group name and flow name * @return {@link FlowStatus} with flow status for the latest execution of the flow */ @Override public FlowStatus get(ComplexResourceKey<FlowStatusId, EmptyRecord> key) { String flowGroup = key.getKey().getFlowGroup(); String flowName = key.getKey().getFlowName(); long flowExecutionId = key.getKey().getFlowExecutionId(); LOG.info("Get called with flowGroup " + flowGroup + " flowName " + flowName + " flowExecutionId " + flowExecutionId); org.apache.gobblin.service.monitoring.FlowStatus flowStatus = _flowStatusGenerator.getFlowStatus(flowName, flowGroup, flowExecutionId); // this returns null to raise a 404 error if flowStatus is null return convertFlowStatus(flowStatus); }
@Test public void testCheckFlowExecutionId() throws Exception { Map<String, String> flowProperties = Maps.newHashMap(); flowProperties.put("param1", "value1"); FlowConfig flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME)) .setTemplateUris(TEST_TEMPLATE_URI).setProperties(new StringMap(flowProperties)); FlowStatusId flowStatusId =_client.createFlowConfig(flowConfig); Assert.assertEquals(TEST_GROUP_NAME, flowStatusId.getFlowGroup()); Assert.assertEquals(TEST_FLOW_NAME, flowStatusId.getFlowName()); Assert.assertTrue(flowStatusId.getFlowExecutionId() != -1); flowConfig = new FlowConfig().setId(new FlowId().setFlowGroup(TEST_GROUP_NAME).setFlowName(TEST_FLOW_NAME)) .setTemplateUris(TEST_TEMPLATE_URI).setProperties(new StringMap(flowProperties)) .setSchedule(new Schedule().setCronSchedule(TEST_SCHEDULE).setRunImmediately(true)); Assert.assertEquals(_client.createFlowConfig(flowConfig).getFlowExecutionId().longValue(), -1L); }