zoukankan      html  css  js  c++  java
  • hdfs的相关api

    连接hdfs

    根据hdfs的版本引用相关的hdfs依赖

            <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-client -->
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-client</artifactId>
                <version>2.6.5</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-common -->
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-common</artifactId>
                <version>2.6.5</version>
            </dependency>
            <!-- https://mvnrepository.com/artifact/org.apache.hadoop/hadoop-hdfs -->
            <dependency>
                <groupId>org.apache.hadoop</groupId>
                <artifactId>hadoop-hdfs</artifactId>
                <version>2.6.5</version>
            </dependency>
    

    将hdfs中的core-site.xmlhdfs-site.xml放进项目的resources目录里

    简单编码测试下

    public class Connection {
        public static void main(String[] args) throws IOException, URISyntaxException, InterruptedException {
            Configuration configuration=new Configuration();
            System.setProperty("HADOOP_USER_NAME", "root");
            FileSystem fs = FileSystem.get(configuration);
            System.out.println(fs.getHomeDirectory());
            //拿到FileSystem后可以简单操作下hdfs,若是运行成功则代表连接成功!
        }
    
    
    }
    
  • 相关阅读:
    贫血模型和充血模型
    DES加密解密
    DDD讀書筆記(四)
    HTTP Caching
    ASP.NET 取得 Request URL 的各个部分和通过ASP.NET获取URL地址的方法
    datalist用aspnetpager分页
    visual studio.net 快捷键[转]
    DataList分页方法
    C#连接各类数据库 [转]
    C#日期函数[转]
  • 原文地址:https://www.cnblogs.com/shouyaya/p/14130657.html
Copyright © 2011-2022 走看看