@@ -132,8 +132,8 @@ protected ShardsIterator shards(ClusterState clusterState, PitSegmentsRequest re
132132 final ShardId shardId = entry .getKey ();
133133 Optional <ShardRouting > shardRouting = shardsIterator .getShardRoutings ().stream ().filter (r -> r .shardId ().equals (shardId )).findFirst ();
134134 ShardRouting sr = shardRouting .get ();
135- iterators . add (sr );
136- // iterators.add(new PitAwareShardRouting(sr, pitId) );
135+ PitAwareShardRouting psr = new PitAwareShardRouting (sr , pitId );
136+ iterators .add (psr );
137137 }
138138 }
139139 }
@@ -175,17 +175,28 @@ protected PitSegmentsRequest readRequestFrom(StreamInput in) throws IOException
175175 }
176176
177177 @ Override
178- protected ShardSegments shardOperation (PitSegmentsRequest request , ShardRouting shardRouting ) {
179- // PitAwareShardRouting pitAwareShardRouting = (PitAwareShardRouting) shardRouting;
180- // SearchContextIdForNode searchContextIdForNode = decode(namedWriteableRegistry,
181- // pitAwareShardRouting.getPitId()).shards().get(shardRouting.shardId());
182- // PitReaderContext pitReaderContext = searchService.getPitReaderContext(searchContextIdForNode.getSearchContextId());
183- // return new ShardSegments(pitReaderContext.getShardRouting(), pitReaderContext.getSegments());
178+ public List <ShardRouting > getShardsFromInputStream (StreamInput in ) throws IOException {
179+ System .out .println ("getShardsFromInputStream from TBBNA = " + in );
180+ return in .readList (PitAwareShardRouting ::new );
181+ }
184182
183+ @ Override
184+ protected ShardSegments shardOperation (PitSegmentsRequest request , ShardRouting shardRouting ) {
185185
186- IndexService indexService = indicesService .indexServiceSafe (shardRouting .index ());
187- IndexShard indexShard = indexService .getShard (shardRouting .id ());
188- return new ShardSegments (indexShard .routingEntry (), indexShard .segments (request .verbose ()));
186+ PitAwareShardRouting pitAwareShardRouting = (PitAwareShardRouting ) shardRouting ;
187+ SearchContextIdForNode searchContextIdForNode = decode (namedWriteableRegistry ,
188+ pitAwareShardRouting .getPitId ()).shards ().get (shardRouting .shardId ());
189+ PitReaderContext pitReaderContext = searchService .getPitReaderContext (searchContextIdForNode .getSearchContextId ());
190+ return new ShardSegments (pitReaderContext .getShardRouting (), pitReaderContext .getSegments ());
191+ // for(String pitId : request.getPitIds()) {
192+ // SearchContextIdForNode searchContextIdForNode = decode(namedWriteableRegistry,
193+ // pitId).shards().get(shardRouting.shardId());
194+ // if(searchContextIdForNode == null) continue;
195+ // PitReaderContext pitReaderContext = searchService.getPitReaderContext(searchContextIdForNode.getSearchContextId());
196+ // return new ShardSegments(pitReaderContext.getShardRouting(), pitReaderContext.getSegments());
197+ //
198+ // }
199+ // return null;
189200 }
190201
191202 public class PitAwareShardRouting extends ShardRouting {
0 commit comments