Skip to content

Commit

Permalink
Rename .getStatsRecorder() to .getReadResponseStatsRecorder()
Browse files Browse the repository at this point in the history
  • Loading branch information
sushantmane committed Sep 15, 2024
1 parent 7ce9a1b commit e7479b5
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void processRequest(GrpcRequestContext requestContext) {
}

/**
* Call must ensure that all fields in the request context are properly set before invoking this method.
* Callers must ensure that all fields in the request context are properly set before invoking this method.
* Callers must also use the appropriate {@link GrpcRequestContext#readResponseStatus} to comply with the API contract.
*
* @param requestContext The context of the request for which a response is being sent
Expand Down Expand Up @@ -265,10 +265,10 @@ public static void reportRequestStats(GrpcRequestContext requestContext) {
if (readResponse == null) {
requestStatsRecorder.setReadResponseStats(null).setResponseSize(0);
} else if (readResponse.isFound()) {
requestStatsRecorder.setReadResponseStats(abstractReadResponse.getStatsRecorder())
requestStatsRecorder.setReadResponseStats(abstractReadResponse.getReadResponseStatsRecorder())
.setResponseSize(abstractReadResponse.getResponseBody().readableBytes());
} else {
requestStatsRecorder.setReadResponseStats(abstractReadResponse.getStatsRecorder()).setResponseSize(0);
requestStatsRecorder.setReadResponseStats(abstractReadResponse.getReadResponseStatsRecorder()).setResponseSize(0);
}

RequestStatsRecorder.recordRequestCompletionStats(requestContext.getRequestStatsRecorder(), true, -1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void write(ChannelHandlerContext ctx, Object msg, ChannelPromise promise)
try {
if (msg instanceof AbstractReadResponse) {
AbstractReadResponse obj = (AbstractReadResponse) msg;
requestStatsRecorder.setReadResponseStats(obj.getStatsRecorder());
requestStatsRecorder.setReadResponseStats(obj.getReadResponseStatsRecorder());
compressionStrategy = obj.getCompressionStrategy();
if (obj.isFound()) {
body = obj.getResponseBody();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ public boolean isFound() {

public abstract int getResponseSchemaIdHeader();

public abstract ReadResponseStatsRecorder getStatsRecorder();
public abstract ReadResponseStatsRecorder getReadResponseStatsRecorder();
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public ReadResponseStats getStats() {
}

@Override
public ReadResponseStatsRecorder getStatsRecorder() {
public ReadResponseStatsRecorder getReadResponseStatsRecorder() {
return this.responseStats;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public ReadResponseStats getStats() {
}

@Override
public ReadResponseStatsRecorder getStatsRecorder() {
public ReadResponseStatsRecorder getReadResponseStatsRecorder() {
return new CompositeReadResponseStatsRecorder(this.chunks);
}

Expand Down Expand Up @@ -93,7 +93,7 @@ private static final class CompositeReadResponseStatsRecorder implements ReadRes
private final ReadResponseStatsRecorder[] statsRecorders;

CompositeReadResponseStatsRecorder(MultiKeyResponseWrapper[] responseChunks) {
this.mergedStats = responseChunks[0].getStatsRecorder();
this.mergedStats = responseChunks[0].getReadResponseStatsRecorder();

/**
* This array can be one element shorter than {@param responseChunks} because the first chunk's storage exec sub
Expand All @@ -102,7 +102,7 @@ private static final class CompositeReadResponseStatsRecorder implements ReadRes
this.statsRecorders = new ReadResponseStatsRecorder[responseChunks.length - 1];
ReadResponseStatsRecorder statsRecorder;
for (int i = 1; i < responseChunks.length; i++) {
statsRecorder = responseChunks[i].getStatsRecorder();
statsRecorder = responseChunks[i].getReadResponseStatsRecorder();
// We merge the stats of all chunks from the 2nd one to the last one into the stats of the 1st chunk.
this.mergedStats.merge(statsRecorder);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ReadResponseStats getStats() {
}

@Override
public ReadResponseStatsRecorder getStatsRecorder() {
public ReadResponseStatsRecorder getReadResponseStatsRecorder() {
return this.responseStats;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,6 @@ public void testIsServerHealthy() {
assertTrue(response.getMessage().contains(VENICE_STORAGE_NODE_HARDWARE_IS_NOT_HEALTHY_MSG));
}

// getCompressionDictionary
@Test
public void testGetCompressionDictionary() {
String storeName = "testStore";
Expand Down Expand Up @@ -132,4 +131,9 @@ public void testGetCompressionDictionary() {
CompressionDictionaryResponse exceptionActualResponse = blockingStub.getCompressionDictionary(request);
assertEquals(exceptionActualResponse.getStatusCode(), VeniceReadResponseStatus.INTERNAL_SERVER_ERROR.getCode());
}

@Test
public void testHandleAdminRequest() {

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -451,7 +451,7 @@ public void merge(ReadResponseStatsRecorder other) {
}

ServerHttpRequestStats stats = mock(ServerHttpRequestStats.class);
multiGetResponseWrapper.getStatsRecorder().recordMetrics(stats);
multiGetResponseWrapper.getReadResponseStatsRecorder().recordMetrics(stats);
if (responseProvider == validResponseProvider) {
verify(stats).recordSuccessRequestKeyCount(recordCount);
}
Expand Down Expand Up @@ -727,7 +727,7 @@ public void testHandleComputeRequest(boolean readComputationEnabled) throws Exce
double expectedReadComputeEfficiency = (double) valueBytes.length / (double) expectedReadComputeOutputSize;

ServerHttpRequestStats stats = mock(ServerHttpRequestStats.class);
computeResponse.getStatsRecorder().recordMetrics(stats);
computeResponse.getReadResponseStatsRecorder().recordMetrics(stats);
verify(stats).recordSuccessRequestKeyCount(keySet.size());
verify(stats).recordDotProductCount(1);
verify(stats).recordHadamardProduct(1);
Expand Down

0 comments on commit e7479b5

Please sign in to comment.