Updated on 2022-09-14 GMT+08:00

Compiling and Running an Application

Scenario

After the code development is complete, you can run an application in the Windows development environment. If the network between the local and the cluster service plane is normal, you can perform the commissioning on the local host.

Procedure

  1. (Optional) In a development environment (for example, IntelliJ IDEA), a user must be specified to run the example code. There are two ways to specify the user:

    Select the sample program HdfsExample.java or ColocationExample.java to be run, right-click the project, and choose Run Configurations from the shortcut menu. In the dialog box that is displayed, select JavaApplication > HdfsExample to set the running parameters. On the menu bar of the IntelliJ IDEA, choose Run > Edit Configurations. In the dialog box that is displayed, set the running user.

    -DHADOOP_USER_NAME=test

    The test user here is an example. To run the example code related to the Colocation operation, the user must be a member of the supergroup group.

  2. If the environment variable is configured according to 1 click Run to run the application. If not, choose the following two projects separately and run the projects:

    • Choose HdfsExample.java, right-click the project and choose Run 'HdfsExample.main()' from the shortcut menu to run the project.
    • Choose ColocationExample.java, right-click the project and choose Run 'ColocationExample.main()' from the shortcut menu to run the project.
    • It is forbidden to restart HDFS service while HDFS application is in running status, otherwise the application will fail.
    • When the Colocation project is run, the HDFS parameter fs.defaultFS cannot be set to viewfs://ClusterX.