Building a Program
Download and use the source code and program package (including function dependencies) provided in this example for format conversion of DIS stream data.
Creating a Project
This example uses a Java function to convert the format of DIS stream data. For details about function development, see Developing Functions in Java. The service code is not described.
Download the sample source code package fss_examples_dis_cloudtable_src.zip, decompress the file, and import it to Eclipse, as shown in Figure 1.
In the sample code, change the proID (project ID) and clusID (cluster ID), and save the changes.
To obtain the project ID, perform the following steps:
- Under the current login account in the upper right corner, choose My Credentials, as shown in Figure 2.
- Obtain the project ID in the project list, as shown in Figure 3.
To obtain the cluster ID, perform the following steps:
- Log in to the CloudTable console.
- In the navigation pane, choose Cluster Management. Click cluster cloudtable-dis created in Creating a Cluster.
- On the cloudtable-dis page that is displayed, find the cluster ID, as shown in Figure 4.
When creating a function on the FunctionGraph console, set a handler in the format of [package name].[file name].[function name], for example, com.huawei.cff.TableTester.MyHandler for the preceding code.
Packaging the Code
Use Eclipse to package the code into a JAR file named Table Tester.jar according to the following figures.
Package the function dependencies by performing the following steps:
- Download program package fss_examples_dis_cloudtable.zip, and decompress it, as shown in Figure 8.
- Use Table Tester.jar to replace DIS Test.jar, as shown in Figure 9.
- Package all of the files into disdemo.zip, as shown in Figure 10.
Creating a Function
When creating a function, specify an agency to delegate FunctionGraph to access DIS and CloudTable resources.
- Log in to the FunctionGraph console, and choose Functions > Function List in the navigation pane.
- Click Create Function.
- Set the function information, as shown in Figure 11.
For Template, select Create from scratch.
For Function Name, enter DISDemo.
For App, select default.
For Agency, select DISDemo created in Preparation.
For Runtime, select Java 8.
For Handler, enter com.huawei.cff.TableTester.MyHandler.
For Code Entry Mode, select Upload ZIP file.
Upload code package disdemo.zip created in Packaging the Code.
- Click Create Function.
Modifying Function Configurations
After the function is created, the default memory is 128 MB, and the default timeout is 3s, which are insufficient for the data processing. Perform the following steps to modify the configurations.
- On the DISDemo page, click the Configuration tab and modify the configuration information, as shown in Figure 12.
For Memory, select 512.
For Timeout, enter 15.
Keep other parameters unchanged.
- Click Save.
Last Article: Preparation
Next Article: Adding an Event Source









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