Java Code Examples for org.apache.hadoop.hbase.util.FSUtils#create()

The following examples show how to use org.apache.hadoop.hbase.util.FSUtils#create() . 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: BackupUtils.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Write the .regioninfo file on-disk.
 */
public static void writeRegioninfoOnFilesystem(final Configuration conf, final FileSystem fs,
    final Path regionInfoDir, RegionInfo regionInfo) throws IOException {
  final byte[] content = RegionInfo.toDelimitedByteArray(regionInfo);
  Path regionInfoFile = new Path(regionInfoDir, "." + HConstants.REGIONINFO_QUALIFIER_STR);
  // First check to get the permissions
  FsPermission perms = CommonFSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY);
  // Write the RegionInfo file content
  FSDataOutputStream out = FSUtils.create(conf, fs, regionInfoFile, perms, null);
  try {
    out.write(content);
  } finally {
    out.close();
  }
}
 
Example 2
Source File: HRegionFileSystem.java    From hbase with Apache License 2.0 5 votes vote down vote up
/**
 * Write the .regioninfo file on-disk.
 * <p/>
 * Overwrites if exists already.
 */
private static void writeRegionInfoFileContent(final Configuration conf, final FileSystem fs,
  final Path regionInfoFile, final byte[] content) throws IOException {
  // First check to get the permissions
  FsPermission perms = CommonFSUtils.getFilePermissions(fs, conf, HConstants.DATA_FILE_UMASK_KEY);
  // Write the RegionInfo file content
  try (FSDataOutputStream out = FSUtils.create(conf, fs, regionInfoFile, perms, null)) {
    out.write(content);
  }
}
 
Example 3
Source File: HFileWriterImpl.java    From hbase with Apache License 2.0 5 votes vote down vote up
/** A helper method to create HFile output streams in constructors */
protected static FSDataOutputStream createOutputStream(Configuration conf,
    FileSystem fs, Path path, InetSocketAddress[] favoredNodes) throws IOException {
  FsPermission perms = CommonFSUtils.getFilePermissions(fs, conf,
      HConstants.DATA_FILE_UMASK_KEY);
  return FSUtils.create(conf, fs, path, perms, favoredNodes);
}