@Test void vacuumWithSpaceInPaths() throws IOException, TException { initialiseApp(); setPartitionedTable("partition 1_"); Path partition2InSnapshot1Dir = Files.createTempDirectory(snapshot1Dir, "partition 2_"); File file2 = File.createTempFile("000000_", null, partition2InSnapshot1Dir.toFile()); writeContentToFiles(file2.toPath(), file2.toPath(), file2.toPath()); Path partition3InSnapshot1Dir = Files.createTempDirectory(snapshot1Dir, "partition 3_"); File file3 = File.createTempFile("000000_", null, partition3InSnapshot1Dir.toFile()); writeContentToFiles(file3.toPath(), file3.toPath(), file3.toPath()); HousekeepingPath path = new HousekeepingPath.Builder().databaseName(databaseName) .tableName(tableName) .path("file:" + partition3InSnapshot1Dir.toString()) .housekeepingStatus(SCHEDULED) .creationTimestamp(LocalDateTime.now()) .cleanupDelay(Duration.parse("P3D")) .lifecycleType(UNREFERENCED.toString()) .build(); repository.save(path); application.run(args); verify(schedulerService, times(3)).scheduleForHousekeeping(housekeepingPath.capture()); List<HousekeepingPath> scheduledPaths = housekeepingPath.getAllValues(); String file1Path = "file:" + partition1InSnapshot0Dir.toString(); String file2Path = "file:" + partition2InSnapshot0Dir.toString(); String file3Path = "file:" + partition2InSnapshot1Dir.toString(); assertThat(scheduledPaths).hasSize(3); assertThat(scheduledPaths).extracting("path") .containsExactlyInAnyOrder(file1Path, file2Path, file3Path); assertThat(assertBytesLogged(21)).isTrue(); }
@Override public void run(ApplicationArguments args) { log.warn("Do not run this tool at the same time as replicating to the target table!"); if (isDryRun) { log.warn("Dry-run only!"); } try { metastore = clientSupplier.get(); housekeepingPaths = fetchHousekeepingPaths(beekeeperRepository); vacuumTable(databaseName, tableName); } catch (URISyntaxException | TException | IOException e) { throw new RuntimeException(e); } finally { if (metastore != null) { metastore.close(); } } }
BeekeeperVacuumToolApplication implements ApplicationRunner { @Override public void run(ApplicationArguments args) { log.warn("Do not run this tool at the same time as replicating to the target table!"); if (isDryRun) { log.warn("Dry-run only!"); } try { metastore = clientSupplier.get(); housekeepingPaths = fetchHousekeepingPaths(beekeeperRepository); vacuumTable(databaseName, tableName); } catch (URISyntaxException | TException | IOException e) { throw new RuntimeException(e); } finally { if (metastore != null) { metastore.close(); } } } }
BeekeeperVacuumToolApplication implements ApplicationRunner { @Override public void run(ApplicationArguments args) { log.warn("Do not run this tool at the same time as replicating to the target table!"); if (isDryRun) { log.warn("Dry-run only!"); } try { metastore = clientSupplier.get(); housekeepingPaths = fetchHousekeepingPaths(beekeeperRepository); vacuumTable(databaseName, tableName); } catch (URISyntaxException | TException | IOException e) { throw new RuntimeException(e); } finally { if (metastore != null) { metastore.close(); } } } @Autowired  BeekeeperVacuumToolApplication(
      Supplier<CloseableMetaStoreClient> clientSupplier,
      SchedulerService schedulerService,
      BeekeeperRepository beekeeperRepository,
      HiveConf conf,
      @Value("${database}") String databaseName,
      @Value("${table}") String tableName,
      @Value("${default-cleanup-delay:P3D}") String cleanupDelay,
      @Value("${dry-run:false}") boolean isDryRun,
      @Value("${partition-batch-size:1000}") short batchSize); }
BeekeeperVacuumToolApplication implements ApplicationRunner { @Override public void run(ApplicationArguments args) { log.warn("Do not run this tool at the same time as replicating to the target table!"); if (isDryRun) { log.warn("Dry-run only!"); } try { metastore = clientSupplier.get(); housekeepingPaths = fetchHousekeepingPaths(beekeeperRepository); vacuumTable(databaseName, tableName); } catch (URISyntaxException | TException | IOException e) { throw new RuntimeException(e); } finally { if (metastore != null) { metastore.close(); } } } @Autowired  BeekeeperVacuumToolApplication(
      Supplier<CloseableMetaStoreClient> clientSupplier,
      SchedulerService schedulerService,
      BeekeeperRepository beekeeperRepository,
      HiveConf conf,
      @Value("${database}") String databaseName,
      @Value("${table}") String tableName,
      @Value("${default-cleanup-delay:P3D}") String cleanupDelay,
      @Value("${dry-run:false}") boolean isDryRun,
      @Value("${partition-batch-size:1000}") short batchSize); @Override void run(ApplicationArguments args); }
BeekeeperVacuumToolApplication implements ApplicationRunner { @Override public void run(ApplicationArguments args) { log.warn("Do not run this tool at the same time as replicating to the target table!"); if (isDryRun) { log.warn("Dry-run only!"); } try { metastore = clientSupplier.get(); housekeepingPaths = fetchHousekeepingPaths(beekeeperRepository); vacuumTable(databaseName, tableName); } catch (URISyntaxException | TException | IOException e) { throw new RuntimeException(e); } finally { if (metastore != null) { metastore.close(); } } } @Autowired  BeekeeperVacuumToolApplication(
      Supplier<CloseableMetaStoreClient> clientSupplier,
      SchedulerService schedulerService,
      BeekeeperRepository beekeeperRepository,
      HiveConf conf,
      @Value("${database}") String databaseName,
      @Value("${table}") String tableName,
      @Value("${default-cleanup-delay:P3D}") String cleanupDelay,
      @Value("${dry-run:false}") boolean isDryRun,
      @Value("${partition-batch-size:1000}") short batchSize); @Override void run(ApplicationArguments args);  }