Search in sources :

Example 6 with LoadBalancingInterceptor

use of com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor in project service-proxy by membrane.

the class EtcdBasedConfigurator method setUpModuleServiceProxy.

private ServiceProxy setUpModuleServiceProxy(String name, int port, String path) {
    log.info("Creating serviceProxy for module: " + path);
    ServiceProxyKey key = new ServiceProxyKey("*", "*", path, port);
    key.setUsePathPattern(true);
    key.setPathRegExp(false);
    ServiceProxy sp = new ServiceProxy(key, null, 0);
    sp.getInterceptors().add(new LoadBalancingInterceptor());
    try {
        sp.init(router);
        router.add(sp);
        runningServiceProxyForModule.put(path, sp);
    } catch (Exception ignored) {
    }
    return sp;
}
Also used : LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) BeansException(org.springframework.beans.BeansException)

Example 7 with LoadBalancingInterceptor

use of com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor in project service-proxy by membrane.

the class MultipleLoadBalancersTest method createBalancingInterceptor.

private LoadBalancingInterceptor createBalancingInterceptor(int port, String name) throws Exception {
    ServiceProxy sp3 = new ServiceProxy(new ServiceProxyKey("localhost", "POST", ".*", port), "thomas-bayer.com", 80);
    LoadBalancingInterceptor balancingInterceptor1 = new LoadBalancingInterceptor();
    balancingInterceptor1.setName(name);
    sp3.getInterceptors().add(balancingInterceptor1);
    balancer.getRuleManager().addProxyAndOpenPortIfNew(sp3);
    balancer.init();
    return balancingInterceptor1;
}
Also used : LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy)

Example 8 with LoadBalancingInterceptor

use of com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor in project service-proxy by membrane.

the class ProxyRuleTest method getInterceptors.

private List<Interceptor> getInterceptors() {
    List<Interceptor> interceptors = new ArrayList<Interceptor>();
    Interceptor balancer = new LoadBalancingInterceptor();
    balancer.setId("roundRobinBalancer");
    interceptors.add(balancer);
    Interceptor acl = new AccessControlInterceptor();
    acl.setId("accessControlInterceptor");
    interceptors.add(acl);
    return interceptors;
}
Also used : LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) AccessControlInterceptor(com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor) ArrayList(java.util.ArrayList) AccessControlInterceptor(com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor) LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) Interceptor(com.predic8.membrane.core.interceptor.Interceptor)

Example 9 with LoadBalancingInterceptor

use of com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor in project service-proxy by membrane.

the class ClusterBalancerTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    extracor = new XMLElementSessionIdExtractor();
    extracor.setLocalName("session");
    extracor.setNamespace("http://predic8.com/session/");
    r = new HttpRouter();
    lb = new LoadBalancingInterceptor();
    lb.setSessionIdExtractor(extracor);
    lb.setName("Default");
    ServiceProxy sp = new ServiceProxy(new ServiceProxyKey(3011), "predic8.com", 80);
    sp.getInterceptors().add(lb);
    r.getRuleManager().addProxyAndOpenPortIfNew(sp);
    r.init();
    BalancerUtil.up(r, "Default", "Default", "localhost", 2000);
    BalancerUtil.up(r, "Default", "Default", "localhost", 3000);
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy)

Example 10 with LoadBalancingInterceptor

use of com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor in project service-proxy by membrane.

the class ClusterNotificationInterceptorTest method setUp.

@Override
@Before
public void setUp() throws Exception {
    Rule rule = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3002), "thomas-bayer.com", 80);
    router = new HttpRouter();
    router.getRuleManager().addProxyAndOpenPortIfNew(rule);
    interceptor = new ClusterNotificationInterceptor();
    router.addUserFeatureInterceptor(interceptor);
    lbi = new LoadBalancingInterceptor();
    lbi.setName("Default");
    Rule rule2 = new ServiceProxy(new ServiceProxyKey("localhost", "*", ".*", 3003), "thomas-bayer.com", 80);
    router.getRuleManager().addProxyAndOpenPortIfNew(rule2);
    rule2.getInterceptors().add(lbi);
    router.init();
}
Also used : ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Rule(com.predic8.membrane.core.rules.Rule) HttpRouter(com.predic8.membrane.core.HttpRouter) Before(org.junit.Before)

Aggregations

ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)8 LoadBalancingInterceptor (com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor)7 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)6 Exchange (com.predic8.membrane.core.exchange.Exchange)4 HttpRouter (com.predic8.membrane.core.HttpRouter)3 Test (org.junit.Test)3 URISyntaxException (java.net.URISyntaxException)2 Before (org.junit.Before)2 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)1 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)1 Outcome (com.predic8.membrane.core.interceptor.Outcome)1 AccessControlInterceptor (com.predic8.membrane.core.interceptor.acl.AccessControlInterceptor)1 ByThreadStrategy (com.predic8.membrane.core.interceptor.balancer.ByThreadStrategy)1 Node (com.predic8.membrane.core.interceptor.balancer.Node)1 RoundRobinStrategy (com.predic8.membrane.core.interceptor.balancer.RoundRobinStrategy)1 Rule (com.predic8.membrane.core.rules.Rule)1 DummyWebServiceInterceptor (com.predic8.membrane.core.services.DummyWebServiceInterceptor)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 BeansException (org.springframework.beans.BeansException)1