@Override public void startElement(String uri, String localName, String qName, Attributes attrs) { depth++; if (equalsOrSuffix(qName, "InternetService")) { thisDepth = depth; } else if (equalsOrSuffix(qName, "PublicIpAddress")) { inPublicIpAddress = true; } }
/** * Retries a predicate until it is met, a timeout occurs, or an exception occurs. */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout, long period, long maxPeriod, TimeUnit unit) { return new RetryablePredicate<T>(findOrBreak, timeout, period, maxPeriod, unit); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code maxPeriod} is 10x {@code period} */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout, long period, TimeUnit unit) { return retry(findOrBreak, timeout, period, period * 10l, unit); }
/** * {@inheritDoc} */ @Override public void close() { closeQuietly(closer); }
/** * {@inheritDoc} */ @Override public InputStream getInput() { return toInputStream(content); }
return; } catch (Throwable throwable) { if (Throwables2.getFirstThrowableOfType(throwable, AuthorizationException.class) != null) { S3ErrorCode code = S3ErrorCode.ACCESS_DENIED; baseRequest.setHandled(true); return; } else if (Throwables2.getFirstThrowableOfType(throwable, TimeoutException.class) != null) { S3ErrorCode code = S3ErrorCode.REQUEST_TIMEOUT;
/** * @return true if the input is an ip4 address and in one of the 3 reserved private blocks. */ public static boolean isPrivateIPAddress(String in) { return IsPrivateIPAddress.INSTANCE.apply(in); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code unit} is in milliseconds */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout, long period, long maxPeriod) { return retry(findOrBreak, timeout, period, maxPeriod, MILLISECONDS); }
/** * {@inheritDoc} */ @Override public InputStream openStream() { return toInputStream(content); }
public void startElement(String uri, String name, String qName, Attributes attrs) { if (equalsOrSuffix(qName, "item")) { itemDepth++; } else if (equalsOrSuffix(qName, "instancesSet")) { inInstancesSet = true; } else if (equalsOrSuffix(qName, "productCodes")) { inProductCodes = true; } else if (equalsOrSuffix(qName, "groupSet")) { inGroupSet = true; } }
/** * @return true if the input is an ip4 address and in one of the 3 reserved private blocks. */ public static boolean isPrivateIPAddress(String in) { return IsPrivateIPAddress.INSTANCE.apply(in); }
/** * Retries a predicate until it is met, a timeout occurs, or an exception occurs. */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout, long period, long maxPeriod, TimeUnit unit) { return new RetryablePredicate<T>(findOrBreak, timeout, period, maxPeriod, unit); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code unit} is in milliseconds, {@code period} * is 50ms, and {@code maxPeriod} 1s. */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout) { return retry(findOrBreak, timeout, DEFAULT_PERIOD, DEFAULT_MAX_PERIOD, MILLISECONDS); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code unit} is in milliseconds, {@code period} * is 50ms, and {@code maxPeriod} 1s. */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout) { return retry(findOrBreak, timeout, DEFAULT_PERIOD, DEFAULT_MAX_PERIOD, MILLISECONDS); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code unit} is in milliseconds */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout, long period, long maxPeriod) { return retry(findOrBreak, timeout, period, maxPeriod, MILLISECONDS); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code unit} is in milliseconds */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout, long period, long maxPeriod) { return retry(findOrBreak, timeout, period, maxPeriod, MILLISECONDS); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code maxPeriod} is 10x {@code period} */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout, long period, TimeUnit unit) { return retry(findOrBreak, timeout, period, period * 10l, unit); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code unit} is in milliseconds, {@code period} * is 50ms, and {@code maxPeriod} 1s. */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout) { return retry(findOrBreak, timeout, DEFAULT_PERIOD, DEFAULT_MAX_PERIOD, MILLISECONDS); }
/** * like {@link #retry(Predicate, long, long, long, TimeUnit)} where {@code maxPeriod} is 10x {@code period} */ public static <T> Predicate<T> retry(Predicate<T> findOrBreak, long timeout, long period, TimeUnit unit) { return retry(findOrBreak, timeout, period, period * 10l, unit); }
protected Predicate<State> statusChecker(final ServerApi api, final String serverId) { return retry(new Predicate<Server.State>() { public boolean apply(Server.State value) { ServerStatus status = api.getStatus(serverId, ServerStatusOptions.Builder.state()); return status.getState() == value; } }, 300, 10, TimeUnit.SECONDS); } }