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