mirror of https://github.com/grpc/grpc-java.git
xds: fix bug of missing total_dropped_requests field in ClusterStats proto (#5862)
This commit is contained in:
parent
f7077a565a
commit
c98fb2d03e
|
|
@ -92,11 +92,15 @@ final class XdsLoadStatsStore implements StatsStore {
|
|||
localityLoadCounters.remove(entry.getKey());
|
||||
}
|
||||
}
|
||||
long totalDrops = 0;
|
||||
for (Map.Entry<String, AtomicLong> entry : dropCounters.entrySet()) {
|
||||
long drops = entry.getValue().getAndSet(0);
|
||||
totalDrops += drops;
|
||||
statsBuilder.addDroppedRequests(DroppedRequests.newBuilder()
|
||||
.setCategory(entry.getKey())
|
||||
.setDroppedCount(entry.getValue().getAndSet(0)));
|
||||
.setDroppedCount(drops));
|
||||
}
|
||||
statsBuilder.setTotalDroppedRequests(totalDrops);
|
||||
return statsBuilder.build();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -374,6 +374,7 @@ public class XdsLoadReportClientImplTest {
|
|||
.addDroppedRequests(DroppedRequests.newBuilder()
|
||||
.setCategory("throttle")
|
||||
.setDroppedCount(numThrottleDrops))
|
||||
.setTotalDroppedRequests(numLbDrops + numThrottleDrops)
|
||||
.build();
|
||||
ClusterStats expectedStats2 = ClusterStats.newBuilder()
|
||||
.setClusterName(SERVICE_AUTHORITY)
|
||||
|
|
@ -387,6 +388,7 @@ public class XdsLoadReportClientImplTest {
|
|||
.addDroppedRequests(DroppedRequests.newBuilder()
|
||||
.setCategory("throttle")
|
||||
.setDroppedCount(0))
|
||||
.setTotalDroppedRequests(0)
|
||||
.build();
|
||||
when(statsStore.generateLoadReport())
|
||||
.thenReturn(expectedStats1, expectedStats2);
|
||||
|
|
|
|||
|
|
@ -135,6 +135,7 @@ public class XdsLoadStatsStoreTest {
|
|||
private static void assertClusterStatsEqual(ClusterStats expected, ClusterStats actual) {
|
||||
assertThat(actual.getClusterName()).isEqualTo(expected.getClusterName());
|
||||
assertThat(actual.getLoadReportInterval()).isEqualTo(expected.getLoadReportInterval());
|
||||
assertThat(actual.getTotalDroppedRequests()).isEqualTo(expected.getTotalDroppedRequests());
|
||||
assertThat(actual.getDroppedRequestsCount()).isEqualTo(expected.getDroppedRequestsCount());
|
||||
assertThat(new HashSet<>(actual.getDroppedRequestsList()))
|
||||
.isEqualTo(new HashSet<>(expected.getDroppedRequestsList()));
|
||||
|
|
|
|||
Loading…
Reference in New Issue