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());
|
localityLoadCounters.remove(entry.getKey());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
long totalDrops = 0;
|
||||||
for (Map.Entry<String, AtomicLong> entry : dropCounters.entrySet()) {
|
for (Map.Entry<String, AtomicLong> entry : dropCounters.entrySet()) {
|
||||||
|
long drops = entry.getValue().getAndSet(0);
|
||||||
|
totalDrops += drops;
|
||||||
statsBuilder.addDroppedRequests(DroppedRequests.newBuilder()
|
statsBuilder.addDroppedRequests(DroppedRequests.newBuilder()
|
||||||
.setCategory(entry.getKey())
|
.setCategory(entry.getKey())
|
||||||
.setDroppedCount(entry.getValue().getAndSet(0)));
|
.setDroppedCount(drops));
|
||||||
}
|
}
|
||||||
|
statsBuilder.setTotalDroppedRequests(totalDrops);
|
||||||
return statsBuilder.build();
|
return statsBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -374,6 +374,7 @@ public class XdsLoadReportClientImplTest {
|
||||||
.addDroppedRequests(DroppedRequests.newBuilder()
|
.addDroppedRequests(DroppedRequests.newBuilder()
|
||||||
.setCategory("throttle")
|
.setCategory("throttle")
|
||||||
.setDroppedCount(numThrottleDrops))
|
.setDroppedCount(numThrottleDrops))
|
||||||
|
.setTotalDroppedRequests(numLbDrops + numThrottleDrops)
|
||||||
.build();
|
.build();
|
||||||
ClusterStats expectedStats2 = ClusterStats.newBuilder()
|
ClusterStats expectedStats2 = ClusterStats.newBuilder()
|
||||||
.setClusterName(SERVICE_AUTHORITY)
|
.setClusterName(SERVICE_AUTHORITY)
|
||||||
|
|
@ -387,6 +388,7 @@ public class XdsLoadReportClientImplTest {
|
||||||
.addDroppedRequests(DroppedRequests.newBuilder()
|
.addDroppedRequests(DroppedRequests.newBuilder()
|
||||||
.setCategory("throttle")
|
.setCategory("throttle")
|
||||||
.setDroppedCount(0))
|
.setDroppedCount(0))
|
||||||
|
.setTotalDroppedRequests(0)
|
||||||
.build();
|
.build();
|
||||||
when(statsStore.generateLoadReport())
|
when(statsStore.generateLoadReport())
|
||||||
.thenReturn(expectedStats1, expectedStats2);
|
.thenReturn(expectedStats1, expectedStats2);
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@ public class XdsLoadStatsStoreTest {
|
||||||
private static void assertClusterStatsEqual(ClusterStats expected, ClusterStats actual) {
|
private static void assertClusterStatsEqual(ClusterStats expected, ClusterStats actual) {
|
||||||
assertThat(actual.getClusterName()).isEqualTo(expected.getClusterName());
|
assertThat(actual.getClusterName()).isEqualTo(expected.getClusterName());
|
||||||
assertThat(actual.getLoadReportInterval()).isEqualTo(expected.getLoadReportInterval());
|
assertThat(actual.getLoadReportInterval()).isEqualTo(expected.getLoadReportInterval());
|
||||||
|
assertThat(actual.getTotalDroppedRequests()).isEqualTo(expected.getTotalDroppedRequests());
|
||||||
assertThat(actual.getDroppedRequestsCount()).isEqualTo(expected.getDroppedRequestsCount());
|
assertThat(actual.getDroppedRequestsCount()).isEqualTo(expected.getDroppedRequestsCount());
|
||||||
assertThat(new HashSet<>(actual.getDroppedRequestsList()))
|
assertThat(new HashSet<>(actual.getDroppedRequestsList()))
|
||||||
.isEqualTo(new HashSet<>(expected.getDroppedRequestsList()));
|
.isEqualTo(new HashSet<>(expected.getDroppedRequestsList()));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue