使用Idea连接阿里云搭建的Hadoop集群
使用阿里云内网搭建集群后,尝试用Idea来进行远程连接并操作集群。具体的搭建流程可以参考我的另一篇博文:在阿里云上搭建Hadoop集群。
测试代码如下
package xyz.xingcang.hdfs;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;
import org.checkerframework.checker.units.qual.Temperature;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.PushbackReader;
import java.net.URI;
import java.net.URISyntaxException;
/**
* @author xingcang
* @create 2020-08-07 09:20
*/
public class HdfsClient {
private String user;
private Configuration configuration;
private URI uri;
private FileSystem fileSystem;
@Before
public void init() throws URISyntaxException, IOException, InterruptedException {
uri = new URI("hdfs://hadoop001:9820");
configuration = new Configuration();
configuration.set("dfs.replication", "3");
user = "xingcang";
fileSystem = Fil