shuan1026 commented on code in PR #11029:
URL: https://github.com/apache/ozone/pull/11029#discussion_r3795320732
##########
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) {
Review Comment:
Done. the first sender exception is kept in an AtomicReference.
--
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]