当前位置: 首页>>代码示例>>Java>>正文


Java NativeIOException类代码示例

本文整理汇总了Java中org.apache.hadoop.io.nativeio.NativeIOException的典型用法代码示例。如果您正苦于以下问题:Java NativeIOException类的具体用法?Java NativeIOException怎么用?Java NativeIOException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


NativeIOException类属于org.apache.hadoop.io.nativeio包,在下文中一共展示了NativeIOException类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: posixFadviseIfPossible

import org.apache.hadoop.io.nativeio.NativeIOException; //导入依赖的package包/类
@Override
public void posixFadviseIfPossible(String name,
  FileDescriptor fd, long offset, long len, int flags)
      throws NativeIOException {
  if ((len < 0) || (len > Integer.MAX_VALUE)) {
    throw new RuntimeException("invalid length of " + len +
        " passed to posixFadviseIfPossible");
  }
  if ((offset < 0) || (offset > Integer.MAX_VALUE)) {
    throw new RuntimeException("invalid offset of " + offset +
        " passed to posixFadviseIfPossible");
  }
  Stats stats = map.get(name);
  if (stats == null) {
    stats = new Stats(name);
    map.put(name, stats);
  }
  stats.fadvise((int)offset, (int)len, flags);
  super.posixFadviseIfPossible(name, fd, offset, len, flags);
}
 
开发者ID:naver,项目名称:hadoop,代码行数:21,代码来源:TestCachingStrategy.java

示例2: createForWrite

import org.apache.hadoop.io.nativeio.NativeIOException; //导入依赖的package包/类
/**
 * Open the specified File for write access, ensuring that it does not exist.
 * @param f the file that we want to create
 * @param permissions we want to have on the file (if security is enabled)
 *
 * @throws AlreadyExistsException if the file already exists
 * @throws IOException if any other error occurred
 */
public static FileOutputStream createForWrite(File f, int permissions)
throws IOException {
  if (skipSecurity) {
    return insecureCreateForWrite(f, permissions);
  } else {
    // Use the native wrapper around open(2)
    try {
      FileDescriptor fd = NativeIO.open(f.getAbsolutePath(),
        NativeIO.O_WRONLY | NativeIO.O_CREAT | NativeIO.O_EXCL,
        permissions);
      return new FileOutputStream(fd);
    } catch (NativeIOException nioe) {
      if (nioe.getErrno() == Errno.EEXIST) {
        throw new AlreadyExistsException(nioe);
      }
      throw nioe;
    }
  }
}
 
开发者ID:Seagate,项目名称:hadoop-on-lustre,代码行数:28,代码来源:SecureIOUtils.java

示例3: submitSyncFileRangeRequest

import org.apache.hadoop.io.nativeio.NativeIOException; //导入依赖的package包/类
public void submitSyncFileRangeRequest(FsVolumeImpl volume,
    final FileDescriptor fd, final long offset, final long nbytes,
    final int flags) {
  execute(volume.getCurrentDir(), new Runnable() {
    @Override
    public void run() {
      try {
        NativeIO.POSIX.syncFileRangeIfPossible(fd, offset, nbytes, flags);
      } catch (NativeIOException e) {
        LOG.warn("sync_file_range error", e);
      }
    }
  });
}
 
开发者ID:naver,项目名称:hadoop,代码行数:15,代码来源:FsDatasetAsyncDiskService.java

示例4: rename

import org.apache.hadoop.io.nativeio.NativeIOException; //导入依赖的package包/类
public static void rename(File from, File to) throws IOException {
  try {
    NativeIO.renameTo(from, to);
  } catch (NativeIOException e) {
    throw new IOException("Failed to rename " + from.getCanonicalPath()
      + " to " + to.getCanonicalPath() + " due to failure in native rename. "
      + e.toString());
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:10,代码来源:Storage.java

示例5: close

import org.apache.hadoop.io.nativeio.NativeIOException; //导入依赖的package包/类
@Override
public void close() throws IOException {
  boolean triedToClose = false, success = false;
  try {
    flush();
    ((FileOutputStream)out).getChannel().force(true);

    triedToClose = true;
    super.close();
    success = true;
  } finally {
    if (success) {
      boolean renamed = tmpFile.renameTo(origFile);
      if (!renamed) {
        // On windows, renameTo does not replace.
        if (origFile.exists() && !origFile.delete()) {
          throw new IOException("Could not delete original file " + origFile);
        }
        try {
          NativeIO.renameTo(tmpFile, origFile);
        } catch (NativeIOException e) {
          throw new IOException("Could not rename temporary file " + tmpFile
            + " to " + origFile + " due to failure in native rename. "
            + e.toString());
        }
      }
    } else {
      if (!triedToClose) {
        // If we failed when flushing, try to close it to not leak an FD
        IOUtils.closeStream(out);
      }
      // close wasn't successful, try to delete the tmp file
      if (!tmpFile.delete()) {
        LOG.warn("Unable to delete tmp file " + tmpFile);
      }
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:39,代码来源:AtomicFileOutputStream.java

示例6: posixFadviseIfPossible

import org.apache.hadoop.io.nativeio.NativeIOException; //导入依赖的package包/类
public void posixFadviseIfPossible(long offset, long len, int flags,
    boolean sync) throws NativeIOException {
  if (fd != null) {
    if (sync) {
      NativeIO.posixFadviseIfPossible(fd, offset, len, flags);
    } else {
      volume.submitNativeIOTask(new PosixFadviseRunnable(fd, offset, len,
            flags, this));
    }
  } else if (file != null) {
    DataNode.LOG.warn("Failed to fadvise as file " + file
        + " is missing file descriptor");
  }
}
 
开发者ID:rhli,项目名称:hadoop-EAR,代码行数:15,代码来源:BlockDataFile.java

示例7: createTaskAsUser0

import org.apache.hadoop.io.nativeio.NativeIOException; //导入依赖的package包/类
private static native WinutilsProcessStub createTaskAsUser0(
String cwd, String jobName, String user, String pidFile, String cmdLine)
throws NativeIOException;
 
开发者ID:naver,项目名称:hadoop,代码行数:4,代码来源:WindowsSecureContainerExecutor.java

示例8: resume

import org.apache.hadoop.io.nativeio.NativeIOException; //导入依赖的package包/类
public native void resume() throws NativeIOException; 
开发者ID:naver,项目名称:hadoop,代码行数:2,代码来源:WindowsSecureContainerExecutor.java


注:本文中的org.apache.hadoop.io.nativeio.NativeIOException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。