Put Mapping: When using a single node and updating a mapping, it is not marked as `acknowledged`, closes #280.

This commit is contained in:
kimchy 2010-07-29 15:21:11 +03:00
parent e955e41a91
commit 4f407e18aa
1 changed files with 22 additions and 19 deletions

View File

@ -205,28 +205,31 @@ public class MetaDataMappingService extends AbstractComponent {
}
}
final AtomicInteger counter = new AtomicInteger(expectedReplies);
final Set<String> 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<String> 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();