@Test public void typicalHandleAlterPartitionEvent() { setupClockAndExtractor(alterPartitionEvent); setupListenerEvent(alterPartitionEvent, ALTER_PARTITION); when(alterPartitionEvent.getOldPartitionLocation()).thenReturn(PATH); List<HousekeepingEntity> housekeepingEntities = generator.generate(alterPartitionEvent, CLIENT_ID); assertThat(housekeepingEntities.size()).isEqualTo(1); assertUnreferencedHousekeepingPathEntity(housekeepingEntities.get(0)); }
@Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterPartitionEvent) listenerEvent).getOldPartitionLocation())); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterTableEvent) listenerEvent).getOldTableLocation())); break; case DROP_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropTableEvent) listenerEvent).getTableLocation())); break; case DROP_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropPartitionEvent) listenerEvent).getPartitionLocation())); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; }
UnreferencedHousekeepingPathGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterPartitionEvent) listenerEvent).getOldPartitionLocation())); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterTableEvent) listenerEvent).getOldTableLocation())); break; case DROP_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropTableEvent) listenerEvent).getTableLocation())); break; case DROP_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropPartitionEvent) listenerEvent).getPartitionLocation())); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } }
UnreferencedHousekeepingPathGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterPartitionEvent) listenerEvent).getOldPartitionLocation())); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterTableEvent) listenerEvent).getOldTableLocation())); break; case DROP_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropTableEvent) listenerEvent).getTableLocation())); break; case DROP_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropPartitionEvent) listenerEvent).getPartitionLocation())); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } UnreferencedHousekeepingPathGenerator(String cleanupDelay); @VisibleForTesting  UnreferencedHousekeepingPathGenerator(CleanupDelayExtractor cleanupDelayExtractor, Clock clock); }
UnreferencedHousekeepingPathGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterPartitionEvent) listenerEvent).getOldPartitionLocation())); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterTableEvent) listenerEvent).getOldTableLocation())); break; case DROP_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropTableEvent) listenerEvent).getTableLocation())); break; case DROP_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropPartitionEvent) listenerEvent).getPartitionLocation())); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } UnreferencedHousekeepingPathGenerator(String cleanupDelay); @VisibleForTesting  UnreferencedHousekeepingPathGenerator(CleanupDelayExtractor cleanupDelayExtractor, Clock clock); @Override List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId); @Override LifecycleEventType getLifecycleEventType(); HousekeepingEntity generateHousekeepingEntity(ListenerEvent listenerEvent, String clientId,
      String cleanupPath); }
UnreferencedHousekeepingPathGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterPartitionEvent) listenerEvent).getOldPartitionLocation())); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((AlterTableEvent) listenerEvent).getOldTableLocation())); break; case DROP_TABLE: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropTableEvent) listenerEvent).getTableLocation())); break; case DROP_PARTITION: housekeepingEntities.add(generateHousekeepingEntity(listenerEvent, clientId, ((DropPartitionEvent) listenerEvent).getPartitionLocation())); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } UnreferencedHousekeepingPathGenerator(String cleanupDelay); @VisibleForTesting  UnreferencedHousekeepingPathGenerator(CleanupDelayExtractor cleanupDelayExtractor, Clock clock); @Override List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId); @Override LifecycleEventType getLifecycleEventType(); HousekeepingEntity generateHousekeepingEntity(ListenerEvent listenerEvent, String clientId,
      String cleanupPath); static final String UNREFERENCED_DATA_RETENTION_PERIOD_PROPERTY_KEY; }