in src/main/java/org/opensearch/performanceanalyzer/transport/PerformanceAnalyzerTransportRequestHandler.java [80:122]
private TransportChannel getShardBulkChannel(T request, TransportChannel channel, Task task) {
String className = request.getClass().getName();
boolean bPrimary = false;
if (className.equals(
"org.opensearch.action.support.replication.TransportReplicationAction$ConcreteShardRequest")) {
bPrimary = true;
} else if (className.equals(
"org.opensearch.action.support.replication.TransportReplicationAction$ConcreteReplicaRequest")) {
bPrimary = false;
} else {
return channel;
}
TransportRequest transportRequest = ((ConcreteShardRequest<?>) request).getRequest();
if (!(transportRequest instanceof BulkShardRequest)) {
return channel;
}
BulkShardRequest bsr = (BulkShardRequest) transportRequest;
PerformanceAnalyzerTransportChannel performanceanalyzerChannel =
new PerformanceAnalyzerTransportChannel();
try {
performanceanalyzerChannel.set(
channel,
System.currentTimeMillis(),
bsr.index(),
bsr.shardId().id(),
bsr.items().length,
bPrimary);
} catch (Exception ex) {
if (!logOnce) {
LOG.error(ex);
logOnce = true;
}
PerformanceAnalyzerApp.WRITER_METRICS_AGGREGATOR.updateStat(
WriterMetrics.OPENSEARCH_REQUEST_INTERCEPTOR_ERROR, "", 1);
}
return performanceanalyzerChannel;
}