protected BaseZuulFilterRunner(FilterType filterType, FilterUsageNotifier usageNotifier, FilterRunner<O, ?> nextStage) { this.usageNotifier = Preconditions.checkNotNull(usageNotifier, "filter usage notifier"); this.nextStage = nextStage; this.RUNNING_FILTER_IDX_SESSION_CTX_KEY = filterType + "RunningFilterIndex"; this.AWAITING_BODY_FLAG_SESSION_CTX_KEY = filterType + "IsAwaitingBody"; }
/** Create a new instance. */ In(String k, Set<String> vs) { Preconditions.checkArg(!vs.isEmpty(), "list of values for :in cannot be empty"); this.k = Preconditions.checkNotNull(k, "k"); this.vs = Preconditions.checkNotNull(vs, "vs"); }
/** * How long to delay before retrying if the request is throttled. This will get doubled * for each attempt that is throttled. Unit is milliseconds. */ public HttpRequestBuilder withInitialRetryDelay(long delay) { Preconditions.checkArg(delay >= 0L, "initial retry delay must be >= 0"); this.initialRetryDelay = delay; return this; }
private void requireHttps(String msg) { Preconditions.checkState("https".equals(uri.getScheme()), msg); }
/** * How long to delay before retrying if the request is throttled. This will get doubled * for each attempt that is throttled. Unit is milliseconds. */ public HttpRequestBuilder withInitialRetryDelay(long delay) { Preconditions.checkArg(delay >= 0L, "initial retry delay must be >= 0"); this.initialRetryDelay = delay; return this; }
private void requireHttps(String msg) { Preconditions.checkState("https".equals(uri.getScheme()), msg); }
protected BaseZuulFilterRunner(FilterType filterType, FilterUsageNotifier usageNotifier, FilterRunner<O, ?> nextStage) { this.usageNotifier = Preconditions.checkNotNull(usageNotifier, "filter usage notifier"); this.nextStage = nextStage; this.RUNNING_FILTER_IDX_SESSION_CTX_KEY = filterType + "RunningFilterIndex"; this.AWAITING_BODY_FLAG_SESSION_CTX_KEY = filterType + "IsAwaitingBody"; }
/** How many times to retry if the intial attempt fails? */ public HttpRequestBuilder withRetries(int n) { Preconditions.checkArg(n >= 0, "number of retries must be >= 0"); this.numAttempts = n + 1; return this; }
private void requireHttps(String msg) { Preconditions.checkState("https".equals(uri.getScheme()), msg); }
protected final AtomicInteger getRunningFilterIndex(I zuulMesg) { final SessionContext ctx = zuulMesg.getContext(); return (AtomicInteger) Preconditions.checkNotNull(ctx.get(RUNNING_FILTER_IDX_SESSION_CTX_KEY), "runningFilterIndex"); }
/** How many times to retry if the intial attempt fails? */ public HttpRequestBuilder withRetries(int n) { Preconditions.checkArg(n >= 0, "number of retries must be >= 0"); this.numAttempts = n + 1; return this; }
private void requireHttps(String msg) { Preconditions.checkState("https".equals(uri.getScheme()), msg); }
private final void runFilters(final T mesg, final AtomicInteger runningFilterIdx) { T inMesg = mesg; String filterName = "-"; try { Preconditions.checkNotNull(mesg, "Input message"); int i = runningFilterIdx.get(); while (i < filters.length) { final ZuulFilter<T, T> filter = filters[i]; filterName = filter.filterName(); final T outMesg = filter(filter, inMesg); if (outMesg == null) { return; //either async filter or waiting for the message body to be buffered } inMesg = outMesg; i = runningFilterIdx.incrementAndGet(); } //Filter chain has reached its end, pass result to the next stage invokeNextStage(inMesg); } catch (Exception ex) { handleException(inMesg, filterName, ex); } }
/** * How long to delay before retrying if the request is throttled. This will get doubled * for each attempt that is throttled. Unit is milliseconds. */ public HttpRequestBuilder withInitialRetryDelay(long delay) { Preconditions.checkArg(delay >= 0L, "initial retry delay must be >= 0"); this.initialRetryDelay = delay; return this; }
/** Stop collecting GC events. */ public synchronized void stop() { Preconditions.checkState(notifListener != null, "logger has not been started"); for (GarbageCollectorMXBean mbean : ManagementFactory.getGarbageCollectorMXBeans()) { if (mbean instanceof NotificationEmitter) { final NotificationEmitter emitter = (NotificationEmitter) mbean; try { emitter.removeNotificationListener(notifListener); } catch (ListenerNotFoundException e) { LOGGER.warn("could not remove gc listener", e); } } } notifListener = null; }
protected final AtomicInteger getRunningFilterIndex(I zuulMesg) { final SessionContext ctx = zuulMesg.getContext(); return (AtomicInteger) Preconditions.checkNotNull(ctx.get(RUNNING_FILTER_IDX_SESSION_CTX_KEY), "runningFilterIndex"); }
/** * How long to delay before retrying if the request is throttled. This will get doubled * for each attempt that is throttled. Unit is milliseconds. */ public HttpRequestBuilder withInitialRetryDelay(long delay) { Preconditions.checkArg(delay >= 0L, "initial retry delay must be >= 0"); this.initialRetryDelay = delay; return this; }
/** Stop collecting GC events. */ public synchronized void stop() { Preconditions.checkState(notifListener != null, "logger has not been started"); for (GarbageCollectorMXBean mbean : ManagementFactory.getGarbageCollectorMXBeans()) { if (mbean instanceof NotificationEmitter) { final NotificationEmitter emitter = (NotificationEmitter) mbean; try { emitter.removeNotificationListener(notifListener); } catch (ListenerNotFoundException e) { LOGGER.warn("could not remove gc listener", e); } } } notifListener = null; }
private final void runFilters(final T mesg, final AtomicInteger runningFilterIdx) { T inMesg = mesg; String filterName = "-"; try { Preconditions.checkNotNull(mesg, "Input message"); int i = runningFilterIdx.get(); while (i < filters.length) { final ZuulFilter<T, T> filter = filters[i]; filterName = filter.filterName(); final T outMesg = filter(filter, inMesg); if (outMesg == null) { return; //either async filter or waiting for the message body to be buffered } inMesg = outMesg; i = runningFilterIdx.incrementAndGet(); } //Filter chain has reached its end, pass result to the next stage invokeNextStage(inMesg); } catch (Exception ex) { handleException(inMesg, filterName, ex); } }
/** Create a new instance. */ DropRollup(AggregateFunction af, List<String> keys) { Preconditions.checkArg(!keys.contains("name"), "name is required and cannot be dropped"); this.af = af; this.keys = keys; }