From 19052a3538bf5991fa8b7d71af43eb9e50316b17 Mon Sep 17 00:00:00 2001 From: kimchy Date: Fri, 11 Mar 2011 15:20:16 +0200 Subject: [PATCH] Add another flag to gateway if it even requires snapshot, so we don't try and snapshot on shutdown for none/local gateway (even though its a no op) --- .../org/elasticsearch/index/gateway/IndexShardGateway.java | 5 +++++ .../index/gateway/IndexShardGatewayService.java | 5 ++++- .../index/gateway/blobstore/BlobStoreIndexShardGateway.java | 4 ++++ .../index/gateway/local/LocalIndexShardGateway.java | 4 ++++ .../index/gateway/none/NoneIndexShardGateway.java | 4 ++++ 5 files changed, 21 insertions(+), 1 deletion(-) 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; }