一、搭建Hadoop 开发环境

  我们在工作中写完的各种代码是在服务器中运行的,HDFS 的操作代码也不例外。在开发阶段,我们使用windows 下的eclipse 作为开发环境,访问运行在虚拟机中的HDFS。也就是通过在本地的eclipse 中的java 代码访问远程linux 中的hdfs。
要使用宿主机中的java 代码访问客户机中的hdfs,需要保证以下几点:
(1)确保宿主机与客户机的网络是互通的
(2)确保宿主机和客户机的防火墙都关闭,因为很多端口需要通过,为了减少防火墙配置,直接关闭.
(3)确保宿主机与客户机使用的jdk 版本一致。如果客户机为jdk6,宿主机为jdk7,那么代码运行时会报不支持的版本的错误。
(4)宿主机的登录用户名必须与客户机的用户名一直。比如我们linux 使用的是root 用户,那么windows 也要使用root 用户,否则会报权限异常
 在eclipse 项目中覆盖hadoop 的org.apache.hadoop.fs.FileUtil 类的checkReturnValue 方法,如图1.1,目的是为了避免权限错误。

aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAxoAAADsCAIAAAB8AUecAAAgAElEQVR4nO2d348c15Xfe/+Afd43A37bFxubeJ3Nznp7AvCFRl4WAebJgHoRkoNYIWFvQqxpWKNWHI5X3niTppxxxjBFG9iQ7GACC+BIQ8XrHZnelrWWNRBJj0eCCGvYlkhJPSJFkSY5JGVVHurXuT+ruqt/VDU/HxwQ3berb906dafvl+eeurfWvXoHwzAMwzAMG9hqZtHaj1/BMAzDMAzDpOWVU+HRF7s3ML8FQRD6KoCBoKdhGIZhlTOPqKpJLTXxhlbCQjUwaUEyDdDlMAzDsMqZVVHV0FID+HHSOmR6oONhGIZhlTNTUSGn+rOA0NRQoeNhGIZhlTO7nFr78SsXLt/A8hhaaujQ/TAMwzDTJq6ZErM2T1NUyKn+DDk1dOh+GIZhmMW6pTFb8/qQU2f+9o+sNnkXT86scsrlqPFLkypi7X70PQzDMKzM5pJTH5j2zJP/4t79jzTbPPPFM3/7R9bjHwazyimPo8avTiqHtfvR9zAMwx560xXMF73klEEDVWJpXh9y6v/+zb80h7Q3/vGxX41zVHvxqZnanid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uguy/XSpNUN8CgAAAGyUPzrVW2/Zpuw0oaSpK3FU5nwfcgoAAACKUProVBibMrOhtAlAq5zKE5tCTgEAAEAxSh+dCoVUy8yG0nOnhLrabOdPRM/7ZB/JUwAAAGCnEtEpKYtkxCmWTUeOtDdt03q99VYOTZVPTgUoKgAAALBSieiUVET2xHRXcZ75PqJTAAAAUITSR6d0oWTXRy41NTQ5Re4UAAAAOCh9dEqd7hMJ6OnyUqpm2mynwSzrglUWF2T7CTkFAAAADsofnQoC1zLnaakaf0pTqoa0KnqAnAIAAAAnFYhOjcEF2QeROgUAAAAOqhGdGrULMo5gzz4AAABwQ3Qq/0IJAAAAABYmLKcybTwuGMdpAAAAYEqZpJzKX8uoXTCGswAAAMC0gpxCTgEAAEAhkFPIKQAAACgEcgo5BQAAAIVATiGnAAAAoBBVkVPpCuhiCXRrYUq4OnrGjn3IKQAAAChGJeSUdeu93nor0UpyW7+YzfaRdjt7A2TkFAAAABRjzHLq/wMhsbkOq4favgAAAABJRU5ErkJggg==" alt="" width="717" height="236" />

图1.1

  如果读者在开发过程中出现权限等问题,请按照本节的提示检查自己的环境。

二、使用FileSystem api 读写数据

  在hadoop 的HDFS 操作中,有个非常重要的api,是org.apache.hadoop.fs.FileSystem,这是我们用户代码操作HDFS 的直接入口,该类含有操作HDFS 的各种方法,类似于jdbc 中操作数据库的直接入口是Connection 类。

那我们怎么获得一个FileSystem 对象

   String uri = "hdfs://10.1.14.24:9000/";
Configuration conf = new Configuration();
FileSystem fs = FileSystem.get(URI.create(uri), conf);

以上代码中,要注意调用的是FileSystem 的静态方法get,传递两个值给形式参数,第一个访问的HDFS 地址,该地址的协议是hdfs,ip 是10.1.14.24,端口是9000。这个地址的完整信息是在配置文件core-site.xml 中指定的,读者可以使用自己环境的配置文件中的设置。第二个参数是一个配置对象。

1. 创建文件夹

使用HDFS 的shell 命令查看一下根目录下的文件情况,如图2.1所示。

图2.1

我们在HDFS 的根目录下创建文件夹,代码如下

------------------------------------------------------------------------------------------------------

final String pathString = "/d1";
            boolean exists = fs.exists(new Path(pathString));
            if(!exists){
            boolean result = fs.mkdirs(new Path(pathString));
            System.out.println(result);
            }

------------------------------------------------------------------------------------------------------

以上代码中要放在Main函数中,

  • 第一行决定创建的文件夹完整路径是“/d1”。
  • 第二行代码是使用方法exitst判断文件夹是否存在;如果不存在,执行创建操作。
  • 第三行创建文件夹,调用的是mkdirs 方法,返回值是布尔值,如果是true,表示创建成功;如果是false,表示创建失败。

现在查看一下是否成功了,如图3.2,3.3可见创建成功了。


图3.2

图 3.3

2. 写文件

我们可以向HDFS 写入文件,代码如下:

-----------------------------------------------------------------------------------------------------

final String pathString = "/d1/f1";
final FSDataOutputStream fsDataOutputStream = fs.create(new Path(pathString));//写出去
IOUtils.copyBytes(new ByteArrayInputStream("my name is Sunddenly".getBytes()),
fsDataOutputStream, conf, true);

------------------------------------------------------------------------------------------------------
第一行代码表示创建的文件是在刚才创建的d1 文件夹下的文件f1;
第二行是调用create 方法创建一个通向HDFS 的输出流;
第三行是通过调用hadoop 的一个工具类IOUtils 的静态方法copyBytes 把一个字符串发送给输出流中。

该静态方法有四个参数:

  • 第一个参数输入流。
  • 第二个参数是输出流。
  • 第三个参数是配置对象。
  • 第四个参数是布尔值,如果是true 表示数据传输完毕后关闭流。

现在看一下是否创建成功了,如图3.4所示。

图3.4

3. 读文件

现在我们把刚才写入到HDFS 的文件“/d1/f1”读出来,代码如下:

------------------------------------------------------------------------------------------------------
    final String pathString = "/d1/f1";
    final FSDataInputStream fsDataInputStream = fs.open(new Path(pathString));//读进来
    IOUtils.copyBytes(fsDataInputStream, System.out, conf, true);

-------------------------------------------------------------------------------------------------------

  • 第一行指定所读文件的路径。
  • 第二行表示调用方法open 打开一个指定的文件,返回值是一个通向该文件的输入流;
  • 第三行还是调用IOUtils.copyBytes 方法,输出的目的地是控制台。

见图3.5


图3.5

4. 查看目录列表和文件详细信息

我们可以把根目录下的所有文件和目录显示出来,代码如下

--------------------------------------------------------------------------------------------------------
    final String pathString = "/";
    final FileStatus[] listStatus = fs.listStatus(new Path(pathString));
    for (FileStatus fileStatus : listStatus) {
      final String type = fileStatus.isDir()?"目录":"文件";
      final short replication = fileStatus.getReplication();
      final String permission = fileStatus.getPermission() .toString();
      final long len = fileStatus.getLen();
      final Path path = fileStatus.getPath();
      System.out.println(type+"\t"+permission+"\t"+replication+"\t"+len+"\t"+path);
    }

-----------------------------------------------------------------------------------------------------------
  调用listStatus方法会得到一个指定路径下的所有文件和文件夹,每一个用FileStatus表示。我们使用for循环显示每一个FileStatus对象。FileStatus对象表示文件的详细信息,里面含有类型、副本数、权限、长度、路径等很多信息,我们只是显示了一部分。结果如图3.6所示。


图 3.6

5. 删除文件或目录

  我们可以删除某个文件或者路径,代码如下

-----------------------------------------------------------------------------------------------------
    final String pathString = "/d1/f1";
    //fs.delete(new Path("/d1"), true);
    fs.deleteOnExit(new Path(pathString));

-----------------------------------------------------------------------------------------------------
  第三行代码表示删除文件“/d1/f1”,注释掉的第二行代码表示递归删除目录“/d1”及下面的所有内容。除了上面列出的fs 的方法外,还有很多方法,请读者自己查阅api。

Hadoop日记Day9---HDFS的java访问接口的更多相关文章

  1. 熟练掌握HDFS的Java API接口访问

    HDFS设计的主要目的是对海量数据进行存储,也就是说在其上能够存储很大量文件(可以存储TB级的文件).HDFS将这些文件分割之后,存储在不同的DataNode上, HDFS 提供了两种访问接口:She ...

  2. 掌握HDFS的Java API接口访问

    HDFS设计的主要目的是对海量数据进行存储,也就是说在其上能够存储很大量文件(可以存储TB级的文件).HDFS将这些文件分割之后,存储在不同的DataNode上, HDFS 提供了两种访问接口:She ...

  3. hadoop学习(五)----HDFS的java操作

    前面我们基本学习了HDFS的原理,hadoop环境的搭建,下面开始正式的实践,语言以java为主.这一节来看一下HDFS的java操作. 1 环境准备 上一篇说了windows下搭建hadoop环境, ...

  4. Hadoop编程调用HDFS(JAVA)

    1.运行环境 开发工具:intellij idea JDK版本:1.8 项目管理工具:Maven 4.0.0 Hadoop环境: Cloudera QuickStart 2.GITHUB地址 http ...

  5. Hadoop(五)搭建Hadoop与Java访问HDFS集群

    前言 上一篇详细介绍了HDFS集群,还有操作HDFS集群的一些命令,常用的命令: hdfs dfs -ls xxx hdfs dfs -mkdir -p /xxx/xxx hdfs dfs -cat ...

  6. Hadoop(五)搭建Hadoop客户端与Java访问HDFS集群

    阅读目录(Content) 一.Hadoop客户端配置 二.Java访问HDFS集群 2.1.HDFS的Java访问接口 2.2.Java访问HDFS主要编程步骤 2.3.使用FileSystem A ...

  7. Hadoop日记系列目录

    下面是Hadoop日记系列的目录,由于目前时间不是很充裕,以后的更新的速度会变慢,会按照一星期发布一期的原则进行,希望能和大家相互学习.交流. 目录安排 1>  Hadoop日记Day1---H ...

  8. 【Hadoop】四、HDFS的java接口

      Hadoop是用java语言实现的,因此HDFS有很好的java接口用以编程,重点就是Hadoop的FileSystem类,它是所有文件系统的抽象类,HDFS实例(DistributedFileS ...

  9. Hadoop学习笔记1 - 使用Java API访问远程hdfs集群

    转载请标注原链接 http://www.cnblogs.com/xczyd/p/8570437.html 2018年3月从新司重新起航了.之前在某司过了的蛋疼三个月,也算给自己放了个小假了. 第一个小 ...

随机推荐

  1. CSS 实例之翻转图片

    具体效果图如下: 主要用到的技术除了3D翻转和定位 ,还用到了一个新的属性 backface-visibility:visable|hidden; 该属性主要是用来设定元素背面是否可见. 具体的步骤如 ...

  2. 【转】CentOS 6.6 升级GCC G++ (当前最新版本为v6.1.0) (完整)

    原文地址:https://www.cnblogs.com/lzpong/p/5755678.html 我这里是centos7 升级到gcc8.1,过程差不多,参考这篇文章,记录一下. ---原文--- ...

  3. 团队项目个人进展——Day08

    一.昨天工作总结 冲刺第八天,昨天看了许多关于wx.request的知识,主要测试了OBJECT参数,同时也对https方面有了一定了解 二.遇到的问题 对文档中的内容只是熟悉,理解并运用起来还存在问 ...

  4. python 遇到的一些坑

    lst = [1, 2, 4] print lst.__iter__().next() # 打印出来的是 1 print lst.__iter__().next() # 打印出来的是 1 # 调用__ ...

  5. Java的8种基本数据类型和3种引用数据类型

    背景 最近被一个问题难倒:问到Java的基本数据类型有8种,具体是哪几个?一起复习下: Java数据类型概述 变量就是申请内存来存储值,即当创建变量的时候,需要在内存中申请空间. 内存管理系统根据变量 ...

  6. LabVIEW TCP/IP 断开重连问题

    LabVIEW的TCP/IP函数库非常好用,但是不恰当地设置打开连接结点的参数将带来一些问题,麻烦.如下图的打开连接的参数设置: 上图中指定了本地的端口,会发生这样的情况.当我们关闭应用程序之后,连接 ...

  7. October 15th 2017 Week 42nd Sunday

    Excellence is a continuous process and not an accident. 卓越是一个持续的过程而不是一个偶然事件. It is said that ten tho ...

  8. dns bind配置教程

    实验环境 三台centos7虚拟机,一台ip为192.168.52.130,一台为192.168.52.131,最后一台为192.168.52.132 安装bind 使用yum -y insall b ...

  9. Volley源码分析(四)NetWork与ResponseDelivery工作原理

    这篇文章主要分析网络请求和结果交付的过程. NetWork工作原理 之前已经说到通过mNetWork.performRequest()方法来得到NetResponse,看一下该方法具体的执行流程,pe ...

  10. 晚上打开eclipse时碰到这个问题 :Workspace in use or cannot be created, choose a different one.

    晚上打开eclipse时碰到这个问题 :Workspace in use or cannot be created, choose a different one. 网上看到这方面的解决方式: 原因: ...