jiwq commented on a change in pull request #826: HDDS-1517. AllocateBlock call fails with ContainerNotFoundException. URL: https://github.com/apache/hadoop/pull/826#discussion_r284762022
########## File path: hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/container/TestSCMContainerManager.java ########## @@ -144,6 +145,41 @@ public void testallocateContainerDistributesAllocation() throws Exception { Assert.assertTrue(pipelineList.size() > 5); } + @Test + public void testAllocateContainerInParallel() throws Exception { + int threadCount = 20; + List<ExecutorService> executors = new ArrayList<>(threadCount); + for (int i = 0; i < threadCount; i++) { + executors.add(Executors.newSingleThreadExecutor()); + } + List<CompletableFuture<ContainerInfo>> futureList = + new ArrayList<>(threadCount); + for (int i = 0; i < threadCount; i++) { + final CompletableFuture<ContainerInfo> future = + new CompletableFuture<>(); + CompletableFuture.supplyAsync(() -> { + try { + ContainerInfo containerInfo = containerManager + .allocateContainer(xceiverClientManager.getType(), + xceiverClientManager.getFactor(), containerOwner); + + Assert.assertNotNull(containerInfo); + Assert.assertNotNull(containerInfo.getPipelineID()); + future.complete(containerInfo); + return containerInfo; + } catch (IOException e) { + future.completeExceptionally(e); + } return future; + }, executors.get(i)); futureList.add(future); + } + try { + CompletableFuture + .allOf(futureList.toArray(new CompletableFuture[futureList.size()])) + .get(); + } catch (Exception e) { + Assert.fail("testAllocateBlockInParallel failed"); + } + } Review comment: Need a blank line between two methods. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services --------------------------------------------------------------------- To unsubscribe, e-mail: common-issues-unsubscr...@hadoop.apache.org For additional commands, e-mail: common-issues-h...@hadoop.apache.org