Refine search
@Override public String getDir() { return delegate.getDir(); }
String containerName) throws IOException, S3Exception { String blobStoreType = getBlobStoreType(blobStore); ListContainerOptions options = new ListContainerOptions(); String encodingType = request.getParameter("encoding-type"); String delimiter = request.getParameter("delimiter"); if (delimiter != null) { options.delimiter(delimiter); } else { options.recursive(); options.prefix(prefix); options.afterMarker(marker); options.maxResults(maxKeys); PageSet<? extends StorageMetadata> set = blobStore.list(containerName, options); String nextMarker = set.getNextMarker(); if (nextMarker != null) { writeSimpleElement(xml, "IsTruncated", "true"); switch (metadata.getType()) { case FOLDER:
@Override public String toString() { return "[dir=" + dir + ", recursive=" + recursive + ", detailed=" + detailed + ", prefix=" + prefix + ", marker=" + getMarker() + ", delimiter=" + delimiter + ", maxResults=" + getMaxResults() + "]"; }
blobStore.list(bucketName, new ListContainerOptions().recursive()); logger.trace(" Found {} files in bucket {}", pageSets.size(), bucketName);
public synchronized boolean hasNewFiles() { // see if there are any files since lastMarker. BlobStoreContext ctx = ContextBuilder.newBuilder(provider) .credentials(user, key) .overrides(new Properties() {{ setProperty(LocationConstants.PROPERTY_ZONE, zone); }}) .buildView(BlobStoreContext.class); BlobStore store = ctx.getBlobStore(); ListContainerOptions options = new ListContainerOptions().maxResults(batchSize).afterMarker(lastMarker); PageSet<? extends StorageMetadata> pages = store.list(container, options); log.debug("Saw {} new files since {}", pages.size() == batchSize ? "many" : Integer.toString(pages.size()), lastMarker); boolean emptiness = getBlobsWithinRange(pages).isEmpty(); if(emptiness) { log.warn("No file found within range {}", new Range(START_TIME, STOP_TIME)); } else { log.debug("New files found within range {}", new Range(START_TIME, STOP_TIME)); } return !emptiness; }
@Test public void testMarker() { ListContainerOptions options = new ListContainerOptions(); options.afterMarker("test"); assertEquals(options.getMarker(), "test"); }
@Test public void testPath() { ListContainerOptions options = new ListContainerOptions(); options.inDirectory("test"); assertEquals(options.getDir(), "test"); }
@Test public void testMaxResults() { ListContainerOptions options = new ListContainerOptions(); options.maxResults(1000); assertEquals(options.getMaxResults(), Integer.valueOf(1000)); }
@Test public void testList_RootNonRecursive() throws IOException { blobStore.createContainerInLocation(null, CONTAINER_NAME); // Testing list for an empty container checkForContainerContent(CONTAINER_NAME, null); TestUtils.createBlobsInContainer(CONTAINER_NAME, "a"); ListContainerOptions options = ListContainerOptions.Builder .withDetails() .inDirectory(""); PageSet<? extends StorageMetadata> res = blobStore.list(CONTAINER_NAME, options); assertTrue(res.size() == 1); assertEquals(res.iterator().next().getName(), "a"); }
@Test public void testTwoOptions() { ListContainerOptions options = new ListContainerOptions(); options.inDirectory("test").maxResults(1); assertEquals(options.getDir(), "test"); assertEquals(options.getMaxResults(), Integer.valueOf(1)); }
@Test public void testPathStatic() { ListContainerOptions options = inDirectory("test"); assertEquals(options.getDir(), "test"); }
@Test public void testMarkerStatic() { ListContainerOptions options = afterMarker("test"); assertEquals(options.getMarker(), "test"); }
@Test public void testMaxResultsStatic() { ListContainerOptions options = maxResults(1000); assertEquals(options.getMaxResults(), Integer.valueOf(1000)); }
@Test public void testRecursive() { ListContainerOptions options = new ListContainerOptions(); options.recursive(); assertTrue(options.isRecursive()); }
@Test public void testRecursiveStatic() { ListContainerOptions options = recursive(); assertTrue(options.isRecursive()); }
@Test(groups = { "integration", "live" }) public void testListContainerPrefix() throws InterruptedException { String containerName = getContainerName(); try { String prefix = "containerprefix"; addTenObjectsUnderPrefix(containerName, prefix); add15UnderRoot(containerName); awaitConsistency(); PageSet<? extends StorageMetadata> container = view.getBlobStore().list( containerName, new ListContainerOptions().prefix(prefix + "/").delimiter("/")); assert container.getNextMarker() == null; assertEquals(container.size(), 10); } finally { returnContainer(containerName); } }
public void testLargerThanOnePageNoOptions() { blobstore.createContainerInLocation(null, "goodies"); for (int i = 0; i < 1001; i++) { blobstore.putBlob("goodies", blobstore.blobBuilder(i + "").payload(i + "").build()); } Iterable<? extends StorageMetadata> listing = concatter.execute("goodies", new ListContainerOptions()); assertEquals(Iterables.size(listing), 1001); }
/** Test that listing with a marker prefix matches the first key with that prefix. */ @Test public void testListMarkerPrefix() throws Exception { BlobStore blobStore = view.getBlobStore(); final String container = getContainerName(); try { blobStore.createContainerInLocation(null, container); blobStore.putBlob(container, blobStore.blobBuilder("a/a").payload("").build()); blobStore.putBlob(container, blobStore.blobBuilder("b/b").payload("").build()); ListContainerOptions options = new ListContainerOptions().afterMarker("b/").recursive(); PageSet<? extends StorageMetadata> res = blobStore.list(container, options); assertThat(res).hasSize(1); assertThat(res.iterator().next().getName()).isEqualTo("b/b"); } finally { returnContainer(container); } }
public void testListMarkers() { String containerName = "testListMarkers"; blobStore.createContainerInLocation(null, containerName); blobStore.putBlob(containerName, blobStore.blobBuilder("abc").payload("").build()); blobStore.putBlob(containerName, blobStore.blobBuilder("foo/bar").payload("").build()); blobStore.putBlob(containerName, blobStore.blobBuilder("foo/baz").payload("").build()); blobStore.putBlob(containerName, blobStore.blobBuilder("qux").payload("").build()); PageSet<? extends StorageMetadata> results = blobStore.list( containerName, ListContainerOptions.Builder.maxResults(1)); assertThat(results.getNextMarker()).isEqualTo("abc"); results = blobStore.list(containerName, ListContainerOptions.Builder.maxResults(1).afterMarker(results.getNextMarker())); assertThat(results.getNextMarker()).isEqualTo("foo/"); results = blobStore.list(containerName, ListContainerOptions.Builder.maxResults(1).afterMarker(results.getNextMarker())); assertThat(results.getNextMarker()).isEqualTo(null); }
private Set<String> listAllBlobs() { Set<String> blobNames = new HashSet<String>(); ListContainerOptions options = new ListContainerOptions(); while (true) { PageSet<? extends StorageMetadata> set = blobStoreRead.list( containerName, options); for (StorageMetadata sm : set) { blobNames.add(sm.getName()); } String marker = set.getNextMarker(); if (marker == null) { break; } options = options.afterMarker(marker); } return blobNames; }