/// <exception cref="System.IO.IOException"/> public override void Close() { if (fp == null) { throw new IOException("Trying to use aborted output stream"); } try { // close should have been called after all pending transactions // have been flushed & synced. // if already closed, just skip if (doubleBuf != null) { doubleBuf.Close(); doubleBuf = null; } // remove any preallocated padding bytes from the transaction log. if (fc != null && fc.IsOpen()) { fc.Truncate(fc.Position()); fc.Close(); fc = null; } fp.Close(); fp = null; } finally { IOUtils.Cleanup(Log, fc, fp); doubleBuf = null; fc = null; fp = null; } fp = null; }
/// <exception cref="System.IO.IOException"/> public override void Close() { // EditLogOutputStream // close should have been called after all pending transactions // have been flushed & synced. int size = doubleBuf.CountBufferedBytes(); if (size != 0) { throw new IOException("BackupEditStream has " + size + " records still to be flushed and cannot be closed." ); } RPC.StopProxy(backupNode); // stop the RPC threads doubleBuf.Close(); doubleBuf = null; }
public virtual void ShouldFailToCloseWhenUnflushed() { EditsDoubleBuffer buf = new EditsDoubleBuffer(1024); buf.WriteRaw(new byte[1], 0, 1); try { buf.Close(); NUnit.Framework.Assert.Fail("Did not fail to close with unflushed data"); } catch (IOException ioe) { if (!ioe.ToString().Contains("still to be flushed")) { throw; } } }