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)

This commit is contained in:
kimchy 2011-03-11 15:20:16 +02:00
parent 3e624bf9e0
commit 19052a3538
5 changed files with 21 additions and 1 deletions

View File

@ -58,6 +58,11 @@ public interface IndexShardGateway extends IndexShardComponent, CloseableIndexCo
*/ */
SnapshotStatus snapshot(Snapshot snapshot) throws IndexShardGatewaySnapshotFailedException; SnapshotStatus snapshot(Snapshot snapshot) throws IndexShardGatewaySnapshotFailedException;
/**
* Returns <tt>true</tt> if snapshot is even required on this gateway (i.e. mainly handles recovery).
*/
boolean requiresSnapshot();
/** /**
* Returns <tt>true</tt> if this gateway requires scheduling management for snapshot * Returns <tt>true</tt> if this gateway requires scheduling management for snapshot
* operations. * operations.

View File

@ -270,7 +270,7 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
} }
public void snapshotOnClose() { public void snapshotOnClose() {
if (snapshotOnClose) { if (shardGateway.requiresSnapshot() && snapshotOnClose) {
try { try {
snapshot("shutdown"); snapshot("shutdown");
} catch (Exception e) { } catch (Exception e) {
@ -296,6 +296,9 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
} }
private synchronized void scheduleSnapshotIfNeeded() { private synchronized void scheduleSnapshotIfNeeded() {
if (!shardGateway.requiresSnapshot()) {
return;
}
if (!shardGateway.requiresSnapshotScheduling()) { if (!shardGateway.requiresSnapshotScheduling()) {
return; return;
} }

View File

@ -109,6 +109,10 @@ public abstract class BlobStoreIndexShardGateway extends AbstractIndexShardCompo
return type() + "://" + blobStore + "/" + shardPath; return type() + "://" + blobStore + "/" + shardPath;
} }
@Override public boolean requiresSnapshot() {
return true;
}
@Override public boolean requiresSnapshotScheduling() { @Override public boolean requiresSnapshotScheduling() {
return true; return true;
} }

View File

@ -177,6 +177,10 @@ public class LocalIndexShardGateway extends AbstractIndexShardComponent implemen
return null; return null;
} }
@Override public boolean requiresSnapshot() {
return false;
}
@Override public boolean requiresSnapshotScheduling() { @Override public boolean requiresSnapshotScheduling() {
return false; return false;
} }

View File

@ -87,6 +87,10 @@ public class NoneIndexShardGateway extends AbstractIndexShardComponent implement
return null; return null;
} }
@Override public boolean requiresSnapshot() {
return false;
}
@Override public boolean requiresSnapshotScheduling() { @Override public boolean requiresSnapshotScheduling() {
return false; return false;
} }