/** * Fetch ExecutableFlow from database. {@inheritDoc} */ @Override public ExecutableFlow getExecutableFlow(final int execId) throws ExecutorManagerException { return this.executorLoader.fetchExecutableFlow(execId); }
/** * Fetch ExecutableFlow from database {@inheritDoc} * * @see azkaban.executor.ExecutorManagerAdapter#getExecutableFlow(int) */ @Override public ExecutableFlow getExecutableFlow(final int execId) throws ExecutorManagerException { return this.executorLoader.fetchExecutableFlow(execId); }
public Object isSlaFailed() { final ExecutableFlow flow; try { flow = this.executorLoader.fetchExecutableFlow(this.execId); } catch (final ExecutorManagerException e) { logger.error("Can't get executable flow.", e); // something wrong, send out alerts return Boolean.TRUE; } return isSlaMissed(flow); }
public Object isSlaPassed() { final ExecutableFlow flow; try { flow = this.executorLoader.fetchExecutableFlow(this.execId); } catch (final ExecutorManagerException e) { logger.error("Can't get executable flow.", e); // something wrong, send out alerts return Boolean.TRUE; } return isSlaGood(flow); }
@Override public Object eval() { logger.info("Checking sla for execution " + this.execId); final ExecutableFlow flow; try { flow = this.executorLoader.fetchExecutableFlow(this.execId); } catch (final ExecutorManagerException e) { logger.error("Can't get executable flow.", e); e.printStackTrace(); // something wrong, send out alerts return Boolean.TRUE; } return isSlaMissed(flow); }
@Override public void doAction() throws Exception { logger.info("Alerting on sla failure."); final Map<String, Object> alert = this.slaOption.getInfo(); if (alert.containsKey(SlaOption.ALERT_TYPE)) { final String alertType = (String) alert.get(SlaOption.ALERT_TYPE); final Alerter alerter = this.alerters.get(alertType); if (alerter != null) { try { final ExecutableFlow flow = this.executorLoader.fetchExecutableFlow(this.execId); alerter.alertOnSla(this.slaOption, SlaOption.createSlaMessage(this.slaOption, flow)); } catch (final Exception e) { e.printStackTrace(); logger.error("Failed to alert by " + alertType); } } else { logger.error("Alerter type " + alertType + " doesn't exist. Failed to alert."); } } }
private ExecutableFlow fetchFlow(final ExecutableFlow flow) throws ExecutorManagerException { return this.loader.fetchExecutableFlow(flow.getExecutionId()); }
private void submitFlow(final ExecutableFlow flow, final ExecutionReference ref) throws Exception { when(this.loader.fetchUnfinishedFlows()).thenReturn(this.unfinishedFlows); when(this.loader.fetchExecutableFlow(flow.getExecutionId())).thenReturn(flow); this.controller.submitExecutableFlow(flow, this.user.getUserId()); this.unfinishedFlows.put(flow.getExecutionId(), new Pair<>(ref, flow)); }
/** * Test running flow is finalized when its executor is removed from DB. */ @Test public void checkExecutorHealthExecutorIdRemoved() throws Exception { this.activeFlows.put(EXECUTION_ID_11, new Pair<>( new ExecutionReference(EXECUTION_ID_11, null), this.flow1)); when(this.loader.fetchExecutableFlow(EXECUTION_ID_11)).thenReturn(this.flow1); this.executorHealthChecker.checkExecutorHealth(); verify(this.loader).updateExecutableFlow(this.flow1); assertThat(this.flow1.getStatus()).isEqualTo(Status.FAILED); }
dsFlow = flow; } else { dsFlow = executorLoader.fetchExecutableFlow(flow.getExecutionId());
/** * 1. Executor 1 throws an exception when trying to dispatch to it 2. ExecutorManager should try * next executor 3. Executor 2 accepts the dispatched execution */ @Test public void testDispatchException() throws Exception { testSetUpForRunningFlows(); this.manager.start(); final ExecutableFlow flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); doReturn(flow1).when(this.loader).fetchExecutableFlow(-1); mockFlowDoesNotExist(); when(this.apiGateway.callWithExecutable(any(), any(), eq(ConnectorParams.EXECUTE_ACTION))) .thenThrow(new ExecutorManagerException("Mocked dispatch exception")) .thenReturn(null); this.manager.submitExecutableFlow(flow1, this.user.getUserId()); waitFlowFinished(flow1); verify(this.apiGateway) .callWithExecutable(flow1, this.manager.fetchExecutor(1), ConnectorParams.EXECUTE_ACTION); verify(this.apiGateway) .callWithExecutable(flow1, this.manager.fetchExecutor(2), ConnectorParams.EXECUTE_ACTION); verify(this.loader, Mockito.times(1)).unassignExecutor(-1); }
/** * ExecutorManager should try to dispatch to all executors & when both fail it should remove the * execution from queue and finalize it. */ @Ignore @Test public void testDispatchFailed() throws Exception { testSetUpForRunningFlows(); this.manager.start(); final ExecutableFlow flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); flow1.getExecutionOptions().setFailureEmails(Arrays.asList("test@example.com")); when(this.loader.fetchExecutableFlow(-1)).thenReturn(flow1); when(this.apiGateway.callWithExecutable(any(), any(), eq(ConnectorParams.EXECUTE_ACTION))) .thenThrow(new ExecutorManagerException("Mocked dispatch exception")); this.manager.submitExecutableFlow(flow1, this.user.getUserId()); waitFlowFinished(flow1); verify(this.apiGateway) .callWithExecutable(flow1, this.manager.fetchExecutor(1), ConnectorParams.EXECUTE_ACTION); verify(this.apiGateway) .callWithExecutable(flow1, this.manager.fetchExecutor(2), ConnectorParams.EXECUTE_ACTION); verify(this.loader, Mockito.times(2)).unassignExecutor(-1); verify(this.mailAlerter).alertOnError(eq(flow1), eq("Failed to dispatch queued execution derived-member-data because reached " + "azkaban.maxDispatchingErrors (tried 2 executors)"), contains("Mocked dispatch exception")); }
/** * ExecutorManager should try to dispatch to all executors until it succeeds. */ @Test public void testDispatchMultipleRetries() throws Exception { this.props.put(Constants.ConfigurationKeys.MAX_DISPATCHING_ERRORS_PERMITTED, 4); testSetUpForRunningFlows(); this.manager.start(); final ExecutableFlow flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); flow1.getExecutionOptions().setFailureEmails(Arrays.asList("test@example.com")); when(this.loader.fetchExecutableFlow(-1)).thenReturn(flow1); // fail 2 first dispatch attempts, then succeed when(this.apiGateway.callWithExecutable(any(), any(), eq(ConnectorParams.EXECUTE_ACTION))) .thenThrow(new ExecutorManagerException("Mocked dispatch exception 1")) .thenThrow(new ExecutorManagerException("Mocked dispatch exception 2")) .thenReturn(null); // this is just to clean up the execution as FAILED after it has been submitted mockFlowDoesNotExist(); this.manager.submitExecutableFlow(flow1, this.user.getUserId()); waitFlowFinished(flow1); // it's random which executor is chosen each time, but both should have been tried at least once verify(this.apiGateway, Mockito.atLeast(1)) .callWithExecutable(flow1, this.manager.fetchExecutor(1), ConnectorParams.EXECUTE_ACTION); verify(this.apiGateway, Mockito.atLeast(1)) .callWithExecutable(flow1, this.manager.fetchExecutor(2), ConnectorParams.EXECUTE_ACTION); // verify that there was a 3rd (successful) dispatch call verify(this.apiGateway, Mockito.times(3)) .callWithExecutable(eq(flow1), any(), eq(ConnectorParams.EXECUTE_ACTION)); verify(this.loader, Mockito.times(2)).unassignExecutor(-1); }
@Test public void testNotFoundFlows() throws Exception { testSetUpForRunningFlows(); this.manager.start(); final ExecutableFlow flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); when(this.loader.fetchExecutableFlow(-1)).thenReturn(flow1); mockFlowDoesNotExist(); this.manager.submitExecutableFlow(flow1, this.user.getUserId()); final ExecutableFlow fetchedFlow = waitFlowFinished(flow1); Assert.assertEquals(fetchedFlow.getStatus(), Status.FAILED); }
} else { this.updaterStage.set("finalizing flow " + execId + " loading from db"); dsFlow = this.executorLoader.fetchExecutableFlow(execId);
@Test public void testKillQueuedFlow() throws Exception { final ExecutorManager manager = createMultiExecutorManagerInstance(); final ExecutableFlow flow1 = TestUtils.createTestExecutableFlow("exectest1", "exec1"); final User testUser = TestUtils.getTestUser(); manager.submitExecutableFlow(flow1, testUser.getUserId()); manager.cancelFlow(flow1, testUser.getUserId()); final ExecutableFlow fetchedFlow = this.loader.fetchExecutableFlow(flow1.getExecutionId()); Assert.assertEquals(fetchedFlow.getStatus(), Status.FAILED); Assert.assertFalse(manager.getRunningFlows().contains(flow1)); }
/** * Fetch ExecutableFlow from database {@inheritDoc} * * @see azkaban.executor.ExecutorManagerAdapter#getExecutableFlow(int) */ @Override public ExecutableFlow getExecutableFlow(final int execId) throws ExecutorManagerException { return this.executorLoader.fetchExecutableFlow(execId); }
public Object isSlaFailed() { final ExecutableFlow flow; try { flow = this.executorLoader.fetchExecutableFlow(this.execId); } catch (final ExecutorManagerException e) { logger.error("Can't get executable flow.", e); // something wrong, send out alerts return Boolean.TRUE; } return isSlaMissed(flow); }
public Object isSlaPassed() { final ExecutableFlow flow; try { flow = this.executorLoader.fetchExecutableFlow(this.execId); } catch (final ExecutorManagerException e) { logger.error("Can't get executable flow.", e); // something wrong, send out alerts return Boolean.TRUE; } return isSlaGood(flow); }
@Override public ExecutableFlow getExecutableFlow(int execId) throws ExecutorManagerException { Pair<ExecutionReference, ExecutableFlow> active = runningFlows.get(execId); if (active == null) { return executorLoader.fetchExecutableFlow(execId); } return active.getSecond(); }