Optimize Node, remove duplicate Settings (#2703)

Removes duplicate Settings

Signed-off-by: ruanwenjun <wenjun@apache.org>
This commit is contained in:
Wenjun Ruan 2022-04-04 23:34:03 +08:00 committed by GitHub
parent 6a2a33d187
commit d848c63260
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 21 deletions

View File

@ -216,25 +216,20 @@ public final class ShardGetService extends AbstractIndexShardComponent {
fetchSourceContext = normalizeFetchSourceContent(fetchSourceContext, gFields); fetchSourceContext = normalizeFetchSourceContent(fetchSourceContext, gFields);
Term uidTerm = new Term(IdFieldMapper.NAME, Uid.encodeId(id)); Term uidTerm = new Term(IdFieldMapper.NAME, Uid.encodeId(id));
Engine.GetResult get = indexShard.get(
new Engine.Get(realtime, true, id, uidTerm).version(version)
.versionType(versionType)
.setIfSeqNo(ifSeqNo)
.setIfPrimaryTerm(ifPrimaryTerm)
);
if (get.exists() == false) {
get.close();
}
if (get == null || get.exists() == false) { try (
return new GetResult(shardId.getIndexName(), id, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, -1, false, null, null, null); Engine.GetResult get = indexShard.get(
} new Engine.Get(realtime, true, id, uidTerm).version(version)
.versionType(versionType)
try { .setIfSeqNo(ifSeqNo)
.setIfPrimaryTerm(ifPrimaryTerm)
)
) {
if (get == null || get.exists() == false) {
return new GetResult(shardId.getIndexName(), id, UNASSIGNED_SEQ_NO, UNASSIGNED_PRIMARY_TERM, -1, false, null, null, null);
}
// break between having loaded it from translog (so we only have _source), and having a document to load // break between having loaded it from translog (so we only have _source), and having a document to load
return innerGetLoadFromStoredFields(id, gFields, fetchSourceContext, get, mapperService); return innerGetLoadFromStoredFields(id, gFields, fetchSourceContext, get, mapperService);
} finally {
get.close();
} }
} }

View File

@ -348,11 +348,7 @@ public class Node implements Closeable {
Settings tmpSettings = Settings.builder() Settings tmpSettings = Settings.builder()
.put(initialEnvironment.settings()) .put(initialEnvironment.settings())
.put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE) .put(Client.CLIENT_TYPE_SETTING_S.getKey(), CLIENT_TYPE)
.build(); // Enabling shard indexing backpressure node-attribute
// Enabling shard indexing backpressure node-attribute
tmpSettings = Settings.builder()
.put(tmpSettings)
.put(NODE_ATTRIBUTES.getKey() + SHARD_INDEXING_PRESSURE_ENABLED_ATTRIBUTE_KEY, "true") .put(NODE_ATTRIBUTES.getKey() + SHARD_INDEXING_PRESSURE_ENABLED_ATTRIBUTE_KEY, "true")
.build(); .build();