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

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

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

origin: apache/eagle

private AlertStreamEvent createAlertEvent(long timestamp, Object[] triggerEvent) {
  String is = policyDef.getInputStreams().get(0);
  final StreamDefinition sd = sds.get(is);
  AlertStreamEvent event = new AlertStreamEvent();
  event.setTimestamp(timestamp);
  event.setData(triggerEvent);
  event.setStreamId(policyDef.getOutputStreams().get(0));
  event.setPolicyId(context.getPolicyDefinition().getName());
  if (this.context.getPolicyEvaluator() != null) {
    event.setCreatedBy(context.getPolicyEvaluator().getName());
  }
  event.setCreatedTime(System.currentTimeMillis());
  event.setSchema(sd);
  return event;
}
origin: apache/eagle

private AlertStreamEvent createAlertEvent(StreamDefinition sd, long timestamp, Object[] triggerEvent) {
  AlertStreamEvent event = new AlertStreamEvent();
  event.setTimestamp(timestamp);
  event.setData(triggerEvent);
  event.setStreamId(policyDef.getOutputStreams().get(0));
  event.setPolicyId(context.getPolicyDefinition().getName());
  if (this.context.getPolicyEvaluator() != null) {
    event.setCreatedBy(context.getPolicyEvaluator().getName());
  }
  event.setCreatedTime(System.currentTimeMillis());
  event.setSchema(sd);
  return event;
}
origin: apache/eagle

@Test
public void testNormal() throws Exception {
  doReturn(streamCounter).when(streamContext).counter();
  publishPartitions.add(createPublishPartition(samplePublishId, samplePolicyId, sampleStreamId));
  publishPartitions.add(createPublishPartition(samplePublishId2, samplePolicyId, sampleStreamId2));
  alertBoltOutputCollectorWrapper.onAlertBoltSpecChange(publishPartitions, new HashSet<>(), new HashSet<>());
  AlertStreamEvent event = new AlertStreamEvent();
  event.setPolicyId(samplePolicyId);
  StreamDefinition sd = new StreamDefinition();
  sd.setStreamId(sampleStreamId);
  sd.setColumns(new ArrayList<>());
  event.setSchema(sd);
  alertBoltOutputCollectorWrapper.emit(event);
  verify(streamCounter, times(1)).incr(anyString());
  verify(outputCollector, times(1)).emit(anyObject());
}
origin: apache/eagle

@Test
public void testExceptional() throws Exception {
  doReturn(streamCounter).when(streamContext).counter();
  publishPartitions.add(createPublishPartition(samplePublishId, samplePolicyId, sampleStreamId));
  publishPartitions.add(createPublishPartition(samplePublishId, samplePolicyId, sampleStreamId));
  alertBoltOutputCollectorWrapper.onAlertBoltSpecChange(publishPartitions, new HashSet<>(), new HashSet<>());
  AlertStreamEvent event = new AlertStreamEvent();
  event.setPolicyId(samplePolicyId);
  StreamDefinition sd = new StreamDefinition();
  sd.setStreamId(sampleStreamId);
  sd.setColumns(new ArrayList<>());
  event.setSchema(sd);
  alertBoltOutputCollectorWrapper.emit(event);
  verify(streamCounter, times(1)).incr(anyString());
  verify(outputCollector, times(1)).emit(anyObject());
}
origin: apache/eagle

  /**
   * Create alert stream event for publisher.
   */
  public static AlertStreamEvent createAlertEvent(StreamEvent event,
                          PolicyHandlerContext context,
                          Map<String, StreamDefinition> sds) {
    PolicyDefinition policyDef = context.getPolicyDefinition();
    AlertStreamEvent alertStreamEvent = new AlertStreamEvent();

    alertStreamEvent.setTimestamp(event.getTimestamp());
    alertStreamEvent.setData(event.getData());
    alertStreamEvent.setStreamId(policyDef.getOutputStreams().get(0));
    alertStreamEvent.setPolicyId(policyDef.getName());

    if (context.getPolicyEvaluator() != null) {
      alertStreamEvent.setCreatedBy(context.getPolicyEvaluator().getName());
    }

    alertStreamEvent.setCreatedTime(System.currentTimeMillis());

    String is = policyDef.getInputStreams().get(0);
    StreamDefinition sd = sds.get(is);
    alertStreamEvent.setSchema(sd);

    return alertStreamEvent;
  }
}
origin: apache/eagle

private 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.setData(data);
  return event;
}
origin: apache/eagle

@Override
public void send(StreamEvent event) throws Exception {
  AlertStreamEvent alert = new AlertStreamEvent();
  alert.setPolicyId(context.getPolicyDefinition().getName());
  alert.setSchema(sds.get(event.getStreamId()));
  this.collector.emit(alert);
}
origin: apache/eagle

event.setData(e.getData());
event.setStreamId(outputStream);
event.setPolicyId(context.getPolicyDefinition().getName());
if (this.context.getPolicyEvaluator() != null) {
  event.setCreatedBy(context.getPolicyEvaluator().getName());
origin: apache/eagle

private AlertStreamEvent create(String streamId) {
  AlertStreamEvent alert = new AlertStreamEvent();
  PolicyDefinition policy = new PolicyDefinition();
  policy.setName("policy1");
  alert.setPolicyId(policy.getName());
  alert.setCreatedTime(System.currentTimeMillis());
  alert.setData(new Object[] {"field_1", 2, "field_3"});
  alert.setStreamId(streamId);
  alert.setCreatedBy(this.toString());
  return alert;
}
origin: apache/eagle

event.setStreamId(originalEvent.getStreamId());
event.setSchema(originalEvent.getSchema());
event.setPolicyId(originalEvent.getPolicyId());
event.setCreatedTime(originalEvent.getCreatedTime());
event.setCreatedBy(originalEvent.getCreatedBy());
origin: apache/eagle

private AlertStreamEvent createWithStreamDef(String hostname, String appName, String state) {
  AlertStreamEvent alert = new AlertStreamEvent();
  PolicyDefinition policy = new PolicyDefinition();
  policy.setName("perfmon_cpu_host_check");
  alert.setPolicyId(policy.getName());
  alert.setCreatedTime(System.currentTimeMillis());
  alert.setData(new Object[] {appName, hostname, state});
  alert.setStreamId("testAlertStream");
  alert.setCreatedBy(this.toString());
  // build stream definition
  StreamDefinition sd = new StreamDefinition();
  StreamColumn appColumn = new StreamColumn();
  appColumn.setName("appname");
  appColumn.setType(StreamColumn.Type.STRING);
  StreamColumn hostColumn = new StreamColumn();
  hostColumn.setName("hostname");
  hostColumn.setType(StreamColumn.Type.STRING);
  StreamColumn stateColumn = new StreamColumn();
  stateColumn.setName("state");
  stateColumn.setType(StreamColumn.Type.STRING);
  sd.setColumns(Arrays.asList(appColumn, hostColumn, stateColumn));
  alert.setSchema(sd);
  return alert;
}
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;
}
origin: apache/eagle

private AlertStreamEvent createWithStreamDef(String hostname, String appName, String state) {
  AlertStreamEvent alert = new AlertStreamEvent();
  PolicyDefinition policy = new PolicyDefinition();
  policy.setName("perfmon_cpu_host_check");
  alert.setPolicyId(policy.getName());
  alert.setCreatedTime(System.currentTimeMillis());
  alert.setData(new Object[] {appName, hostname, state});
  alert.setStreamId("testAlertStream");
  alert.setCreatedBy(this.toString());
  // build stream definition
  StreamDefinition sd = new StreamDefinition();
  StreamColumn appColumn = new StreamColumn();
  appColumn.setName("appname");
  appColumn.setType(StreamColumn.Type.STRING);
  StreamColumn hostColumn = new StreamColumn();
  hostColumn.setName("hostname");
  hostColumn.setType(StreamColumn.Type.STRING);
  StreamColumn stateColumn = new StreamColumn();
  stateColumn.setName("state");
  stateColumn.setType(StreamColumn.Type.STRING);
  sd.setColumns(Arrays.asList(appColumn, hostColumn, stateColumn));
  alert.setSchema(sd);
  return alert;
}
origin: apache/eagle

private AlertStreamEvent mockAlertEvent (String policyId) {
  AlertStreamEvent event = new AlertStreamEvent();
  event.setSiteId("test");
  event.setCreatedBy("junit");
  event.setCreatedTime(1480491075923L);
  event.setPolicyId(policyId);
  event.setStreamId("ALERT_STREAM");
  event.setSchema(mockAlertStreamDefinition("ALERT_STREAM"));
  event.setMetaVersion("SAMPLE_META_VERSION");
  event.setTimestamp(1480491075923L);
  event.setData(new Object[]{"test_cluster", "cpu.usage", "localhost", "hadoop", 0.98});
  event.ensureAlertId();
  return event;
}
origin: apache/eagle

alertStreamEvent.setData(new Object[]{"namevalue", "hostvalue", "1", 10, 0.1, -0.2, "{\"name\":\"heap.COMMITTED\", \"Value\":\"175636480\"}", 1});
alertStreamEvent.setSchema(streamDefinition);
alertStreamEvent.setPolicyId("setPolicyId");
alertStreamEvent.setCreatedTime(1234);
alertStreamEvent.ensureAlertId();
origin: apache/eagle

PolicyDefinition policy = new PolicyDefinition();
policy.setName("switch_check");
alert.setPolicyId(policy.getName());
alert.setCreatedTime(System.currentTimeMillis());
alert.setData(new Object[] {appName, hostname, message, severity, docId, df_device, df_type, colo});
org.apache.eagle.alert.engine.modelAlertStreamEventsetPolicyId

Popular methods of AlertStreamEvent

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

Popular in Java

  • Start an intent from android
  • addToBackStack (FragmentTransaction)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • getSupportFragmentManager (FragmentActivity)
  • OutputStream (java.io)
    A writable sink for bytes.Most clients will use output streams that write data to the file system (
  • InetAddress (java.net)
    An Internet Protocol (IP) address. This can be either an IPv4 address or an IPv6 address, and in pra
  • Stream (java.util.stream)
    A sequence of elements supporting sequential and parallel aggregate operations. The following exampl
  • JCheckBox (javax.swing)
  • Logger (org.apache.log4j)
    This is the central class in the log4j package. Most logging operations, except configuration, are d
  • Reflections (org.reflections)
    Reflections one-stop-shop objectReflections scans your classpath, indexes the metadata, allows you t
  • 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