Skip to content

Commit

Permalink
[FLINK-1930] [runtime] Improve exception when bufferpools have been s…
Browse files Browse the repository at this point in the history
…hut down.
  • Loading branch information
StephanEwen committed Apr 23, 2015
1 parent 4672e95 commit 4dbf030
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private Buffer requestBuffer(boolean isBlocking) throws InterruptedException, IO

while (availableMemorySegments.isEmpty()) {
if (isDestroyed) {
return null;
throw new IllegalStateException("Buffer pool is destroyed.");
}

if (numberOfRequestedMemorySegments < currentPoolSize) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ public void testRequestMoreThanAvailable() throws IOException {
public void testRequestAfterDestroy() throws IOException {
localBufferPool.lazyDestroy();

assertNull(localBufferPool.requestBuffer());
try {
localBufferPool.requestBuffer();
fail("Call should have failed with an IllegalStateException");
}
catch (IllegalStateException e) {
// we expect exactly that
}
}

@Test
Expand Down Expand Up @@ -292,7 +298,13 @@ public List<Buffer> call() throws Exception {

// Try to request the next buffer (but pool should be destroyed either right before
// the request or more likely during the request).
assertNull(localBufferPool.requestBufferBlocking());
try {
localBufferPool.requestBufferBlocking();
fail("Call should have failed with an IllegalStateException");
}
catch (IllegalStateException e) {
// we expect exactly that
}

return requested;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,21 @@ public void testDestroyAll() {
assertEquals(globalPool.getTotalNumberOfMemorySegments(), globalPool.getNumberOfAvailableMemorySegments());

// can request no more buffers
assertNull(fixedPool.requestBuffer());
assertNull(nonFixedPool.requestBuffer());
try {
fixedPool.requestBuffer();
fail("Should fail with an IllegalStateException");
}
catch (IllegalStateException e) {
// that's the way we like it, aha, aha
}

try {
nonFixedPool.requestBuffer();
fail("Should fail with an IllegalStateException");
}
catch (IllegalStateException e) {
// stayin' alive
}

// can create a new pool now
assertNotNull(globalPool.createBufferPool(10, false));
Expand Down

0 comments on commit 4dbf030

Please sign in to comment.