don't snapshot gateway when cleaning shard

This commit is contained in:
kimchy 2010-08-20 00:59:37 +03:00
parent 4a2e076c6a
commit a05c367c5e
2 changed files with 20 additions and 9 deletions

View File

@ -270,18 +270,21 @@ public class IndexShardGatewayService extends AbstractIndexShardComponent implem
}
}
public synchronized void close(boolean delete) {
if (snapshotScheduleFuture != null) {
snapshotScheduleFuture.cancel(true);
snapshotScheduleFuture = null;
}
if (!delete && snapshotOnClose) {
public void snapshotOnClose() {
if (snapshotOnClose) {
try {
snapshot("shutdown");
} catch (Exception e) {
logger.warn("failed to snapshot on close", e);
}
}
}
public synchronized void close(boolean delete) {
if (snapshotScheduleFuture != null) {
snapshotScheduleFuture.cancel(true);
snapshotScheduleFuture = null;
}
// don't really delete the shard gateway if we are *not* primary,
// the primary will close it
if (!indexShard.routingEntry().primary()) {

View File

@ -208,7 +208,7 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
threadPool.cached().execute(new Runnable() {
@Override public void run() {
try {
deleteShard(shardId, delete, delete);
deleteShard(shardId, delete, !delete, delete);
} catch (Exception e) {
logger.warn("failed to close shard, delete [{}]", e, delete);
} finally {
@ -276,10 +276,10 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
}
@Override public synchronized void cleanShard(int shardId) throws ElasticSearchException {
deleteShard(shardId, true, false);
deleteShard(shardId, true, false, false);
}
private void deleteShard(int shardId, boolean delete, boolean deleteGateway) throws ElasticSearchException {
private void deleteShard(int shardId, boolean delete, boolean snapshotGateway, boolean deleteGateway) throws ElasticSearchException {
Injector shardInjector;
IndexShard indexShard;
synchronized (this) {
@ -335,8 +335,16 @@ public class InternalIndexService extends AbstractIndexComponent implements Inde
} catch (Exception e) {
// ignore
}
try {
// now, we can snapshot to the gateway, it will be only the translog
if (snapshotGateway) {
shardInjector.getInstance(IndexShardGatewayService.class).snapshotOnClose();
}
} catch (Exception e) {
// ignore
}
try {
shardInjector.getInstance(IndexShardGatewayService.class).close(deleteGateway);
} catch (Exception e) {
// ignore