Search in sources :

Example 1 with FailoverInvoker

use of io.gravitee.gateway.http.core.invoker.failover.FailoverInvoker in project gravitee-gateway by gravitee-io.

the class InvokerFactory method doCreateInstance.

@Override
protected Invoker doCreateInstance() throws Exception {
    LoadBalancer lb = api.getProxy().getLoadBalancer();
    DefaultInvoker invoker;
    if (lb != null) {
        switch(lb.getType()) {
            case RANDOM:
                invoker = new RandomLoadBalancer(endpointManager.endpoints());
                break;
            case WEIGHTED_RANDOM:
                invoker = new WeightedRandomLoadBalancer(endpointManager.endpoints());
                break;
            case WEIGHTED_ROUND_ROBIN:
                invoker = new WeightedRoundRobinLoadBalancer(endpointManager.endpoints());
                break;
            default:
                invoker = new RoundRobinLoadBalancer(endpointManager.endpoints());
                break;
        }
    } else {
        invoker = new RoundRobinLoadBalancer(endpointManager.endpoints());
    }
    if (api.getProxy().failoverEnabled()) {
        applicationContext.getAutowireCapableBeanFactory().autowireBean(invoker);
        invoker = new FailoverInvoker(invoker);
    }
    return invoker;
}
Also used : WeightedRandomLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRandomLoadBalancer) WeightedRoundRobinLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRoundRobinLoadBalancer) DefaultInvoker(io.gravitee.gateway.http.core.invoker.DefaultInvoker) FailoverInvoker(io.gravitee.gateway.http.core.invoker.failover.FailoverInvoker) WeightedRandomLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRandomLoadBalancer) LoadBalancer(io.gravitee.definition.model.LoadBalancer) RandomLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.RandomLoadBalancer) RoundRobinLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.RoundRobinLoadBalancer) WeightedRoundRobinLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRoundRobinLoadBalancer) RoundRobinLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.RoundRobinLoadBalancer) WeightedRoundRobinLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRoundRobinLoadBalancer) WeightedRandomLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRandomLoadBalancer) RandomLoadBalancer(io.gravitee.gateway.http.core.invoker.loadbalancer.RandomLoadBalancer)

Aggregations

LoadBalancer (io.gravitee.definition.model.LoadBalancer)1 DefaultInvoker (io.gravitee.gateway.http.core.invoker.DefaultInvoker)1 FailoverInvoker (io.gravitee.gateway.http.core.invoker.failover.FailoverInvoker)1 RandomLoadBalancer (io.gravitee.gateway.http.core.invoker.loadbalancer.RandomLoadBalancer)1 RoundRobinLoadBalancer (io.gravitee.gateway.http.core.invoker.loadbalancer.RoundRobinLoadBalancer)1 WeightedRandomLoadBalancer (io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRandomLoadBalancer)1 WeightedRoundRobinLoadBalancer (io.gravitee.gateway.http.core.invoker.loadbalancer.WeightedRoundRobinLoadBalancer)1