Quick Start

General Procedure

The following is the general procedure for using DIS:

Buying a Pay-Per-Use DIS Incremental Package

You need to create a stream before using DIS.

Preparing a DIS Application Development Environment

Before developing DIS applications, you need to install application development tools. Then, obtain the SDK and sample project and import them to the development environment.

Sending Data to a DIS Stream

Install an application based on data uploading services and run it to send data to the cloud. The DIS stream information can be viewed on the DIS console.

Obtaining Data from a DIS Stream

Write a consumer application and run it to retrieve data from the cloud.

Buying a Pay-Per-Use DIS Incremental Package

  1. Select an enabled instance and click Buy.
  2. Access the page for buying a DGC incremental package and set parameters. See Table 1 for parameter details.
    Figure 1 Configuring parameters for a DIS incremental package
    Table 1 Parameters for a DIS incremental package

    Parameter

    Description

    Package

    Select DIS.

    Billing Mode

    Select Pay per Use.

    Workspace

    Select the workspace where the DIS incremental package will be used. For example, if you want to buy a DIS incremental package for workspace A of instance test, select A. After you buy the DIS incremental package, a DIS cluster will be displayed in workspace A.

    Stream

    The name of the DIS stream to be created. Stream names must be unique. They can be up to 64 characters long. Only letters, numbers, hyphens (-), and underscores (_) are allowed.

    Stream Type

    Common and Advanced are available.

    • Common: Each partition supports a maximum read speed of 2 MB/s and a maximum write speed of 1 MB/s or 1,000 records/s.
    • Advanced: Each partition supports a maximum read speed of 10 MB/s and a maximum write speed of 5 MB/s or 2,000 records/s.

    Partitions

    Partitions are the base throughput unit of a DIS stream.
    • For a common DIS stream, the value of Partitions is an integer from 1 to 50. A user can create up to 50 partitions.
    • For an advanced DIS stream, the value of Partitions is an integer from 1 to 10. A user can create up to 10 partitions.

    Calculator

    Used to estimate how many partitions are needed based on the information you entered.
    1. Click Calculator.
    2. In the Calculate Partition dialog box, specify Avg. Size of Written Records, Max. Records Written, and Consumer Programs. The Partitions field then displays the recommended number of partitions. The value of this field cannot be modified.
      NOTE:
      Partition calculation formulas:
      • Based on the traffic (the final value must be rounded up):

        Common stream: Average record size x (1 + 20%) x Max. written records/(1 x 1,024 KB) (20% is the reserved partition percentage.)

        Advanced stream: Average record size x (1 + 20%) x Max. written records/(5 x 1,024 KB) (20% is the reserved partition percentage.)

      • Based on the consumer application quantity (the final value must be rounded up):

        (The number of consumer applications/2) x The number of partitions calculated based on the traffic (The result of the number of consumer applications/2 must reserve two decimals.)

        The larger value calculated based on the previous two formulas is considered as the estimated partition value.

    3. Click OK. The estimated value is automatically used as the value of Partitions.

    Retention Period (hours)

    The maximum number of hours for which data can be preserved in DIS streams. Data will be deleted when the retention period expires.

    Data Format

    • BLOB: a collection of binary data stored as a single entity in a database management system. If Data Format is set to BLOB, the supported Dump Destination can be OBS or MRS.
    • JSON: an open-standard file format that uses easy-to-read text to transmit data objects consisting of attribute values and arrays. If Data Format is set to JSON, the supported Dump Destination can be OBS, MRS, DLI, CloudTable, or DWS.
    • CSV: a simple text format for storing tabular data in a plain text file. Commas are used as delimiters. If Data Format is set to CSV, the supported Dump Destination can be OBS, MRS, DLI, or DWS.

    Auto Scaling

    You can enable or disable the auto scaling switch when creating a stream.

    Set the switch to or , respectively, to enable or disable auto scaling.

    NOTE:

    You can choose whether to enable auto scaling when creating a stream. You can also modify the auto scaling attributes for a stream that has already been created.

    Down To

    The lower limit for automatic scale-down. The number of target partitions for automatic scale-down cannot drop below this lower limit.

    Up To

    The upper limit for automatic scale-up. The number of target partitions for automatic scale-up cannot exceed this upper limit.

  3. Click Buy Now. If there are no changes made to the specifications, submit the order.
  4. View the new DIS stream in the corresponding workspace.
    Figure 2 Viewing a stream

Preparing a DIS Application Development Environment

  • JDK 1.8 or later has been installed.
  • Eclipse has been installed.
  1. Configure a JDK using Eclipse.
    1. Start Eclipse and choose Window > Preferences. The Preferences dialog box is displayed.
    2. In the navigation tree, choose Java. On the Java page, configure general settings for Java development and then click OK. See Figure 3.
      Figure 3 Preferences
    3. In the navigation tree, choose Java > Installed JREs. See Figure 4.
      • Ensure that configured JDK environmental variables are displayed on the Installed JREs page. Then go to 1.c.i.
      • To configure different variables for different versions of JDK, perform 1.c.ii to 1.c.iv.
      Figure 4 Installed JREs
      1. Select the installed JDK and click OK.
      2. Click Add. The Add JRE dialog box is displayed. See Figure 5.
        Figure 5 JRE Type
      3. Select a JRE type and click Next. See Figure 6.
        Figure 6 JRE Definition
      4. Configure the basic information about JDK and click Finish.
        • JRE home: JDK installation path.
        • Default VM arguments: JDK running parameters.
  2. Download the huaweicloud-sdk-dis-XXX-XXX.zip package from https://dis-publish.obs-website.cn-north-1.myhuaweicloud.com/.

  3. Import the Eclipse project.
    1. Start Eclipse. Choose File > Import. The Import dialog box is displayed.
    1. Choose Maven > Existing Maven Projects, and click Next. The Import dialog box is displayed.
    2. Click Browse and select a save location for the dis-sdk-demo sample project. In the Projects area, select a sample project. See Figure 7.
      Figure 7 Import Maven Projects1
    3. Click Finish.
  4. Import the Eclipse project.
    1. Start Eclipse. Choose File > Import. The Import dialog box is displayed.
    1. Choose General > Existing Projects into Workspace and click Next. The Import dialog box is displayed.
    2. Click Browse and select a save location for the dis-sdk-demo sample project. In the Projects area, select a sample project. See Figure 8.
      Figure 8 Import Projects
    3. Click Finish.
  5. Import the maven project.
    1. Start Eclipse. Choose File > Import. The Import dialog box is displayed.
    1. Choose Maven > Existing Maven Projects, and click Next. The Import Maven Projects dialog box is displayed.
    2. Click Browse and select a save location for the dis-sdk-demo sample project. In the Projects area, select a sample project. See Figure 9.
      Figure 9 Import Maven Projects2
    3. Click Finish.
  6. Configure the demo project.
    1. Set the project code to UTF-8.
      1. In the navigation tree on the left, right-click the required project under Project Explorer and choose Properties from the shortcut menu. The Properties for dis-sdk-demo page is displayed.
      2. In the left list, select Resource. The Resource pane is displayed.
      3. Set Text file encoding to Other. In the Others drop-down list, select UTF-8.
      4. Click Apply and Close to complete the encoding configuration.
    2. Import the JAR in dependency package.
      1. In the navigation pane, choose Project Explorer. Right-click the chosen project and choose Properties from the shortcut menu.
      2. In the left list, select Java Build Path. The Java Build Path pane is displayed.
      3. Click the Libraries tab, and then click Add External JARs. The JAR Selection dialog box is displayed.
      4. Select the directory where the dis-sdk folder is located and click Open.
      5. On the Properties for dis-sdk-demo page, click Apply and Close to import all JAR files from the current path and the third_lib folder to the project.
      Figure 10 Java Build Path
    3. Add a JDK.
      1. In the navigation pane, choose Project Explorer. Right-click the chosen project and choose Properties from the shortcut menu.
      2. In the left list, select Java Build Path. The Java Build Path pane is displayed.
      3. Click the Libraries tab, and then click Add Library. The Add Library dialog box is displayed.
      4. Select JRE System Library and click Next. Ensure that the version of Workspace default JRE is jdk1.8 or later.
      5. Click Finish to exit the Add Library dialog box.
      6. Click Apply and Close to add the JDK.
  7. Initialize a DIS client sample.

    You can obtain the DIS region information from Obtaining the Authentication Information.

Sending Data to a DIS Stream

Local data is continuously uploaded to DIS.

The example code file is the ProducerDemo.java file in the \dis-sdk-demo\src\main\java\com\bigdata\dis\sdk\demo directory decompressed from the huaweicloud-sdk-dis-java-X.X.X.zip package. The compression package is downloaded in Preparing a DIS Application Development Environment.

Right-click the producer application and choose Run As > 1 Java Application from the shortcut menu. See Figure 11.
Figure 11 Running the application

While data is being sent to DIS, the DIS console displays DIS stream information. If information similar to the following is displayed, the data has been successfully sent to DIS:
14:40:20.090 [main] INFOcom.bigdata.dis.sdk.DISConfig - get from classLoader
14:40:20.093 [main] INFODEMOT - ========== BEGIN PUT ============
14:40:21.186 [main] INFOcom.bigdata.dis.sdk.util.config.ConfigurationUtils - get from classLoader
14:40:21.187 [main] INFOcom.bigdata.dis.sdk.util.config.ConfigurationUtils - propertyMapFromFile size : 2
14:40:22.092 [main] INFOcom.bigdata.dis.sdk.demo.ProducerDemo - Put 3 records[3 successful / 0 failed].
14:40:22.092 [main] INFOcom.bigdata.dis.sdk.demo.ProducerDemo - [hello world.] put success, partitionId [shardId-0000000000], partitionKey [964885], sequenceNumber [0]
14:40:22.092 [main] INFOcom.bigdata.dis.sdk.demo.ProducerDemo - [hello world.] put success, partitionId [shardId-0000000000], partitionKey [910960], sequenceNumber [1]
14:40:22.092 [main] INFOcom.bigdata.dis.sdk.demo.ProducerDemo - [hello world.] put success, partitionId [shardId-0000000000], partitionKey [528377], sequenceNumber [2]
14:40:22.092 [main] INFOcom.bigdata.dis.sdk.demo.ProducerDemo - ========== PUT OVER ============

Obtaining Data from a DIS Stream

The example code file is the ConsumerDemo.java file in the \dis-sdk-demo\src\main\java\com\bigdata\dis\sdk\demo directory decompressed from the huaweicloud-sdk-dis-java-X.X.X.zipdis-sdk-XXX.zip package. The compression package is downloaded in Preparing a DIS Application Development Environment.

If information similar to the following appears, data has been successfully retrieved from DIS:
14:55:42.954 [main] INFOcom.bigdata.dis.sdk.DISConfig - get from classLoader
14:55:44.103 [main] INFOcom.bigdata.dis.sdk.util.config.ConfigurationUtils - get from classLoader
14:55:44.105 [main] INFOcom.bigdata.dis.sdk.util.config.ConfigurationUtils - propertyMapFromFile size : 2
14:55:45.235 [main] INFOcom.bigdata.dis.sdk.demo.ConsumerDemo - Get stream streamName[partitionId=0] cursor success : eyJnZXRJdGVyYXRvclBhcmFtIjp7InN0cmVhbS1uYW1lIjoiZGlzLTEzbW9uZXkiLCJwYXJ0aXRpb24taWQiOiIwIiwiY3Vyc29yLXR5cGUiOiJBVF9TRVFVRU5DRV9OVU1CRVIiLCJzdGFydGluZy1zZXF1ZW5jZS1udW1iZXIiOiIxMDY4OTcyIn0sImdlbmVyYXRlVGltZXN0YW1wIjoxNTEzNjY2NjMxMTYxfQ
14:55:45.305 [main] INFOcom.bigdata.dis.sdk.demo.ConsumerDemo - Get Record [hello world.], partitionKey [964885], sequenceNumber [0].
14:55:45.305 [main] INFOcom.bigdata.dis.sdk.demo.ConsumerDemo - Get Record [hello world.], partitionKey [910960], sequenceNumber [1].
14:55:46.359 [main] INFOcom.bigdata.dis.sdk.demo.ConsumerDemo - Get Record [hello world.], partitionKey [528377], sequenceNumber [2].