Cluster metadata files destroyed when using blob store gateway causing data loss, closes #1564,

This commit is contained in:
Shay Banon 2011-12-22 20:42:37 +02:00
parent a0fb6f3d92
commit 3d9e87201e
1 changed files with 16 additions and 1 deletions

View File

@ -32,6 +32,12 @@ import org.elasticsearch.gateway.Gateway;
import org.elasticsearch.gateway.GatewayException;
import org.elasticsearch.threadpool.ThreadPool;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.TimeUnit;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
import static org.elasticsearch.common.util.concurrent.EsExecutors.daemonThreadFactory;
/**
*
*/
@ -41,6 +47,8 @@ public abstract class SharedStorageGateway extends AbstractLifecycleComponent<Ga
private final ThreadPool threadPool;
private ExecutorService writeStateExecutor;
public SharedStorageGateway(Settings settings, ThreadPool threadPool, ClusterService clusterService) {
super(settings);
this.threadPool = threadPool;
@ -50,11 +58,18 @@ public abstract class SharedStorageGateway extends AbstractLifecycleComponent<Ga
@Override
protected void doStart() throws ElasticSearchException {
clusterService.add(this);
this.writeStateExecutor = newSingleThreadExecutor(daemonThreadFactory(settings, "gateway#writeMetaData"));
}
@Override
protected void doStop() throws ElasticSearchException {
clusterService.remove(this);
writeStateExecutor.shutdown();
try {
writeStateExecutor.awaitTermination(10, TimeUnit.SECONDS);
} catch (InterruptedException e) {
// ignore
}
}
@Override
@ -101,7 +116,7 @@ public abstract class SharedStorageGateway extends AbstractLifecycleComponent<Ga
if (!event.metaDataChanged()) {
return;
}
threadPool.cached().execute(new Runnable() {
writeStateExecutor.execute(new Runnable() {
@Override
public void run() {
logger.debug("writing to gateway {} ...", this);