Skip to content

Commit 9d96759

Browse files
committed
iter
1 parent 4495cda commit 9d96759

File tree

1 file changed

+16
-15
lines changed

1 file changed

+16
-15
lines changed

server/src/main/java/org/elasticsearch/search/SearchService.java

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ public class SearchService extends AbstractLifecycleComponent implements IndexEv
372372
private final String sessionId;
373373

374374
private final Tracer tracer;
375-
private Map<ShardId, Set<ReaderContext>> relocatingContexts = ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency();
375+
private Map<ShardId, Set<Supplier<ReaderContext>>> relocatingContexts = ConcurrentCollections.newConcurrentMapWithAggressiveConcurrency();
376376

377377
public SearchService(
378378
ClusterService clusterService,
@@ -1379,7 +1379,7 @@ public final ReaderContext createAndPutRelocatedPitContext(
13791379
}
13801380
}
13811381

1382-
public void addRelocatingContext(ShardId shardId, ReaderContext readerContext) {
1382+
public void addRelocatingContext(ShardId shardId, Supplier<ReaderContext> readerContext) {
13831383
this.relocatingContexts.computeIfAbsent(shardId, k -> ConcurrentCollections.newConcurrentSet()).add(readerContext);
13841384
}
13851385

@@ -1426,12 +1426,12 @@ public void afterIndexShardStarted(IndexShard indexShard) {
14261426
logger.debug("afterIndexShardStarted [{}]", indexShard);
14271427
ShardId shardId = indexShard.shardId();
14281428
if (relocatingContexts.containsKey(shardId)) {
1429-
Set<ReaderContext> readerContexts = relocatingContexts.get(shardId);
1430-
for (ReaderContext readerContext : readerContexts) {
1431-
putReaderContext(readerContext);
1432-
logger.debug("added context [{}] to active readers", readerContext.id());
1433-
relocatingContexts.remove(shardId);
1429+
Set<Supplier<ReaderContext>> readerContexts = relocatingContexts.get(shardId);
1430+
for (Supplier<ReaderContext> readerContext : readerContexts) {
1431+
ReaderContext newReaderContext = readerContext.get();
1432+
logger.debug("added context [{}] to active readers", newReaderContext.id());
14341433
}
1434+
relocatingContexts.remove(shardId);
14351435
}
14361436
}
14371437

@@ -1984,14 +1984,15 @@ protected void doRun() {
19841984
freeReaderContext(context.id());
19851985
}
19861986
}
1987-
for (Set<ReaderContext> contexts : relocatingContexts.values()) {
1988-
for (ReaderContext context : contexts) {
1989-
if (context.isExpired()) {
1990-
logger.debug("freeing relocating search context [{}]", context.id());
1991-
freeReaderContext(context.id());
1992-
}
1993-
}
1994-
}
1987+
// TODO clean up pending relocating contexts. How long to wait for a relocation to complete?
1988+
// for (Set<Supplier<ReaderContext>> contexts : relocatingContexts.values()) {
1989+
// for (Supplier<ReaderContext> context : contexts) {
1990+
// if (context.isExpired()) {
1991+
// logger.debug("freeing relocating search context [{}]", context.id());
1992+
// freeReaderContext(context.id());
1993+
// }
1994+
// }
1995+
// }<
19951996
}
19961997

19971998
@Override

0 commit comments

Comments
 (0)