wait before closing the shard if a snapshot is still in progress

This commit is contained in:
kimchy 2010-04-01 22:56:05 +03:00
parent 4b2ff13833
commit 50249f4e52
1 changed files with 10 additions and 4 deletions

View File

@ -161,19 +161,25 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
}); });
} catch (IllegalIndexShardStateException e) { } catch (IllegalIndexShardStateException e) {
// ignore, that's fine // ignore, that's fine
} catch (IndexShardGatewaySnapshotFailedException e) {
throw e;
} catch (Exception e) { } catch (Exception e) {
logger.warn("Failed to snapshot on close", e); throw new IndexShardGatewaySnapshotFailedException(shardId, "Failed to snapshot", e);
} }
} }
public void close(boolean delete) { public synchronized void close(boolean delete) {
if (snapshotScheduleFuture != null) { if (snapshotScheduleFuture != null) {
snapshotScheduleFuture.cancel(true); snapshotScheduleFuture.cancel(true);
snapshotScheduleFuture = null; snapshotScheduleFuture = null;
} }
if (!delete && snapshotOnClose) { if (!delete && snapshotOnClose) {
logger.debug("Snapshotting on close ..."); logger.debug("Snapshotting on close ...");
snapshot(); try {
snapshot();
} catch (Exception e) {
logger.warn("Failed to snapshot on close", e);
}
} }
// don't really delete the shard gateway if we are *not* primary, // don't really delete the shard gateway if we are *not* primary,
// the primary will close it // the primary will close it
@ -213,7 +219,7 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
try { try {
snapshot(); snapshot();
} catch (Exception e) { } catch (Exception e) {
logger.warn("Failed to snapshot", e); logger.warn("Failed to snapshot (scheduled)", e);
} }
} }
} }