@Test public void typicalUpdatePartitionedTableWithShorterCleanupDelay() { HousekeepingMetadata existingTable = spy(createHousekeepingMetadataTable()); HousekeepingMetadata metadata = createHousekeepingMetadataTable(); metadata.setCleanupDelay(Duration.parse("PT3H")); when(housekeepingMetadataRepository.findRecordForCleanupByDbTableAndPartitionName(DATABASE_NAME, TABLE_NAME, null)).thenReturn(Optional.of(existingTable)); when(housekeepingMetadataRepository.findMaximumCleanupTimestampForDbAndTable(DATABASE_NAME, TABLE_NAME)).thenReturn( CREATION_TIMESTAMP.plus(Duration.parse("P30D"))); when(housekeepingMetadataRepository.countRecordsForGivenDatabaseAndTableWherePartitionIsNotNull(DATABASE_NAME, TABLE_NAME)).thenReturn(1L); expiredHousekeepingMetadataSchedulerService.scheduleForHousekeeping(metadata); verify(existingTable).setPath(metadata.getPath()); verify(existingTable).setHousekeepingStatus(metadata.getHousekeepingStatus()); verify(existingTable).setCleanupDelay(metadata.getCleanupDelay()); verify(existingTable).setClientId(metadata.getClientId()); verify(existingTable).getCleanupTimestamp(); verify(existingTable, times(2)).getDatabaseName(); verify(existingTable, times(2)).getTableName(); verify(existingTable).setCleanupTimestamp(CREATION_TIMESTAMP.plus(Duration.parse("P30D"))); verifyNoMoreInteractions(existingTable); verify(housekeepingMetadataRepository).save(existingTable); }
@Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } }
ExpiredHousekeepingMetadataSchedulerService implements SchedulerService { @Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } } }
ExpiredHousekeepingMetadataSchedulerService implements SchedulerService { @Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } } @Autowired  ExpiredHousekeepingMetadataSchedulerService(HousekeepingMetadataRepository housekeepingMetadataRepository); }
ExpiredHousekeepingMetadataSchedulerService implements SchedulerService { @Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } } @Autowired  ExpiredHousekeepingMetadataSchedulerService(HousekeepingMetadataRepository housekeepingMetadataRepository); @Override LifecycleEventType getLifecycleEventType(); @Override @TimedTaggable("metadata-scheduled") void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity); }
ExpiredHousekeepingMetadataSchedulerService implements SchedulerService { @Override @TimedTaggable("metadata-scheduled") public void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity) { HousekeepingMetadata housekeepingMetadata = createOrUpdateHousekeepingMetadata( (HousekeepingMetadata) housekeepingEntity); try { housekeepingMetadataRepository.save(housekeepingMetadata); log.info(format("Successfully scheduled %s", housekeepingMetadata)); } catch (Exception e) { throw new BeekeeperException(format("Unable to schedule %s", housekeepingMetadata), e); } } @Autowired  ExpiredHousekeepingMetadataSchedulerService(HousekeepingMetadataRepository housekeepingMetadataRepository); @Override LifecycleEventType getLifecycleEventType(); @Override @TimedTaggable("metadata-scheduled") void scheduleForHousekeeping(HousekeepingEntity housekeepingEntity);  }