Create Streaming Analytics Processors

Create a streaming analytics processor to analyze the data coming from your sensors and devices. Define the properties for your streaming analytics processor, generate the source template, and then edit the generated source template to implement the logic to process and analyze the data.

Before creating your analytics processor, ensure that you finished defining the links that you want to use. If there are links that aren’t properly defined when you generate the source template, the code generator will ignore them.
  1. Go to your IoT application and select Analytics.
  2. Select Analytics Processors.
  3. If this is your first analytics processor, click Create Analytics Processor. Otherwise, click the Create icon next to the Search field.
  4. Enter a name to identify your analytics processor, and optionally a brief description.
  5. Click Create.
  6. From the Type list, select Streaming.
  7. Select the links that you want to use in your analytics processor:
    1. Click the Links field.
      The list of available links appears.
    2. Select a link from the list of available links.
    3. Repeat for all the links you want to include.
    The code to inject the selected links into the analytics processor will be automatically generated when you generate the source template.
  8. In the Implementation Class field, enter the fully qualified name that you want to use for the Java class of your analytics processor.
    The packages included in the fully qualified name are included in the package statement of the generated source template.
  9. (Optional) Click the Enabled toggle button to disable the analytics processor if you don’t want to include it the next time you deploy the application.
    You might want to disable the analytics processor while you’re developing it, until it’s ready to be deployed.
  10. Click Generate Source Template.

    Note:

    When you generate the source template, apart from the code, you also generate the underlying infrastructure for your analytics processor to interact with the associated links. This is the reason why you must define your links before generating the source template. It also means that you can’t just add the instance attribute and injection code to the generated source template. If you do this, the deploying of the analytics processor will fail.
    A message indicating that the source was generated successfully appears next to the Generate Source Template button.
  11. Click the Code tab located at the top of the page, above the components diagram, to view and edit the generated source code.

    This is an example of the generated code:

    package com.yellowiron;
    
    import oracle.iot.analytics.StreamingAnalyticsProcessor;
    import oracle.iot.analytics.Link;
    import oracle.iot.analytics.RESTRequest;
    import oracle.iot.analytics.DataOutput;
    import org.apache.spark.api.java.JavaRDD;
    import org.apache.spark.streaming.api.java.JavaDStream;
    import javax.inject.Inject;
    import yellowiron.fuel.attributes.*;
    import com.iota.yellowiron.Fuel;
    
    public final class FuelProcessor implements StreamingAnalyticsProcessor {
    
        @Inject @Link("FuelLevel")
    	  private JavaDStream <DATAMessage> input_fuellevel;
    
        @Inject @Link("FuelData")
    	  private JavaRDD <DATAMessage> output_fueldata;
    
        @Override
        public void setup() {
        }
    
    }
  12. Modify the source template to add functionality to your analytics processor.
  13. Click Save.
After you finish writing your code, you can deploy your analytics processor. See Deploy Analytics.