Class HashPartitioningPolicy
java.lang.Object
org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy
org.eclipse.persistence.descriptors.partitioning.FieldPartitioningPolicy
org.eclipse.persistence.descriptors.partitioning.HashPartitioningPolicy
- All Implemented Interfaces:
Serializable
PUBLIC:
HashPartitioningPolicy partitions access to a database cluster by the hash of a field value from the object,
such as the object's location, or tenant.
The hash indexes into the list of connection pools.
All write or read request for objects with that hash value are sent to the server.
If a query does not include the field as a parameter, then it can either be sent
to all servers and unioned, or left to the session's default behavior.
- See Also:
- Author:
- James Sutherland
-
Field Summary
Fields inherited from class org.eclipse.persistence.descriptors.partitioning.FieldPartitioningPolicy
partitionField, unionUnpartitionableQueries
Fields inherited from class org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy
name
-
Constructor Summary
ConstructorDescriptionHashPartitioningPolicy
(String partitionField) HashPartitioningPolicy
(String partitionField, boolean unionUnpartitionableQueries) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addConnectionPool
(String connectionPool) PUBLIC: Add the connection pool name to the list of pools to rotate queries through.PUBLIC: Return the list of connection pool names to replicate queries to.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.void
initialize
(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Default the connection pools to all pools if unset.void
partitionPersist
(org.eclipse.persistence.internal.sessions.AbstractSession session, Object object, ClassDescriptor descriptor) INTERNAL: Allow for the persist call to assign the partition.void
setConnectionPools
(List<String> connectionPools) PUBLIC: Set the list of connection pool names to replicate queries to.Methods inherited from class org.eclipse.persistence.descriptors.partitioning.FieldPartitioningPolicy
extractPartitionValueForPersist, getPartitionField, getPartitionFieldName, getUnionUnpartitionableQueries, setPartitionField, setPartitionField, setUnionUnpartitionableQueries
Methods inherited from class org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy
acquireAccessor, convertClassNamesToClasses, getAccessor, getName, setName
-
Field Details
-
connectionPools
-
-
Constructor Details
-
HashPartitioningPolicy
public HashPartitioningPolicy() -
HashPartitioningPolicy
-
HashPartitioningPolicy
-
-
Method Details
-
initialize
public void initialize(org.eclipse.persistence.internal.sessions.AbstractSession session) INTERNAL: Default the connection pools to all pools if unset.- Overrides:
initialize
in classPartitioningPolicy
-
getConnectionPools
PUBLIC: Return the list of connection pool names to replicate queries to. -
setConnectionPools
PUBLIC: Set the list of connection pool names to replicate queries to. A connection pool with the same name must be defined on the ServerSession. -
addConnectionPool
PUBLIC: Add the connection pool name to the list of pools to rotate queries through. -
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.- Specified by:
getConnectionsForQuery
in classPartitioningPolicy
-
partitionPersist
public void partitionPersist(org.eclipse.persistence.internal.sessions.AbstractSession session, Object object, ClassDescriptor descriptor) INTERNAL: Allow for the persist call to assign the partition.- Overrides:
partitionPersist
in classPartitioningPolicy
-