Check if the given {@link GobblinTrackingEvent} is a failure event
189728
public static boolean isFailureEvent(GobblinTrackingEvent event) {
    String eventType = event.getMetadata().get(EVENT_TYPE);
    return StringUtils.isNotEmpty(eventType) && eventType.equals(FAILURE_EVENT_TYPE);
  }
1166162
@Override
    public int getFailureCount() {
        int fail = 0;
        for (Future<Boolean> future : futures) {
            try {
                if (future.isDone() && future.get().equals(Boolean.FALSE)) {
                    fail++;
                }
            } catch (Exception e) {
                fail++;
                log.error(e.getMessage(), e);
            }
        }
        return fail;
    }
207632
def on_failure(object, *args)
      state = machine.states.match!(object)
      machine.invalidate(object, :state, :invalid_transition, [[:event, human_name(object.class)], [:state, state.human_name(object.class)]])

      transition = Transition.new(object, machine, name, state.name, state.name)
      transition.args = args if args.any?
      transition.run_callbacks(:before => false)
    end
826776
public boolean failedWithUnexpectedEOF() {
        // Implementation note - there are several ways for the Groovy compiler
        // to report an unexpected EOF. Perhaps this implementation misses some.
        // If you find another way, please add it.
        if (getErrorCollector().hasErrors()) {
            Message last = (Message) getErrorCollector().getLastError();
            Throwable cause = null;
            if (last instanceof SyntaxErrorMessage) {
                cause = ((SyntaxErrorMessage) last).getCause().getCause();
            }
            if (cause != null) {
                if (cause instanceof NoViableAltException) {
                    return isEofToken(((NoViableAltException) cause).token);
                } else if (cause instanceof NoViableAltForCharException) {
                    char badChar = ((NoViableAltForCharException) cause).foundChar;
                    return badChar == CharScanner.EOF_CHAR;
                } else if (cause instanceof MismatchedCharException) {
                    char badChar = (char) ((MismatchedCharException) cause).foundChar;
                    return badChar == CharScanner.EOF_CHAR;
                } else if (cause instanceof MismatchedTokenException) {
                    return isEofToken(((MismatchedTokenException) cause).token);
                }
            }
        }
        return false;
    }
51050
private void validateEvent(CloudTrailEvent event) {
        if (event.getEventData().getAccountId() == null) {
            logger.error(String.format("Event %s doesn't have account ID.", event.getEventData()));
        }

        // more validation here...
    }
1203684
public S onFailure(CheckedConsumer<? extends ExecutionCompletedEvent<R>> listener) {
    failureListener = EventListener.of(Assert.notNull(listener, "listener"));
    return (S) this;
  }
700333
public boolean isAbortable(R result, Throwable failure) {
    for (BiPredicate<R, Throwable> predicate : abortConditions) {
      try {
        if (predicate.test(result, failure))
          return true;
      } catch (Exception t) {
        // Ignore confused user-supplied predicates.
        // They should not be allowed to halt execution of the operation.
      }
    }
    return false;
  }
229744
public boolean isFailure(R result, Throwable failure) {
    for (BiPredicate<R, Throwable> predicate : failureConditions) {
      try {
        if (predicate.test(result, failure))
          return true;
      } catch (Exception ignored) {
        // Ignore confused user-supplied predicates.
        // They should not be allowed to halt execution of the operation.
      }
    }

    // Fail by default if a failure is not checked by a condition
    return failure != null && !failuresChecked;
  }
176677
public static void checkEventCriteria(final AttributeImpl attribute) throws DevFailed {
        // Check if value is not numerical (always true for State and String)
        if (attribute.isState() || attribute.isString()) {
            return;
        }
        // Else check criteria
        final EventProperties props = attribute.getProperties().getEventProp();
        if (props.arch_event.period.equals(Constants.NOT_SPECIFIED)
                && props.arch_event.abs_change.equals(Constants.NOT_SPECIFIED)
                && props.arch_event.rel_change.equals(Constants.NOT_SPECIFIED)) {
            throw DevFailedUtils.newDevFailed(ExceptionMessages.EVENT_CRITERIA_NOT_SET,
                    "Archive event properties (archive_abs_change or "
                            + "archive_rel_change or archive_period) for attribute " + attribute.getName()
                            + " are not set");
        }
    }
1083649
private void checkForFailure(FilterJoinNode node) {
    if (node.hasFailure()) {
      logger.error("Node processing failed: {}", node.getFailure());
      throw new ElasticsearchException("Unexpected failure while processing a node", node.getFailure());
    }
  }
549589
public static void checkEventCriteria(final AttributeImpl attribute, final EventType eventType) throws DevFailed {
        switch (eventType) {
            case CHANGE_EVENT:
                ChangeEventTrigger.checkEventCriteria(attribute);
                break;
            case ARCHIVE_EVENT:
                ArchiveEventTrigger.checkEventCriteria(attribute);
                break;
            default:
                break;
        }
    }
1174245
public void invokeHookBoltFail(Tuple tuple, Duration failLatency) {
    if (taskHooks.size() != 0) {
      BoltFailInfo failInfo = new BoltFailInfo(tuple, getThisTaskId(), failLatency);

      for (ITaskHook taskHook : taskHooks) {
        taskHook.boltFail(failInfo);
      }
    }
  }
1055058
public static boolean isLineageEvent(GobblinTrackingEvent event) {
    String eventType = event.getMetadata().get(EVENT_TYPE);
    return StringUtils.isNotEmpty(eventType) && eventType.equals(LINEAGE_EVENT_TYPE);
  }
1251649
public GobblinTrackingEvent build() {
    if (rootCause != null) {
      metadata.put(ROOT_CAUSE, ExceptionUtils.getStackTrace(rootCause));
    }
    return new GobblinTrackingEvent(0L, namespace, name, metadata);
  }
625667
static boolean detect(final String detectPattern, final String failurePattern, final long timeout,
                          final int maxLines, final InputStreamReader reader,
                          final PartialLineBuffer buffer) throws IOException, ThreshholdException {
        if (null == detectPattern && null == failurePattern) {
            throw new IllegalArgumentException("detectPattern or failurePattern required");
        }
        long start = System.currentTimeMillis();
        int linecount = 0;
        final Pattern success;
        if (null != detectPattern) {
            success = Pattern.compile(detectPattern);
        } else {
            success = null;
        }
        final Pattern failure;
        if (null != failurePattern) {
            failure = Pattern.compile(failurePattern);
        } else {
            failure = null;
        }
        outer:
        while (System.currentTimeMillis() < start + timeout && linecount < maxLines && !Thread.currentThread()
            .isInterrupted()) {
            //check buffer first, it may already contain data
            String line = buffer.readLine();
            while (null != line) {
                logger.debug("read line: " + line);
                start = System.currentTimeMillis();
                linecount++;
                if (null != success && success.matcher(line).matches()) {
                    logger.debug("success matched");
                    return true;
                } else if (null != failure && failure.matcher(line).matches()) {
                    logger.debug("failure matched");
                    return false;
                }
                if (linecount >= maxLines) {
                    break outer;
                }
                line = buffer.readLine();
            }
            line = buffer.getPartialLine();
            if (null != line) {
                logger.debug("read partial: " + line);
                if (null != success && success.matcher(line).matches()) {
                    logger.debug("success matched partial");
                    buffer.clearPartial();
                    return true;
                } else if (null != failure && failure.matcher(line).matches()) {
                    logger.debug("failure matched partial");
                    buffer.clearPartial();
                    return false;
                }else {
                    buffer.unmarkPartial();
                }
            }

            if (!reader.ready()) {
                try {
                    Thread.sleep(500);
                } catch (InterruptedException e) {
                    Thread.currentThread().interrupt();
                    return false;
                }
                continue;
            }
            final int c = buffer.read(reader);
            if (c < 0) {
                //end of stream
                logger.debug("end of input");
            } else if (c > 0) {
                logger.debug("read " + c);
            }

        }
        if (Thread.currentThread().isInterrupted()) {
            logger.debug("detect interrupted");
        }
        if (linecount >= maxLines) {
            logger.debug("max input lines");
            throw new ThreshholdException(maxLines, ThresholdType.lines);
        } else if (System.currentTimeMillis() >= start + timeout) {
            logger.debug("max timeout");
            throw new ThreshholdException(timeout, ThresholdType.milliseconds);
        } else {
            //
            return false;
        }
    }
329118
@Override
    public void streamingFailed(final StreamingErrorEvent event) {
        assertStateConsistency(fileUploadId, event.getFileName());

        if (!isUploadInterrupted()) {
            interruptUploadDueToUploadFailed();
        }
        publishUploadFailedAndFinishedEvent(fileUploadId, event.getException());
    }
10780
public void notifyFailure(final Callback<?> callback, final Throwable error) {
    invokeLater(new Runnable() {
      public void run() {
        callback.onFailure(error);
      }
    });
  }