boolean deleteSource = false;
boolean overwrite = true;
boolean returnValue = false;
Configuration hdfsconf = new Configuration();
hdfsconf.addResource(new Path("/usr/local/hadoop/conf/core-site.xml"));
FileSystem hdfs = FileSystem.get(hdfsconf);
Configuration localconf = new Configuration();
//Copy the index files to HDFS
FileSystem.getLocal(localconf).setVerifyChecksum(true);
returnValue = FileUtil.copy(FileSystem.getLocal(localconf),
solrDataDir, hdfs, hdfsDataDir, deleteSource, overwrite,
hdfsconf);
System.out.println("Upload all index files in local Solr dir to "
+ hdfsconf.get("fs.default.name"));
在执行以上代码时报错,在上传的文件中有一文件(segment.gen)的校验码出错,无法完成上传。
打开要上传的本地目录,使用ls -all查看隐藏文件,发现有隐藏的crc文件,无法上传的segment.gen也有对应的crc文件。