Search in sources :

Example 6 with Endpoint

use of io.gravitee.gateway.api.endpoint.Endpoint in project gravitee-gateway by gravitee-io.

the class RandomLoadBalancer method nextEndpoint.

@Override
public synchronized io.gravitee.gateway.api.endpoint.Endpoint nextEndpoint(Request serverRequest, ExecutionContext executionContext) {
    List<Endpoint> endpoints = endpoints();
    int size = endpoints.size();
    if (size == 0) {
        return null;
    } else if (size == 1) {
        // There is only 1
        return endpoints.get(0);
    }
    index = RANDOM.nextInt(size);
    return endpoints().get(index);
}
Also used : Endpoint(io.gravitee.gateway.api.endpoint.Endpoint) Endpoint(io.gravitee.gateway.api.endpoint.Endpoint)

Example 7 with Endpoint

use of io.gravitee.gateway.api.endpoint.Endpoint in project gravitee-gateway by gravitee-io.

the class WeightedLoadBalancer method loadRuntimeRatios.

private void loadRuntimeRatios() {
    runtimeRatios.clear();
    int position = 0;
    for (Endpoint endpoint : endpoints()) {
        runtimeRatios.add(new WeightRatio(position++, endpoint.weight()));
    }
}
Also used : Endpoint(io.gravitee.gateway.api.endpoint.Endpoint) Endpoint(io.gravitee.gateway.api.endpoint.Endpoint)

Example 8 with Endpoint

use of io.gravitee.gateway.api.endpoint.Endpoint in project gravitee-gateway by gravitee-io.

the class WeightedRandomLoadBalancer method loadRatios.

private void loadRatios() {
    int sum = 0;
    for (Endpoint endpoint : endpoints()) {
        sum += endpoint.weight();
    }
    distributionRatioSum = sum;
    runtimeRatioSum = distributionRatioSum;
}
Also used : Endpoint(io.gravitee.gateway.api.endpoint.Endpoint) Endpoint(io.gravitee.gateway.api.endpoint.Endpoint)

Example 9 with Endpoint

use of io.gravitee.gateway.api.endpoint.Endpoint in project gravitee-gateway by gravitee-io.

the class WeightedRandomLoadBalancer method nextEndpoint.

@Override
public synchronized Endpoint nextEndpoint(Request serverRequest, ExecutionContext executionContext) {
    List<Endpoint> endpoints = endpoints();
    if (endpoints.isEmpty()) {
        return null;
    }
    int index = selectProcessIndex();
    lastIndex = index;
    return endpoints.get(index);
}
Also used : Endpoint(io.gravitee.gateway.api.endpoint.Endpoint) Endpoint(io.gravitee.gateway.api.endpoint.Endpoint)

Example 10 with Endpoint

use of io.gravitee.gateway.api.endpoint.Endpoint in project gravitee-gateway by gravitee-io.

the class DefaultEndpointLifecycleManager method stop.

public void stop(String endpointName) {
    logger.info("Closing endpoint: name[{}]", endpointName);
    Endpoint endpoint = endpointsByName.remove(endpointName);
    stop(endpoint);
}
Also used : Endpoint(io.gravitee.gateway.api.endpoint.Endpoint) HttpEndpoint(io.gravitee.gateway.http.core.endpoint.HttpEndpoint)

Aggregations

Endpoint (io.gravitee.gateway.api.endpoint.Endpoint)12 HttpEndpoint (io.gravitee.gateway.http.core.endpoint.HttpEndpoint)4 Connector (io.gravitee.gateway.api.Connector)3 Test (org.junit.Test)3 QueryStringDecoder (io.netty.handler.codec.http.QueryStringDecoder)2 UrlEscapers (com.google.common.net.UrlEscapers)1 HttpHeaders (io.gravitee.common.http.HttpHeaders)1 HttpMethod (io.gravitee.common.http.HttpMethod)1 HttpStatusCode (io.gravitee.common.http.HttpStatusCode)1 Api (io.gravitee.definition.model.Api)1 ExecutionContext (io.gravitee.gateway.api.ExecutionContext)1 Invoker (io.gravitee.gateway.api.Invoker)1 Request (io.gravitee.gateway.api.Request)1 Buffer (io.gravitee.gateway.api.buffer.Buffer)1 EndpointManager (io.gravitee.gateway.api.endpoint.EndpointManager)1 Handler (io.gravitee.gateway.api.handler.Handler)1 ProxyConnection (io.gravitee.gateway.api.proxy.ProxyConnection)1 ProxyRequest (io.gravitee.gateway.api.proxy.ProxyRequest)1 ProxyRequestBuilder (io.gravitee.gateway.api.proxy.builder.ProxyRequestBuilder)1 ReadStream (io.gravitee.gateway.api.stream.ReadStream)1