Excessive mapping parsing when cluster state changes, closes #575.
This commit is contained in:
parent
9361e3bd2b
commit
5ac42f2a4f
|
@ -34,6 +34,7 @@ import java.io.IOException;
|
|||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import static org.elasticsearch.common.collect.ImmutableMap.*;
|
||||
import static org.elasticsearch.common.collect.Lists.*;
|
||||
|
@ -575,8 +576,11 @@ public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
|
|||
|
||||
doXContent(builder, params);
|
||||
|
||||
// sort the mappers so we get consistent serialization format
|
||||
TreeMap<String, XContentMapper> sortedMappers = new TreeMap<String, XContentMapper>(mappers);
|
||||
|
||||
// check internal mappers first (this is only relevant for root object)
|
||||
for (XContentMapper mapper : mappers.values()) {
|
||||
for (XContentMapper mapper : sortedMappers.values()) {
|
||||
if (mapper instanceof InternalMapper) {
|
||||
mapper.toXContent(builder, params);
|
||||
}
|
||||
|
@ -589,7 +593,7 @@ public class ObjectMapper implements XContentMapper, IncludeInAllMapper {
|
|||
|
||||
if (!mappers.isEmpty()) {
|
||||
builder.startObject("properties");
|
||||
for (XContentMapper mapper : mappers.values()) {
|
||||
for (XContentMapper mapper : sortedMappers.values()) {
|
||||
if (!(mapper instanceof InternalMapper)) {
|
||||
mapper.toXContent(builder, params);
|
||||
}
|
||||
|
|
|
@ -276,9 +276,9 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
|||
logger.debug("[{}] adding mapping [{}], source [{}]", index, mappingType, mappingSource.string());
|
||||
}
|
||||
mapperService.add(mappingType, mappingSource.string());
|
||||
// if (!mapperService.documentMapper(mappingType).mappingSource().equals(mappingSource)) {
|
||||
// logger.warn("[{}] parsed mapping [{}], and got different sources\noriginal:\n{}\nparsed:\n{}", mappingType, mappingSource, mapperService.documentMapper(mappingType).mappingSource());
|
||||
// }
|
||||
if (!mapperService.documentMapper(mappingType).mappingSource().equals(mappingSource)) {
|
||||
logger.warn("[{}] parsed mapping [{}], and got different sources\noriginal:\n{}\nparsed:\n{}", index, mappingType, mappingSource, mapperService.documentMapper(mappingType).mappingSource());
|
||||
}
|
||||
nodeMappingCreatedAction.nodeMappingCreated(new NodeMappingCreatedAction.NodeMappingCreatedResponse(index, mappingType, event.state().nodes().localNodeId()));
|
||||
} else {
|
||||
DocumentMapper existingMapper = mapperService.documentMapper(mappingType);
|
||||
|
@ -288,9 +288,9 @@ public class IndicesClusterStateService extends AbstractLifecycleComponent<Indic
|
|||
logger.debug("[{}] updating mapping [{}], source [{}]", index, mappingType, mappingSource.string());
|
||||
}
|
||||
mapperService.add(mappingType, mappingSource.string());
|
||||
// if (!mapperService.documentMapper(mappingType).mappingSource().equals(mappingSource)) {
|
||||
// logger.warn("[{}] parsed mapping [{}], and got different sources\noriginal:\n{}\nparsed:\n{}", mappingType, mappingSource, mapperService.documentMapper(mappingType).mappingSource());
|
||||
// }
|
||||
if (!mapperService.documentMapper(mappingType).mappingSource().equals(mappingSource)) {
|
||||
logger.warn("[{}] parsed mapping [{}], and got different sources\noriginal:\n{}\nparsed:\n{}", index, mappingType, mappingSource, mapperService.documentMapper(mappingType).mappingSource());
|
||||
}
|
||||
nodeMappingCreatedAction.nodeMappingCreated(new NodeMappingCreatedAction.NodeMappingCreatedResponse(index, mappingType, event.state().nodes().localNodeId()));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue