在本地调试连接hdfs进行写文件操作,连接异常。
java.io.IOException: Failed on local exception: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.; Host Details : local host is: “Gore-PC/10.108.66.211”; destination host is: “10.108.66.81”:9000;
Caused by: com.google.protobuf.InvalidProtocolBufferException: Protocol message end-group tag did not match expected tag.
public static void main(String[] args) throws IOException {
System.setProperty("hadoop.home.dir", "d:/hadoop-common-2.2.0-bin/");
// 将本地文件上传到hdfs。
String target = "hdfs://10.94.1.104:9000/home/history/sample.csv";
FileInputStream fis = new FileInputStream(new File("D:\\home\\table.csv"));// 读取本地文件
Configuration config = new Configuration();
FileSystem fs = FileSystem.get(URI.create(target), config);