Skip to content

Commit 25e5e9d

Browse files
committed
Call getLastUnsafeSegmentGenerationForGets directly on Engine
1 parent 87240c5 commit 25e5e9d

File tree

2 files changed

+2
-13
lines changed

2 files changed

+2
-13
lines changed

server/src/main/java/org/elasticsearch/action/get/TransportGetFromTranslogAction.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.elasticsearch.index.IndexService;
2828
import org.elasticsearch.index.engine.Engine;
2929
import org.elasticsearch.index.engine.InternalEngine;
30-
import org.elasticsearch.index.engine.ReadOnlyEngine;
3130
import org.elasticsearch.index.get.GetResult;
3231
import org.elasticsearch.index.shard.IndexShard;
3332
import org.elasticsearch.index.shard.ShardId;
@@ -82,11 +81,7 @@ protected void doExecute(Task task, Request request, ActionListener<Response> li
8281
if (engine == null) {
8382
throw new AlreadyClosedException("engine closed");
8483
}
85-
if (engine instanceof InternalEngine internalEngine) {
86-
segmentGeneration = internalEngine.getLastUnsafeSegmentGenerationForGets();
87-
} else if (engine instanceof ReadOnlyEngine readOnlyEngine) {
88-
segmentGeneration = readOnlyEngine.getLastUnsafeSegmentGenerationForGets();
89-
}
84+
segmentGeneration = engine.getLastUnsafeSegmentGenerationForGets();
9085
}
9186
return new Response(result, indexShard.getOperationPrimaryTerm(), segmentGeneration);
9287
});

server/src/main/java/org/elasticsearch/action/get/TransportShardMultiGetFomTranslogAction.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,6 @@
2323
import org.elasticsearch.common.io.stream.StreamOutput;
2424
import org.elasticsearch.index.IndexService;
2525
import org.elasticsearch.index.engine.Engine;
26-
import org.elasticsearch.index.engine.InternalEngine;
27-
import org.elasticsearch.index.engine.ReadOnlyEngine;
2826
import org.elasticsearch.index.shard.IndexShard;
2927
import org.elasticsearch.index.shard.ShardId;
3028
import org.elasticsearch.indices.IndicesService;
@@ -103,11 +101,7 @@ protected void doExecute(Task task, Request request, ActionListener<Response> li
103101
if (engine == null) {
104102
throw new AlreadyClosedException("engine closed");
105103
}
106-
if (engine instanceof InternalEngine internalEngine) {
107-
segmentGeneration = internalEngine.getLastUnsafeSegmentGenerationForGets();
108-
} else if (engine instanceof ReadOnlyEngine readOnlyEngine) {
109-
segmentGeneration = readOnlyEngine.getLastUnsafeSegmentGenerationForGets();
110-
}
104+
segmentGeneration = engine.getLastUnsafeSegmentGenerationForGets();
111105
}
112106
return new Response(multiGetShardResponse, indexShard.getOperationPrimaryTerm(), segmentGeneration);
113107
});

0 commit comments

Comments
 (0)