Search in sources :

Example 1 with AbstractLoadBalancer

use of com.netflix.loadbalancer.AbstractLoadBalancer in project java-chassis by ServiceComb.

the class SessionStickinessRule method isErrorThresholdMet.

private boolean isErrorThresholdMet() {
    AbstractLoadBalancer lb = (AbstractLoadBalancer) getLoadBalancer();
    LoadBalancerStats stats = lb.getLoadBalancerStats();
    if (stats != null && stats.getServerStats() != null && stats.getServerStats().size() > 0) {
        ServerStats serverStats = stats.getSingleServerStat(lastServer);
        int successiveFaildCount = serverStats.getSuccessiveConnectionFailureCount();
        if (Configuration.INSTANCE.getSuccessiveFailedTimes() > 0 && successiveFaildCount >= Configuration.INSTANCE.getSuccessiveFailedTimes()) {
            serverStats.clearSuccessiveConnectionFailureCount();
            return true;
        }
    }
    return false;
}
Also used : ServerStats(com.netflix.loadbalancer.ServerStats) LoadBalancerStats(com.netflix.loadbalancer.LoadBalancerStats) AbstractLoadBalancer(com.netflix.loadbalancer.AbstractLoadBalancer)

Example 2 with AbstractLoadBalancer

use of com.netflix.loadbalancer.AbstractLoadBalancer in project incubator-servicecomb-java-chassis by apache.

the class SessionStickinessRule method isErrorThresholdMet.

private boolean isErrorThresholdMet() {
    AbstractLoadBalancer lb = (AbstractLoadBalancer) getLoadBalancer();
    LoadBalancerStats stats = lb.getLoadBalancerStats();
    if (stats != null && stats.getServerStats() != null && stats.getServerStats().size() > 0) {
        ServerStats serverStats = stats.getSingleServerStat(lastServer);
        int successiveFaildCount = serverStats.getSuccessiveConnectionFailureCount();
        if (Configuration.INSTANCE.getSuccessiveFailedTimes(microserviceName) > 0 && successiveFaildCount >= Configuration.INSTANCE.getSuccessiveFailedTimes(microserviceName)) {
            serverStats.clearSuccessiveConnectionFailureCount();
            return true;
        }
    }
    return false;
}
Also used : ServerStats(com.netflix.loadbalancer.ServerStats) LoadBalancerStats(com.netflix.loadbalancer.LoadBalancerStats) AbstractLoadBalancer(com.netflix.loadbalancer.AbstractLoadBalancer)

Example 3 with AbstractLoadBalancer

use of com.netflix.loadbalancer.AbstractLoadBalancer in project java-chassis by ServiceComb.

the class SessionStickinessRule method chooseNextServer.

private Server chooseNextServer(Object key) {
    AbstractLoadBalancer lb = (AbstractLoadBalancer) getLoadBalancer();
    triggerRule.setLoadBalancer(lb);
    lastServer = triggerRule.choose(key);
    lastAccessedTime = System.currentTimeMillis();
    return lastServer;
}
Also used : AbstractLoadBalancer(com.netflix.loadbalancer.AbstractLoadBalancer)

Example 4 with AbstractLoadBalancer

use of com.netflix.loadbalancer.AbstractLoadBalancer in project incubator-servicecomb-java-chassis by apache.

the class SessionStickinessRule method chooseNextServer.

private Server chooseNextServer(Object key) {
    AbstractLoadBalancer lb = (AbstractLoadBalancer) getLoadBalancer();
    triggerRule.setLoadBalancer(lb);
    lastServer = triggerRule.choose(key);
    lastAccessedTime = System.currentTimeMillis();
    return lastServer;
}
Also used : AbstractLoadBalancer(com.netflix.loadbalancer.AbstractLoadBalancer)

Aggregations

AbstractLoadBalancer (com.netflix.loadbalancer.AbstractLoadBalancer)4 LoadBalancerStats (com.netflix.loadbalancer.LoadBalancerStats)2 ServerStats (com.netflix.loadbalancer.ServerStats)2