Class RoundRobinPartitioningPolicy
java.lang.Object
org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy
org.eclipse.persistence.descriptors.partitioning.ReplicationPartitioningPolicy
org.eclipse.persistence.descriptors.partitioning.RoundRobinPartitioningPolicy
- All Implemented Interfaces:
Serializable
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:
- Author:
- James Sutherland
-
Field Summary
Fields inherited from class org.eclipse.persistence.descriptors.partitioning.ReplicationPartitioningPolicy
connectionPools
Fields inherited from class org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy
name
-
Constructor Summary
ConstructorDescriptionRoundRobinPartitioningPolicy
(boolean replicateWrites) RoundRobinPartitioningPolicy
(String... pools) RoundRobinPartitioningPolicy
(List<String> pools) -
Method Summary
Modifier and TypeMethodDescriptionList<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.boolean
PUBLIC: Return if write queries should be replicated.org.eclipse.persistence.internal.databaseaccess.Accessor
nextAccessor
(ServerSession session, DatabaseQuery query) INTERNAL: Return the next connection accessor.int
INTERNAL: Return the next pool index to use.void
setReplicateWrites
(boolean replicateWrites) PUBLIC: Set if write queries should be replicated.Methods inherited from class org.eclipse.persistence.descriptors.partitioning.ReplicationPartitioningPolicy
addConnectionPool, getConnectionPools, initialize, setConnectionPools
Methods inherited from class org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy
acquireAccessor, convertClassNamesToClasses, getAccessor, getName, partitionPersist, setName
-
Field Details
-
currentIndex
protected volatile int currentIndex -
replicateWrites
protected boolean replicateWrites
-
-
Constructor Details
-
RoundRobinPartitioningPolicy
public RoundRobinPartitioningPolicy() -
RoundRobinPartitioningPolicy
public RoundRobinPartitioningPolicy(boolean replicateWrites) -
RoundRobinPartitioningPolicy
-
RoundRobinPartitioningPolicy
-
-
Method Details
-
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 classReplicationPartitioningPolicy
-
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.
-