Skip to content

Commit 17f079d

Browse files
pit seg
Signed-off-by: Bharathwaj G <[email protected]>
1 parent 92b7d24 commit 17f079d

File tree

2 files changed

+29
-12
lines changed

2 files changed

+29
-12
lines changed

server/src/main/java/org/opensearch/action/admin/indices/segments/TransportPitSegmentsAction.java

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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 {

server/src/main/java/org/opensearch/action/support/broadcast/node/TransportBroadcastByNodeAction.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,6 +532,11 @@ private void onShardOperation(
532532
}
533533
}
534534

535+
public List<ShardRouting> getShardsFromInputStream(StreamInput in) throws IOException {
536+
System.out.println("getShardsFromInputStream from TBBNA = " + in);
537+
return in.readList(ShardRouting::new);
538+
}
539+
535540
/**
536541
* A node request
537542
*
@@ -547,7 +552,8 @@ public class NodeRequest extends TransportRequest implements IndicesRequest {
547552
public NodeRequest(StreamInput in) throws IOException {
548553
super(in);
549554
indicesLevelRequest = readRequestFrom(in);
550-
shards = in.readList(ShardRouting::new);
555+
//shards = in.readList(ShardRouting::new);
556+
shards = getShardsFromInputStream(in);
551557
nodeId = in.readString();
552558
}
553559

0 commit comments

Comments
 (0)