Module eclipselink

Class RoundRobinPartitioningPolicy

  • All Implemented Interfaces:
    Serializable

    public class RoundRobinPartitioningPolicy
    extends ReplicationPartitioningPolicy
    PUBLIC: RoundRobinPartitioningPolicy sends requests in a round robin fashion to the set of connection pools. It is for load-balancing read queries across a cluster of database machines. It requires that the full database be replicated on each machine, so does not support partitioning. The data should either be read-only, or writes should be replicated on the database.
    See Also:
    Serialized Form
    Author:
    James Sutherland
    Since:
    EclipseLink 2.2
    • Field Detail

      • currentIndex

        protected volatile int currentIndex
      • replicateWrites

        protected boolean replicateWrites
    • Constructor Detail

      • RoundRobinPartitioningPolicy

        public RoundRobinPartitioningPolicy()
      • RoundRobinPartitioningPolicy

        public RoundRobinPartitioningPolicy​(boolean replicateWrites)
      • RoundRobinPartitioningPolicy

        public RoundRobinPartitioningPolicy​(String... pools)
      • RoundRobinPartitioningPolicy

        public RoundRobinPartitioningPolicy​(List<String> pools)
    • Method Detail

      • getReplicateWrites

        public boolean getReplicateWrites()
        PUBLIC: Return if write queries should be replicated. This allows for a set of database to be written to and kept in synch, and have reads load-balanced across the databases.
      • setReplicateWrites

        public void setReplicateWrites​(boolean replicateWrites)
        PUBLIC: Set if write queries should be replicated. This allows for a set of database to be written to and kept in synch, and have reads load-balanced across the databases.
      • getConnectionsForQuery

        public List<org.eclipse.persistence.internal.databaseaccess.Accessor> getConnectionsForQuery​(org.eclipse.persistence.internal.sessions.AbstractSession session,
                                                                                                     DatabaseQuery query,
                                                                                                     org.eclipse.persistence.internal.sessions.AbstractRecord arguments)
        INTERNAL: Get a connection from one of the pools in a round robin rotation fashion.
        Overrides:
        getConnectionsForQuery in class ReplicationPartitioningPolicy
      • nextIndex

        public int nextIndex()
        INTERNAL: Return the next pool index to use.
      • nextAccessor

        public org.eclipse.persistence.internal.databaseaccess.Accessor nextAccessor​(ServerSession session,
                                                                                     DatabaseQuery query)
        INTERNAL: Return the next connection accessor.