org.apache.hadoop.io.IOUtils#writeFully ( )源码实例Demo

下面列出了org.apache.hadoop.io.IOUtils#writeFully ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: hadoop   文件: EditLogFileOutputStream.java
private void preallocate() throws IOException {
  long position = fc.position();
  long size = fc.size();
  int bufSize = doubleBuf.getReadyBuf().getLength();
  long need = bufSize - (size - position);
  if (need <= 0) {
    return;
  }
  long oldSize = size;
  long total = 0;
  long fillCapacity = fill.capacity();
  while (need > 0) {
    fill.position(0);
    IOUtils.writeFully(fc, fill, size);
    need -= fillCapacity;
    size += fillCapacity;
    total += fillCapacity;
  }
  if(LOG.isDebugEnabled()) {
    LOG.debug("Preallocated " + total + " bytes at the end of " +
    		"the edit log (offset " + oldSize + ")");
  }
}
 
源代码2 项目: big-c   文件: EditLogFileOutputStream.java
private void preallocate() throws IOException {
  long position = fc.position();
  long size = fc.size();
  int bufSize = doubleBuf.getReadyBuf().getLength();
  long need = bufSize - (size - position);
  if (need <= 0) {
    return;
  }
  long oldSize = size;
  long total = 0;
  long fillCapacity = fill.capacity();
  while (need > 0) {
    fill.position(0);
    IOUtils.writeFully(fc, fill, size);
    need -= fillCapacity;
    size += fillCapacity;
    total += fillCapacity;
  }
  if(LOG.isDebugEnabled()) {
    LOG.debug("Preallocated " + total + " bytes at the end of " +
    		"the edit log (offset " + oldSize + ")");
  }
}
 
源代码3 项目: hadoop   文件: BestEffortLongFile.java
public void set(long newVal) throws IOException {
  lazyOpen();
  buf.clear();
  buf.putLong(newVal);
  buf.flip();
  IOUtils.writeFully(ch, buf, 0);
  value = newVal;
}
 
源代码4 项目: big-c   文件: BestEffortLongFile.java
public void set(long newVal) throws IOException {
  lazyOpen();
  buf.clear();
  buf.putLong(newVal);
  buf.flip();
  IOUtils.writeFully(ch, buf, 0);
  value = newVal;
}