Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9003649
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:44:20+00:00 2026-06-16T00:44:20+00:00

I have a dir structure: / DIR files DIR usr My HDFS is available

  • 0

I have a dir structure:

/  
   DIR files
   DIR usr

My HDFS is available at hdfs://db:123, so I create configuration:

configuration.set("fs.default.name", "hdfs://db:123");

Then all directories / paths are relative to the root (/). I created a directory files and that is where I want to keep all my files.

Do I have to manually append /files/ to the beginning of each path in my code or can I create configuration:

configuration.set("fs.default.name", "hdfs://db:123/files");

and no changes in the code will be necessary?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:44:20+00:00Added an answer on June 16, 2026 at 12:44 am

    Usually the paths you pass are either relative to the users HDFS home directory if no leading slash is passed, or absolute if prefixed with a /.

    If you look in the source for Path.makeQualified you should see a test for if the path is not absolute (this is from 1.0.3):

    /** Returns a qualified path object. */
    public Path makeQualified(FileSystem fs) {
      Path path = this;
      if (!isAbsolute()) {
        path = new Path(fs.getWorkingDirectory(), this);
      }
    

    DistributedFileSystem.getWorkingDirectory() uses a instance variable called workingDir in response, which can be set using the setWorkingDirectory(path) method. If you don’t set the working directory yourself, the default is the user’s home directory (as can be seen in the DistributedFileSystem.initialize(..) method:

    this.workingDir = getHomeDirectory();
    

    And DistributedFileSystem.getHomeDirectory():

    public Path getHomeDirectory() {
      return new Path("/user/" + dfs.ugi.getShortUserName()).makeQualified(this);
    }
    

    It doesn’t appear you can configure the working directory via a configuration property so you’re going to have to call the following before you submit your job (after which all relative paths will be relative to /files):

    FileSystem.get(configuration).setWorkingDirectory("/files");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a plain project structure: Base Dir src ;; Pile of Clojure files
Say I have this url: http://site.example/dir/ In this folder I have these files: test.ascx.cs
I have scrip contain command line: set dir=%1 cd %dir% test.bat echo successful When
In a new project I am working on I have the following dir structure:
I need to search a directory structure for all files beginning with a period
I have pom.xml with the structure like: <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>2.5</version> <configuration> <includes>
I have this dir structure for logs logs -2012 --01 ---01.php ---02.php --02 ---20.php
I have two txt files: File1.txt – contains list of src dir; and File2.txt
I want to update SVN property svn:needs-lock on all files in a directory structure
I have a subdirectory structure in my project with two cmake files. One of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.