From e06de6b24c6f8531bd85de2707cd05dd4c7d8051 Mon Sep 17 00:00:00 2001 From: Shay Banon Date: Fri, 3 Feb 2012 14:20:42 +0200 Subject: [PATCH] only check if settings need to change or mappings need to be checked if the index metadata has actually changed --- .../cluster/ClusterChangedEvent.java | 16 ++++++++++++++++ .../cluster/IndicesClusterStateService.java | 11 +++++++++++ 2 files changed, 27 insertions(+) diff --git a/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java b/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java index 6fb0c84d6f6..b4b8ff85408 100644 --- a/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java +++ b/src/main/java/org/elasticsearch/cluster/ClusterChangedEvent.java @@ -21,6 +21,8 @@ package org.elasticsearch.cluster; import com.google.common.collect.ImmutableList; import com.google.common.collect.Lists; +import org.elasticsearch.cluster.metadata.IndexMetaData; +import org.elasticsearch.cluster.metadata.MetaData; import org.elasticsearch.cluster.node.DiscoveryNodes; import java.util.List; @@ -122,6 +124,20 @@ public class ClusterChangedEvent { return state.metaData() != previousState.metaData(); } + public boolean indexMetaDataChanged(IndexMetaData current) { + MetaData previousMetaData = previousState.metaData(); + if (previousMetaData == null) { + return true; + } + IndexMetaData previousIndexMetaData = previousMetaData.index(current.index()); + // no need to check on version, since disco modules will make sure to use the + // same instance if its a version match + if (previousIndexMetaData == current) { + return false; + } + return false; + } + public boolean blocksChanged() { return state.blocks() != previousState.blocks(); } diff --git a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java index 1f2d5271798..2829ecd2ef1 100644 --- a/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java +++ b/src/main/java/org/elasticsearch/indices/cluster/IndicesClusterStateService.java @@ -304,11 +304,18 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent typesToRefresh = null; String index = indexMetaData.index(); IndexService indexService = indicesService.indexServiceSafe(index);