1. 程式人生 > >從hdfs下載到本地出現null chmod

從hdfs下載到本地出現null chmod

1、錯誤資訊:
Exception in thread “main” java.io.IOException: (null) entry in command string: null chmod 0644 F:\hadoop_work\mygit\chapter03\code\project04\dir3
at org.apache.hadoop.util.Shell S h e l

l C o m m a n d E x e
c u t o r . e x e c u
t e ( S h e l l . j a v a : 770 ) a t o r g . a p a c h e . h a d o o p . u t i l . S h e l l . e x e c C o m m a n d ( S h e l l . j a v a : 866 ) a t o r g . a p a c h e . h a d o o p . u t i l . S h e l l . e x e c C o m m a n d ( S h e l l . j a v a : 849 ) a t o r g . a p a c h e . h a d o o p . f s . R a w L o c a l F i l e S y s t e m . s e t P e r m i s s i o n ( R a w L o c a l F i l e S y s t e m . j a v a : 733 ) a t o r g . a p a c h e . h a d o o p . f s . R a w L o c a l F i l e S y s t e m ShellCommandExecutor.execute(Shell.java:770) at org.apache.hadoop.util.Shell.execCommand(Shell.java:866) at org.apache.hadoop.util.Shell.execCommand(Shell.java:849) at org.apache.hadoop.fs.RawLocalFileSystem.setPermission(RawLocalFileSystem.java:733) at org.apache.hadoop.fs.RawLocalFileSystem LocalFSFileOutputStream.(RawLocalFileSystem.java:225)
at org.apache.hadoop.fs.RawLocalFileSystem L o c a l F S F i l e O u t p u t S t r e a m . < i n i t > ( R a w L o c a l F i l e S y s t e m . j a v a : 209 ) a t o r g . a p a c h e . h a d o o p . f s . R a w L o c a l F i l e S y s t e m . c r e a t e O u t p u t S t r e a m W i t h M o d e ( R a w L o c a l F i l e S y s t e m . j a v a : 307 ) a t o r g . a p a c h e . h a d o o p . f s . R a w L o c a l F i l e S y s t e m . c r e a t e ( R a w L o c a l F i l e S y s t e m . j a v a : 296 ) a t o r g . a p a c h e . h a d o o p . f s . R a w L o c a l F i l e S y s t e m . c r e a t e ( R a w L o c a l F i l e S y s t e m . j a v a : 328 ) a t o r g . a p a c h e . h a d o o p . f s . C h e c k s u m F i l e S y s t e m LocalFSFileOutputStream.<init>(RawLocalFileSystem.java:209) at org.apache.hadoop.fs.RawLocalFileSystem.createOutputStreamWithMode(RawLocalFileSystem.java:307) at org.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:296) at org.apache.hadoop.fs.RawLocalFileSystem.create(RawLocalFileSystem.java:328) at org.apache.hadoop.fs.ChecksumFileSystem ChecksumFSOutputSummer.(ChecksumFileSystem.java:398)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:461)
at org.apache.hadoop.fs.ChecksumFileSystem.create(ChecksumFileSystem.java:440)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:911)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:892)
at org.apache.hadoop.fs.FileSystem.create(FileSystem.java:789)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:365)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:338)
at org.apache.hadoop.fs.FileUtil.copy(FileUtil.java:289)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:2034)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:2003)
at org.apache.hadoop.fs.FileSystem.copyToLocalFile(FileSystem.java:1979)
at com.hdfs_basic.App.filedown(App.java:79)
at com.hdfs_basic.App.main(App.java:105)

2、原來的:
fs.copyToLocalFile(htfsfile, localfile);
3、解決方法:**
fs.copyToLocalFile(false,htfsfile, localfile,true);
第一個false引數表示不刪除原始檔,第4個true引數表示使用本地原檔案系統