@Override public void committed(long l) { try { long bytesOutstanding = highestSentOffset - l; if (fSize - bytesOutstanding > COMPACT_AT) { fSize = 0; outToDisk.close(); File outBufTmp = new File(outBuf.getAbsoluteFile(), outBuf.getName() + ".tmp"); if (!outBuf.renameTo(outBufTmp)) { log.warn( "Cannot rename temp file " + outBuf.getAbsolutePath() + " to " + outBufTmp.getAbsolutePath()); } ; outToDisk = new DataOutputStream(new FileOutputStream(outBuf, false)); DataInputStream dis = new DataInputStream(new FileInputStream(outBufTmp)); while (dis.available() > 0) { Chunk c = ChunkImpl.read(dis); if (c.getSeqID() > l) { // not yet committed c.write(outToDisk); fSize += c.getData().length; } } dis.close(); if (!outBufTmp.delete()) { log.warn("Can not delete temp file: " + outBufTmp.getAbsolutePath()); } ; } } catch (IOException e) { log.error(e); // should this be fatal? } }