0
votes

I am following some example to try to get the DistributedFileSystem using the following, however I found the following returns deprecated error

FileSystem fs=FileSystem.get(conf);
DistributedFileSystem hdfs = (DistributedFileSystem) fs;

Exception in thread "main" java.lang.ClassCastException: org.apache.hadoop.fs.LocalFileSystem cannot be cast to org.apache.hadoop.hdfs.DistributedFileSystem at Hadoop.File.infoNode(File.java:55) at Hadoop.Driver.main(Driver.java:8) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:498)

How to fix this?

1

1 Answers

0
votes

This is not a depreciation error

LocalFileSystem cannot be cast

Your conf object needs to be initialized with a fs.defaultFS that starts with hdfs:// instead of file://

Check out the core-site.xml file in your HADOOP_CONF_DIR to set the property