org.eclipse.persistence.descriptors.partitioning
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:
- java.io.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
Method Summary |
java.util.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. |
boolean |
getReplicateWrites()
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 |
nextIndex()
INTERNAL:
Return the next pool index to use. |
void |
setReplicateWrites(boolean replicateWrites)
PUBLIC:
Set if write queries should be replicated. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
currentIndex
protected volatile int currentIndex
replicateWrites
protected boolean replicateWrites
RoundRobinPartitioningPolicy
public RoundRobinPartitioningPolicy()
RoundRobinPartitioningPolicy
public RoundRobinPartitioningPolicy(boolean replicateWrites)
RoundRobinPartitioningPolicy
public RoundRobinPartitioningPolicy(java.lang.String... pools)
RoundRobinPartitioningPolicy
public RoundRobinPartitioningPolicy(java.util.List<java.lang.String> pools)
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 java.util.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.