Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Anchor
top73
top73


Tip
titleWant to create a new Mathematical Function/Action?

It's simple! Learn to create customized Mathematical Function/Action in InSights Insights Inference on this page.

In order to run create a new Mathematical Function/Action in  InSights  Insights Inference, there are changes that should be made in list of files shown on this page. Please adhere the following instructions, and make respective changes -

Panel

On this page:


Table of Contents


Info

%WORKSPACE%  is the directory which contains InSights Insights - Development Platform.

Changes in

ConfigAttributes

ExecutionActions.java


Browse the directory - "%WORKSPACE%\Insights\PlatformInsights\src\main\java\com\cognizant\devops\platforminsights\core\enums\ConfigAttributesExecutionActions.java"

Add the changes a new enum in ConfigAttributes.java as highlighted in Red in the below panel.

Panel
titleBGColor#ddfade
titleConfigAttributesExecutionActions.java

package com.cognizant.devops.platformcommons.core.enums;


public enum ExecutionActions {

AVERAGE, COUNT, MINMAX, (Add your new Mathematical Function/Action Name here)

}


Writing Java code for Custom Mathematical Function/Action


  • Create a new package under "%WORKSPACE%\Insights\PlatformInsights\src\main\java". Use "com.cognizant.devops.platforminsights.core" as base, then append your custom package structure.
  • Import "ConfigConstants.java" from the package, and use the constants specified there to code the Mathematical Function/Action such as SPARK_ES_HOSTSPARK_ES_PORT, SPARK_ES_CONFIGINDEX, SPARK_ES_RESULTINDEXetc,.Also, please refer to existing Mathematical Function/Action classes such as "CountActionImpl" , "MinMaxActionImpl" etc,. for coding strategies.
  • Your new ActionClass must extend BaseActionImp.java, and override execute() method.
Info

ConfigConstants.java class reads/contains the "sparkConfigurations" from server-config.json. To check the changes in server-config, click here.


Changes in SparkJobExecutor.java


Browse the directory - "%WORKSPACE%\Insights\PlatformInsights\src\main\java\com\cognizant\devops\platforminsights\core\SparkJobExecutor.java"

Add the changes in ConfigAttributes.java as highlighted in Red in the below panel.

Panel
titleBGColor#ddfade
titleConfigAttributes.java

package com.cognizant.devops.platforminsights.core;


public enum SparkJobExecutor implements Job,Serializable{

...

...

...

private void executeJob(SparkJobConfiguration job)  throws InsightsSparkJobFailedException{


KPIDefinition kpiDefinition = job.getKpiDefinition(job.getKpiDefinition());


if(ExecutionActions.AVERAGE == kpiDefinition.getAction()){

log.debug("KPI action found as AVERAGE");

BaseActionImpl impl = new AverageActionImpl(kpiDefinition);

impl.execute();

} else if(ExecutionActions.COUNT == kpiDefinition.getAction()){

log.debug("KPI action found as COUNT");

BaseActionImpl impl = new CountActionImpl(kpiDefinition);

impl.execute();

}

else if(ExecutionActions.MINMAX == kpiDefinition.getAction()){

log.debug("KPI action found as MINMAX");

BaseActionImpl impl = new MinMaxActionImpl(kpiDefinition);

impl.execute();

}

//(Instance of a Custom Mathematical Function/Action)

else if(ExecutionActions.YourCustomActionName == kpiDefinition.getAction()){

log.debug("KPI action found as Your Custom Action name");

BaseActionImpl impl = new YourCustomActionImplementationClassName(kpiDefinition);

impl.execute();

}

}

...

...

...

}


Using new Mathematical Function/Action in Insights Inference - KPI


  • Create KPI jobs based on the new Action. Specify the new Mathematical Function/Action in the KPI's "action".
Info

To know how to use "action" in Insights Inference - KPI, click here.