/** * Checks obj in the blob container */ public boolean exists(BlobContainer blobContainer, String name) throws IOException { return blobContainer.blobExists(blobName(name)); }
/** * Checks obj in the blob container */ public boolean exists(BlobContainer blobContainer, String name) throws IOException { return blobContainer.blobExists(blobName(name)); }
/** * Checks obj in the blob container */ public boolean exists(BlobContainer blobContainer, String name) throws IOException { return blobContainer.blobExists(blobName(name)); }
/** * Checks obj in the blob container */ public boolean exists(BlobContainer blobContainer, String name) throws IOException { return blobContainer.blobExists(blobName(name)); }
/** * Checks obj in the blob container */ public boolean exists(BlobContainer blobContainer, String name) throws IOException { return blobContainer.blobExists(blobName(name)); }
@Override public void verify(String seed, DiscoveryNode localNode) { assertSnapshotOrGenericThread(); if (isReadOnly()) { try { latestIndexBlobId(); } catch (IOException e) { throw new RepositoryVerificationException(metadata.name(), "path " + basePath() + " is not accessible on node " + localNode, e); } } else { BlobContainer testBlobContainer = blobStore().blobContainer(basePath().add(testBlobPrefix(seed))); if (testBlobContainer.blobExists("master.dat")) { try { BytesArray bytes = new BytesArray(seed); try (InputStream stream = bytes.streamInput()) { testBlobContainer.writeBlob("data-" + localNode.getId() + ".dat", stream, bytes.length(), true); } } catch (IOException exp) { throw new RepositoryVerificationException(metadata.name(), "store location [" + blobStore() + "] is not accessible on the node [" + localNode + "]", exp); } } else { throw new RepositoryVerificationException(metadata.name(), "a file written by master to the store [" + blobStore() + "] cannot be accessed on the node [" + localNode + "]. " + "This might indicate that the store [" + blobStore() + "] is not shared between this node and the master node or " + "that permissions on the store don't allow reading files written by the master node"); } } }
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")); } }
for (IndexId indexId : repositoryData.getIndices().values()) { if (indexId.getName().equals("test-idx-3")) { assertFalse(indicesBlobContainer.blobExists(indexId.getId())); // deleted index
/** * Writes snapshot index file * <p> * This file can be used by read-only repositories that are unable to list files in the repository * * @param snapshots list of snapshot ids * @throws IOException I/O errors */ protected void writeSnapshotList(List<SnapshotId> snapshots) throws IOException { final BytesReference bRef; try(BytesStreamOutput bStream = new BytesStreamOutput()) { try(StreamOutput stream = new OutputStreamStreamOutput(bStream)) { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream); builder.startObject(); builder.startArray("snapshots"); for (SnapshotId snapshot : snapshots) { builder.value(snapshot.getSnapshot()); } builder.endArray(); builder.endObject(); builder.close(); } bRef = bStream.bytes(); } if (snapshotsBlobContainer.blobExists(SNAPSHOTS_FILE)) { snapshotsBlobContainer.deleteBlob(SNAPSHOTS_FILE); } snapshotsBlobContainer.writeBlob(SNAPSHOTS_FILE, bRef); }
if (snapshotsBlobContainer.blobExists(oldSnapshotIndexFile)) { snapshotsBlobContainer.deleteBlob(oldSnapshotIndexFile); genBytes = bStream.bytes(); if (snapshotsBlobContainer.blobExists(INDEX_LATEST_BLOB)) { snapshotsBlobContainer.deleteBlob(INDEX_LATEST_BLOB);
@Override public void verify(String seed) { BlobContainer testBlobContainer = blobStore.blobContainer(basePath.add(testBlobPrefix(seed))); DiscoveryNode localNode = clusterService.localNode(); if (testBlobContainer.blobExists("master.dat")) { try { testBlobContainer.writeBlob("data-" + localNode.getId() + ".dat", new BytesArray(seed)); } catch (IOException exp) { throw new RepositoryVerificationException(repositoryName, "store location [" + blobStore + "] is not accessible on the node [" + localNode + "]", exp); } } else { throw new RepositoryVerificationException(repositoryName, "a file written by master to the store [" + blobStore + "] cannot be accessed on the node [" + localNode + "]. " + "This might indicate that the store [" + blobStore + "] is not shared between this node and the master node or " + "that permissions on the store don't allow reading files written by the master node"); } }
/** * Writes the incompatible snapshot ids list to the `incompatible-snapshots` blob in the repository. * * Package private for testing. */ void writeIncompatibleSnapshots(RepositoryData repositoryData) throws IOException { assert isReadOnly() == false; // can not write to a read only repository final BytesReference bytes; try (BytesStreamOutput bStream = new BytesStreamOutput()) { try (StreamOutput stream = new OutputStreamStreamOutput(bStream)) { XContentBuilder builder = XContentFactory.contentBuilder(XContentType.JSON, stream); repositoryData.incompatibleSnapshotsToXContent(builder, ToXContent.EMPTY_PARAMS); builder.close(); } bytes = bStream.bytes(); } if (snapshotsBlobContainer.blobExists(INCOMPATIBLE_SNAPSHOTS_BLOB)) { snapshotsBlobContainer.deleteBlob(INCOMPATIBLE_SNAPSHOTS_BLOB); } // write the incompatible snapshots blob writeAtomic(INCOMPATIBLE_SNAPSHOTS_BLOB, bytes); }
@Override public void verify(String seed, DiscoveryNode localNode) { BlobContainer testBlobContainer = blobStore().blobContainer(basePath().add(testBlobPrefix(seed))); if (testBlobContainer.blobExists("master.dat")) { try { BytesArray bytes = new BytesArray(seed); try (InputStream stream = bytes.streamInput()) { testBlobContainer.writeBlob("data-" + localNode.getId() + ".dat", stream, bytes.length()); } } catch (IOException exp) { throw new RepositoryVerificationException(metadata.name(), "store location [" + blobStore() + "] is not accessible on the node [" + localNode + "]", exp); } } else { throw new RepositoryVerificationException(metadata.name(), "a file written by master to the store [" + blobStore() + "] cannot be accessed on the node [" + localNode + "]. " + "This might indicate that the store [" + blobStore() + "] is not shared between this node and the master node or " + "that permissions on the store don't allow reading files written by the master node"); } }
@Override public void verify(String seed, DiscoveryNode localNode) { assertSnapshotOrGenericThread(); BlobContainer testBlobContainer = blobStore().blobContainer(basePath().add(testBlobPrefix(seed))); if (testBlobContainer.blobExists("master.dat")) { try { BytesArray bytes = new BytesArray(seed); try (InputStream stream = bytes.streamInput()) { testBlobContainer.writeBlob("data-" + localNode.getId() + ".dat", stream, bytes.length(), true); } } catch (IOException exp) { throw new RepositoryVerificationException(metadata.name(), "store location [" + blobStore() + "] is not accessible on the node [" + localNode + "]", exp); } } else { throw new RepositoryVerificationException(metadata.name(), "a file written by master to the store [" + blobStore() + "] cannot be accessed on the node [" + localNode + "]. " + "This might indicate that the store [" + blobStore() + "] is not shared between this node and the master node or " + "that permissions on the store don't allow reading files written by the master node"); } }
@Override public void verify(String seed, DiscoveryNode localNode) { assertSnapshotOrGenericThread(); BlobContainer testBlobContainer = blobStore().blobContainer(basePath().add(testBlobPrefix(seed))); if (testBlobContainer.blobExists("master.dat")) { try { BytesArray bytes = new BytesArray(seed); try (InputStream stream = bytes.streamInput()) { testBlobContainer.writeBlob("data-" + localNode.getId() + ".dat", stream, bytes.length(), true); } } catch (IOException exp) { throw new RepositoryVerificationException(metadata.name(), "store location [" + blobStore() + "] is not accessible on the node [" + localNode + "]", exp); } } else { throw new RepositoryVerificationException(metadata.name(), "a file written by master to the store [" + blobStore() + "] cannot be accessed on the node [" + localNode + "]. " + "This might indicate that the store [" + blobStore() + "] is not shared between this node and the master node or " + "that permissions on the store don't allow reading files written by the master node"); } }