public Writer create() throws IOException { if ((path != null ? 1 : 0) + (ostream != null ? 1 : 0) != 1) { throw new AssertionError("Please specify exactly one of " + "filesystem/path or path"); } if (path != null) { ostream = HFileWriterImpl.createOutputStream(conf, fs, path, favoredNodes); try { ostream.setDropBehind(shouldDropBehind && cacheConf.shouldDropBehindCompaction()); } catch (UnsupportedOperationException uoe) { LOG.trace("Unable to set drop behind on {}", path, uoe); LOG.debug("Unable to set drop behind on {}", path.getName()); } } return new HFileWriterImpl(conf, cacheConf, path, ostream, comparator, fileContext); } }
@Override public void setDropBehind(Boolean dropBehind) throws IOException { try { underlyingOS.setDropBehind(dropBehind); } catch(FSError e) { throw propagateFSError(e); } } }
static void createHdfsFile(FileSystem fs, Path p, long length, Boolean dropBehind) throws Exception { FSDataOutputStream fos = null; try { // create file with replication factor of 1 fos = fs.create(p, (short)1); if (dropBehind != null) { fos.setDropBehind(dropBehind); } byte buf[] = new byte[8196]; while (length > 0) { int amt = (length > buf.length) ? buf.length : (int)length; fos.write(buf, 0, amt); length -= amt; } } catch (IOException e) { LOG.error("ioexception", e); } finally { if (fos != null) { fos.close(); } } }
public Writer create() throws IOException { if ((path != null ? 1 : 0) + (ostream != null ? 1 : 0) != 1) { throw new AssertionError("Please specify exactly one of " + "filesystem/path or path"); } if (path != null) { ostream = AbstractHFileWriter.createOutputStream(conf, fs, path, favoredNodes); try { ostream.setDropBehind(shouldDropBehind && cacheConf.shouldDropBehindCompaction()); } catch (UnsupportedOperationException uoe) { if (LOG.isTraceEnabled()) LOG.trace("Unable to set drop behind on " + path, uoe); else if (LOG.isDebugEnabled()) LOG.debug("Unable to set drop behind on " + path); } } return createWriter(fs, path, ostream, comparator, fileContext); }