/** * In rare cases may include some duplicates in cases where async staged uploads complete * during iteration. * * @return Iterator over all ids available * @throws DataStoreException */ @Override public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException { return Iterators.concat(Iterators.transform(cache.getStagingCache().getAllIdentifiers(), new Function<String, DataIdentifier>() { @Nullable @Override public DataIdentifier apply(@Nullable String id) { return new DataIdentifier(id); } }), backend.getAllIdentifiers()); }
/** * In rare cases may include some duplicates in cases where async staged uploads complete * during iteration. * * @return Iterator over all ids available * @throws DataStoreException */ @Override public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException { return Iterators.concat(Iterators.transform(cache.getStagingCache().getAllIdentifiers(), new Function<String, DataIdentifier>() { @Nullable @Override public DataIdentifier apply(@Nullable String id) { return new DataIdentifier(id); } }), backend.getAllIdentifiers()); }
/** * In rare cases may include some duplicates in cases where async staged uploads complete * during iteration. * * @return Iterator over all ids available * @throws DataStoreException */ @Override public Iterator<DataIdentifier> getAllIdentifiers() throws DataStoreException { return Iterators.concat(Iterators.transform(cache.getStagingCache().getAllIdentifiers(), new Function<String, DataIdentifier>() { @Nullable @Override public DataIdentifier apply(@Nullable String id) { return new DataIdentifier(id); } }), backend.getAllIdentifiers()); }
/** * GetAllIdentifiers without adding. * @throws Exception */ @Test public void testGetAllIdentifiersNoAdd() throws Exception { Iterator<String> ids = stagingCache.getAllIdentifiers(); assertFalse(ids.hasNext()); }
/** * GetAllIdentifiers after staging before upload. * @throws Exception */ @Test public void testGetAllIdentifiers() throws Exception { // add load List<ListenableFuture<Integer>> futures = put(folder); // Check getAllIdentifiers Iterator<String> idsIter = stagingCache.getAllIdentifiers(); assertEquals(ID_PREFIX + 0, Iterators.getOnlyElement(idsIter)); //start taskLatch.countDown(); callbackLatch.countDown(); assertFuture(futures, 0); assertCacheStats(stagingCache, 0, 0, 1, 1); // Should not return anything idsIter = stagingCache.getAllIdentifiers(); assertEquals(0, Iterators.size(idsIter)); }
@Test public void testZeroCache() throws IOException { stagingCache = UploadStagingCache.build(root, null, 1/*threads*/, 0 /* bytes */, uploader, null/*cache*/, statsProvider, executor, null, 3000, 6000); closer.register(stagingCache); File f = copyToFile(randomStream(0, 4 * 1024), folder.newFile()); Optional<SettableFuture<Integer>> future = stagingCache.put(ID_PREFIX + 0, f); assertFalse(future.isPresent()); assertNull(stagingCache.getIfPresent(ID_PREFIX + 0)); assertEquals(0, Iterators.size(stagingCache.getAllIdentifiers())); assertEquals(0, stagingCache.getStats().getMaxTotalWeight()); }