@Test public void typicalHandleCreateTableEvent() { setupClockAndExtractor(createTableEvent); setupListenerEvent(createTableEvent, CREATE_TABLE); when(createTableEvent.getTableLocation()).thenReturn(PATH); List<HousekeepingEntity> housekeepingEntities = generator.generate(createTableEvent, CLIENT_ID); assertThat(housekeepingEntities.size()).isEqualTo(1); assertExpiredHousekeepingMetadataEntity(housekeepingEntities.get(0), null); }
@Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case CREATE_TABLE: housekeepingEntities.add(generateHousekeepingEntity((CreateTableEvent) listenerEvent, clientId)); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity((AlterTableEvent) listenerEvent, clientId)); break; case ADD_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AddPartitionEvent) listenerEvent, clientId)); break; case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AlterPartitionEvent) listenerEvent, clientId)); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; }
ExpiredHousekeepingMetadataGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case CREATE_TABLE: housekeepingEntities.add(generateHousekeepingEntity((CreateTableEvent) listenerEvent, clientId)); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity((AlterTableEvent) listenerEvent, clientId)); break; case ADD_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AddPartitionEvent) listenerEvent, clientId)); break; case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AlterPartitionEvent) listenerEvent, clientId)); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } }
ExpiredHousekeepingMetadataGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case CREATE_TABLE: housekeepingEntities.add(generateHousekeepingEntity((CreateTableEvent) listenerEvent, clientId)); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity((AlterTableEvent) listenerEvent, clientId)); break; case ADD_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AddPartitionEvent) listenerEvent, clientId)); break; case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AlterPartitionEvent) listenerEvent, clientId)); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } ExpiredHousekeepingMetadataGenerator(String cleanupDelay); @VisibleForTesting  ExpiredHousekeepingMetadataGenerator(CleanupDelayExtractor cleanupDelayExtractor, Clock clock); }
ExpiredHousekeepingMetadataGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case CREATE_TABLE: housekeepingEntities.add(generateHousekeepingEntity((CreateTableEvent) listenerEvent, clientId)); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity((AlterTableEvent) listenerEvent, clientId)); break; case ADD_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AddPartitionEvent) listenerEvent, clientId)); break; case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AlterPartitionEvent) listenerEvent, clientId)); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } ExpiredHousekeepingMetadataGenerator(String cleanupDelay); @VisibleForTesting  ExpiredHousekeepingMetadataGenerator(CleanupDelayExtractor cleanupDelayExtractor, Clock clock); @Override List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId); @Override LifecycleEventType getLifecycleEventType(); }
ExpiredHousekeepingMetadataGenerator implements HousekeepingEntityGenerator { @Override public List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId) { List<HousekeepingEntity> housekeepingEntities = new ArrayList<>(); switch (listenerEvent.getEventType()) { case CREATE_TABLE: housekeepingEntities.add(generateHousekeepingEntity((CreateTableEvent) listenerEvent, clientId)); break; case ALTER_TABLE: housekeepingEntities.add(generateHousekeepingEntity((AlterTableEvent) listenerEvent, clientId)); break; case ADD_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AddPartitionEvent) listenerEvent, clientId)); break; case ALTER_PARTITION: housekeepingEntities.add(generateHousekeepingEntity((AlterPartitionEvent) listenerEvent, clientId)); break; default: throw new BeekeeperException(format("No handler case for %s event type", listenerEvent.getEventType())); } return housekeepingEntities; } ExpiredHousekeepingMetadataGenerator(String cleanupDelay); @VisibleForTesting  ExpiredHousekeepingMetadataGenerator(CleanupDelayExtractor cleanupDelayExtractor, Clock clock); @Override List<HousekeepingEntity> generate(ListenerEvent listenerEvent, String clientId); @Override LifecycleEventType getLifecycleEventType(); static final String EXPIRED_DATA_RETENTION_PERIOD_PROPERTY_KEY; }