@Override public void flush() { Preconditions.checkState( state.equals(ReaderWriterState.OPEN), "Attempt to write to a writer in state:%s", state); logger.debug("Flushing all cached writers for view:{}", view); /* * There's a potential for flushing entries that are created by other * threads while looping through the writers. While normally just wasteful, * on HDFS, this is particularly bad. We should probably do something about * this, but it will be difficult as Cache (ideally) uses multiple * partitions to prevent cached writer contention. */ for (DatasetWriter<E> writer : cachedWriters.asMap().values()) { logger.debug("Flushing partition writer:{}", writer); writer.flush(); } }