From f5a9f2d94817f83156f46c67020f880c462824ed Mon Sep 17 00:00:00 2001 From: kimchy Date: Tue, 11 Jan 2011 23:38:46 +0200 Subject: [PATCH] If the cluster does not contain any indices then index templates do not survive cluster restart, closes #617. --- .../org/elasticsearch/gateway/local/LocalGateway.java | 9 ++++----- .../gateway/shared/SharedStorageGateway.java | 4 ++++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java index 1e20a325a98..5d44144899d 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/local/LocalGateway.java @@ -152,11 +152,6 @@ public class LocalGateway extends AbstractLifecycleComponent implements listener.onSuccess(); return; } - if (electedState.state().metaData().indices().isEmpty()) { - logger.debug("no indices in metadata"); - listener.onSuccess(); - return; - } logger.debug("elected state from [{}]", electedState.node()); final LocalGatewayMetaState state = electedState.state(); @@ -179,6 +174,10 @@ public class LocalGateway extends AbstractLifecycleComponent implements } @Override public void clusterStateProcessed(ClusterState clusterState) { + if (state.metaData().indices().isEmpty()) { + listener.onSuccess(); + return; + } // go over the meta data and create indices, we don't really need to copy over // the meta data per index, since we create the index and it will be added automatically for (final IndexMetaData indexMetaData : state.metaData()) { diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java index 0e9c9fd2414..1bffb047416 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/gateway/shared/SharedStorageGateway.java @@ -149,6 +149,10 @@ public abstract class SharedStorageGateway extends AbstractLifecycleComponent