Tabnine Logo
AlertStreamEvent.setBody
Code IndexAdd Tabnine to your IDE (free)

How to use
setBody
method
in
org.apache.eagle.alert.engine.model.AlertStreamEvent

Best Java code snippets using org.apache.eagle.alert.engine.model.AlertStreamEvent.setBody (Showing top 2 results out of 315)

origin: apache/eagle

@Override
public synchronized AlertStreamEvent filter(AlertStreamEvent event) {
  Preconditions.checkArgument(this.policyDefinitionRepository.containsKey(event.getPolicyId()), "Unknown policyId " + event.getPolicyId());
  PolicyDefinition policyDefinition = this.policyDefinitionRepository.get(event.getPolicyId());
  StringWriter bodyWriter = new StringWriter();
  StringWriter subjectWriter = new StringWriter();
  try {
    VelocityContext alertContext = buildAlertContext(policyDefinition, event);
    Template template = engine.getTemplate(getAlertBodyTemplateName(event.getPolicyId()));
    template.merge(alertContext, bodyWriter);
    event.setBody(bodyWriter.toString());
    template = engine.getTemplate(getAlertSubjectTemplateName(event.getPolicyId()));
    template.merge(alertContext, subjectWriter);
    event.setSubject(subjectWriter.toString());
  } finally {
    try {
      bodyWriter.close();
    } catch (IOException e) {
      LOG.warn(e.getMessage(), e);
    }
    try {
      subjectWriter.close();
    } catch (IOException e) {
      LOG.warn(e.getMessage(), e);
    }
  }
  return event;
}
origin: apache/eagle

public static AlertStreamEvent createEvent(StreamDefinition stream, PolicyDefinition policy, Object[] data) {
  AlertStreamEvent event = new AlertStreamEvent();
  event.setPolicyId(policy.getName());
  event.setSchema(stream);
  event.setStreamId(stream.getStreamId());
  event.setTimestamp(System.currentTimeMillis());
  event.setCreatedTime(System.currentTimeMillis());
  event.setSubject("Namenode Disk Used 98%");
  event.setBody("Disk Usage of Test cluster's name node (<a href=\"#\">namenode.hostname.domain</a>) is <strong style=\"color: red\">98%</strong> at <strong>2016-11-30 12:30:45</strong>, exceeding alert threshold <strong>90</strong>%");
  event.setData(data);
  event.ensureAlertId();
  event.setSeverity(AlertSeverity.CRITICAL);
  event.setCategory("HDFS");
  event.setContext(new HashMap<String,Object>(){{
    put(AlertPublishEvent.SITE_ID_KEY,"TestCluster");
  }});
  Assert.assertNotNull(event.getAlertId());
  return event;
}
org.apache.eagle.alert.engine.modelAlertStreamEventsetBody

Popular methods of AlertStreamEvent

  • ensureAlertId
  • getAlertId
  • getBody
  • getCreatedTime
  • getPolicyId
  • getSubject
  • setData
  • toString
  • <init>
  • getContext
  • getData
  • getDataMap
  • getData,
  • getDataMap,
  • getStreamId,
  • setContext,
  • setCreatedTime,
  • setPolicyId,
  • setSchema,
  • setStreamId,
  • setTimestamp,
  • getCategory

Popular in Java

  • Making http requests using okhttp
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (Timer)
  • FileInputStream (java.io)
    An input stream that reads bytes from a file. File file = ...finally if (in != null) in.clos
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Collections (java.util)
    This class consists exclusively of static methods that operate on or return collections. It contains
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • XPath (javax.xml.xpath)
    XPath provides access to the XPath evaluation environment and expressions. Evaluation of XPath Expr
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now