|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.buckets.BucketDispatcher
public class BucketDispatcher
This class is a dispatcher for maintaining a set of local buckets.
Kept buckets can be accessed using unique bucket identifiers (BIDs).
New buckets can be created using the createBucket(java.lang.Class extends messif.buckets.LocalBucket>, long, long, long, boolean, java.util.Map
method - the unique ID is assigned automatically.
To create a bucket, a specific bucket implementation class, capacity settings and additional class-specific parameters are needed.
They are either passed to the createBucket
method, or the dispatcher's default values are used.
Automatic pivot choosers can be created for new buckets - see setAutoPivotChooser(java.lang.Class extends messif.pivotselection.AbstractPivotChooser>)
.
To remove a bucket from the dispatcher, use removeBucket(int, boolean)
. Note that
objects remain inside the bucket, just the bucket will be no longer maintained
by this dispatcher.
LocalBucket
,
Serialized FormField Summary | |
---|---|
protected java.lang.Class<? extends AbstractPivotChooser> |
autoPivotChooserClass
The class of pivot chooser that is automatically created for newly created buckets |
protected AbstractPivotChooser |
autoPivotChooserInstance
The pivot chooser instance that chooses pivots for all the buckets in this dispatcher |
protected long |
bucketCapacity
Default bucket hard capacity for newly created buckets |
protected long |
bucketLowOccupation
Default bucket hard low-occupation for newly created buckets |
protected boolean |
bucketOccupationAsBytes
Default flag whether to store occupation & capacity in bytes (true) or number of objects (false) for newly created buckets |
protected long |
bucketSoftCapacity
Default bucket soft capacity for newly created buckets |
protected java.util.Map<LocalBucket,AbstractPivotChooser> |
createdPivotChoosers
The hash table of pivot choosers that are assigned to buckets of this dispatcher |
protected java.lang.Class<? extends LocalBucket> |
defaultBucketClass
Default class for newly created buckets |
protected java.util.Map<java.lang.String,java.lang.Object> |
defaultBucketClassParams
Default parameters for newly created buckets with default bucket class |
protected static java.util.logging.Logger |
log
Logger for the bucket dispatcher |
static int |
UNASSIGNED_BUCKET_ID
The ID of buckets that do not belong to a dispatcher |
Constructor Summary | |
---|---|
BucketDispatcher(int maxBuckets,
long bucketCapacity,
java.lang.Class<? extends LocalBucket> defaultBucketClass)
Creates a new instance of BucketDispatcher only with maximal capacity specification. |
|
BucketDispatcher(int maxBuckets,
long bucketCapacity,
long bucketSoftCapacity,
long bucketLowOccupation,
boolean bucketOccupationAsBytes,
java.lang.Class<? extends LocalBucket> defaultBucketClass)
Creates a new instance of BucketDispatcher with full specification of default values. |
|
BucketDispatcher(int maxBuckets,
long bucketCapacity,
long bucketSoftCapacity,
long bucketLowOccupation,
boolean bucketOccupationAsBytes,
java.lang.Class<? extends LocalBucket> defaultBucketClass,
java.util.Map<java.lang.String,java.lang.Object> defaultBucketClassParams)
Creates a new instance of BucketDispatcher with full specification of default values. |
Method Summary | |
---|---|
LocalBucket |
addBucket(LocalBucket bucket)
Add an existing bucket to this dispatcher. |
protected AbstractPivotChooser |
createAutoPivotChooser(LocalBucket bucket)
Creates a new pivot chooser for the provided bucket. |
LocalBucket |
createBucket()
Create new local bucket with the default storage class and default storage capacity. |
LocalBucket |
createBucket(java.lang.Class<? extends LocalBucket> storageClass)
Create new local bucket with specified storage class and default storage capacity. |
static LocalBucket |
createBucket(java.lang.Class<? extends LocalBucket> storageClass,
long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes,
java.util.Map<java.lang.String,java.lang.Object> storageClassParams)
Create new local bucket with specified storage class and storage capacity (different from default values). |
LocalBucket |
createBucket(java.lang.Class<? extends LocalBucket> storageClass,
java.util.Map<java.lang.String,java.lang.Object> storageClassParams)
Create new local bucket with specified storage class and default storage capacity. |
LocalBucket |
createBucket(java.lang.Class<? extends LocalBucket> storageClass,
java.util.Map<java.lang.String,java.lang.Object> storageClassParams,
long capacity,
long softCapacity,
long lowOccupation)
Create new local bucket with specified storage class and storage capacity (different from default values). |
LocalBucket |
createBucket(long capacity,
long softCapacity,
long lowOccupation)
Create new local bucket with default storage class and specified storage capacity. |
void |
destroy()
Destroys all buckets managed by this dispatcher. |
void |
finalize()
Finalize all buckets managed by this dispatcher. |
java.util.Set<java.lang.Integer> |
getAllBucketIDs()
Returns the set of bucket IDs maintaned by this dispatcher. |
java.util.Collection<LocalBucket> |
getAllBuckets()
Returns the collection of all buckets maintained by this dispatcher. |
AbstractPivotChooser |
getAutoPivotChooser(int bucketID)
Returns pivot chooser that was automatically created for a bucket of this dispatcher. |
java.lang.Class<? extends AbstractPivotChooser> |
getAutoPivotChooserClass()
Returns the class of the pivot chooser that is currently used for buckets in this dispatcher. |
LocalBucket |
getBucket(int bucketID)
Returns the bucket with the specified ID. |
long |
getBucketCapacity()
Returns the default hard capactity limit for new buckets. |
int |
getBucketCount()
Returns the actual number of buckets maintained by this dispatcher. |
long |
getBucketLowOccupation()
Returns the default hard low-occupation capactity limit for new buckets. |
boolean |
getBucketOccupationAsBytes()
Returns the default flag whether to compute occupation & capacity in bytes (true) or number of objects (false) for new buckets. |
long |
getBucketSoftCapacity()
Returns the default soft capactity limit for new buckets. |
java.lang.Class<? extends LocalBucket> |
getDefaultBucketClass()
Returns the default class for newly created buckets. |
java.util.Map<java.lang.String,java.lang.Object> |
getDefaultBucketClassParams()
Returns the default parameters for newly created buckets with default bucket class. |
int |
getObjectCount()
Returns the sum of object counts stored in all buckets maintained by this dispatcher. |
long |
getOccupation()
Returns the sum of occupations of all buckets maintained by this dispatcher. |
int |
getOverloadedBucketCount()
Returns number of buckets that exceed their soft-capacities. |
LocalBucket |
moveBucket(int bucketID,
BucketDispatcher targetDispatcher)
Move the bucket with the specified ID to another dispatcher. |
void |
removeBucket(int bucketID)
Delete the bucket with specified ID from this dispatcher. |
LocalBucket |
removeBucket(int bucketID,
boolean destroyBucket)
Delete the bucket with specified ID from this dispatcher. |
void |
setAllBucketLowOccupation(long bucketLowOccupation)
Set the low occupattion for all buckets registered by this dispatcher. |
void |
setAllBucketSoftCapacity(long bucketSoftCapacity)
Set the soft capacity for all buckets registered by this dispatcher. |
void |
setAutoPivotChooser(AbstractPivotChooser autoPivotChooserInstance)
Set the pivot chooser instance that chooses pivots for all the buckets in this dispatcher. |
void |
setAutoPivotChooser(java.lang.Class<? extends AbstractPivotChooser> autoPivotChooserClass)
Set the class of pivot chooser that will be created whenever a bucket is created by this dispatcher. |
void |
setBucketCapacity(long bucketCapacity)
Set bucket capacity for all new buckets. |
void |
setBucketLowOccupation(long bucketLowOccupation)
Set param "low occupeation" for all new buckets |
void |
setBucketOccupationAsBytes(boolean bucketOccupationAsBytes)
Set param bucketOccupationAsBytes for all new buckets. |
void |
setBucketSoftCapacity(long bucketSoftCapacity)
Set new soft capacity for all new buckets. |
void |
setDefaultBucketClass(java.lang.Class<? extends LocalBucket> defaultBucketClass)
Set default class for all new buckets |
void |
setDefaultBucketClassParams(java.util.Map<java.lang.String,java.lang.Object> defaultBucketClassParams)
New parameters for all new default buckets |
java.lang.String |
toString()
Returns information about storage maintained by this dispatcher. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static java.util.logging.Logger log
public static final int UNASSIGNED_BUCKET_ID
protected long bucketCapacity
protected long bucketSoftCapacity
protected long bucketLowOccupation
protected boolean bucketOccupationAsBytes
protected java.lang.Class<? extends LocalBucket> defaultBucketClass
protected java.util.Map<java.lang.String,java.lang.Object> defaultBucketClassParams
protected java.lang.Class<? extends AbstractPivotChooser> autoPivotChooserClass
protected AbstractPivotChooser autoPivotChooserInstance
protected final java.util.Map<LocalBucket,AbstractPivotChooser> createdPivotChoosers
Constructor Detail |
---|
public BucketDispatcher(int maxBuckets, long bucketCapacity, long bucketSoftCapacity, long bucketLowOccupation, boolean bucketOccupationAsBytes, java.lang.Class<? extends LocalBucket> defaultBucketClass, java.util.Map<java.lang.String,java.lang.Object> defaultBucketClassParams)
maxBuckets
- the maximal number of buckets maintained by this dispatcherbucketCapacity
- the default bucket hard capacity for newly created bucketsbucketSoftCapacity
- the default bucket soft capacity for newly created bucketsbucketLowOccupation
- the default bucket hard low-occupation for newly created bucketsbucketOccupationAsBytes
- the default flag whether to store occupation & capacity in bytes (true) or number of objects (false) for newly create bucketsdefaultBucketClass
- the default class for newly created bucketsdefaultBucketClassParams
- the default parameters for newly created buckets with default bucket classpublic BucketDispatcher(int maxBuckets, long bucketCapacity, long bucketSoftCapacity, long bucketLowOccupation, boolean bucketOccupationAsBytes, java.lang.Class<? extends LocalBucket> defaultBucketClass)
maxBuckets
- the maximal number of buckets maintained by this dispatcherbucketCapacity
- the default bucket hard capacity for newly created bucketsbucketSoftCapacity
- the default bucket soft capacity for newly created bucketsbucketLowOccupation
- the default bucket hard low-occupation for newly created bucketsbucketOccupationAsBytes
- the default flag whether to store occupation & capacity in bytes (true) or number of objects (false) for newly create bucketsdefaultBucketClass
- the default class for newly created bucketspublic BucketDispatcher(int maxBuckets, long bucketCapacity, java.lang.Class<? extends LocalBucket> defaultBucketClass)
maxBuckets
- the maximal number of buckets maintained by this dispatcherbucketCapacity
- the default bucket hard capacity for newly created bucketsdefaultBucketClass
- the default class for newly created bucketsMethod Detail |
---|
public void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
- if there was an error during releasing resourcespublic void destroy() throws java.lang.Throwable
java.lang.Throwable
- if there was an error during destroying bucketspublic AbstractPivotChooser getAutoPivotChooser(int bucketID)
bucketID
- the ID of the bucket for which to get the pivot chooser
public void setAutoPivotChooser(java.lang.Class<? extends AbstractPivotChooser> autoPivotChooserClass) throws java.lang.IllegalArgumentException
autoPivotChooserClass
- the class of the pivot chooser to create
java.lang.IllegalArgumentException
- if the specified class is abstract or does not have a public nullary constructorpublic void setAutoPivotChooser(AbstractPivotChooser autoPivotChooserInstance)
autoPivotChooserInstance
- the pivot chooser instancepublic java.lang.Class<? extends AbstractPivotChooser> getAutoPivotChooserClass()
protected AbstractPivotChooser createAutoPivotChooser(LocalBucket bucket)
getAutoPivotChooser(int)
will
return it for the bucket.
bucket
- the bucket for which to create pivot chooser
public void setBucketCapacity(long bucketCapacity)
bucketCapacity
- new hard capacity.public void setBucketLowOccupation(long bucketLowOccupation)
bucketLowOccupation
- new low occupation.public void setBucketOccupationAsBytes(boolean bucketOccupationAsBytes)
bucketOccupationAsBytes
for all new buckets.
bucketOccupationAsBytes
- new value for param bucketOccupationAsBytes
.public void setBucketSoftCapacity(long bucketSoftCapacity)
bucketSoftCapacity
- new soft capacity parampublic void setDefaultBucketClass(java.lang.Class<? extends LocalBucket> defaultBucketClass)
defaultBucketClass
- new bucket default class.public void setDefaultBucketClassParams(java.util.Map<java.lang.String,java.lang.Object> defaultBucketClassParams)
defaultBucketClassParams
- new params for default bucketspublic void setAllBucketSoftCapacity(long bucketSoftCapacity)
bucketSoftCapacity
- new bucket soft capacity for the existing bucketspublic void setAllBucketLowOccupation(long bucketLowOccupation)
bucketLowOccupation
- new low occupation.public long getBucketCapacity()
public long getBucketSoftCapacity()
public long getBucketLowOccupation()
public boolean getBucketOccupationAsBytes()
public java.lang.Class<? extends LocalBucket> getDefaultBucketClass()
public java.util.Map<java.lang.String,java.lang.Object> getDefaultBucketClassParams()
public int getBucketCount()
public int getOverloadedBucketCount()
public long getOccupation()
public int getObjectCount()
public java.util.Set<java.lang.Integer> getAllBucketIDs()
public java.util.Collection<LocalBucket> getAllBuckets()
public LocalBucket getBucket(int bucketID) throws java.util.NoSuchElementException
bucketID
- the ID of the bucket to return
java.util.NoSuchElementException
- if there is no bucket associated with the specified ID in this dispatcherpublic static LocalBucket createBucket(java.lang.Class<? extends LocalBucket> storageClass, long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes, java.util.Map<java.lang.String,java.lang.Object> storageClassParams) throws java.lang.IllegalArgumentException
storageClass
- the class that represents the bucket implementation to usecapacity
- the hard capacity of the new bucketsoftCapacity
- the soft capacity of the new bucket (soft <= hard must hold otherwise hard is set to soft)lowOccupation
- the low-occupation limit for the new bucketoccupationAsBytes
- flag whether the occupation (and thus all the limits) are in bytes or number of objectsstorageClassParams
- additional parameters for creating a new instance of the storageClass
java.lang.IllegalArgumentException
- if public LocalBucket createBucket(java.lang.Class<? extends LocalBucket> storageClass, java.util.Map<java.lang.String,java.lang.Object> storageClassParams, long capacity, long softCapacity, long lowOccupation) throws BucketStorageException, java.lang.IllegalArgumentException
storageClass
- the class that represents the bucket implementation to usestorageClassParams
- additional parameters for creating a new instance of the storageClasscapacity
- the hard capacity of the new bucketsoftCapacity
- the soft capacity of the new bucket (soft <= hard must hold otherwise hard is set to soft)lowOccupation
- the low-occupation limit for the new bucket
BucketStorageException
- if the maximal number of buckets is already allocated
java.lang.IllegalArgumentException
- if public LocalBucket createBucket() throws BucketStorageException, java.lang.IllegalArgumentException
BucketStorageException
- if the maximal number of buckets is already allocated
java.lang.IllegalArgumentException
- if public LocalBucket createBucket(java.lang.Class<? extends LocalBucket> storageClass) throws BucketStorageException, java.lang.IllegalArgumentException
storageClass
- the class that represents the bucket implementation to use
BucketStorageException
- if the maximal number of buckets is already allocated
java.lang.IllegalArgumentException
- if public LocalBucket createBucket(java.lang.Class<? extends LocalBucket> storageClass, java.util.Map<java.lang.String,java.lang.Object> storageClassParams) throws BucketStorageException, java.lang.IllegalArgumentException
storageClass
- the class that represents the bucket implementation to usestorageClassParams
- additional parameters for creating a new instance of the storageClass
BucketStorageException
- if the maximal number of buckets is already allocated
java.lang.IllegalArgumentException
- if public LocalBucket createBucket(long capacity, long softCapacity, long lowOccupation) throws BucketStorageException, java.lang.IllegalArgumentException
capacity
- the hard capacity of the new bucketsoftCapacity
- the soft capacity of the new bucket (soft <= hard must hold otherwise hard is set to soft)lowOccupation
- the low-occupation limit for the new bucket
BucketStorageException
- if the maximal number of buckets is already allocated
java.lang.IllegalArgumentException
- if public LocalBucket addBucket(LocalBucket bucket) throws java.lang.IllegalStateException, BucketStorageException
bucket
- the bucket to add to this dispatcher
java.lang.IllegalStateException
- if the bucket is already maintained by another one
BucketStorageException
- if the maximal number of buckets is already allocatedpublic LocalBucket removeBucket(int bucketID, boolean destroyBucket) throws java.util.NoSuchElementException
destroyBucket == false
),
the bucket will be no longer maintained by this dispatcher, but no objects
are deleted from the bucket.
bucketID
- the ID of the bucket to deletedestroyBucket
- if true, all the objects in the bucket are destroyed.
java.util.NoSuchElementException
- if there is no bucket with the specified IDpublic void removeBucket(int bucketID) throws java.util.NoSuchElementException
destroyed
,
i.e. all objects are deleted and
However, statistics for the bucket are destroyed.
bucketID
- the ID of the bucket to delete
java.util.NoSuchElementException
- if there is no bucket with the specified IDpublic LocalBucket moveBucket(int bucketID, BucketDispatcher targetDispatcher) throws java.util.NoSuchElementException, BucketStorageException
bucketID
- the ID of the bucket to movetargetDispatcher
- the target dispatcher to move the bucket to
java.util.NoSuchElementException
- if there is no bucket with the specified ID
BucketStorageException
- if the maximal number of buckets is already allocatedpublic java.lang.String toString()
toString
in class java.lang.Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |