summaryrefslogtreecommitdiff
path: root/plugins/repository-azure
diff options
context:
space:
mode:
authorAli Beyad <ali@elastic.co>2016-07-01 17:26:16 -0400
committerAli Beyad <ali@elastic.co>2016-07-01 17:52:57 -0400
commit05998224d8ecc11bef0b5a2432044e6a54585fa3 (patch)
treee4676db5b165f0c11940eef1c2b9811a77363262 /plugins/repository-azure
parent62397c0c3d662932f0069e0d56f258f0754cc8b8 (diff)
Adding repository index generational files
Before, a repository would maintain an index file (named 'index') per repository, that contained the current snapshots in the repository. This file was not atomically written, so repositories had to depend on listing the blobs in the repository to determine what the current snapshots are, and only rely on the index file if the repository does not support the listBlobs operation. This could cause an incorrect view of the current snapshots in the repository if any prior snapshot delete operations failed to delete snapshot metadata files. This commit introduces the atomic writing of the index file, and because atomic writes are not guaranteed if the file already exists, we write to a generational index file (index-N, where N is the current generation). We also maintain an index-latest file that contains the current generation, for those repositories that cannot list blobs. Closes #19002 Relates #18156
Diffstat (limited to 'plugins/repository-azure')
-rw-r--r--plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java3
-rw-r--r--plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java3
-rw-r--r--plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceMock.java7
3 files changed, 10 insertions, 3 deletions
diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java
index 2809b8588f..510b6d20f0 100644
--- a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java
+++ b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/blobstore/AzureBlobStore.java
@@ -34,6 +34,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.repositories.RepositoryName;
import org.elasticsearch.repositories.RepositorySettings;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
@@ -127,7 +128,7 @@ public class AzureBlobStore extends AbstractComponent implements BlobStore {
this.client.deleteBlob(this.accountName, this.locMode, container, blob);
}
- public InputStream getInputStream(String container, String blob) throws URISyntaxException, StorageException
+ public InputStream getInputStream(String container, String blob) throws URISyntaxException, StorageException, IOException
{
return this.client.getInputStream(this.accountName, this.locMode, container, blob);
}
diff --git a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java
index 13db36aeb5..137ff20efb 100644
--- a/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java
+++ b/plugins/repository-azure/src/main/java/org/elasticsearch/cloud/azure/storage/AzureStorageService.java
@@ -29,6 +29,7 @@ import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.common.unit.ByteSizeValue;
import org.elasticsearch.common.unit.TimeValue;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
@@ -75,7 +76,7 @@ public interface AzureStorageService {
void deleteBlob(String account, LocationMode mode, String container, String blob) throws URISyntaxException, StorageException;
InputStream getInputStream(String account, LocationMode mode, String container, String blob)
- throws URISyntaxException, StorageException;
+ throws URISyntaxException, StorageException, IOException;
OutputStream getOutputStream(String account, LocationMode mode, String container, String blob)
throws URISyntaxException, StorageException;
diff --git a/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceMock.java b/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceMock.java
index 8160c56032..5d4f9c6f69 100644
--- a/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceMock.java
+++ b/plugins/repository-azure/src/test/java/org/elasticsearch/cloud/azure/storage/AzureStorageServiceMock.java
@@ -31,6 +31,8 @@ import org.elasticsearch.common.settings.Settings;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URISyntaxException;
@@ -79,7 +81,10 @@ public class AzureStorageServiceMock extends AbstractLifecycleComponent<AzureSto
}
@Override
- public InputStream getInputStream(String account, LocationMode mode, String container, String blob) {
+ public InputStream getInputStream(String account, LocationMode mode, String container, String blob) throws IOException {
+ if (!blobExists(account, mode, container, blob)) {
+ throw new FileNotFoundException("missing blob [" + blob + "]");
+ }
return new ByteArrayInputStream(blobs.get(blob).toByteArray());
}