Updated on 2022-11-18 GMT+08:00

Configuring and Importing Sample Projects

Scenario

To execute sample codes of CQL, perform the following operations:

Applications can be submitted through the Windows or Linux environment during application development.

Windows Environment

  1. Obtain the sample project folder cql-examples in the src\storm-examples directory where the sample code is decompressed. For details, see Configuring Huawei Open-Source Mirrors.
  2. Copy the cluster configuration file obtained in section Preparing an Operating Environment to the cql-examples\src\main\resources directory of the sample project.
  3. After installing the IntelliJ IDEA and JDK, configure the JDK in the IntelliJ IDEA.

    1. Start IntelliJ IDEA and choose Configure.
      Figure 1 Quick Start
    2. Choose Project Defaults > Project Structure from the drop-down list box.
      Figure 2 Configure

    3. On the Project Structure for New Projects page that is displayed, select SDKs and click the plus sign (+) to add JDK.
      Figure 3 Project Structure for New Projects
    4. In the displayed Select Home Directory for JDK window, select the JDK directory, and click OK.
      Figure 4 Select Home Directory for JDK
    5. After selecting the JDK, click OK to complete the configuration.
      Figure 5 Completing the JDK configuration

  4. Import the sample project into the IntelliJ IDEA development environment.

    1. Choose Open.
    2. The dialog box for browsing directories is displayed.
    3. Select the sample project directory and click OK.

  5. Set the IntelliJ IDEA text file coding format to prevent invalid characters.

    1. On the IntelliJ IDEA menu bar, choose File > Settings.

      The Settings window is displayed.

    2. Choose Editor > File Encodings in the navigation tree. In the Project Encoding area and Global Encoding area, set the parameter to UTF-8, click Apply, and then click OK, as shown in Figure 6.
      Figure 6 Setting the IntelliJ IDEA coding format

  6. Add the configuration information such as the address of the open-source image repository to the setting.xml configuration file of the local Maven by referring to Configuring Huawei Open-Source Mirrors.

    When using the IntelliJ IDEA development tool, you can choose File > Settings > Build, Execution, Deployment > Build Tools > Maven to view the directory where the settings.xml file is stored. Ensure that the directory is <Local Maven installation directory>\conf\settings.xml.
    Figure 7 Directory for storing the settings.xml file

Linux Environment

  1. Initialize client environment variables.

    Access the installation directory /opt/client/, and run the following command to import environment variables:

    source bigdata_env

  2. Access Storm/streaming-cql-*/bin in the installation directory and run the following command:

    ./cql

    If information about the currently running application is found and no error occurs after you run the following command, the commands are successfully run.

    [root@host1 bin]# ./cql
     End CQL with ';' and end client with 'exit;' 
    Streaming>show applications;
    applicationName      Status     Num_workers  Uptime_secs
    Streaming>