Create Batch Analytics Processors

Use analytics processors to analyze large volumes of batch data. Define the properties for your batch 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.
To create a batch analytics processor:
  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.
    The Create Analytics Processor dialog appears.
  4. Enter a name to identify your analytics processor, and optionally a brief description.
    The description you provide appears in the REST API documentation for this batch analytics processor.
  5. Click Create.
    The page for the new analytics processor appears.
  6. From the Type list, select Batch.
    The properties below the Type list change.
  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. From the Parameter list, select the analytics object that you want to pass to the execute method of this batch analytics processor.
  10. (Optional) From the Return list, select an analytics object to define the return type for the execute method of this batch analytics processor.
    If you don’t select a return type, the execute method in the generated source template will be Void.
  11. Select at least one method to expose in the REST endpoint for this analytics processor.
    Available methods are: get, post, put, and delete.
  12. (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.
  13. Click Generate Source Template.

    Note:

    When you generate the source template, apart from the code, you’re also generating the underlying infrastructure for your analytics processor to interact with the associated links. This is the reason why you must properly 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.
  14. 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() {
        }
    
    }
  15. Modify the source template to add functionality to your analytics processor.
  16. Click Save.
After you finish writing your code, you can deploy your analytics processor. See Deploy Analytics.