mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 01:04:29 +00:00
Shared concurrent raster builds
- Made concurrent demands for one chunk wait for a single water raster build - Added a test that a second demand reuses the build already running
This commit is contained in:
1 parent
1899de7f3d
commit
0d148c69b5
2 files changed
+67
-1
No files matched your search
+28
@@ -215,6 +215,34 @@ public class HydrologyRuntimeTest {
|
||||
assertEquals(planned + 1L, runtime.previewRevision());
|
||||
}
|
||||
|
||||
@Test(timeout = 180_000L)
|
||||
public void concurrentDemandsShareOneRasterBuild() throws Exception {
|
||||
FakePlanners planners = new FakePlanners(settings(0, false));
|
||||
HydrologyRuntime runtime = runtime(planners, () -> false);
|
||||
runtime.prepareWindowsAround(0, 0, 0, 0, 1).get(TIMEOUT_SECONDS, TimeUnit.SECONDS);
|
||||
CountDownLatch gate = new CountDownLatch(1);
|
||||
planners.naturalGate = gate;
|
||||
AtomicReference<ChunkWaterRaster> first = new AtomicReference<>();
|
||||
AtomicReference<ChunkWaterRaster> second = new AtomicReference<>();
|
||||
Thread leader = new Thread(() -> first.set(runtime.raster(0, 0)));
|
||||
Thread follower = new Thread(() -> second.set(runtime.raster(0, 0)));
|
||||
try {
|
||||
leader.start();
|
||||
await(() -> planners.naturalSamples.get() > 0, "the first demand starts sampling");
|
||||
follower.start();
|
||||
await(() -> follower.getState() == Thread.State.WAITING || follower.getState() == Thread.State.TIMED_WAITING,
|
||||
"the second demand waits");
|
||||
assertEquals(0, planners.naturalSamplesOn(follower));
|
||||
} finally {
|
||||
gate.countDown();
|
||||
leader.join(TimeUnit.SECONDS.toMillis(TIMEOUT_SECONDS));
|
||||
follower.join(TimeUnit.SECONDS.toMillis(TIMEOUT_SECONDS));
|
||||
}
|
||||
assertFalse(first.get().provisional());
|
||||
assertSame(first.get(), second.get());
|
||||
assertEquals(0, planners.naturalSamplesOn(follower));
|
||||
}
|
||||
|
||||
@Test(timeout = 180_000L)
|
||||
public void failedRasterDoesNotAdvancePreviewRevision() throws Exception {
|
||||
FakePlanners planners = new FakePlanners(settings(0, false));
|
||||
|
||||
Reference in new issue
Block a user