/** * {@inheritDoc} */ @Override protected void finishWrite() throws Exception { sequenceFile.hflush(); sequenceFile.close(); super.finishWrite(); LOG.debug("Closing writer with " + counter.get() + " items"); }
/** Closes the channel and returns the bundle result. */ public final void close() throws Exception { checkState(outputFile != null, "FileResult.close cannot be called with a null outputFile"); LOG.debug("Closing {}", outputFile); try { writeFooter(); } catch (Exception e) { closeChannelAndThrow(channel, outputFile, e); } try { finishWrite(); } catch (Exception e) { closeChannelAndThrow(channel, outputFile, e); } // It is valid for a subclass to either close the channel or not. // They would typically close the channel e.g. if they are wrapping it in another channel // and the wrapper needs to be closed. if (channel.isOpen()) { LOG.debug("Closing channel to {}.", outputFile); try { channel.close(); } catch (Exception e) { throw new IOException(String.format("Failed closing channel to %s", outputFile), e); } } LOG.info("Successfully wrote temporary file {}", outputFile); }