public final class Partition extends java.lang.Object
Note that partitions are only visible on their active and replica nodes, not all nodes in the cluster.
| Modifier and Type | Class and Description |
|---|---|
static class |
Partition.Properties
The Partition properties used when defining a partition
|
static class |
Partition.State
The Partition states
|
| Modifier and Type | Field and Description |
|---|---|
static int |
ActiveNodeIndex
Index to the active node in the nodes array
|
static long |
DefaultObjectsLockedPerTransaction
The default number of objects locked per transaction when
performing a migrate or update.
|
| Modifier and Type | Method and Description |
|---|---|
java.lang.String |
getActiveNode()
Get the active node for the partition.
|
Partition.State |
getCurrentState()
Get the current state for the partition.
|
java.util.Date |
getLastStateChangeTime()
Get the last time the state for the partition was updated
|
java.lang.String |
getName()
Get the partition name.
|
java.lang.String[] |
getNodeList()
Get the complete node list for the partition.
|
Partition.Properties |
getProperties()
Get the properties currently defined for the partition.
|
ReplicaNode |
getReplicaNode(int idx)
Get the ReplicaNode instance for the given replica node index.
|
ReplicaNode |
getReplicaNode(java.lang.String nodeName)
Get the ReplicaNode instance for the given replica node name.
|
java.lang.String[] |
getReplicaNodes()
Get the replica node list for the partition.
|
void |
migrate(Partition.Properties partitionProperties,
java.lang.String activeNode,
ReplicaNode[] replicas)
Migrate the partition.
|
void |
migrate(java.lang.String[] nodes)
Deprecated.
|
void |
setNotifier(PartitionNotifier partitionNotifier)
Associated a notifier with the partition.
|
void |
update()
Deprecated.
|
void |
update(Partition.Properties partitionProperties)
Update the partition.
|
public static final int ActiveNodeIndex
public static final long DefaultObjectsLockedPerTransaction
public final java.lang.String getName()
public final java.lang.String getActiveNode()
public final java.lang.String[] getReplicaNodes()
public final java.lang.String[] getNodeList()
The node list is a String array of node names, with the active node being at ActiveNodeIndex, followed by a prioritized list of replica nodes.
public final Partition.State getCurrentState()
public final ReplicaNode getReplicaNode(int idx) throws java.lang.IndexOutOfBoundsException
idx - Index into the ReplicaNode array.java.lang.IndexOutOfBoundsException - The idx isn't valid.public final ReplicaNode getReplicaNode(java.lang.String nodeName) throws java.lang.IllegalArgumentException
nodeName - Name of replica node.java.lang.IllegalArgumentException - The nodeName was invalid.public final java.util.Date getLastStateChangeTime()
public final Partition.Properties getProperties()
The restoreFromNode property is not stored in the runtime since it has no meaning outside of the initial definePartition(). So this method will return a Properties instance with a null restoreFromNode value.
@Deprecated public final void update() throws NodeMismatch, NotActiveNode
update(Properties) instead.NodeMismatchNotActiveNodepublic final void update(Partition.Properties partitionProperties) throws NodeMismatch, NotActiveNode
This method is used to re-partition all instances that exist in a
partition. For each instance in the partition, the PartitionMapper defined for that type is accessed, and the
instance re-assigned to the partition that the PartitionMapper.getPartition(java.lang.Object) method returns. The update() method
must be called on the current active node for the partition.
To split a partition, the applications should create the new partition, install a new PartitionMapper for all types managed by the partition, and call the update() method for the existing partition.
To merge two or more partitions, the applications should install a new PartitionMapper for all types managed by the partition(s), and call the update() method for all the partitions that need to be merged.
It is important that all partitions returned when executing the PartitionMapper's getPartition() call for a type all contain identical node lists. If the partition returned contains a different node list than this partition, a NodeMismatch exception is thrown, and the update() terminates. To fix this, perform a migrate() on all partitions that will be split or merged to insure that they have identical node lists before performing an update().
partitionProperties - Optional properties for the partition.
If null, the default property values are used.NodeMismatch - The re-partitioning of instances was done using partitions that
have different node lists.NotActiveNode - The current node is not the active node for the partition.@Deprecated public final void migrate(java.lang.String[] nodes) throws NotActiveNode, java.lang.IllegalArgumentException
migrate(Properties, String, ReplicaNode []) instead.NotActiveNodejava.lang.IllegalArgumentExceptionpublic final void migrate(Partition.Properties partitionProperties, java.lang.String activeNode, ReplicaNode[] replicas) throws NotActiveNode, java.lang.IllegalArgumentException
This method is used to migrate all instances that exist in a partition. For each instance in the partition, the object is migrated as needed to all nodes in the replicas array, and to the new activeNode if it is different from the current active node. This method must be called on the currently active node for the partition.
Any properties passed in only apply to the current migrate() command, properties passed into definePartition() are saved and used during failover.
partitionProperties - Optional properties for the partition.
If null, the default property values are used.activeNode - Active node after migrate completes.replicas - An ordered list of replica nodes for the partition.
Should be passed in as a null instance or a zero length array if
no replicas exists.NotActiveNode - The current node is not the active node for the partition.java.lang.IllegalArgumentException - The activeNode or replica array was invalid.public final void setNotifier(PartitionNotifier partitionNotifier)
This method is used to associate a user defined PartitionNotifier
instance with a partition.
PartitionNotifier instances are local to a node, this method should be executed on all nodes which need to determine if a partition state change occurs.
The same PartitionNotifier instance can be associated with multiple partitions. Multiple PartitionNotifier instances can be installed for a given Partition. When a state change occurs, all instances are executed, no order is guaranteed when executing the notifiers. To remove a notifier, the PartitionNotifier instance should be deleted.
partitionNotifier - User defined notifier instance.