Top Description Fields Constructors Methods
org.eclipse.persistence.descriptors.partitioning

public Class HashPartitioningPolicy

extends FieldPartitioningPolicy
Class Inheritance
Imports
java.util.ArrayList, .List, org.eclipse.persistence.descriptors.ClassDescriptor, org.eclipse.persistence.internal.databaseaccess.Accessor, org.eclipse.persistence.internal.sessions.AbstractRecord, .AbstractSession, org.eclipse.persistence.queries.DatabaseQuery, org.eclipse.persistence.sessions.server.ServerSession

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.
Author
James Sutherland
Since
EclipseLink 2.2

Field Summary

Modifier and TypeField and Description
protected List<String>
Inherited from org.eclipse.persistence.descriptors.partitioning.FieldPartitioningPolicy:
partitionFieldunionUnpartitionableQueries

Constructor Summary

AccessConstructor and Description
public
public
public
HashPartitioningPolicy(String partitionField, boolean unionUnpartitionableQueries)

Method Summary

Modifier and TypeMethod and Description
public void
addConnectionPool(String connectionPool)

PUBLIC: Add the connection pool name to the list of pools to rotate queries through.

private int
public List<String>
getConnectionPools()

PUBLIC: Return the list of connection pool names to replicate queries to.

public List<Accessor>
getConnectionsForQuery(AbstractSession session, DatabaseQuery query, AbstractRecord arguments)

Implements abstract org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy.getConnectionsForQuery.

INTERNAL: Get a connection from one of the pools in a round robin rotation fashion.
public void
initialize(AbstractSession session)

Overrides org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy.initialize.

INTERNAL: Default the connection pools to all pools if unset.
public void
partitionPersist(AbstractSession session, Object object, ClassDescriptor descriptor)

Overrides org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy.partitionPersist.

INTERNAL: Allow for the persist call to assign the partition.
public void
setConnectionPools(List<String> connectionPools)

PUBLIC: Set the list of connection pool names to replicate queries to.

Inherited from org.eclipse.persistence.descriptors.partitioning.FieldPartitioningPolicy:
extractPartitionValueForPersistgetPartitionFieldgetPartitionFieldNamegetUnionUnpartitionableQueriessetPartitionFieldsetPartitionFieldsetUnionUnpartitionableQueries

Field Detail

connectionPoolsback to summary
protected List<String> connectionPools

Constructor Detail

HashPartitioningPolicyback to summary
public HashPartitioningPolicy()
HashPartitioningPolicyback to summary
public HashPartitioningPolicy(String partitionField)
HashPartitioningPolicyback to summary
public HashPartitioningPolicy(String partitionField, boolean unionUnpartitionableQueries)

Method Detail

addConnectionPoolback to summary
public void addConnectionPool(String connectionPool)

PUBLIC: Add the connection pool name to the list of pools to rotate queries through.

computePartitionIdback to summary
private int computePartitionId(Object o)
getConnectionPoolsback to summary
public List<String> getConnectionPools()

PUBLIC: Return the list of connection pool names to replicate queries to.

getConnectionsForQueryback to summary
public List<Accessor> getConnectionsForQuery(AbstractSession session, DatabaseQuery query, AbstractRecord arguments)

Implements abstract org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy.getConnectionsForQuery.

INTERNAL: Get a connection from one of the pools in a round robin rotation fashion.

Annotations
@Override
initializeback to summary
public void initialize(AbstractSession session)

Overrides org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy.initialize.

INTERNAL: Default the connection pools to all pools if unset.

Annotations
@Override
partitionPersistback to summary
public void partitionPersist(AbstractSession session, Object object, ClassDescriptor descriptor)

Overrides org.eclipse.persistence.descriptors.partitioning.PartitioningPolicy.partitionPersist.

INTERNAL: Allow for the persist call to assign the partition.

Annotations
@Override
setConnectionPoolsback to summary
public void setConnectionPools(List<String> connectionPools)

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.