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.
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
- Select an enabled instance and click Buy.
- 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
- Click Buy Now. If there are no changes made to the specifications, submit the order.
- 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.
- Configure a JDK using Eclipse.
- Start Eclipse and choose Window > Preferences. The Preferences dialog box is displayed.
- In the navigation tree, choose Java. On the Java page, configure general settings for Java development and then click OK. See Figure 3.
- In the navigation tree, choose Java > Installed JREs. See Figure 4.
-
Download the huaweicloud-sdk-dis-XXX-XXX.zip package from https://dis-publish.obs-website.cn-north-1.myhuaweicloud.com/.
- Import the Eclipse project.
- Start Eclipse. Choose File > Import. The Import dialog box is displayed.
- Choose Maven > Existing Maven Projects, and click Next. The Import dialog box is displayed.
- 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.
- Click Finish.
- Import the Eclipse project.
- Start Eclipse. Choose File > Import. The Import dialog box is displayed.
- Choose General > Existing Projects into Workspace and click Next. The Import dialog box is displayed.
- 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.
- Click Finish.
- Import the maven project.
- Start Eclipse. Choose File > Import. The Import dialog box is displayed.
- Choose Maven > Existing Maven Projects, and click Next. The Import Maven Projects dialog box is displayed.
- 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.
- Click Finish.
- Configure the demo project.
- Set the project code to UTF-8.
- 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.
- In the left list, select Resource. The Resource pane is displayed.
- Set Text file encoding to Other. In the Others drop-down list, select UTF-8.
- Click Apply and Close to complete the encoding configuration.
- Import the JAR in dependency package.
- In the navigation pane, choose Project Explorer. Right-click the chosen project and choose Properties from the shortcut menu.
- In the left list, select Java Build Path. The Java Build Path pane is displayed.
- Click the Libraries tab, and then click Add External JARs. The JAR Selection dialog box is displayed.
- Select the directory where the dis-sdk folder is located and click Open.
- 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
- Add a JDK.
- In the navigation pane, choose Project Explorer. Right-click the chosen project and choose Properties from the shortcut menu.
- In the left list, select Java Build Path. The Java Build Path pane is displayed.
- Click the Libraries tab, and then click Add Library. The Add Library dialog box is displayed.
- Select JRE System Library and click Next. Ensure that the version of Workspace default JRE is jdk1.8 or later.
- Click Finish to exit the Add Library dialog box.
- Click Apply and Close to add the JDK.
- Set the project code to UTF-8.
- 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.
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.
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].
Last Article: Data Sources Supported by DIS
Next Article: Managing DIS Streams










Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.