@Test void extractingURIFails() { String path = "not a real path"; housekeepingPath.setPath(path); assertThatExceptionOfType(BeekeeperException.class) .isThrownBy(() -> s3PathCleaner.cleanupPath(housekeepingPath)) .withMessage(format("'%s' is not an S3 path.", path)); }
@Override @TimedTaggable("s3-paths-deleted") public void cleanupPath(HousekeepingEntity housekeepingEntity) { S3SchemeURI s3SchemeURI = new S3SchemeURI(housekeepingEntity.getPath()); String key = s3SchemeURI.getKey(); String bucket = s3SchemeURI.getBucket(); S3BytesDeletedCalculator bytesDeletedCalculator = new S3BytesDeletedCalculator(s3Client); boolean isFile = s3Client.doesObjectExist(bucket, key); try { if (isFile) { deleteFile(bucket, key, bytesDeletedCalculator); } else { deleteFilesInDirectory(bucket, key, bytesDeletedCalculator); deleteSentinelFiles(s3SchemeURI, key, bucket, housekeepingEntity.getTableName()); } } finally { long bytesDeleted = bytesDeletedCalculator.getBytesDeleted(); if (bytesDeleted > 0) { bytesDeletedReporter.reportTaggable(bytesDeleted, housekeepingEntity, FileSystemType.S3); } } }
S3PathCleaner implements PathCleaner { @Override @TimedTaggable("s3-paths-deleted") public void cleanupPath(HousekeepingEntity housekeepingEntity) { S3SchemeURI s3SchemeURI = new S3SchemeURI(housekeepingEntity.getPath()); String key = s3SchemeURI.getKey(); String bucket = s3SchemeURI.getBucket(); S3BytesDeletedCalculator bytesDeletedCalculator = new S3BytesDeletedCalculator(s3Client); boolean isFile = s3Client.doesObjectExist(bucket, key); try { if (isFile) { deleteFile(bucket, key, bytesDeletedCalculator); } else { deleteFilesInDirectory(bucket, key, bytesDeletedCalculator); deleteSentinelFiles(s3SchemeURI, key, bucket, housekeepingEntity.getTableName()); } } finally { long bytesDeleted = bytesDeletedCalculator.getBytesDeleted(); if (bytesDeleted > 0) { bytesDeletedReporter.reportTaggable(bytesDeleted, housekeepingEntity, FileSystemType.S3); } } } }
S3PathCleaner implements PathCleaner { @Override @TimedTaggable("s3-paths-deleted") public void cleanupPath(HousekeepingEntity housekeepingEntity) { S3SchemeURI s3SchemeURI = new S3SchemeURI(housekeepingEntity.getPath()); String key = s3SchemeURI.getKey(); String bucket = s3SchemeURI.getBucket(); S3BytesDeletedCalculator bytesDeletedCalculator = new S3BytesDeletedCalculator(s3Client); boolean isFile = s3Client.doesObjectExist(bucket, key); try { if (isFile) { deleteFile(bucket, key, bytesDeletedCalculator); } else { deleteFilesInDirectory(bucket, key, bytesDeletedCalculator); deleteSentinelFiles(s3SchemeURI, key, bucket, housekeepingEntity.getTableName()); } } finally { long bytesDeleted = bytesDeletedCalculator.getBytesDeleted(); if (bytesDeleted > 0) { bytesDeletedReporter.reportTaggable(bytesDeleted, housekeepingEntity, FileSystemType.S3); } } } S3PathCleaner(S3Client s3Client, SentinelFilesCleaner sentinelFilesCleaner,
      BytesDeletedReporter bytesDeletedReporter); }
S3PathCleaner implements PathCleaner { @Override @TimedTaggable("s3-paths-deleted") public void cleanupPath(HousekeepingEntity housekeepingEntity) { S3SchemeURI s3SchemeURI = new S3SchemeURI(housekeepingEntity.getPath()); String key = s3SchemeURI.getKey(); String bucket = s3SchemeURI.getBucket(); S3BytesDeletedCalculator bytesDeletedCalculator = new S3BytesDeletedCalculator(s3Client); boolean isFile = s3Client.doesObjectExist(bucket, key); try { if (isFile) { deleteFile(bucket, key, bytesDeletedCalculator); } else { deleteFilesInDirectory(bucket, key, bytesDeletedCalculator); deleteSentinelFiles(s3SchemeURI, key, bucket, housekeepingEntity.getTableName()); } } finally { long bytesDeleted = bytesDeletedCalculator.getBytesDeleted(); if (bytesDeleted > 0) { bytesDeletedReporter.reportTaggable(bytesDeleted, housekeepingEntity, FileSystemType.S3); } } } S3PathCleaner(S3Client s3Client, SentinelFilesCleaner sentinelFilesCleaner,
      BytesDeletedReporter bytesDeletedReporter); @Override @TimedTaggable("s3-paths-deleted") void cleanupPath(HousekeepingEntity housekeepingEntity); }
S3PathCleaner implements PathCleaner { @Override @TimedTaggable("s3-paths-deleted") public void cleanupPath(HousekeepingEntity housekeepingEntity) { S3SchemeURI s3SchemeURI = new S3SchemeURI(housekeepingEntity.getPath()); String key = s3SchemeURI.getKey(); String bucket = s3SchemeURI.getBucket(); S3BytesDeletedCalculator bytesDeletedCalculator = new S3BytesDeletedCalculator(s3Client); boolean isFile = s3Client.doesObjectExist(bucket, key); try { if (isFile) { deleteFile(bucket, key, bytesDeletedCalculator); } else { deleteFilesInDirectory(bucket, key, bytesDeletedCalculator); deleteSentinelFiles(s3SchemeURI, key, bucket, housekeepingEntity.getTableName()); } } finally { long bytesDeleted = bytesDeletedCalculator.getBytesDeleted(); if (bytesDeleted > 0) { bytesDeletedReporter.reportTaggable(bytesDeleted, housekeepingEntity, FileSystemType.S3); } } } S3PathCleaner(S3Client s3Client, SentinelFilesCleaner sentinelFilesCleaner,
      BytesDeletedReporter bytesDeletedReporter); @Override @TimedTaggable("s3-paths-deleted") void cleanupPath(HousekeepingEntity housekeepingEntity);  }