Updated on 2022-11-18 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. In a development environment (such as IntelliJ IDEA), choose the following two projects separately and run the projects:

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

Note

During security authentication, Hadoop needs to obtain the domain name of the host where the client is located (Default Realm, which is obtained from environment variable USERDNSDOMAIN). If the host does not have a domain name, the following error message is displayed when you run the sample program:

You can set environment variable USERDNSDOMAIN of the system to prevent this problem. The details are as follows:

  1. Right-click Computer and choose Properties from the shortcut menu. The dialog box shown in the following figure is displayed. Click Advanced system settings > Advanced > Environment Variables.
  2. Set the system environment variable and click "New". The New System Variable dialog box is displayed. Enter USERDNSDOMAIN in Variable name and set the Variable value to a non-null character string, for example, test.

    Click OK twice. The system environment variable is set.

  3. Close the sample project, open it again, and run it.