AzureArchiveManager implements SegmentArchiveManager { @Override public boolean exists(String archiveName) { try { return getDirectory(archiveName).listBlobsSegmented(null, false, null, 1, null, null, null).getLength() > 0; } catch (IOException | StorageException | URISyntaxException e) { log.error("Can't check the existence of {}", archiveName, e); return false; } } AzureArchiveManager(CloudBlobDirectory cloudBlobDirectory, IOMonitor ioMonitor, FileStoreMonitor fileStoreMonitor); @Override List<String> listArchives(); @Override SegmentArchiveReader open(String archiveName); @Override SegmentArchiveReader forceOpen(String archiveName); @Override SegmentArchiveWriter create(String archiveName); @Override boolean delete(String archiveName); @Override boolean renameTo(String from, String to); @Override void copyFile(String from, String to); @Override boolean exists(String archiveName); @Override void recoverEntries(String archiveName, LinkedHashMap<UUID, byte[]> entries); @Override void backup(@NotNull String archiveName, @NotNull String backupArchiveName, @NotNull Set<UUID> recoveredEntries);  }
@Test public void testExists() throws IOException, URISyntaxException { SegmentArchiveManager manager = new AzurePersistence(container.getDirectoryReference("oak")).createArchiveManager(false, false, new IOMonitorAdapter(), new FileStoreMonitorAdapter(), new RemoteStoreMonitorAdapter()); SegmentArchiveWriter writer = manager.create("data00000a.tar"); List<UUID> uuids = new ArrayList<>(); for (int i = 0; i < 10; i++) { UUID u = UUID.randomUUID(); writer.writeSegment(u.getMostSignificantBits(), u.getLeastSignificantBits(), new byte[10], 0, 10, 0, 0, false); uuids.add(u); } writer.flush(); writer.close(); Assert.assertTrue(manager.exists("data00000a.tar")); Assert.assertFalse(manager.exists("data00001a.tar")); }