Search in sources :

Example 26 with ServiceProxy

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

the class EtcdBasedConfigurator method shutdownRunningClusterNode.

private void shutdownRunningClusterNode(EtcdNodeInformation node) {
    log.info("Destroying " + node);
    ServiceProxy sp = runningServiceProxyForModule.get(node.getModule());
    LoadBalancingInterceptor lbi = (LoadBalancingInterceptor) sp.getInterceptors().get(0);
    lbi.getClusterManager().removeNode(Balancer.DEFAULT_NAME, baseUrl, port);
    runningNodesForModule.get(node.getModule()).remove(node);
}
Also used : LoadBalancingInterceptor(com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy)

Example 27 with ServiceProxy

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

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

the class EtcdPublisher method readConfig.

public void readConfig() {
    nodesFromConfig.clear();
    for (Rule rule : router.getRuleManager().getRules()) {
        if (!(rule instanceof ServiceProxy))
            continue;
        ServiceProxy sp = (ServiceProxy) rule;
        if (sp.getPath() == null)
            continue;
        nodesFromConfig.add(new EtcdNodeInformation(sp.getPath().getValue(), "/" + UUID.randomUUID().toString(), "localhost", Integer.toString(sp.getPort()), sp.getName()));
    }
}
Also used : ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Rule(com.predic8.membrane.core.rules.Rule)

Example 29 with ServiceProxy

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

the class UnavailableSoapProxyTest method setup.

@Before
public void setup() {
    r = new Router();
    HttpClientConfiguration httpClientConfig = new HttpClientConfiguration();
    httpClientConfig.setMaxRetries(1);
    r.setHttpClientConfig(httpClientConfig);
    r.setHotDeploy(false);
    r.setRetryInit(true);
    sp = new SOAPProxy();
    sp.setPort(2000);
    sp.setWsdl("http://localhost:2001/axis2/services/BLZService?wsdl");
    sp3 = new ServiceProxy();
    sp3.setPort(2000);
    sp3.setTarget(new AbstractServiceProxy.Target("localhost", 2001));
    ValidatorInterceptor v = new ValidatorInterceptor();
    v.setWsdl("http://localhost:2001/axis2/services/BLZService?wsdl");
    sp3.getInterceptors().add(v);
    SOAPProxy sp2 = new SOAPProxy();
    sp2.setPort(2001);
    sp2.setWsdl("http://www.thomas-bayer.com/axis2/services/BLZService?wsdl");
    r2 = new Router();
    r2.setHotDeploy(false);
    r2.getRules().add(sp2);
// r2 will be started during the test
}
Also used : ValidatorInterceptor(com.predic8.membrane.core.interceptor.schemavalidation.ValidatorInterceptor) Router(com.predic8.membrane.core.Router) HttpClientConfiguration(com.predic8.membrane.core.transport.http.client.HttpClientConfiguration) Before(org.junit.Before)

Example 30 with ServiceProxy

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

the class ExceptionHandlingTest method setUp.

@Before
public void setUp() throws Exception {
    router = new HttpRouter();
    router.getTransport().setPrintStackTrace(printStackTrace);
    ServiceProxy sp2 = new ServiceProxy(new ServiceProxyKey("*", "*", ".*", getPort()), "", -1);
    sp2.getInterceptors().add(new AbstractInterceptor() {

        @Override
        public Outcome handleRequest(Exchange exc) throws Exception {
            throw new Exception("secret");
        }
    });
    router.getRuleManager().addProxyAndOpenPortIfNew(sp2);
    router.init();
}
Also used : Exchange(com.predic8.membrane.core.exchange.Exchange) ServiceProxyKey(com.predic8.membrane.core.rules.ServiceProxyKey) ServiceProxy(com.predic8.membrane.core.rules.ServiceProxy) Outcome(com.predic8.membrane.core.interceptor.Outcome) AbstractInterceptor(com.predic8.membrane.core.interceptor.AbstractInterceptor) HttpRouter(com.predic8.membrane.core.HttpRouter) ParseException(org.apache.http.ParseException) IOException(java.io.IOException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) Before(org.junit.Before)

Aggregations

ServiceProxy (com.predic8.membrane.core.rules.ServiceProxy)47 ServiceProxyKey (com.predic8.membrane.core.rules.ServiceProxyKey)34 HttpRouter (com.predic8.membrane.core.HttpRouter)25 Before (org.junit.Before)19 Rule (com.predic8.membrane.core.rules.Rule)17 Exchange (com.predic8.membrane.core.exchange.Exchange)16 Outcome (com.predic8.membrane.core.interceptor.Outcome)14 AbstractInterceptor (com.predic8.membrane.core.interceptor.AbstractInterceptor)12 IOException (java.io.IOException)9 Test (org.junit.Test)9 LoadBalancingInterceptor (com.predic8.membrane.core.interceptor.balancer.LoadBalancingInterceptor)5 ArrayList (java.util.ArrayList)4 Router (com.predic8.membrane.core.Router)3 Mapping (com.predic8.membrane.core.interceptor.rewrite.RewriteInterceptor.Mapping)3 AbstractServiceProxy (com.predic8.membrane.core.rules.AbstractServiceProxy)3 ProxyRule (com.predic8.membrane.core.rules.ProxyRule)3 HttpClientConfiguration (com.predic8.membrane.core.transport.http.client.HttpClientConfiguration)3 URISyntaxException (java.net.URISyntaxException)3 Interceptor (com.predic8.membrane.core.interceptor.Interceptor)2 MockInterceptor (com.predic8.membrane.core.interceptor.MockInterceptor)2