@Test public void testDeleteAllJobs() throws Exception { RequestExecution requestExecution = createRequestExecution(true); Assert.assertNotNull(requestExecution); executionScheduleManager.scheduleBatch(requestExecution); String jobName1 = executionScheduleManager.getJobName(requestExecution .getId(), 10L); String jobName2 = executionScheduleManager.getJobName(requestExecution .getId(), 12L); JobDetail jobDetail1 = scheduler.getJobDetail(JobKey.jobKey(jobName1, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)); JobDetail jobDetail2 = scheduler.getJobDetail(JobKey.jobKey(jobName2, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)); Assert.assertNotNull(jobDetail1); Assert.assertNotNull(jobDetail2); Assert.assertTrue(!scheduler.getTriggersOfJob(JobKey.jobKey(jobName1, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)).isEmpty()); executionScheduleManager.deleteAllJobs(requestExecution); Assert.assertTrue(scheduler.getTriggersOfJob(JobKey.jobKey(jobName1, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)).isEmpty()); }
public void deleteAllJobs(RequestExecution requestExecution) throws AmbariException { if (!isSchedulerAvailable()) { throw new AmbariException("Scheduler unavailable."); } Batch batch = requestExecution.getBatch(); if (batch != null) { List<BatchRequest> batchRequests = batch.getBatchRequests(); if (batchRequests != null) { for (BatchRequest batchRequest : batchRequests) { String jobName = getJobName(requestExecution.getId(), batchRequest.getOrderId()); LOG.debug("Deleting Job, jobName = " + jobName); try { executionScheduler.deleteJob(JobKey.jobKey(jobName, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)); } catch (SchedulerException e) { LOG.warn("Unable to delete job, " + jobName, e); throw new AmbariException(e.getMessage()); } } } } }
ExecutionScheduleManager { public void deleteAllJobs(RequestExecution requestExecution) throws AmbariException { if (!isSchedulerAvailable()) { throw new AmbariException("Scheduler unavailable."); } Batch batch = requestExecution.getBatch(); if (batch != null) { List<BatchRequest> batchRequests = batch.getBatchRequests(); if (batchRequests != null) { for (BatchRequest batchRequest : batchRequests) { String jobName = getJobName(requestExecution.getId(), batchRequest.getOrderId()); LOG.debug("Deleting Job, jobName = " + jobName); try { executionScheduler.deleteJob(JobKey.jobKey(jobName, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)); } catch (SchedulerException e) { LOG.warn("Unable to delete job, " + jobName, e); throw new AmbariException(e.getMessage()); } } } } } }
ExecutionScheduleManager { public void deleteAllJobs(RequestExecution requestExecution) throws AmbariException { if (!isSchedulerAvailable()) { throw new AmbariException("Scheduler unavailable."); } Batch batch = requestExecution.getBatch(); if (batch != null) { List<BatchRequest> batchRequests = batch.getBatchRequests(); if (batchRequests != null) { for (BatchRequest batchRequest : batchRequests) { String jobName = getJobName(requestExecution.getId(), batchRequest.getOrderId()); LOG.debug("Deleting Job, jobName = " + jobName); try { executionScheduler.deleteJob(JobKey.jobKey(jobName, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)); } catch (SchedulerException e) { LOG.warn("Unable to delete job, " + jobName, e); throw new AmbariException(e.getMessage()); } } } } } @Inject  ExecutionScheduleManager(Configuration configuration,
                                  ExecutionScheduler executionScheduler,
                                  InternalTokenStorage tokenStorage,
                                  Clusters clusters,
                                  ActionDBAccessor actionDBAccessor,
                                  Gson gson); }
ExecutionScheduleManager { public void deleteAllJobs(RequestExecution requestExecution) throws AmbariException { if (!isSchedulerAvailable()) { throw new AmbariException("Scheduler unavailable."); } Batch batch = requestExecution.getBatch(); if (batch != null) { List<BatchRequest> batchRequests = batch.getBatchRequests(); if (batchRequests != null) { for (BatchRequest batchRequest : batchRequests) { String jobName = getJobName(requestExecution.getId(), batchRequest.getOrderId()); LOG.debug("Deleting Job, jobName = " + jobName); try { executionScheduler.deleteJob(JobKey.jobKey(jobName, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)); } catch (SchedulerException e) { LOG.warn("Unable to delete job, " + jobName, e); throw new AmbariException(e.getMessage()); } } } } } @Inject  ExecutionScheduleManager(Configuration configuration,
                                  ExecutionScheduler executionScheduler,
                                  InternalTokenStorage tokenStorage,
                                  Clusters clusters,
                                  ActionDBAccessor actionDBAccessor,
                                  Gson gson); void start(); void stop(); boolean isSchedulerAvailable(); void scheduleJob(Trigger trigger); boolean continueOnMisfire(JobExecutionContext jobExecutionContext); void scheduleBatch(RequestExecution requestExecution); void updateBatchSchedule(RequestExecution requestExecution); void validateSchedule(Schedule schedule); void deleteAllJobs(RequestExecution requestExecution); Long executeBatchRequest(long executionId,
                                  long batchId,
                                  String clusterName); BatchRequestResponse getBatchRequestResponse(Long requestId, String clusterName); void updateBatchRequest(long executionId, long batchId, String clusterName,
                                 BatchRequestResponse batchRequestResponse,
                                 boolean statusOnly); boolean hasToleranceThresholdExceeded(Long executionId,
      String clusterName, Map<String, Integer> taskCounts); void finalizeBatch(long executionId, String clusterName); }
ExecutionScheduleManager { public void deleteAllJobs(RequestExecution requestExecution) throws AmbariException { if (!isSchedulerAvailable()) { throw new AmbariException("Scheduler unavailable."); } Batch batch = requestExecution.getBatch(); if (batch != null) { List<BatchRequest> batchRequests = batch.getBatchRequests(); if (batchRequests != null) { for (BatchRequest batchRequest : batchRequests) { String jobName = getJobName(requestExecution.getId(), batchRequest.getOrderId()); LOG.debug("Deleting Job, jobName = " + jobName); try { executionScheduler.deleteJob(JobKey.jobKey(jobName, ExecutionJob.LINEAR_EXECUTION_JOB_GROUP)); } catch (SchedulerException e) { LOG.warn("Unable to delete job, " + jobName, e); throw new AmbariException(e.getMessage()); } } } } } @Inject  ExecutionScheduleManager(Configuration configuration,
                                  ExecutionScheduler executionScheduler,
                                  InternalTokenStorage tokenStorage,
                                  Clusters clusters,
                                  ActionDBAccessor actionDBAccessor,
                                  Gson gson); void start(); void stop(); boolean isSchedulerAvailable(); void scheduleJob(Trigger trigger); boolean continueOnMisfire(JobExecutionContext jobExecutionContext); void scheduleBatch(RequestExecution requestExecution); void updateBatchSchedule(RequestExecution requestExecution); void validateSchedule(Schedule schedule); void deleteAllJobs(RequestExecution requestExecution); Long executeBatchRequest(long executionId,
                                  long batchId,
                                  String clusterName); BatchRequestResponse getBatchRequestResponse(Long requestId, String clusterName); void updateBatchRequest(long executionId, long batchId, String clusterName,
                                 BatchRequestResponse batchRequestResponse,
                                 boolean statusOnly); boolean hasToleranceThresholdExceeded(Long executionId,
      String clusterName, Map<String, Integer> taskCounts); void finalizeBatch(long executionId, String clusterName); static final String USER_ID_HEADER; }