Search in sources :

Example 6 with Alert

use of io.cdap.cdap.etl.api.Alert in project cdap by caskdata.

the class CombinedEmitter method emitAlert.

@Override
public void emitAlert(Map<String, String> payload) {
    Alert alert = new Alert(stageName, payload);
    emitted.add(RecordInfo.<Object>builder(alert, stageName, RecordType.ALERT).build());
}
Also used : Alert(io.cdap.cdap.etl.api.Alert)

Example 7 with Alert

use of io.cdap.cdap.etl.api.Alert in project cdap by caskdata.

the class StreamingAlertPublishFunction method call.

@Override
public void call(JavaRDD<Alert> data, Time batchTime) throws Exception {
    MacroEvaluator evaluator = new DefaultMacroEvaluator(new BasicArguments(sec), batchTime.milliseconds(), sec.getSecureStore(), sec.getServiceDiscoverer(), sec.getNamespace());
    PluginContext pluginContext = new SparkPipelinePluginContext(sec.getPluginContext(), sec.getMetrics(), stageSpec.isStageLoggingEnabled(), stageSpec.isProcessTimingEnabled());
    String stageName = stageSpec.getName();
    AlertPublisher alertPublisher = pluginContext.newPluginInstance(stageName, evaluator);
    PipelineRuntime pipelineRuntime = new SparkPipelineRuntime(sec, batchTime.milliseconds());
    AlertPublisherContext alertPublisherContext = new DefaultAlertPublisherContext(pipelineRuntime, stageSpec, sec.getMessagingContext(), sec.getAdmin());
    alertPublisher.initialize(alertPublisherContext);
    StageMetrics stageMetrics = new DefaultStageMetrics(sec.getMetrics(), stageName);
    TrackedIterator<Alert> trackedAlerts = new TrackedIterator<>(data.collect().iterator(), stageMetrics, Constants.Metrics.RECORDS_IN);
    alertPublisher.publish(trackedAlerts);
    alertPublisher.destroy();
}
Also used : DefaultMacroEvaluator(io.cdap.cdap.etl.common.DefaultMacroEvaluator) MacroEvaluator(io.cdap.cdap.api.macro.MacroEvaluator) AlertPublisher(io.cdap.cdap.etl.api.AlertPublisher) SparkPipelineRuntime(io.cdap.cdap.etl.spark.SparkPipelineRuntime) PipelineRuntime(io.cdap.cdap.etl.common.PipelineRuntime) SparkPipelinePluginContext(io.cdap.cdap.etl.spark.plugin.SparkPipelinePluginContext) PluginContext(io.cdap.cdap.api.plugin.PluginContext) SparkPipelineRuntime(io.cdap.cdap.etl.spark.SparkPipelineRuntime) TrackedIterator(io.cdap.cdap.etl.common.TrackedIterator) SparkPipelinePluginContext(io.cdap.cdap.etl.spark.plugin.SparkPipelinePluginContext) DefaultMacroEvaluator(io.cdap.cdap.etl.common.DefaultMacroEvaluator) Alert(io.cdap.cdap.etl.api.Alert) BasicArguments(io.cdap.cdap.etl.common.BasicArguments) AlertPublisherContext(io.cdap.cdap.etl.api.AlertPublisherContext) DefaultAlertPublisherContext(io.cdap.cdap.etl.common.DefaultAlertPublisherContext) DefaultAlertPublisherContext(io.cdap.cdap.etl.common.DefaultAlertPublisherContext) DefaultStageMetrics(io.cdap.cdap.etl.common.DefaultStageMetrics) StageMetrics(io.cdap.cdap.etl.api.StageMetrics) DefaultStageMetrics(io.cdap.cdap.etl.common.DefaultStageMetrics)

Example 8 with Alert

use of io.cdap.cdap.etl.api.Alert in project cdap by caskdata.

the class PipeEmitter method emitAlert.

@Override
public void emitAlert(Map<String, String> payload) {
    Alert alert = new Alert(stageName, ImmutableMap.copyOf(payload));
    RecordInfo<Alert> alertRecord = RecordInfo.builder(alert, stageName, RecordType.ALERT).build();
    for (PipeStage<RecordInfo<Alert>> alertConsumer : alertConsumers) {
        alertConsumer.consume(alertRecord);
    }
}
Also used : RecordInfo(io.cdap.cdap.etl.common.RecordInfo) Alert(io.cdap.cdap.etl.api.Alert)

Aggregations

Alert (io.cdap.cdap.etl.api.Alert)8 AlertPublisher (io.cdap.cdap.etl.api.AlertPublisher)3 AlertPublisherContext (io.cdap.cdap.etl.api.AlertPublisherContext)3 StageMetrics (io.cdap.cdap.etl.api.StageMetrics)3 DefaultAlertPublisherContext (io.cdap.cdap.etl.common.DefaultAlertPublisherContext)3 DefaultStageMetrics (io.cdap.cdap.etl.common.DefaultStageMetrics)3 PipelineRuntime (io.cdap.cdap.etl.common.PipelineRuntime)3 TrackedIterator (io.cdap.cdap.etl.common.TrackedIterator)3 HashMap (java.util.HashMap)3 StructuredRecord (io.cdap.cdap.api.data.format.StructuredRecord)2 Schema (io.cdap.cdap.api.data.schema.Schema)2 Table (io.cdap.cdap.api.dataset.table.Table)2 MacroEvaluator (io.cdap.cdap.api.macro.MacroEvaluator)2 Message (io.cdap.cdap.api.messaging.Message)2 MessageFetcher (io.cdap.cdap.api.messaging.MessageFetcher)2 DefaultMacroEvaluator (io.cdap.cdap.etl.common.DefaultMacroEvaluator)2 ETLStage (io.cdap.cdap.etl.proto.v2.ETLStage)2 StageSpec (io.cdap.cdap.etl.proto.v2.spec.StageSpec)2 AppRequest (io.cdap.cdap.proto.artifact.AppRequest)2 ApplicationId (io.cdap.cdap.proto.id.ApplicationId)2