Building a Program
Download the source code and program package (including function dependencies) to create a function from scratch for converting DIS stream data formats.
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, modify proID (project ID), clusID (cluster ID), and hostName (CloudTable endpoint), and save the modification.
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.
- Select Create from scratch, set the function information, and click Create Function.
- For Function Type, select Event Function.
- For Function Name: Enter a function name, for example, DISDemo.
- For Agency, select DISDemo created in Preparation.
- For Runtime, select Java 8.
- On the function details page, configure the following information:
- Choose Configuration > Basic Settings, change the handler to com.huawei.cff.TableTester.MyHandler, and click Save.
- On the Code tab, choose Upload > Local ZIP, upload the disdemo.zip package generated in Packaging the Code.
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 details page, choose Configuration > Basic Settings, and modify the following information as required:
- For Memory, select 512.
- For Execution Timeout, enter 15.
- Keep other parameters unchanged.
- Click Save.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot