mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Matthew Swift
28.47.2016 275d120e8f2df481c5d5d488b349036a3d15791a
OPENDJ-3425: rename "sharded" load-balancer to "affinity"

The term "sharded" was causing confusion among users who assumed that
the algorithm was intended for write scalability through the use of data
partitioning. This is not the case: the algorithm is uses server
"affinity" in order to increase consistency.

Confusion is likely to increase with the addition of a data distribution
algorithm (OPENDJ-3425).
3 files modified
36 ■■■■ changed files
opendj-core/src/main/java/org/forgerock/opendj/ldap/Connections.java 18 ●●●● patch | view | raw | blame | history
opendj-core/src/test/java/org/forgerock/opendj/ldap/ConnectionsTestCase.java 6 ●●●● patch | view | raw | blame | history
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java 12 ●●●● patch | view | raw | blame | history
opendj-core/src/main/java/org/forgerock/opendj/ldap/Connections.java
@@ -426,7 +426,7 @@
     * @param options
     *         This configuration options for the load-balancer.
     * @return The new round-robin load balancer.
     * @see #newShardedRequestLoadBalancer(Collection, Options)
     * @see #newAffinityRequestLoadBalancer(Collection, Options)
     * @see #newFailoverLoadBalancer(Collection, Options)
     * @see #newLeastRequestsLoadBalancer(Collection, Options)
     * @see #LOAD_BALANCER_EVENT_LISTENER
@@ -495,7 +495,7 @@
     *         This configuration options for the load-balancer.
     * @return The new fail-over load balancer.
     * @see #newRoundRobinLoadBalancer(Collection, Options)
     * @see #newShardedRequestLoadBalancer(Collection, Options)
     * @see #newAffinityRequestLoadBalancer(Collection, Options)
     * @see #newLeastRequestsLoadBalancer(Collection, Options)
     * @see #LOAD_BALANCER_EVENT_LISTENER
     * @see #LOAD_BALANCER_MONITORING_INTERVAL
@@ -513,7 +513,7 @@
    }
    /**
     * Creates a new "sharded" load-balancer which will load-balance individual requests across the provided set of
     * Creates a new "affinity" load-balancer which will load-balance individual requests across the provided set of
     * connection factories, each typically representing a single replica, using an algorithm that ensures that requests
     * targeting a given DN will always be routed to the same replica. In other words, this load-balancer increases
     * consistency whilst maintaining read-scalability by simulating a "single master" replication topology, where each
@@ -553,16 +553,16 @@
     * @see #LOAD_BALANCER_MONITORING_INTERVAL
     * @see #LOAD_BALANCER_SCHEDULER
     */
    public static ConnectionFactory newShardedRequestLoadBalancer(
    public static ConnectionFactory newAffinityRequestLoadBalancer(
            final Collection<? extends ConnectionFactory> factories, final Options options) {
        return new RequestLoadBalancer("ShardedRequestLoadBalancer",
        return new RequestLoadBalancer("AffinityRequestLoadBalancer",
                                       factories,
                                       options,
                                       newShardedRequestLoadBalancerNextFunction(factories),
                                       newAffinityRequestLoadBalancerNextFunction(factories),
                                       NOOP_END_OF_REQUEST_FUNCTION);
    }
    static Function<Request, RequestWithIndex, NeverThrowsException> newShardedRequestLoadBalancerNextFunction(
    static Function<Request, RequestWithIndex, NeverThrowsException> newAffinityRequestLoadBalancerNextFunction(
            final Collection<? extends ConnectionFactory> factories) {
        return new Function<Request, RequestWithIndex, NeverThrowsException>() {
            private final int maxIndex = factories.size();
@@ -637,7 +637,7 @@
     * In other words, this load-balancer provides availability and partition tolerance, but sacrifices consistency.
     * When a replica is not available, its number of active requests will not decrease until the requests time out,
     * which will have the effect of directing requests to the other replicas. Consistency is low compared to the
     * "sharded" load-balancer, because there is no guarantee that requests for the same DN are directed to the same
     * "affinity" load-balancer, because there is no guarantee that requests for the same DN are directed to the same
     * replica.
     * <p/>
     * It is possible to increase consistency by providing a {@link AffinityControl} with a
@@ -664,7 +664,7 @@
     * @return The new least requests load balancer.
     * @see #newRoundRobinLoadBalancer(Collection, Options)
     * @see #newFailoverLoadBalancer(Collection, Options)
     * @see #newShardedRequestLoadBalancer(Collection, Options)
     * @see #newAffinityRequestLoadBalancer(Collection, Options)
     * @see #LOAD_BALANCER_EVENT_LISTENER
     * @see #LOAD_BALANCER_MONITORING_INTERVAL
     * @see #LOAD_BALANCER_SCHEDULER
opendj-core/src/test/java/org/forgerock/opendj/ldap/ConnectionsTestCase.java
@@ -74,10 +74,10 @@
    }
    @Test
    public void shardedRequestLoadBalancerUsesConsistentIndexing() {
    public void affinityRequestLoadBalancerUsesConsistentIndexing() {
        final Function<Request, RequestWithIndex, NeverThrowsException> f =
                newShardedRequestLoadBalancerNextFunction(asList(mock(ConnectionFactory.class),
                                                             mock(ConnectionFactory.class)));
                newAffinityRequestLoadBalancerNextFunction(asList(mock(ConnectionFactory.class),
                                                                  mock(ConnectionFactory.class)));
        // These two DNs have a different hash code.
        final DN dn1 = DN.valueOf("cn=target1,dc=example,dc=com");
opendj-ldap-sdk-examples/src/main/java/org/forgerock/opendj/examples/Proxy.java
@@ -57,7 +57,7 @@
 *         <remoteAddress1> <remotePort1> [<remoteAddress2> <remotePort2> ...]}
 * </pre>
 *
 * Where {@code <mode>} is one of "round-robin", "fail-over", or "sharded". The default is round-robin.
 * Where {@code <mode>} is one of "round-robin", "fail-over", or "affinity". The default is round-robin.
 */
public final class Proxy {
    /**
@@ -164,11 +164,11 @@
            return LoadBalancingAlgorithm.ROUND_ROBIN;
        case "fail-over":
            return LoadBalancingAlgorithm.FAIL_OVER;
        case "sharded":
            return LoadBalancingAlgorithm.SHARDED;
        case "affinity":
            return LoadBalancingAlgorithm.AFFINITY;
        default:
            System.err.println("Unrecognized load-balancing algorithm '" + algorithmName + "'. Should be one of "
                                       + "'round-robin', 'fail-over', or 'sharded'.");
                                       + "'round-robin', 'fail-over', or 'affinity'.");
            System.exit(1);
        }
        return LoadBalancingAlgorithm.ROUND_ROBIN; // keep compiler happy.
@@ -189,10 +189,10 @@
                return Connections.newFailoverLoadBalancer(factories, options);
            }
        },
        SHARDED {
        AFFINITY {
            @Override
            ConnectionFactory newLoadBalancer(final Collection<ConnectionFactory> factories, final Options options) {
                return Connections.newShardedRequestLoadBalancer(factories, options);
                return Connections.newAffinityRequestLoadBalancer(factories, options);
            }
        };