|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectmessif.buckets.Bucket
messif.buckets.LocalBucket
public abstract class LocalBucket
This class represents the Bucket that is maintained locally (i.e. on the current computer). The local bucket maintains statistics for number of reads, inserts and deletions. This class provides most of the implementation using a naive approach, minimal implementation of the underlying class must have at least methods getObjectCount, storeObject and iterator. Getting an object and removing one is done through the methods of the iterator. More effective implementations can override other methods as well. For deletion, you need to override method iterator:removeInternal().
Field Summary | |
---|---|
protected static StatisticRefCounter |
counterBucketAddObject
Number of object inserts statistic per bucket |
protected static StatisticRefCounter |
counterBucketDelObject
Number of object deletions statistic per bucket |
protected static StatisticRefCounter |
counterBucketRead
Number of bucket reads statistic per bucket |
Constructor Summary | |
---|---|
protected |
LocalBucket(long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes)
Constructs a new LocalBucket instance and setups all bucket limits |
Method Summary | ||
---|---|---|
void |
addObject(LocalAbstractObject object)
Insert a new object into this bucket. |
|
protected void |
addObject(LocalAbstractObject object,
Addible<LocalAbstractObject> addible)
Check if the object object can added to this bucket. |
|
BucketErrorCode |
addObjectErrCode(LocalAbstractObject object)
Insert a new object into this bucket and returns error code instead of exception. |
|
int |
deleteAllObjects()
Delete all objects from this bucket. |
|
int |
deleteObject(LocalAbstractObject object,
int deleteLimit)
Delete all objects from this bucket that are data-equals to
the specified object. |
|
protected void |
deleteObject(Removable<LocalAbstractObject> removable)
Check if the object can be deleted from this bucket. |
|
LocalAbstractObject |
deleteObject(UniqueID objectID)
Delete object with the specified ID from this bucket. |
|
void |
deregisterFilter(BucketFilter filter)
Remove a filter from the filter chain |
|
void |
destroy()
Destroy this bucket. |
|
void |
finalize()
Finalize this bucket. |
|
AbstractObjectIterator<LocalAbstractObject> |
getAllObjects()
Returns iterator over all objects from this bucket. |
|
int |
getBucketID()
Returns the unique ID of this bucket. |
|
long |
getCapacity()
Returns the maximal capacity of this bucket. |
|
|
getFilter(java.lang.Class<T> filterClass)
Returns the first registered filter that has the specified class |
|
Index<LocalAbstractObject> |
getIndex()
Returns the index defined on this bucket that can be used for searching. |
|
long |
getLowOccupation()
Returns the minimal occupation of this bucket. |
|
protected abstract ModifiableIndex<LocalAbstractObject> |
getModifiableIndex()
Returns the index (including storage) for this bucket. |
|
LocalAbstractObject |
getObject(AbstractObjectKey key)
Retrieve an object with the specified key from this bucket. |
|
LocalAbstractObject |
getObject(java.lang.String locator)
Retrieve an object with the specified locator from this bucket. |
|
LocalAbstractObject |
getObject(UniqueID objectID)
Retrieves an object with the specified ID from this bucket. |
|
int |
getObjectCount()
Returns current number of objects stored in this bucket. |
|
long |
getOccupation()
Returns the current occupation of this bucket. |
|
double |
getOccupationRatio()
Returns an occupation ratio with respect to the bucket's soft capacity, i.e. the current occupation divided by the soft capacity. |
|
long |
getSoftCapacity()
Returns the soft capacity of this bucket. |
|
boolean |
isBucketStandalone()
Returns whether this bucket is standalone bucket or if it is maintained by a bucket dispatcher. |
|
boolean |
isSoftCapacityExceeded()
Returns true if the soft-capacity of the bucket has been exceeded. |
|
void |
registerFilter(BucketFilter filter)
Append a new filter to the filter chain. |
|
void |
setLowOccupation(long lowOccupation)
Set param "low occupeation" for thsi bucket |
|
void |
setSoftCapacity(long softCapacity)
Set new soft capacity for this bucket |
|
java.lang.String |
toString()
Returns a string representation of this bucket. |
Methods inherited from class messif.buckets.Bucket |
---|
addObjects, addObjects, deleteObject, deleteObjects, processQuery, provideObjects, split |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final StatisticRefCounter counterBucketRead
protected static final StatisticRefCounter counterBucketAddObject
protected static final StatisticRefCounter counterBucketDelObject
Constructor Detail |
---|
protected LocalBucket(long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes)
capacity
- maximal capacity of the bucket - cannot be exceededsoftCapacity
- maximal soft capacity of the bucketlowOccupation
- a minimal occupation for deleting objects - cannot be loweredoccupationAsBytes
- flag whether the occupation (and thus all the limits) are in bytes or number of objectsMethod Detail |
---|
public void finalize() throws java.lang.Throwable
BucketDispatcher
when it is finalized.
finalize
in class java.lang.Object
java.lang.Throwable
- if there was an error while cleaningpublic void destroy() throws java.lang.Throwable
BucketDispatcher
when the bucket is removed
from the dispatcher.
java.lang.Throwable
- if there was an error while cleaningpublic int getBucketID()
getBucketID
in class Bucket
public boolean isBucketStandalone()
public void setLowOccupation(long lowOccupation)
lowOccupation
- new low occupation.public void setSoftCapacity(long softCapacity)
softCapacity
- new soft capacity parampublic long getCapacity()
public long getSoftCapacity()
public long getLowOccupation()
public long getOccupation()
public double getOccupationRatio()
public boolean isSoftCapacityExceeded()
public int getObjectCount()
protected abstract ModifiableIndex<LocalAbstractObject> getModifiableIndex()
public Index<LocalAbstractObject> getIndex()
public void registerFilter(BucketFilter filter)
filter
- the new filter to appendpublic void deregisterFilter(BucketFilter filter)
filter
- the filter to removepublic <T extends BucketFilter> T getFilter(java.lang.Class<T> filterClass) throws java.util.NoSuchElementException
T
- the class of the filterfilterClass
- filter class to search for
java.util.NoSuchElementException
- if there was no filter with the specified classprotected void addObject(LocalAbstractObject object, Addible<LocalAbstractObject> addible) throws BucketStorageException
object
can added to this bucket.
object
- the object to addaddible
- the Addible
that actually stores the object
BucketStorageException
- if there was an error adding the objectprotected void deleteObject(Removable<LocalAbstractObject> removable) throws BucketStorageException
object
can be deleted from this bucket.
This includes the pre-checks of the filters and also the low-occupation check.
removable
- the object that is going to be removed
BucketStorageException
- if the object cannot be removed (reason is stored in the exception)public void addObject(LocalAbstractObject object) throws BucketStorageException
Bucket
addObject
in class Bucket
object
- a new object to be inserted
BucketStorageException
- if the object cannot be inserted into the bucketpublic final BucketErrorCode addObjectErrCode(LocalAbstractObject object)
Bucket
addObjectErrCode
in class Bucket
object
- the new object to be inserted
public LocalAbstractObject deleteObject(UniqueID objectID) throws java.util.NoSuchElementException, BucketStorageException
Bucket
deleteObject
in class Bucket
objectID
- the ID of the object to delete
java.util.NoSuchElementException
- if there is no object with the specified ID in this bucket
BucketStorageException
- if the object cannot be deleted from the bucketpublic int deleteObject(LocalAbstractObject object, int deleteLimit) throws BucketStorageException
Bucket
data-equals
to
the specified object. If deleteLimit
is greater than zero, only the first deleteLimit
data-equal objects found are deleted.
deleteObject
in class Bucket
object
- the object to match againstdeleteLimit
- the maximal number of deleted objects (zero means unlimited)
BucketStorageException
- if there was an object that cannot be deleted from the bucketpublic int deleteAllObjects() throws BucketStorageException
Bucket
deleteAllObjects
in class Bucket
BucketStorageException
- if there was an object that cannot be deleted from the bucketpublic LocalAbstractObject getObject(UniqueID objectID) throws java.util.NoSuchElementException
Bucket
getObject
in class Bucket
objectID
- the ID of the object to retrieve
java.util.NoSuchElementException
- if there is no object with the specified ID in this bucketpublic LocalAbstractObject getObject(java.lang.String locator) throws java.util.NoSuchElementException
Bucket
getObject
in class Bucket
locator
- the locator URI of the object to retrieve
java.util.NoSuchElementException
- This exception is thrown if there is no object with the specified locator in this bucketpublic LocalAbstractObject getObject(AbstractObjectKey key) throws java.util.NoSuchElementException
Bucket
getObject
in class Bucket
key
- the key of the object to retrieve
java.util.NoSuchElementException
- This exception is thrown if there is no object with the specified key in this bucketpublic AbstractObjectIterator<LocalAbstractObject> getAllObjects()
Bucket
getAllObjects
in class Bucket
public 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 |