Class ElasticSearchExchangeStore

java.lang.Object
com.predic8.membrane.core.exchangestore.AbstractExchangeStore
com.predic8.membrane.core.exchangestore.ElasticSearchExchangeStore
All Implemented Interfaces:
ExchangeStore

public class ElasticSearchExchangeStore extends AbstractExchangeStore
Description
Used for storing exchanges in the Elasticsearch.
Explanation
Elasticsearch 7 is required. Exchanges can be viewed in admin console and using standard Elasticsearch tools. Before writing, this class will check if index exists in current Elasticsearch instance. If index does not exist, it will create index and set up mapping for data types. If the existing index already have mapping this step will be skipped in order to not to overwrite existing mapping.
Topic
5. Monitoring, Logging and Statistics
  • Constructor Details

    • ElasticSearchExchangeStore

      public ElasticSearchExchangeStore()
  • Method Details

    • init

      public void init(Router router)
      Specified by:
      init in interface ExchangeStore
      Overrides:
      init in class AbstractExchangeStore
    • wrapForBulkOperationElasticSearch

      public String wrapForBulkOperationElasticSearch(String index, String id, String value)
    • snap

      public void snap(AbstractExchange exc, Interceptor.Flow flow)
      Description copied from interface: ExchangeStore
      Adds the current state of the exchange to the store.

      Implementations should take a snapshot of the current state of the request (or response) headers and register a body observer in which they will be called back as soon as the body has fully been received.

      If flow==REQUEST, the request is added. Elsewise, the response is added (if present).

    • collect

      public void collect(ExchangeCollector collector)
      Specified by:
      collect in interface ExchangeStore
      Overrides:
      collect in class AbstractExchangeStore
    • getExchangeDtoById

      public AbstractExchangeSnapshot getExchangeDtoById(int id)
    • getSourceElementFromElasticSearchResponse

      public List<Map> getSourceElementFromElasticSearchResponse(Map response)
    • getHitsElementFromElasticSearchResponse

      public List getHitsElementFromElasticSearchResponse(Map response)
    • getSourceElementFromHitsElement

      public List<Map> getSourceElementFromHitsElement(List hits)
    • getExchangeById

      public AbstractExchange getExchangeById(long id)
      Specified by:
      getExchangeById in interface ExchangeStore
      Overrides:
      getExchangeById in class AbstractExchangeStore
    • remove

      public void remove(AbstractExchange exchange)
    • removeAllExchanges

      public void removeAllExchanges(Rule rule)
    • removeAllExchanges

      public void removeAllExchanges(AbstractExchange[] exchanges)
    • getExchanges

      public AbstractExchange[] getExchanges(RuleKey ruleKey)
    • getNumberOfExchanges

      public int getNumberOfExchanges(RuleKey ruleKey)
    • getStatistics

      public StatisticCollector getStatistics(RuleKey ruleKey)
    • getAllExchanges

      public Object[] getAllExchanges()
    • getAllExchangesAsList

      public List<AbstractExchange> getAllExchangesAsList()
    • getFilteredSortedPaged

      public ExchangeQueryResult getFilteredSortedPaged(QueryParameter params, boolean useXForwardedForAsClientAddr) throws Exception
      Specified by:
      getFilteredSortedPaged in interface ExchangeStore
      Overrides:
      getFilteredSortedPaged in class AbstractExchangeStore
      Throws:
      Exception
    • getClient

      public HttpClient getClient()
    • setClient

      public void setClient(HttpClient client)
    • getUpdateIntervalMs

      public int getUpdateIntervalMs()
    • setUpdateIntervalMs

      public void setUpdateIntervalMs(int updateIntervalMs)
    • getLocation

      public String getLocation()
    • setLocation

      public void setLocation(String location)
      Default
      http://localhost:9200
      Description
      base URL of Elasticsearch
    • setIndex

      public void setIndex(String index)
      Default
      membrane
      Description
      index name to use for Elasticsearch
    • getIndex

      public String getIndex()
    • getDocumentPrefix

      public String getDocumentPrefix()
    • setDocumentPrefix

      public void setDocumentPrefix(String documentPrefix)
      Default
      set to hostname as default
      Description
      used for issuer field. Can be used to check which membrane instance is writing current exchange
    • getMaxBodySize

      public int getMaxBodySize()
    • setMaxBodySize

      public void setMaxBodySize(int maxBodySize)
      Default
      100000
    • getBodyExceedingMaxSizeStrategy

      public BodyCollectingMessageObserver.Strategy getBodyExceedingMaxSizeStrategy()
    • setBodyExceedingMaxSizeStrategy

      public void setBodyExceedingMaxSizeStrategy(BodyCollectingMessageObserver.Strategy bodyExceedingMaxSizeStrategy)
      Default
      TRUNCATE
      Description
      The strategy to use (TRUNCATE or ERROR) when a HTTP message body is larger than the maxBodySize.