adelapena commented on a change in pull request #1110:
URL: https://github.com/apache/cassandra/pull/1110#discussion_r672205210
##########
File path: test/unit/org/apache/cassandra/service/reads/DigestResolverTest.java
##########
@@ -78,6 +80,70 @@ public void noRepairNeeded()
assertPartitionsEqual(filter(iter(response)), resolver.getData());
}
+ @Test
+ public void multiThreadedNoRepairNeededReadCallback() throws
InterruptedException
+ {
+ SinglePartitionReadCommand command =
SinglePartitionReadCommand.fullPartitionRead(cfm, nowInSec, dk);
+ EndpointsForToken targetReplicas = EndpointsForToken.of(dk.getToken(),
full(EP1), full(EP2));
+ PartitionUpdate response = update(row(1000, 4, 4), row(1000, 5,
5)).build();
+ ReplicaPlan.SharedForTokenRead plan = plan(ConsistencyLevel.ONE,
targetReplicas);
+
+ ExecutorService pool = Executors.newFixedThreadPool(4);
+ long endTime = System.nanoTime() + TimeUnit.MINUTES.toNanos(2);
+
+ try
+ {
+ while (System.nanoTime() < endTime)
+ {
+ final long startNanos = System.nanoTime();
+ final DigestResolver<EndpointsForToken,
ReplicaPlan.ForTokenRead> resolver = new DigestResolver<>(command, plan,
startNanos);
+ final ReadCallback<EndpointsForToken,
ReplicaPlan.ForTokenRead> callback = new ReadCallback<>(resolver, command,
plan, startNanos);
+
+ final CountDownLatch startlatch = new CountDownLatch(2);
+
+ pool.execute(() ->
+ {
+ startlatch.countDown();
+
+ try
+ {
+ startlatch.await();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+
+ callback.onResponse(response(command, EP1,
iter(response), true));
+ });
+
+ pool.execute(() ->
+ {
+ startlatch.countDown();
+
+ try
+ {
+ startlatch.await();
+ }
+ catch (InterruptedException e)
+ {
+ Thread.currentThread().interrupt();
+ }
+
+ callback.onResponse(response(command, EP2,
iter(response), true));
+ });
+
+ callback.awaitResults();
+ Assert.assertTrue(resolver.isDataPresent());
+ resolver.responsesMatch();
Review comment:
Perhaps we can put this inside an `assertTrue`, just in case.
--
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]