Updated on 2024-08-10 GMT+08:00

Configuring and Importing Sample Projects

Scenario

HDFS provides sample projects for multiple scenarios to help you quickly learn HDFS projects.

The procedure for importing HDFS example codes is described as follows: Figure 1 shows the procedure.

Figure 1 Sample project importing procedure

Configuring and Importing Sample Projects

  1. Obtain the sample project folder hdfs-example-security in the src directory where the sample code is decompressed. For details, see Obtaining the MRS Application Development Sample Project.
  2. Copy the user.keytab and krb5.conf files obtained in Preparing MRS Application Development User section to the conf directory of the sample project.
  3. After installing the IntelliJ IDEA and JDK tools, configure JDK in IntelliJ IDEA.

    1. Open IntelliJ IDEA and click Configure.
      Figure 2 Quick Start
    2. Choose Project Defaults > Project Structure.
      Figure 3 Configure

    3. In the displayed Project Structure for New Projects interface, click SDKs. Then click the plus sign (+) and choose JDK.
      Figure 4 Project Structure for New Projects
    4. In the displayed Select Home Directory for JDK interface, select the JDK directory, and click OK.
      Figure 5 Select Home Directory for JDK
    5. Click OK.
      Figure 6 Completing the JDK configuration

  4. Import the example project to the IntelliJ IDEA development environment.

    1. Open IntelliJ IDEA and choose File > Open.
    2. Choose the directory of the example project hdfs-example-security. Click OK.

  5. Add the related jar files the example project depending on into classpath.

    If the sample project code is obtained from an open-source image site, dependency JAR files are automatically downloaded after Maven is configured (for details, see Configuring Huawei Open Source Image Repository).

  6. Add the conf directory in the project to the resource path. On the menu bar of the Intellij IDEA, choose File > Project Structure. In the dialog box that is displayed, click Modules, select the current project and click Resources > conf > OK to set the resource directory. Figure 7 shows the directory for setting the project resource.

    Figure 7 Setting the Project Resource Directory

  7. Set the IntelliJ IDEA text file coding format to prevent garbled characters.

    1. On the IntelliJ IDEA menu bar, choose File > Settings.
    2. Choose Editor > File Encodings from the navigation tree of the Settings window. In the "Global Encoding" and "Project Encodings" area, set the value to UTF-8, click Apply, and click OK, as shown in Figure 8
      Figure 8 Setting the IntelliJ IDEA coding format