private EditLogOutputStream invalidateEditsDirAtIndex(int index)
throws IOException {
FSImage fsimage = cluster.getNameNode(0).avatars.get(0).avatar.getFSImage();
FSEditLog editLog = fsimage.getEditLog();
JournalAndStream jas = editLog.getJournals().get(index);
EditLogFileOutputStream elos = (EditLogFileOutputStream) jas
.getCurrentStream();
EditLogFileOutputStream spyElos = spy(elos);
doThrow(new IOException("fail on write()")).when(spyElos).write(
(FSEditLogOp) any());
doThrow(new IOException("fail on write()")).when(spyElos).writeRaw(
(byte[]) any(), anyInt(), anyInt());
doThrow(new IOException("fail on write()")).when(spyElos).writeRawOp(
(byte[]) any(), anyInt(), anyInt(), anyLong());
doNothing().when(spyElos).abort();
jas.setCurrentStreamForTests(spyElos);
return elos;
}