apply feedback from @mikemccand

This commit is contained in:
Simon Willnauer 2015-12-14 16:09:20 +01:00
parent 6cefdc82f6
commit b0144c557c
4 changed files with 11 additions and 13 deletions

View File

@ -781,9 +781,9 @@ public class InternalEngine extends Engine {
// we need to fail the engine. it might have already been failed before
// but we are double-checking it's failed and closed
if (indexWriter.isOpen() == false && indexWriter.getTragicException() != null) {
failEngine("already closed by tragic event", indexWriter.getTragicException());
failEngine("already closed by tragic event on the index writer", indexWriter.getTragicException());
} else if (translog.isOpen() == false && translog.getTragicException() != null) {
failEngine("already closed by tragic event", translog.getTragicException());
failEngine("already closed by tragic event on the translog", translog.getTragicException());
}
return true;
} else if (t != null &&

View File

@ -128,10 +128,10 @@ public final class BufferingTranslogWriter extends TranslogWriter {
}
// we can do this outside of the write lock but we have to protect from
// concurrent syncs
ensureOpen(); // just for kicks - the checkpoint happens or not either way
try {
ensureOpen(); // just for kicks - the checkpoint happens or not either way
checkpoint(offsetToSync, opsCounter, channelReference);
} catch (IOException ex) {
} catch (Throwable ex) {
closeWithTragicEvent(ex);
throw ex;
}

View File

@ -130,12 +130,10 @@ public class TranslogWriter extends TranslogReader {
protected final void closeWithTragicEvent(Throwable throwable) throws IOException {
try (ReleasableLock lock = writeLock.acquire()) {
if (throwable != null) {
if (tragedy == null) {
tragedy = throwable;
} else {
tragedy.addSuppressed(throwable);
}
if (tragedy == null) {
tragedy = throwable;
} else {
tragedy.addSuppressed(throwable);
}
close();
}

View File

@ -1310,7 +1310,7 @@ public class TranslogTests extends ESTestCase {
super.write(src);
src.position(pos);
src.limit(limit);
throw new IOException("no space left on device");
throw new IOException("__FAKE__ no space left on device");
}
}
return super.write(src);
@ -1334,7 +1334,7 @@ public class TranslogTests extends ESTestCase {
} catch (IOException ex) {
failed = true;
assertFalse(translog.isOpen());
assertEquals("no space left on device", ex.getMessage());
assertEquals("__FAKE__ no space left on device", ex.getMessage());
}
simulateDiskFull.set(randomBoolean());
}
@ -1345,7 +1345,7 @@ public class TranslogTests extends ESTestCase {
fail("we are already closed");
} catch (AlreadyClosedException ex) {
assertNotNull(ex.getCause());
assertEquals(ex.getCause().getMessage(), "no space left on device");
assertEquals(ex.getCause().getMessage(), "__FAKE__ no space left on device");
}
}