use of com.predic8.membrane.core.exchange.AbstractExchange in project service-proxy by membrane.
the class ElasticSearchExchangeStore method getStatistics.
@Override
public StatisticCollector getStatistics(RuleKey ruleKey) {
StatisticCollector statistics = new StatisticCollector(false);
List<AbstractExchange> exchangesList = Arrays.asList(getExchanges(ruleKey));
if (exchangesList == null || exchangesList.isEmpty())
return statistics;
for (int i = 0; i < exchangesList.size(); i++) statistics.collectFrom(exchangesList.get(i));
return statistics;
}
use of com.predic8.membrane.core.exchange.AbstractExchange in project service-proxy by membrane.
the class LimitedMemoryExchangeStore method addObservers.
private void addObservers(AbstractExchange exc, AbstractExchange excCopy, Flow flow) throws Exception {
Message msg = null;
if (flow == Flow.REQUEST) {
msg = exc.getRequest();
} else
msg = exc.getResponse();
msg.addObserver(new MessageObserver() {
@Override
public void bodyRequested(AbstractBody body) {
}
@Override
public void bodyComplete(AbstractBody body) {
try {
cleanSnapshot(Exchange.updateCopy(exc, excCopy));
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
exc.addExchangeViewerListener(new AbstractExchangeViewerListener() {
@Override
public void setExchangeFinished() {
try {
cleanSnapshot(Exchange.updateCopy(exc, excCopy));
} catch (Exception e) {
e.printStackTrace();
}
}
});
cleanSnapshot(Exchange.updateCopy(exc, excCopy));
}
use of com.predic8.membrane.core.exchange.AbstractExchange in project service-proxy by membrane.
the class LimitedMemoryExchangeStore method getStatistics.
public synchronized StatisticCollector getStatistics(RuleKey key) {
StatisticCollector statistics = new StatisticCollector(false);
List<AbstractExchange> exchangesList = getExchangeList(key);
if (exchangesList == null || exchangesList.isEmpty())
return statistics;
for (int i = 0; i < exchangesList.size(); i++) statistics.collectFrom(exchangesList.get(i));
return statistics;
}
use of com.predic8.membrane.core.exchange.AbstractExchange in project service-proxy by membrane.
the class LimitedMemoryExchangeStore method newSnap.
private void newSnap(AbstractExchange exc, Flow flow) {
AbstractExchange excCopy = null;
try {
if (flow == Flow.REQUEST) {
excCopy = cleanSnapshot(exc.createSnapshot());
snapInternal(excCopy, flow);
} else
excCopy = cleanSnapshot(Exchange.updateCopy(exc, getExchangeById((int) exc.getId())));
addObservers(exc, excCopy, flow);
modify();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.predic8.membrane.core.exchange.AbstractExchange in project service-proxy by membrane.
the class MemoryExchangeStore method snap.
public void snap(AbstractExchange exc, Flow flow) {
if (flow != Flow.REQUEST)
return;
if (isKeyInStore(exc)) {
getKeyList(exc).add(exc);
} else {
List<AbstractExchange> list = new Vector<AbstractExchange>();
list.add(exc);
exchangesMap.put(exc.getRule().getKey(), list);
}
totals.add(exc);
for (IExchangesStoreListener listener : exchangesStoreListeners) {
exc.addExchangeStoreListener(listener);
listener.addExchange(exc.getRule(), exc);
}
}
Aggregations