public abstract class SplitPolicy extends java.lang.Object implements ObjectMatcher<LocalAbstractObject>, java.io.Serializable
object matcher
that decides the target partition of a given object according to this policy.
Some (or all) parameters can be unspecified when the policy is instantiated and can be provided through
setParameter(java.lang.String, java.lang.Object)
method later. However, the match
method returns
UnsupportedOperationException
until all the parameters are fully specified, i.e.
isComplete()
returns true).
If desired, some parameters can be locked, so they can't be changed anymore.Modifier and Type | Class and Description |
---|---|
protected static interface |
SplitPolicy.ParameterField
Annotation of split policy parameter field.
|
Modifier and Type | Field and Description |
---|---|
static int |
PART_ID_ANY
Identification of any partition (returned if a region cannot fit a single partition).
|
Modifier | Constructor and Description |
---|---|
protected |
SplitPolicy()
Creates a new instance of SplitPolicy.
|
Modifier and Type | Method and Description |
---|---|
protected BucketBallRegion |
getBucketBallRegion(LocalBucket bucket)
Returns the
BucketBallRegion associated with the specified bucket. |
java.lang.Object |
getParameter(java.lang.String parameter)
Returns the value of the specified parameter.
|
java.util.Set<java.lang.String> |
getParameterNames()
Returns all parameter names for this policy.
|
java.lang.Class<?> |
getParameterType(java.lang.String parameter)
Returns the type of the specified policy parameter.
|
abstract int |
getPartitionsCount()
Returns the number of partitions of this policy.
|
boolean |
isComplete()
Returns true if this policy has all the arguments necessary for a split defined.
|
boolean |
isParameterFilled(java.lang.String parameter)
Returns true if the specified parameter has a value set.
|
boolean |
isParameterLocked(java.lang.String parameter)
Returns true if the specified parameter is locked.
|
void |
lockParameter(java.lang.String parameter)
Locks the specified policy parameter.
|
abstract int |
match(BallRegion region)
Returns the group (partition) to which the whole ball region belongs.
|
abstract int |
match(LocalAbstractObject object)
Returns the group (partition) to which a given object belongs.
|
int |
match(LocalBucket bucket)
Returns the group (partition) to which the whole bucket belongs.
|
void |
setParameter(java.lang.String parameter,
java.lang.Object value)
Use this method to set the policy parameter.
|
public static final int PART_ID_ANY
-1
protected SplitPolicy()
public abstract int match(BallRegion region)
match(messif.objects.BallRegion)
method.region
- a ball region that is tested for the matching conditionpublic abstract int match(LocalAbstractObject object)
match
in interface ObjectMatcher<LocalAbstractObject>
object
- an object that is tested for the matching conditionprotected BucketBallRegion getBucketBallRegion(LocalBucket bucket) throws java.util.NoSuchElementException
BucketBallRegion
associated with the specified bucket.
It must be registered in the bucket as filter, otherwise a NoSuchElementException is thrown.bucket
- the bucket to get the region forBucketBallRegion
associated with bucketjava.util.NoSuchElementException
- if there was no ball region associatedpublic int match(LocalBucket bucket)
match(messif.objects.BallRegion)
method.
If there is no BucketBallRegion
registered in the bucket, -1 is returned.bucket
- a bucket that is tested for the matching conditionpublic boolean isComplete()
public java.util.Set<java.lang.String> getParameterNames()
public void setParameter(java.lang.String parameter, java.lang.Object value) throws java.lang.IllegalStateException, java.util.NoSuchElementException, java.lang.NullPointerException
parameter
- the name of the policy parametervalue
- new value for the parameterjava.lang.IllegalStateException
- if the specified parameter is lockedjava.util.NoSuchElementException
- if there is no parameter for the specified namejava.lang.NullPointerException
- if the specified value is nullpublic java.lang.Object getParameter(java.lang.String parameter) throws java.lang.IllegalStateException, java.util.NoSuchElementException
parameter
- the name of the policy parameterjava.lang.IllegalStateException
- if the parameter is not filled yetjava.util.NoSuchElementException
- if there is no parameter for the specified namepublic boolean isParameterLocked(java.lang.String parameter) throws java.util.NoSuchElementException
parameter
- the name of the policy parameterjava.util.NoSuchElementException
- if there is no parameter for the specified namepublic void lockParameter(java.lang.String parameter) throws java.util.NoSuchElementException
setParameter(java.lang.String, java.lang.Object)
method anymore.parameter
- the name of the policy parameterjava.util.NoSuchElementException
- if there is no parameter for the specified namepublic boolean isParameterFilled(java.lang.String parameter) throws java.util.NoSuchElementException
setParameter(java.lang.String, java.lang.Object)
was called for the specified parameter.parameter
- the name of the policy parameterjava.util.NoSuchElementException
- if there is no parameter for the specified namepublic java.lang.Class<?> getParameterType(java.lang.String parameter) throws java.util.NoSuchElementException
parameter
- the name of the policy parameterjava.util.NoSuchElementException
- if there is no parameter for the specified namepublic abstract int getPartitionsCount()