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

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

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

origin: apache/eagle

@Override
public void emit(AlertStreamEvent event) {
  if (event == null) {
    return;
  }
  event.ensureAlertId();
  Set<PublishPartition> clonedPublishPartitions = new HashSet<>(publishPartitions);
  for (PublishPartition publishPartition : clonedPublishPartitions) {
    // skip the publish partition which is not belong to this policy and also check streamId
    PublishPartition cloned = publishPartition.clone();
    Optional.ofNullable(event)
        .filter(x -> x != null
            && x.getSchema() != null
            && cloned.getPolicyId().equalsIgnoreCase(x.getPolicyId())
            && (cloned.getStreamId().equalsIgnoreCase(x.getSchema().getStreamId())
            || cloned.getStreamId().equalsIgnoreCase(Publishment.STREAM_NAME_DEFAULT)))
        .ifPresent(x -> {
          cloned.getColumns().stream()
              .filter(y -> event.getSchema().getColumnIndex(y) >= 0
                  && event.getSchema().getColumnIndex(y) < event.getSchema().getColumns().size())
              .map(y -> event.getData()[event.getSchema().getColumnIndex(y)])
              .filter(y -> y != null)
              .forEach(y -> cloned.getColumnValues().add(y));
          synchronized (outputLock) {
            streamContext.counter().incr("alert_count");
            delegate.emit(Arrays.asList(cloned, event));
          }
        });
  }
}
origin: apache/eagle

public String streamEventToJson(AlertStreamEvent event) {
  Map<String, Object> jsonMap = new HashMap<String, Object>();
  jsonMap.put("policyId", event.getPolicyId());
  jsonMap.put("streamId", event.getStreamId());
  jsonMap.put("createBy", event.getCreatedBy());
  jsonMap.put("createTime", event.getCreatedTime());
  // data
  int size = event.getData().length;
  List<StreamColumn> columns = event.getSchema().getColumns();
  for (int i = 0; i < size; i++) {
    if (columns.size() < i) {
      // redundant check to log inconsistency
      LOG.error(" stream event data have different lenght compare to column definition! ");
    } else {
      jsonMap.put(columns.get(i).getName(), event.getData()[i]);
    }
  }
  return JsonUtils.writeValueAsString(jsonMap);
}
origin: apache/eagle

  private static VelocityContext buildAlertContext(PolicyDefinition policyDefinition, AlertStreamEvent event) {
    VelocityContext context = new VelocityContext();
    context.put(AlertContextFields.SITE_ID, event.getSiteId());
    context.put(AlertContextFields.STREAM_ID, event.getStreamId());
    context.put(AlertContextFields.ALERT_ID, event.getAlertId());
    context.put(AlertContextFields.CREATED_BY, event.getCreatedBy());
    context.put(AlertContextFields.CREATED_TIMESTAMP, event.getCreatedTime());
    context.put(AlertContextFields.CREATED_TIME,  String.format("%s %s",
        DateTimeUtil.millisecondsToHumanDateWithSeconds(event.getCreatedTime()),
        DateTimeUtil.CURRENT_TIME_ZONE.getID()));
    context.put(AlertContextFields.ALERT_TIMESTAMP, event.getTimestamp());
    context.put(AlertContextFields.ALERT_TIME,  String.format("%s %s",
        DateTimeUtil.millisecondsToHumanDateWithSeconds(event.getTimestamp()),
        DateTimeUtil.CURRENT_TIME_ZONE.getID()));
    context.put(AlertContextFields.ALERT_SCHEMA, event.getSchema());
    context.put(AlertContextFields.ALERT_EVENT, event);

    context.put(AlertContextFields.POLICY_ID, policyDefinition.getName());
    context.put(AlertContextFields.POLICY_DESC, policyDefinition.getDescription());
    context.put(AlertContextFields.POLICY_TYPE, policyDefinition.getDefinition().getType());
    context.put(AlertContextFields.POLICY_DEFINITION, policyDefinition.getDefinition().getValue());
    context.put(AlertContextFields.POLICY_HANDLER, policyDefinition.getDefinition().getHandlerClass());

    for (Map.Entry<String, Object> entry : event.getDataMap().entrySet()) {
      context.put(entry.getKey(), entry.getValue());
    }
    return context;
  }
}
origin: apache/eagle

StreamDefinition streamDefinition = event.getSchema();
HashMap<String, String> customFieldValues = new HashMap<>();
String stateFiledValue = null;
origin: apache/eagle

StreamDefinition streamDefinition = outputEvent.getSchema();
for (int i = 0; i < outputEvent.getData().length; i++) {
  if (i > streamDefinition.getColumns().size()) {
origin: apache/eagle

private DedupValue createDedupValue(EventUniq eventEniq, AlertStreamEvent event, String stateFieldValue) {
  DedupValue dedupValue;
  dedupValue = new DedupValue();
  dedupValue.setFirstOccurrence(eventEniq.timestamp);
  int idx = event.getSchema().getColumnIndex(DOC_ID);
  if (idx >= 0) {
    dedupValue.setDocId(event.getData()[idx].toString());
  } else {
    dedupValue.setDocId("");
  }
  dedupValue.setCount(1);
  dedupValue.setCloseTime(0);
  dedupValue.setStateFieldValue(stateFieldValue);
  return dedupValue;
}
origin: apache/eagle

event.setSchema(originalEvent.getSchema());
event.setPolicyId(originalEvent.getPolicyId());
event.setCreatedTime(originalEvent.getCreatedTime());
event.setCreatedBy(originalEvent.getCreatedBy());
event.setTimestamp(originalEvent.getTimestamp());
StreamDefinition streamDefinition = event.getSchema();
for (int i = 0; i < event.getData().length; i++) {
  String colName = streamDefinition.getColumns().get(i).getName();
origin: apache/eagle

@Test
public void testNormal() throws Exception {
  Config config = ConfigFactory.load();
  DedupCache dedupCache = new DedupCache(config, "testPublishment");
  StreamDefinition stream = createStream();
  PolicyDefinition policy = createPolicy(stream.getStreamId(), "testPolicy");
  String[] states = new String[] {"OPEN", "WARN", "CLOSE"};
  Random random = new Random();
  for (int i = 0; i < 20; i++) {
    AlertStreamEvent event = createEvent(stream, policy, new Object[] {
      System.currentTimeMillis(), "host1", "testPolicy-host1-01", states[random.nextInt(3)], 0, 0
    });
    HashMap<String, String> dedupFieldValues = new HashMap<String, String>();
    dedupFieldValues.put("alertKey", (String) event.getData()[event.getSchema().getColumnIndex("alertKey")]);
    List<AlertStreamEvent> result = dedupCache.dedup(event,
      new EventUniq(event.getStreamId(), event.getPolicyId(), event.getCreatedTime(), dedupFieldValues),
      "state",
      (String) event.getData()[event.getSchema().getColumnIndex("state")], "closed");
    System.out.println((i + 1) + " >>>> " + ToStringBuilder.reflectionToString(result));
  }
  Assert.assertTrue(true);
}
origin: apache/eagle

@Override
public List<AlertStreamEvent> dedup(AlertStreamEvent event) {
  StreamDefinition streamDefinition = event.getSchema();
  HashMap<String, String> customFieldValues = new HashMap<>();
  String stateFiledValue = null;
org.apache.eagle.alert.engine.modelAlertStreamEventgetSchema

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

  • Parsing JSON documents to java classes using gson
  • putExtra (Intent)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • addToBackStack (FragmentTransaction)
  • VirtualMachine (com.sun.tools.attach)
    A Java virtual machine. A VirtualMachine represents a Java virtual machine to which this Java vir
  • Charset (java.nio.charset)
    A charset is a named mapping between Unicode characters and byte sequences. Every Charset can decode
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • JarFile (java.util.jar)
    JarFile is used to read jar entries and their associated data from jar files.
  • JButton (javax.swing)
  • JTable (javax.swing)
  • CodeWhisperer 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