Class SyncZuulFilterAdapter<I extends ZuulMessage,O extends ZuulMessage>

java.lang.Object
com.netflix.zuul.filters.SyncZuulFilterAdapter<I,O>
All Implemented Interfaces:
ShouldFilter<I>, SyncZuulFilter<I,O>, ZuulFilter<I,O>
Direct Known Subclasses:
MissingEndpointHandlingFilter, PassportStampingFilter, ProxyEndpoint

public abstract class SyncZuulFilterAdapter<I extends ZuulMessage,O extends ZuulMessage> extends Object implements SyncZuulFilter<I,O>
Base class to help implement SyncZuulFilter. Note that the class BaseSyncFilter does exist but it derives from BaseFilter which in turn creates a new instance of CachedDynamicBooleanProperty for "filterDisabled" every time you create a new instance of the ZuulFilter. Normally it is not too much of a concern as the instances of ZuulFilters are "effectively" singleton and are cached by ZuulFilterLoader. However, if you ever have a need for instantiating a new ZuulFilter instance per request - aka EdgeProxyEndpoint or Inbound/Outbound PassportStampingFilter creating new instances of CachedDynamicBooleanProperty per instance of ZuulFilter will quickly kill your server's performance in two ways - a) Instances of CachedDynamicBooleanProperty are *very* heavy CPU wise to create due to extensive hookups machinery in their constructor b) They leak memory as they add themselves to some ConcurrentHashMap and are never garbage collected. TL;DR use this as a base class for your ZuulFilter if you intend to create new instances of ZuulFilter Created by saroskar on 6/8/17.
  • Constructor Details

    • SyncZuulFilterAdapter

      public SyncZuulFilterAdapter()
  • Method Details

    • isDisabled

      public boolean isDisabled()
      Specified by:
      isDisabled in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
    • shouldFilter

      public boolean shouldFilter(I msg)
      Description copied from interface: ShouldFilter
      a "true" return from this method means that the apply() method should be invoked
      Specified by:
      shouldFilter in interface ShouldFilter<I extends ZuulMessage>
      Returns:
      true if the apply() method should be invoked. false will not invoke the apply() method
    • filterOrder

      public int filterOrder()
      Description copied from interface: ZuulFilter
      filterOrder() must also be defined for a filter. Filters may have the same filterOrder if precedence is not important for a filter. filterOrders do not need to be sequential.
      Specified by:
      filterOrder in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
      Returns:
      the int order of a filter
    • filterType

      public FilterType filterType()
      Description copied from interface: ZuulFilter
      to classify a filter by type. Standard types in Zuul are "in" for pre-routing filtering, "end" for routing to an origin, "out" for post-routing filters.
      Specified by:
      filterType in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
      Returns:
      FilterType
    • overrideStopFilterProcessing

      public boolean overrideStopFilterProcessing()
      Description copied from interface: ZuulFilter
      Whether this filter's shouldFilter() method should be checked, and apply() called, even if SessionContext.stopFilterProcessing has been set.
      Specified by:
      overrideStopFilterProcessing in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
      Returns:
      boolean
    • applyAsync

      public rx.Observable<O> applyAsync(I input)
      Description copied from interface: ZuulFilter
      if shouldFilter() is true, this method will be invoked. this method is the core method of a ZuulFilter
      Specified by:
      applyAsync in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
    • getSyncType

      public FilterSyncType getSyncType()
      Specified by:
      getSyncType in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
    • needsBodyBuffered

      public boolean needsBodyBuffered(I input)
      Description copied from interface: ZuulFilter
      Filter indicates it needs to read and buffer whole body before it can operate on the messages by returning true. The decision can be made at runtime, looking at the request type. For example if the incoming message is a MSL message MSL decryption filter can return true here to buffer whole MSL message before it tries to decrypt it.
      Specified by:
      needsBodyBuffered in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
      Returns:
      true if this filter needs to read whole body before it can run, false otherwise
    • processContentChunk

      public io.netty.handler.codec.http.HttpContent processContentChunk(ZuulMessage zuulMessage, io.netty.handler.codec.http.HttpContent chunk)
      Description copied from interface: ZuulFilter
      Optionally transform HTTP content chunk received.
      Specified by:
      processContentChunk in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
    • incrementConcurrency

      public void incrementConcurrency()
      Description copied from interface: ZuulFilter
      Called by zuul filter runner before sending request through this filter. The filter can throw ZuulFilterConcurrencyExceededException if it has reached its concurrent requests limit and does not wish to process the request. Generally only useful for async filters.
      Specified by:
      incrementConcurrency in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>
    • decrementConcurrency

      public void decrementConcurrency()
      Description copied from interface: ZuulFilter
      Called by zuul filter after request is processed by this filter.
      Specified by:
      decrementConcurrency in interface ZuulFilter<I extends ZuulMessage,O extends ZuulMessage>