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;
}
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;
}
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;
}
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);
}
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();
}
Aggregations