Search in sources :

Example 26 with AbstractExchange

use of com.predic8.membrane.core.exchange.AbstractExchange in project service-proxy by membrane.

the class MemoryExchangeStore method getStatistics.

public StatisticCollector getStatistics(RuleKey key) {
    StatisticCollector statistics = new StatisticCollector(false);
    List<AbstractExchange> exchangesList = exchangesMap.get(key);
    if (exchangesList == null || exchangesList.isEmpty())
        return statistics;
    for (int i = 0; i < exchangesList.size(); i++) statistics.collectFrom(exchangesList.get(i));
    return statistics;
}
Also used : AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange) StatisticCollector(com.predic8.membrane.core.rules.StatisticCollector)

Example 27 with AbstractExchange

use of com.predic8.membrane.core.exchange.AbstractExchange in project service-proxy by membrane.

the class MemoryExchangeStore method removeAllExchanges.

public void removeAllExchanges(Rule rule) {
    AbstractExchange[] exchanges = getExchanges(rule.getKey());
    exchangesMap.remove(rule.getKey());
    totals.removeAll(Arrays.asList(exchanges));
    for (IExchangesStoreListener listener : exchangesStoreListeners) {
        listener.removeExchanges(rule, exchanges);
    }
}
Also used : IExchangesStoreListener(com.predic8.membrane.core.model.IExchangesStoreListener) AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange)

Example 28 with AbstractExchange

use of com.predic8.membrane.core.exchange.AbstractExchange in project service-proxy by membrane.

the class AbortExchangeTest method assertExchangeStoreHas.

private void assertExchangeStoreHas(ExchangeStore exchangeStore, int numberOfExchanges, int responsePresent) {
    List<AbstractExchange> list = exchangeStore.getAllExchangesAsList();
    Assert.assertEquals(numberOfExchanges, list.size());
    for (AbstractExchange e : list) {
        Assert.assertEquals("Exchange has " + (responsePresent == 1 ? "no " : "") + "response", responsePresent, e.getResponse() != null ? 1 : 0);
    }
}
Also used : AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange)

Aggregations

AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)17 IOException (java.io.IOException)7 Exchange (com.predic8.membrane.core.exchange.Exchange)5 AbstractExchangeSnapshot (com.predic8.membrane.core.exchange.snapshots.AbstractExchangeSnapshot)4 DynamicAbstractExchangeSnapshot (com.predic8.membrane.core.exchange.snapshots.DynamicAbstractExchangeSnapshot)4 Message (com.predic8.membrane.core.http.Message)4 IExchangesStoreListener (com.predic8.membrane.core.model.IExchangesStoreListener)4 StatisticCollector (com.predic8.membrane.core.rules.StatisticCollector)4 UnknownHostException (java.net.UnknownHostException)4 CacheBuilder (com.google.common.cache.CacheBuilder)3 AbstractExchangeViewerListener (com.predic8.membrane.core.model.AbstractExchangeViewerListener)3 JsonGenerationException (com.fasterxml.jackson.core.JsonGenerationException)2 JsonGenerator (com.fasterxml.jackson.core.JsonGenerator)2 MCElement (com.predic8.membrane.annot.MCElement)2 AbstractBody (com.predic8.membrane.core.http.AbstractBody)2 Header (com.predic8.membrane.core.http.Header)2 JSONContent (com.predic8.membrane.core.interceptor.rest.JSONContent)2 SQLException (java.sql.SQLException)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Cache (com.google.common.cache.Cache)1