diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGateway.java index 37b787f2e9f..24998fa2eef 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGateway.java @@ -58,6 +58,11 @@ public interface IndexShardGateway extends IndexShardComponent, CloseableIndexCo */ SnapshotStatus snapshot(Snapshot snapshot) throws IndexShardGatewaySnapshotFailedException; + /** + * Returns true if snapshot is even required on this gateway (i.e. mainly handles recovery). + */ + boolean requiresSnapshot(); + /** * Returns true if this gateway requires scheduling management for snapshot * operations. diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java index 99f10659da1..24deff57215 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/IndexShardGatewayService.java @@ -270,7 +270,7 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem } public void snapshotOnClose() { - if (snapshotOnClose) { + if (shardGateway.requiresSnapshot() && snapshotOnClose) { try { snapshot("shutdown"); } catch (Exception e) { @@ -296,6 +296,9 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem } private synchronized void scheduleSnapshotIfNeeded() { + if (!shardGateway.requiresSnapshot()) { + return; + } if (!shardGateway.requiresSnapshotScheduling()) { return; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexShardGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexShardGateway.java index eb8e2b861b4..b1499862ef8 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexShardGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/blobstore/BlobStoreIndexShardGateway.java @@ -109,6 +109,10 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo return type() + "://" + blobStore + "/" + shardPath; } + @Override public boolean requiresSnapshot() { + return true; + } + @Override public boolean requiresSnapshotScheduling() { return true; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java index 4760ae197b2..891056957d7 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/local/LocalIndexShardGateway.java @@ -177,6 +177,10 @@ public class LocalIndexShardGateway extends AbstractIndexShardComponent implemen return null; } + @Override public boolean requiresSnapshot() { + return false; + } + @Override public boolean requiresSnapshotScheduling() { return false; } diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java index 4f8e3d81fe4..f34a4ff4a56 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/index/gateway/none/NoneIndexShardGateway.java @@ -87,6 +87,10 @@ public class NoneIndexShardGateway extends AbstractIndexShardComponent implement return null; } + @Override public boolean requiresSnapshot() { + return false; + } + @Override public boolean requiresSnapshotScheduling() { return false; }