Java Code Examples for org.apache.hadoop.io.nativeio.NativeIO#getShareDeleteFileInputStream()

The following examples show how to use org.apache.hadoop.io.nativeio.NativeIO#getShareDeleteFileInputStream() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FsDatasetImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override // FsDatasetSpi
public LengthInputStream getMetaDataInputStream(ExtendedBlock b)
    throws IOException {
  File meta = FsDatasetUtil.getMetaFile(getBlockFile(b), b.getGenerationStamp());
  if (meta == null || !meta.exists()) {
    return null;
  }
  if (isNativeIOAvailable) {
    return new LengthInputStream(
        NativeIO.getShareDeleteFileInputStream(meta),
        meta.length());
  }
  return new LengthInputStream(new FileInputStream(meta), meta.length());
}
 
Example 2
Source File: FsDatasetImpl.java    From hadoop with Apache License 2.0 5 votes vote down vote up
@Override // FsDatasetSpi
public InputStream getBlockInputStream(ExtendedBlock b,
    long seekOffset) throws IOException {
  File blockFile = getBlockFileNoExistsCheck(b, true);
  if (isNativeIOAvailable) {
    return NativeIO.getShareDeleteFileInputStream(blockFile, seekOffset);
  } else {
    try {
      return openAndSeek(blockFile, seekOffset);
    } catch (FileNotFoundException fnfe) {
      throw new IOException("Block " + b + " is not valid. " +
          "Expected block file at " + blockFile + " does not exist.");
    }
  }
}
 
Example 3
Source File: FsDatasetImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override // FsDatasetSpi
public LengthInputStream getMetaDataInputStream(ExtendedBlock b)
    throws IOException {
  File meta = FsDatasetUtil.getMetaFile(getBlockFile(b), b.getGenerationStamp());
  if (meta == null || !meta.exists()) {
    return null;
  }
  if (isNativeIOAvailable) {
    return new LengthInputStream(
        NativeIO.getShareDeleteFileInputStream(meta),
        meta.length());
  }
  return new LengthInputStream(new FileInputStream(meta), meta.length());
}
 
Example 4
Source File: FsDatasetImpl.java    From big-c with Apache License 2.0 5 votes vote down vote up
@Override // FsDatasetSpi
public InputStream getBlockInputStream(ExtendedBlock b,
    long seekOffset) throws IOException {
  File blockFile = getBlockFileNoExistsCheck(b, true);
  if (isNativeIOAvailable) {
    return NativeIO.getShareDeleteFileInputStream(blockFile, seekOffset);
  } else {
    try {
      return openAndSeek(blockFile, seekOffset);
    } catch (FileNotFoundException fnfe) {
      throw new IOException("Block " + b + " is not valid. " +
          "Expected block file at " + blockFile + " does not exist.");
    }
  }
}