public static BlobPath cleanPath() { return new BlobPath(); }
public BlobPath add(String path) { List<String> paths = new ArrayList<>(this.paths); paths.add(path); return new BlobPath(Collections.unmodifiableList(paths)); }
public static BlobPath cleanPath() { return new BlobPath(); }
public static BlobPath cleanPath() { return new BlobPath(); }
public static BlobPath cleanPath() { return new BlobPath(); }
public static BlobPath cleanPath() { return new BlobPath(); }
public BlobPath add(String path) { List<String> paths = new ArrayList<>(this.paths); paths.add(path); return new BlobPath(Collections.unmodifiableList(paths)); }
public BlobPath add(String path) { List<String> paths = new ArrayList<>(this.paths); paths.add(path); return new BlobPath(Collections.unmodifiableList(paths)); }
public BlobPath add(String path) { List<String> paths = new ArrayList<>(this.paths); paths.add(path); return new BlobPath(Collections.unmodifiableList(paths)); }
public BlobPath add(String path) { List<String> paths = new ArrayList<>(); paths.addAll(this.paths); paths.add(path); return new BlobPath(Collections.unmodifiableList(paths)); }
public void testMoveAndList() throws IOException { try(BlobStore store = newBlobStore()) { final BlobContainer container = store.blobContainer(new BlobPath()); assertThat(container.listBlobs().size(), equalTo(0)); int numberOfFooBlobs = randomIntBetween(0, 10);
public void testContainerCreationAndDeletion() throws IOException { try(BlobStore store = newBlobStore()) { final BlobContainer containerFoo = store.blobContainer(new BlobPath().add("foo")); final BlobContainer containerBar = store.blobContainer(new BlobPath().add("bar")); byte[] data1 = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16))); byte[] data2 = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16))); writeBlob(containerFoo, "test", new BytesArray(data1)); writeBlob(containerBar, "test", new BytesArray(data2)); assertArrayEquals(readBlobFully(containerFoo, "test", data1.length), data1); assertArrayEquals(readBlobFully(containerBar, "test", data2.length), data2); assertTrue(containerFoo.blobExists("test")); assertTrue(containerBar.blobExists("test")); store.delete(new BlobPath()); assertFalse(containerFoo.blobExists("test")); assertFalse(containerBar.blobExists("test")); } }
String basePath = repositorySettings.settings().get("base_path", null); if (Strings.hasLength(basePath)) { BlobPath path = new BlobPath(); for(String elem : Strings.splitStringToArray(basePath, '/')) { path = path.add(elem);
public void testVerifyOverwriteFails() throws IOException { try (BlobStore store = newBlobStore()) { final String blobName = "foobar"; final BlobContainer container = store.blobContainer(new BlobPath()); byte[] data = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16))); final BytesArray bytesArray = new BytesArray(data); writeBlob(container, blobName, bytesArray); // should not be able to overwrite existing blob expectThrows(IOException.class, () -> writeBlob(container, blobName, bytesArray)); container.deleteBlob(blobName); writeBlob(container, blobName, bytesArray); // after deleting the previous blob, we should be able to write to it again } }
public void testDeleteBlob() throws IOException { try (BlobStore store = newBlobStore()) { final String blobName = "foobar"; final BlobContainer container = store.blobContainer(new BlobPath()); expectThrows(IOException.class, () -> container.deleteBlob(blobName)); byte[] data = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16))); final BytesArray bytesArray = new BytesArray(data); writeBlob(container, blobName, bytesArray); container.deleteBlob(blobName); // should not raise // blob deleted, so should raise again expectThrows(IOException.class, () -> container.deleteBlob(blobName)); } }
public void testWriteRead() throws IOException { try(BlobStore store = newBlobStore()) { final BlobContainer container = store.blobContainer(new BlobPath()); byte[] data = randomBytes(randomIntBetween(10, scaledRandomIntBetween(1024, 1 << 16))); writeBlob(container, "foobar", new BytesArray(data)); try (InputStream stream = container.readBlob("foobar")) { BytesRefBuilder target = new BytesRefBuilder(); while (target.length() < data.length) { byte[] buffer = new byte[scaledRandomIntBetween(1, data.length - target.length())]; int offset = scaledRandomIntBetween(0, buffer.length - 1); int read = stream.read(buffer, offset, buffer.length - offset); target.append(new BytesRef(buffer, offset, read)); } assertEquals(data.length, target.length()); assertArrayEquals(data, Arrays.copyOfRange(target.bytes(), 0, target.length())); } } }