shuan1026 commented on code in PR #11029:
URL: https://github.com/apache/ozone/pull/11029#discussion_r3795357542
##########
hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/hdds/scm/TestXceiverClientMetrics.java:
##########
@@ -105,54 +105,44 @@ public void testMetrics(@TempDir Path metaDir) throws
Exception {
assertCounter("CreateContainerLatencyNumOps", 1L, containerMetrics);
breakFlag = false;
- latch = new CountDownLatch(1);
-
- int numRequest = 10;
- List<CompletableFuture<ContainerCommandResponseProto>> computeResults
- = new ArrayList<>();
- // start new thread to send async requests
- Thread sendThread = new Thread(() -> {
- while (!breakFlag) {
+ int numSenderThreads = 10;
+ latch = new CountDownLatch(numSenderThreads);
+ List<CompletableFuture<ContainerCommandResponseProto>> computeResults =
+ Collections.synchronizedList(new ArrayList<>());
+ XceiverClientMetrics clientMetrics =
+ XceiverClientManager.getXceiverClientMetrics();
+
+ for (int i = 0; i < numSenderThreads; i++) {
+ Thread sendThread = new Thread(() -> {
try {
- // use async interface for testing pending metrics
- for (int i = 0; i < numRequest; i++) {
- BlockID blockID = ContainerTestHelper.
-
getTestBlockID(container.getContainerInfo().getContainerID());
- ContainerProtos.ContainerCommandRequestProto smallFileRequest;
-
- smallFileRequest = ContainerTestHelper.getWriteSmallFileRequest(
- client.getPipeline(), blockID, 1024);
- CompletableFuture<ContainerProtos.ContainerCommandResponseProto>
- response =
- client.sendCommandAsync(smallFileRequest).getResponse();
- computeResults.add(response);
+ while (!breakFlag) {
+ BlockID blockID = ContainerTestHelper.getTestBlockID(
+ container.getContainerInfo().getContainerID());
+ ContainerCommandRequestProto smallFileRequest =
+ ContainerTestHelper.getWriteSmallFileRequest(
+ client.getPipeline(), blockID, 1024);
+ computeResults.add(
+ client.sendCommandAsync(smallFileRequest).getResponse());
}
-
- Thread.sleep(1000);
} catch (Exception ignored) {
+ } finally {
+ latch.countDown();
}
- }
-
- latch.countDown();
- });
- sendThread.start();
+ });
+ sendThread.start();
+ }
GenericTestUtils.waitFor(() -> {
// check if pending metric count is increased
- MetricsRecordBuilder metric =
- getMetrics(XceiverClientMetrics.SOURCE_NAME);
- long pendingOps = getLongCounter("PendingOps", metric);
- long pendingPutSmallFileOps =
- getLongCounter("numPendingPutSmallFile", metric);
-
- if (pendingOps > 0 && pendingPutSmallFileOps > 0) {
+ if (clientMetrics.getPendingContainerOpCountMetrics(
Review Comment:
Done. restored PendingOps > 0 && numPendingPutSmallFile > 0 via
getMetrics(SOURCE_NAME), same as the original test.
> The getSource NPE problem ([the comment in
HDDS-11646](https://issues.apache.org/jira/browse/HDDS-11646)) only appears if
this method is re-entered in the same JVM after close(), which was a side
effect of the timeout + test-flaky rerun. With the flaky timeout fixed that
path should not run, so I kept the original snapshot API. We can follow up on
the metrics unregister lifecycle separately.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]