Skip to Content
Previous

Editing Adapter Configuration Files

By Gunesh Pinar

Edit a set of adapter configuration files in order to make the custom adapter available to both the HANA Streaming Analytics server at run time and in HANA Studio at design time.

Details

You will learn

  • Locate which files to edit locally on HANA Studio and on the Streaming Server
  • How to edit the modulesdefine and custommodulesdefine .xml files
  • How to edit the parametersdefine.xml file
  • To transfer the files edited on the Streaming Server to the client where the HANA Studio is running

IMPORTANT! Since you’re running a multidb SAP HANA environment, $STREAMING_CUSTOM_ADAPTERS_HOME will refer to

 /hana/shared/<SID>/streaming/cluster/<tenant db>/adapters
assuming you have used the default location of /hana as the root directory for the installation.

For this step, we will be adding our custom modules to the modulesdefine.xml file and custommodulesdefine.xml file, and adding parameter definitions from the .cnxml file to parametersdefine.xsd. The modulesdefine.xml file is located in the $STREAMING_HOME/adapters/framework/config directory, the custommodulesdefine.xml file is located in the $STREAMING_CUSTOM_ADAPTERS_HOME/configdirectory, and the parametersdefine.xsd is located in the $STREAMING_CUSTOM_ADAPTERS_HOME/config directory. We are not creating these files from scratch. The purpose of the modulesdefine.xml file is to define our custom modules (Transporter and Formatter) so HANA Streaming Analytics knows what they do and where they reside.

The parametersdefine.xsd file simply defines what elements are valid in an adapter_config.xml file (adapter configuration file). Since we have used a custom element – MqttInputTransporterParameters – in our adapter_config.xml file, we must define it in parametersdefine.xsd.

Step 1: Edit modulesdefine.xml and custommodulesdefine.xml

The full source code for the modulesdefine.xml and custommodulesdefine.xml files are provided in the Appendix Section

  1. Open modulesdefine.xml in a text editor.

  2. We will add our Transporter module to the TransporterDefnList

    • Create a <TransporterDefn> element.

        <TransporterDefn>
      
    • Create a <Name> element. Specify the name of our custom Transporter class.

        <Name>MqttTransporter</Name>
      
    • Create a <Class> element.

        <Class>com.sap.MqttTransporter</Class>
      
    • Create an <OutputData> element.

        <OutputData>String</OutputData>
      
    • Close off the <TransporterDefn> element.

      </TransporterDefn>
      
  3. We will add our formatter module to the formatterDefnList

    • Create a <FormatterDefn> element.

        <FormatterDefn>
      
    • Create a <Name> element. Specify the name of our custom Transporter class.

        <Name>MqttFormatter</Name>
      
    • Create a <Class> element.

        <Class>com.sap.MqttFormatter</Class>
      
    • Create an <InputData> element.

        <InputData>String</InputData>
      
    • Create an <OutputData> element.

        <OutputData>Esp</OutputData>
      
    • Close off the <FormatterDefn> element.

        </FormatterDefn>
      
  4. Repeat steps 1 to 3 for custommodulesdefine.xml.

For the question below, select the correct answer, and click Validate.

What is the purpose of editing the `modulesdefine.xml` file:
×
Step 2: Edit parametersdefine.xsd

The full source code for the parametersdefine.xsd file is provided in the Appendix Section

  1. Open parametersdefine.xsd in a text editor.

  2. Add the following line to the <xs:choice> element

      <xs:element name="MQTTInputTransporterParameters" type="MQTTInputTransporterParametersDefn"/>
    
  3. Since we have defined the MQTTInputTransporterParameters type to be MQTTInputTransporterParametersDefn, we must now set up a rule for it.

    • Create a <xs:complex> element and specify the name attribute.

    XML <xs:complexType name="MQTTInputTransporterParametersDefn">

    • Create an <xs:all> element.

    • Create an <xs:element> element for each MQTTInputTransporterParametersDefn parameter (Topic and MosquittoServerAddress) and specify name and type attributes for each.

    XML <xs:element name="MosquittoServerAddress" type="xs:string"></xs:element> <xs:element name="Topic" type="xs:string"></xs:element>

    • Close off the <xs:all> and <xs:complexType> elements.

    XML </xs:all> </xs:complexType>

Appendix  

modulesdefine.xml

This is not the full markup of the file. Open your modulesdefine.xml file in a text editor and add the TransporterDefn and FormatterDefn elements of the markup shown below.


<?xml version="1.0" encoding="utf-8"?> <ModulesDefinition> <TransporterDefnList> … … <TransporterDefn> <Name>MqttTransporter</Name> <Class>com.sap.MqttTransporter</Class> <OutputData>String</OutputData> </TransporterDefn> </TransporterDefnList> <FormatterDefnList> … … <FormatterDefn> <Name>MqttFormatter</Name> <Class>com.sap.MqttFormatter</Class> <InputData>String</InputData> <OutputData>ESP</OutputData> </FormatterDefn> </FormatterDefnList> … </ModulesDefinition>

custommodulesdefine.xml

This is not the full markup of the file. Open your custommodulesdefine.xml file in a text editor and add the TransporterDefn and FormatterDefn elements of the markup shown below.

<?xml version="1.0" encoding="utf-8"?>

<ModulesDefinition>
  <TransporterDefnList>
    …
    …
    <TransporterDefn>
      <Name>MqttTransporter</Name>
      <Class>com.sap.MqttTransporter</Class>
      <OutputData>String</OutputData>
    </TransporterDefn>

  </TransporterDefnList>

  <FormatterDefnList>
    …
    …
    <FormatterDefn>
      <Name>MqttFormatter</Name>
      <Class>com.sap.MqttFormatter</Class>
      <InputData>String</InputData>
      <OutputData>ESP</OutputData>
    </FormatterDefn>

 </FormatterDefnList>

…

</ModulesDefinition>

paramtersdefine.xsd

This is not the full markup of the file. Open your custommodulesdefine.xml file in a text editor and add the xs:element and xs:complexType elements of the markup shown below.


<?xml version="1.0"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"> <xs:include schemaLocation="standard_module_parametersdefine.xsd"/> <xs:complexType name="DefinedTypeParameters"> <xs:sequence> <xs:choice minOccurs="0" maxOccurs="1"> … <xs:element name="MQTTInputTransporterParameters" type="MQTTInputTransporterParametersDefn"/> … </xs:choice> </xs:sequence> </xs:complexType> … <xs:complexType name="MQTTInputTransporterParametersDefn"> <xs:all> <xs:element name="MosquittoServerAddress" type="xs:string"></xs:element> <xs:element name="Topic" type="xs:string"></xs:element> </xs:all> </xs:complexType> … </xs:schema>

Next Steps

Next
Back to top