@Test void metadataCleanerException() { Mockito .doNothing() .doThrow(new BeekeeperException("Error")) .when(metadataCleaner) .dropTable( Mockito.any(HousekeepingMetadata.class), Mockito.any(HiveClient.class) ); List<HousekeepingMetadata> tables = List .of(createHousekeepingMetadata("table1", "s3: createHousekeepingMetadata("table2", "s3: tables.forEach(table -> metadataRepository.save(table)); pagingCleanupService.cleanUp(Instant.now()); verify(metadataCleaner, times(2)).dropTable( metadataCaptor.capture(), hiveClientCaptor.capture()); assertThat(metadataCaptor.getAllValues()) .extracting("tableName") .containsExactly(tables.get(0).getTableName(), tables.get(1).getTableName()); List<HousekeepingMetadata> result = metadataRepository.findAll(); assertThat(result.size()).isEqualTo(2); HousekeepingMetadata housekeepingMetadata1 = result.get(0); HousekeepingMetadata housekeepingMetadata2 = result.get(1); assertThat(housekeepingMetadata1.getTableName()).isEqualTo(tables.get(0).getTableName()); assertThat(housekeepingMetadata1.getPath()).isEqualTo(tables.get(0).getPath()); assertThat(housekeepingMetadata1.getHousekeepingStatus()).isEqualTo(DELETED); assertThat(housekeepingMetadata1.getCleanupAttempts()).isEqualTo(1); assertThat(housekeepingMetadata2.getTableName()).isEqualTo(tables.get(1).getTableName()); assertThat(housekeepingMetadata2.getPath()).isEqualTo(tables.get(1).getPath()); assertThat(housekeepingMetadata2.getHousekeepingStatus()).isEqualTo(FAILED); assertThat(housekeepingMetadata2.getCleanupAttempts()).isEqualTo(1); }
@Override @Timed("metadata-cleanup-job") public void cleanUp(Instant referenceTime) { try { metadataHandlers.forEach(handler -> pagingCleanup(handler, referenceTime)); } catch (Exception e) { throw new BeekeeperException(format("Metadata cleanup failed for instant %s", referenceTime.toString()), e); } }
PagingMetadataCleanupService implements CleanupService { @Override @Timed("metadata-cleanup-job") public void cleanUp(Instant referenceTime) { try { metadataHandlers.forEach(handler -> pagingCleanup(handler, referenceTime)); } catch (Exception e) { throw new BeekeeperException(format("Metadata cleanup failed for instant %s", referenceTime.toString()), e); } } }
PagingMetadataCleanupService implements CleanupService { @Override @Timed("metadata-cleanup-job") public void cleanUp(Instant referenceTime) { try { metadataHandlers.forEach(handler -> pagingCleanup(handler, referenceTime)); } catch (Exception e) { throw new BeekeeperException(format("Metadata cleanup failed for instant %s", referenceTime.toString()), e); } } PagingMetadataCleanupService(
      List<MetadataHandler> metadataHandlers,
      int pageSize,
      boolean dryRunEnabled); }
PagingMetadataCleanupService implements CleanupService { @Override @Timed("metadata-cleanup-job") public void cleanUp(Instant referenceTime) { try { metadataHandlers.forEach(handler -> pagingCleanup(handler, referenceTime)); } catch (Exception e) { throw new BeekeeperException(format("Metadata cleanup failed for instant %s", referenceTime.toString()), e); } } PagingMetadataCleanupService(
      List<MetadataHandler> metadataHandlers,
      int pageSize,
      boolean dryRunEnabled); @Override @Timed("metadata-cleanup-job") void cleanUp(Instant referenceTime); }
PagingMetadataCleanupService implements CleanupService { @Override @Timed("metadata-cleanup-job") public void cleanUp(Instant referenceTime) { try { metadataHandlers.forEach(handler -> pagingCleanup(handler, referenceTime)); } catch (Exception e) { throw new BeekeeperException(format("Metadata cleanup failed for instant %s", referenceTime.toString()), e); } } PagingMetadataCleanupService(
      List<MetadataHandler> metadataHandlers,
      int pageSize,
      boolean dryRunEnabled); @Override @Timed("metadata-cleanup-job") void cleanUp(Instant referenceTime);  }