/** <code>t</code> maybe null */ private void log(int level, Throwable t, String format, Object... args) { final String msg = current.get() + format(convertCurlyBraces(format), args); if (isLocationAware) { ((LocationAwareLogger) logger).log(null, FQCN, level, msg, null, t); } else { switch (level) { case LocationAwareLogger.INFO_INT: logger.info(msg); break; case LocationAwareLogger.WARN_INT: logger.warn(msg); break; case LocationAwareLogger.ERROR_INT: logger.error(msg); break; default: Prelude.unexhaustiveMatch(); } } }
sleep(60000);
/** * Wait for a certain status of a resource. * * @return either an exception or the status code of the last http response */ public static Either<Exception, Integer> waitForResource(final TrustedHttpClient http, final URI resourceUri, final int expectedStatus, final long timeout, final long pollingInterval) { long now = 0L; while (true) { final HttpHead head = new HttpHead(resourceUri); final Either<Exception, Integer> result = http.<Integer> run(head).apply(getStatusCode); for (final Integer status : result.right()) { if (eq(status, expectedStatus) || now >= timeout) { return right(status); } else if (now < timeout) { if (!sleep(pollingInterval)) { return left(new Exception("Interrupted")); } else { now = now + pollingInterval; } } } for (Exception e : result.left()) { return left(e); } } } }
/** Pattern matching on the wrapped list. */ public final <B> B match(List<Matcher<A, B>> ms) { for (Matcher<A, B> m : ms) { if (m.matches(this)) { return m.apply(this); } } return unexhaustiveMatch(); }
private static Object toJsonSimple(Val val) { if (val instanceof SVal) { return ((SVal) val).getVal(); } if (val instanceof Obj) { return toJsonSimple((Obj) val); } if (val instanceof Arr) { return toJsonSimple((Arr) val); } if (val.equals(NULL)) { return null; } return Prelude.unexhaustiveMatch(); }