@Test void cantRun() { final int days = 5; final int negativeDays = -1 * days; final int pageSize = 10; Mockito.when(this.jobCleanupProperties.getRetention()).thenReturn(days).thenReturn(negativeDays); Mockito.when(this.jobCleanupProperties.getPageSize()).thenReturn(pageSize); Mockito .when( this.persistenceService.deleteJobsCreatedBefore( Mockito.any(Instant.class), Mockito.anySet(), Mockito.anyInt() ) ) .thenThrow(new RuntimeException("test")); Assertions.assertThatExceptionOfType(RuntimeException.class).isThrownBy(() -> this.task.run()); }
@Override public void run() { final long start = System.nanoTime(); final Instant runtime = Instant.now(); final Set<Tag> tags = Sets.newHashSet(); try { this.deleteJobs(); final Instant creationThreshold = runtime.minus(1L, ChronoUnit.HOURS); this.deleteClusters(creationThreshold); this.deactivateCommands(runtime); this.deleteCommands(creationThreshold); this.deleteApplications(creationThreshold); this.deleteFiles(creationThreshold); this.deleteTags(creationThreshold); MetricsUtils.addSuccessTags(tags); } catch (final Throwable t) { MetricsUtils.addFailureTagsWithException(tags, t); throw t; } finally { this.registry .timer(DATABASE_CLEANUP_DURATION_TIMER_NAME, tags) .record(System.nanoTime() - start, TimeUnit.NANOSECONDS); } }
DatabaseCleanupTask extends LeaderTask { @Override public void run() { final long start = System.nanoTime(); final Instant runtime = Instant.now(); final Set<Tag> tags = Sets.newHashSet(); try { this.deleteJobs(); final Instant creationThreshold = runtime.minus(1L, ChronoUnit.HOURS); this.deleteClusters(creationThreshold); this.deactivateCommands(runtime); this.deleteCommands(creationThreshold); this.deleteApplications(creationThreshold); this.deleteFiles(creationThreshold); this.deleteTags(creationThreshold); MetricsUtils.addSuccessTags(tags); } catch (final Throwable t) { MetricsUtils.addFailureTagsWithException(tags, t); throw t; } finally { this.registry .timer(DATABASE_CLEANUP_DURATION_TIMER_NAME, tags) .record(System.nanoTime() - start, TimeUnit.NANOSECONDS); } } }
DatabaseCleanupTask extends LeaderTask { @Override public void run() { final long start = System.nanoTime(); final Instant runtime = Instant.now(); final Set<Tag> tags = Sets.newHashSet(); try { this.deleteJobs(); final Instant creationThreshold = runtime.minus(1L, ChronoUnit.HOURS); this.deleteClusters(creationThreshold); this.deactivateCommands(runtime); this.deleteCommands(creationThreshold); this.deleteApplications(creationThreshold); this.deleteFiles(creationThreshold); this.deleteTags(creationThreshold); MetricsUtils.addSuccessTags(tags); } catch (final Throwable t) { MetricsUtils.addFailureTagsWithException(tags, t); throw t; } finally { this.registry .timer(DATABASE_CLEANUP_DURATION_TIMER_NAME, tags) .record(System.nanoTime() - start, TimeUnit.NANOSECONDS); } } DatabaseCleanupTask(
        @NotNull final DatabaseCleanupProperties cleanupProperties,
        @NotNull final Environment environment,
        @NotNull final DataServices dataServices,
        @NotNull final MeterRegistry registry
    ); }
DatabaseCleanupTask extends LeaderTask { @Override public void run() { final long start = System.nanoTime(); final Instant runtime = Instant.now(); final Set<Tag> tags = Sets.newHashSet(); try { this.deleteJobs(); final Instant creationThreshold = runtime.minus(1L, ChronoUnit.HOURS); this.deleteClusters(creationThreshold); this.deactivateCommands(runtime); this.deleteCommands(creationThreshold); this.deleteApplications(creationThreshold); this.deleteFiles(creationThreshold); this.deleteTags(creationThreshold); MetricsUtils.addSuccessTags(tags); } catch (final Throwable t) { MetricsUtils.addFailureTagsWithException(tags, t); throw t; } finally { this.registry .timer(DATABASE_CLEANUP_DURATION_TIMER_NAME, tags) .record(System.nanoTime() - start, TimeUnit.NANOSECONDS); } } DatabaseCleanupTask(
        @NotNull final DatabaseCleanupProperties cleanupProperties,
        @NotNull final Environment environment,
        @NotNull final DataServices dataServices,
        @NotNull final MeterRegistry registry
    ); @Override GenieTaskScheduleType getScheduleType(); @Override Trigger getTrigger(); @Override void run(); @Override void cleanup(); }
DatabaseCleanupTask extends LeaderTask { @Override public void run() { final long start = System.nanoTime(); final Instant runtime = Instant.now(); final Set<Tag> tags = Sets.newHashSet(); try { this.deleteJobs(); final Instant creationThreshold = runtime.minus(1L, ChronoUnit.HOURS); this.deleteClusters(creationThreshold); this.deactivateCommands(runtime); this.deleteCommands(creationThreshold); this.deleteApplications(creationThreshold); this.deleteFiles(creationThreshold); this.deleteTags(creationThreshold); MetricsUtils.addSuccessTags(tags); } catch (final Throwable t) { MetricsUtils.addFailureTagsWithException(tags, t); throw t; } finally { this.registry .timer(DATABASE_CLEANUP_DURATION_TIMER_NAME, tags) .record(System.nanoTime() - start, TimeUnit.NANOSECONDS); } } DatabaseCleanupTask(
        @NotNull final DatabaseCleanupProperties cleanupProperties,
        @NotNull final Environment environment,
        @NotNull final DataServices dataServices,
        @NotNull final MeterRegistry registry
    ); @Override GenieTaskScheduleType getScheduleType(); @Override Trigger getTrigger(); @Override void run(); @Override void cleanup();  }