Search in sources :

Example 6 with RuleKey

use of com.predic8.membrane.core.rules.RuleKey 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;
}
Also used : AbstractExchange(com.predic8.membrane.core.exchange.AbstractExchange) StatisticCollector(com.predic8.membrane.core.rules.StatisticCollector)

Example 7 with RuleKey

use of com.predic8.membrane.core.rules.RuleKey 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 8 with RuleKey

use of com.predic8.membrane.core.rules.RuleKey in project service-proxy by membrane.

the class RuleMatchingInterceptor method getRule.

private Rule getRule(Exchange exc) {
    Request request = exc.getRequest();
    AbstractHttpHandler handler = exc.getHandler();
    // retrieve value to match
    String hostHeader = request.getHeader().getHost();
    String method = request.getMethod();
    String uri = request.getUri();
    String version = request.getVersion();
    int port = handler.isMatchLocalPort() ? handler.getLocalPort() : -1;
    String localIP = handler.getLocalAddress().getHostAddress();
    // match it
    Rule rule = router.getRuleManager().getMatchingRule(hostHeader, method, uri, version, port, localIP);
    if (rule != null) {
        if (log.isDebugEnabled())
            log.debug("Matching Rule found for RuleKey " + hostHeader + " " + method + " " + uri + " " + port + " " + localIP);
        return rule;
    }
    return findProxyRule(exc);
}
Also used : Request(com.predic8.membrane.core.http.Request) Rule(com.predic8.membrane.core.rules.Rule) NullRule(com.predic8.membrane.core.rules.NullRule) ProxyRule(com.predic8.membrane.core.rules.ProxyRule) AbstractHttpHandler(com.predic8.membrane.core.transport.http.AbstractHttpHandler)

Aggregations

AbstractExchange (com.predic8.membrane.core.exchange.AbstractExchange)4 RuleKey (com.predic8.membrane.core.rules.RuleKey)3 StatisticCollector (com.predic8.membrane.core.rules.StatisticCollector)3 Rule (com.predic8.membrane.core.rules.Rule)2 CacheBuilder (com.google.common.cache.CacheBuilder)1 Exchange (com.predic8.membrane.core.exchange.Exchange)1 AbstractExchangeSnapshot (com.predic8.membrane.core.exchange.snapshots.AbstractExchangeSnapshot)1 DynamicAbstractExchangeSnapshot (com.predic8.membrane.core.exchange.snapshots.DynamicAbstractExchangeSnapshot)1 Request (com.predic8.membrane.core.http.Request)1 NullRule (com.predic8.membrane.core.rules.NullRule)1 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)1 AbstractHttpHandler (com.predic8.membrane.core.transport.http.AbstractHttpHandler)1 IOException (java.io.IOException)1 UnknownHostException (java.net.UnknownHostException)1