From 4f407e18aa3f4cdf9da3085af8d6cf0ad2fc4ae9 Mon Sep 17 00:00:00 2001 From: kimchy Date: Thu, 29 Jul 2010 15:21:11 +0300 Subject: [PATCH] Put Mapping: When using a single node and updating a mapping, it is not marked as `acknowledged`, closes #280. --- .../metadata/MetaDataMappingService.java | 41 ++++++++++--------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java index 7f855523f2c..c04e05df691 100644 --- a/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java +++ b/modules/elasticsearch/src/main/java/org/elasticsearch/cluster/metadata/MetaDataMappingService.java @@ -205,28 +205,31 @@ public class MetaDataMappingService extends AbstractComponent { } } - - final AtomicInteger counter = new AtomicInteger(expectedReplies); - final Set indicesSet = newHashSet(request.indices); - final NodeMappingCreatedAction.Listener nodeMappingListener = new NodeMappingCreatedAction.Listener() { - @Override public void onNodeMappingCreated(NodeMappingCreatedAction.NodeMappingCreatedResponse response) { - if (indicesSet.contains(response.index()) && response.type().equals(request.mappingType)) { - if (counter.decrementAndGet() == 0) { - listener.onResponse(new Response(true)); - nodeMappingCreatedAction.remove(this); + if (expectedReplies == 0) { + listener.onResponse(new Response(true)); + } else { + final AtomicInteger counter = new AtomicInteger(expectedReplies); + final Set indicesSet = newHashSet(request.indices); + final NodeMappingCreatedAction.Listener nodeMappingListener = new NodeMappingCreatedAction.Listener() { + @Override public void onNodeMappingCreated(NodeMappingCreatedAction.NodeMappingCreatedResponse response) { + if (indicesSet.contains(response.index()) && response.type().equals(request.mappingType)) { + if (counter.decrementAndGet() == 0) { + listener.onResponse(new Response(true)); + nodeMappingCreatedAction.remove(this); + } } } - } - }; - nodeMappingCreatedAction.add(nodeMappingListener); + }; + nodeMappingCreatedAction.add(nodeMappingListener); - Timeout timeoutTask = timerService.newTimeout(new TimerTask() { - @Override public void run(Timeout timeout) throws Exception { - listener.onResponse(new Response(false)); - nodeMappingCreatedAction.remove(nodeMappingListener); - } - }, request.timeout, TimerService.ExecutionType.THREADED); - listener.timeout = timeoutTask; + Timeout timeoutTask = timerService.newTimeout(new TimerTask() { + @Override public void run(Timeout timeout) throws Exception { + listener.onResponse(new Response(false)); + nodeMappingCreatedAction.remove(nodeMappingListener); + } + }, request.timeout, TimerService.ExecutionType.THREADED); + listener.timeout = timeoutTask; + } return newClusterStateBuilder().state(currentState).metaData(builder).build();