Hadoop Create/Delete folder error

Source: Internet
Author: User

Log4j:warn No Appenders could is found for logger (org.apache.hadoop.metrics2.lib.MutableMetricsFactory).
Log4j:warn Initialize the log4j system properly.
Log4j:warn See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.IllegalArgumentException: wrong Fs:hdfs://sandbox.hortonworks.com:8020/user /testdir, expected:file:///
At Org.apache.hadoop.fs.FileSystem.checkPath (filesystem.java:645)
At Org.apache.hadoop.fs.RawLocalFileSystem.pathToFile (rawlocalfilesystem.java:80)
At Org.apache.hadoop.fs.RawLocalFileSystem.mkdirs (rawlocalfilesystem.java:423)
At Org.apache.hadoop.fs.ChecksumFileSystem.mkdirs (checksumfilesystem.java:590)
At Com.hdfs.directory.CreateDir.main (createdir.java:19)
Running on this machine will cause the above error to be changed to the following code:

 Packagecom.hdfs.directory;Importjava.io.IOException;Importorg.apache.hadoop.conf.Configuration;ImportOrg.apache.hadoop.fs.FileSystem;ImportOrg.apache.hadoop.fs.Path; Public classCreatedir {/**     * @paramargs *@throwsIOException*/     Public Static voidMain (string[] args)throwsIOException {//TODO auto-generated Method StubConfiguration conf=NewConfiguration (); Path NewPath=NewPath ("Hdfs://sandbox.hortonworks.com:8020/user/testdir"); //FileSystem fs=filesystem.get (conf);FileSystem fs =newpath.getfilesystem (conf);        Fs.mkdirs (NewPath); Fs.close ();//filestatus Filestatus=fs.getfilestatus (New Path ("/user/long1657/20130908"));            }}

or Hadoop-related configuration information, placed in the project directory:

After executing the above code: the/user/testdir directory was successfully deleted:

After you add a Hadoop-related configuration file to your project, you can create the folder successfully with the following code:

 Packagecom.hdfs.directory;Importjava.io.IOException;Importorg.apache.hadoop.conf.Configuration;ImportOrg.apache.hadoop.fs.FileSystem;ImportOrg.apache.hadoop.fs.Path; Public classcreatedirwithconf {/**     * @paramargs *@throwsIOException*/     Public Static voidMain (string[] args)throwsIOException {//TODO auto-generated Method StubConfiguration conf=NewConfiguration (); FileSystem FS=filesystem.get (conf); Fs.mkdirs (NewPath ("Hdfs://sandbox.hortonworks.com:8020/user/testdir")); Fs.close ();//filestatus Filestatus=fs.getfilestatus (New Path ("/user/long1657/20130908"));            }}

Hadoop Create/Delete folder error

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.