Github user dineshjoshi commented on a diff in the pull request:
https://github.com/apache/cassandra/pull/279#discussion_r225404225
--- Diff:
test/burn/org/apache/cassandra/utils/memory/LongBufferPoolTest.java ---
@@ -327,24 +373,41 @@ BufferCheck sample()
return checks.get(index);
}
-
- private int sum1toN(int n)
- {
- return (n * (n + 1)) / 2;
- }
}));
}
- boolean first = true;
while (!latch.await(10L, TimeUnit.SECONDS))
{
- if (!first)
- BufferPool.assertAllRecycled();
- first = false;
+ int stalledThreads = 0;
+ int doneThreads = 0;
+
for (AtomicBoolean progress : makingProgress)
{
- assert progress.get();
- progress.set(false);
+ if (progress.getAndSet(false) == false)
+ stalledThreads++;
+ }
+
+ for (Future<Boolean> r : ret)
+ {
+ if (r.isDone())
+ doneThreads++;
+ }
+ if (doneThreads == 0) // If any threads have completed, they
will stop making progress/recycling buffers.
+ { // Assertions failures on the threads
will be caught below.
+ assert stalledThreads == 0;
+ boolean allFreed = burnFreed.getAndSet(false);
+ for (AtomicBoolean freedMemory : freedAllMemory)
+ {
+ allFreed = allFreed && freedMemory.getAndSet(false);
+ }
+ if (allFreed)
+ {
+ BufferPool.assertAllRecycled();
+ }
+ else
+ {
--- End diff --
According to the code style, you can skip braces here.
Reference:
http://cassandra.apache.org/doc/latest/development/code_style.html
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]