@Override public short getDefaultReplication(FileSystem fs, Path path) { return fs.getDefaultReplication(path); }
@SuppressWarnings("deprecation") @Override public short getDefaultReplication() { return fs.getDefaultReplication(); }
/** * Get the default replication for a path. * The given path will be used to locate the actual FileSystem to query. * The full path does not have to exist. * @param path of the file * @return default replication for the path's filesystem */ public short getDefaultReplication(Path path) { return getDefaultReplication(); }
@Override public short getDefaultReplication(Path f) { return fs.getDefaultReplication(f); }
@Override public short getDefaultReplication(Path f) { return fs.getDefaultReplication(f); }
@Override public short getDefaultReplication() { return fs.getDefaultReplication(); }
public short getDefaultReplication() { return this.underlyingFs.getDefaultReplication(); }
public int getFsDesiredReplication() { short replication = 0; if (fs != null && destPath != null) { if (refGetDefaultReplication != null) { try { replication = (Short) refGetDefaultReplication.invoke(fs, destPath); } catch (IllegalAccessException e) { logger.warn("Unexpected error calling getDefaultReplication(Path)", e); } catch (InvocationTargetException e) { logger.warn("Unexpected error calling getDefaultReplication(Path)", e); } } else { // will not work on Federated HDFS (see HADOOP-8014) replication = fs.getDefaultReplication(); } } return replication; }
/** * Gets the desired number of replicas to store for each block of the file. * * @return The replication factor for the blocks of the file. */ public short getReplicationFactor() { if (DEFAULT == mReplicationFactor) { return getFileSystem().getDefaultReplication(); } return mReplicationFactor; }
/** * Serialize a {@link State} instance to a file. * * @param fs the {@link FileSystem} instance for creating the file * @param jobStateFilePath the path to the file * @param state the {@link State} to serialize * @param <T> the {@link State} object type * @throws IOException if it fails to serialize the {@link State} instance */ public static <T extends State> void serializeState(FileSystem fs, Path jobStateFilePath, T state) throws IOException { serializeState(fs, jobStateFilePath, state, fs.getDefaultReplication(jobStateFilePath)); }
public short getDefaultReplication(Path path) { return this.underlyingFs.getDefaultReplication(replaceScheme(path, this.replacementScheme, this.underlyingScheme)); }
/** * Constructor. */ protected FSDataOutputStreamBuilder(@Nonnull FileSystem fileSystem, @Nonnull Path p) { Preconditions.checkNotNull(fileSystem); Preconditions.checkNotNull(p); fs = fileSystem; path = p; bufferSize = fs.getConf().getInt(IO_FILE_BUFFER_SIZE_KEY, IO_FILE_BUFFER_SIZE_DEFAULT); replication = fs.getDefaultReplication(path); blockSize = fs.getDefaultBlockSize(p); }
/** * Create an FSDataOutputStream at the indicated Path. * @param f the file to create * @param overwrite if a file with this name already exists, then if true, * the file will be overwritten, and if false an exception will be thrown. * @throws IOException IO failure */ public FSDataOutputStream create(Path f, boolean overwrite) throws IOException { return create(f, overwrite, getConf().getInt(IO_FILE_BUFFER_SIZE_KEY, IO_FILE_BUFFER_SIZE_DEFAULT), getDefaultReplication(f), getDefaultBlockSize(f)); }
/** * Create an FSDataOutputStream at the indicated Path with write-progress * reporting. * Files are overwritten by default. * @param f the file to create * @param progress to report progress * @throws IOException IO failure */ public FSDataOutputStream create(Path f, Progressable progress) throws IOException { return create(f, true, getConf().getInt(IO_FILE_BUFFER_SIZE_KEY, IO_FILE_BUFFER_SIZE_DEFAULT), getDefaultReplication(f), getDefaultBlockSize(f), progress); }
/** * Create an FSDataOutputStream at the indicated Path. * @param f the file to create * @param overwrite if a path with this name already exists, then if true, * the file will be overwritten, and if false an error will be thrown. * @param bufferSize the size of the buffer to be used. * @throws IOException IO failure */ public FSDataOutputStream create(Path f, boolean overwrite, int bufferSize ) throws IOException { return create(f, overwrite, bufferSize, getDefaultReplication(f), getDefaultBlockSize(f)); }
@Override public short getDefaultReplication(Path f) { try { InodeTree.ResolveResult<FileSystem> res = fsState.resolve(getUriPath(f), true); return res.targetFileSystem.getDefaultReplication(res.remainingPath); } catch (FileNotFoundException e) { throw new NotInMountpointException(f, "getDefaultReplication"); } }
/** * @return desired replication for destination file. */ public short getReplication(FileSystem targetFs) { return getPreserve().preserve(PreserveAttributes.Option.REPLICATION) ? getOrigin().getReplication() : targetFs.getDefaultReplication(this.destination); }
/** @throws Exception If failed. */ @SuppressWarnings("deprecation") @Test public void testSetPermissionCheckNonRecursiveness() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); FSDataOutputStream os = fs.create(file, FsPermission.getDefault(), false, 64 * 1024, fs.getDefaultReplication(), fs.getDefaultBlockSize(), null); os.close(); Path tmpDir = new Path(fsHome, "/tmp"); FsPermission perm = new FsPermission((short)123); fs.setPermission(tmpDir, perm); assertEquals(perm, fs.getFileStatus(tmpDir).getPermission()); assertEquals(FsPermission.getDefault(), fs.getFileStatus(file).getPermission()); }
/** @throws Exception If failed. */ @SuppressWarnings("deprecation") @Test public void testSetPermissionCheckDefaultPermission() throws Exception { Path fsHome = new Path(primaryFsUri); Path file = new Path(fsHome, "/tmp/my"); FSDataOutputStream os = fs.create(file, FsPermission.getDefault(), false, 64 * 1024, fs.getDefaultReplication(), fs.getDefaultBlockSize(), null); os.close(); fs.setPermission(file, null); assertEquals(FsPermission.getDefault(), fs.getFileStatus(file).getPermission()); assertEquals(FsPermission.getDefault(), fs.getFileStatus(file.getParent()).getPermission()); }
@Test public void test() throws IOException, InterruptedException, ExecutionException, FSUtils.StreamLacksCapabilityException { Path f = new Path(TEST_UTIL.getDataTestDir(), "test"); FileSystem fs = FileSystem.getLocal(TEST_UTIL.getConfiguration()); AsyncFSOutput out = AsyncFSOutputHelper.createOutput(fs, f, false, true, fs.getDefaultReplication(f), fs.getDefaultBlockSize(f), GROUP, CHANNEL_CLASS); TestFanOutOneBlockAsyncDFSOutput.writeAndVerify(fs, f, out); } }