Class ElasticSearchExchangeStore
java.lang.Object
com.predic8.membrane.core.exchangestore.AbstractExchangeStore
com.predic8.membrane.core.exchangestore.ElasticSearchExchangeStore
- All Implemented Interfaces:
ExchangeStore
- 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
-
Field Summary
Fields inherited from class com.predic8.membrane.core.exchangestore.AbstractExchangeStore
exchangesStoreListeners -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcollect(ExchangeCollector collector) Object[]getExchangeById(long id) getExchangeDtoById(int id) getExchanges(RuleKey ruleKey) getFilteredSortedPaged(QueryParameter params, boolean useXForwardedForAsClientAddr) getHitsElementFromElasticSearchResponse(Map response) getIndex()intintgetNumberOfExchanges(RuleKey ruleKey) getSourceElementFromElasticSearchResponse(Map response) getStatistics(RuleKey ruleKey) intvoidvoidremove(AbstractExchange exchange) voidremoveAllExchanges(AbstractExchange[] exchanges) voidremoveAllExchanges(Rule rule) voidsetBodyExceedingMaxSizeStrategy(BodyCollectingMessageObserver.Strategy bodyExceedingMaxSizeStrategy) voidsetClient(HttpClient client) voidsetDocumentPrefix(String documentPrefix) voidvoidsetLocation(String location) voidsetMaxBodySize(int maxBodySize) voidsetUpdateIntervalMs(int updateIntervalMs) voidsnap(AbstractExchange exc, Interceptor.Flow flow) Adds the current state of the exchange to the store.wrapForBulkOperationElasticSearch(String index, String id, String value) Methods inherited from class com.predic8.membrane.core.exchangestore.AbstractExchangeStore
addExchangesStoreListener, getClientStatistics, getLastModified, getMax, notifyListenersOnExchangeAdd, notifyListenersOnExchangeRemoval, pathContains, refreshExchangeStoreListeners, removeExchangesStoreListener, requestHeaderContains, responseHeaderContains, waitForModification
-
Constructor Details
-
ElasticSearchExchangeStore
public ElasticSearchExchangeStore()
-
-
Method Details
-
init
- Specified by:
initin interfaceExchangeStore- Overrides:
initin classAbstractExchangeStore
-
wrapForBulkOperationElasticSearch
-
snap
Description copied from interface:ExchangeStoreAdds 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
- Specified by:
collectin interfaceExchangeStore- Overrides:
collectin classAbstractExchangeStore
-
getExchangeDtoById
-
getSourceElementFromElasticSearchResponse
-
getHitsElementFromElasticSearchResponse
-
getSourceElementFromHitsElement
-
getExchangeById
- Specified by:
getExchangeByIdin interfaceExchangeStore- Overrides:
getExchangeByIdin classAbstractExchangeStore
-
remove
-
removeAllExchanges
-
removeAllExchanges
-
getExchanges
-
getNumberOfExchanges
-
getStatistics
-
getAllExchanges
-
getAllExchangesAsList
-
getFilteredSortedPaged
public ExchangeQueryResult getFilteredSortedPaged(QueryParameter params, boolean useXForwardedForAsClientAddr) throws Exception - Specified by:
getFilteredSortedPagedin interfaceExchangeStore- Overrides:
getFilteredSortedPagedin classAbstractExchangeStore- Throws:
Exception
-
getClient
-
setClient
-
getUpdateIntervalMs
public int getUpdateIntervalMs() -
setUpdateIntervalMs
public void setUpdateIntervalMs(int updateIntervalMs) -
getLocation
-
setLocation
- Default
- http://localhost:9200
- Description
- base URL of Elasticsearch
-
setIndex
- Default
- membrane
- Description
- index name to use for Elasticsearch
-
getIndex
-
getDocumentPrefix
-
setDocumentPrefix
- 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
-
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.
-