public abstract class LocalBucket extends Bucket implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
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
|
Modifier | Constructor and Description |
---|---|
protected |
LocalBucket(long capacity,
long softCapacity,
long lowOccupation,
boolean occupationAsBytes,
long occupation)
Constructs a new LocalBucket instance and setups all bucket limits
|
Modifier and Type | Method and Description |
---|---|
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. |
int |
deleteObject(java.lang.String locatorURI,
int deleteLimit)
Delete all objects from this bucket that have the specified
locatorURI . |
protected int |
deleteObjects(ModifiableSearch<LocalAbstractObject> search,
int deleteLimit)
Delete objects that are retrieved by the given search.
|
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.
|
<T extends BucketFilter> |
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.
|
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 the minimal occupation of this bucket.
|
void |
setSoftCapacity(long softCapacity)
Set the soft capacity of this bucket.
|
java.lang.String |
toString()
Returns a string representation of this bucket.
|
addObjects, addObjects, deleteObject, deleteObject, processQuery, provideObjects, split
protected static final StatisticRefCounter counterBucketRead
protected static final StatisticRefCounter counterBucketAddObject
protected static final StatisticRefCounter counterBucketDelObject
protected LocalBucket(long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes, long occupation)
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 objectsoccupation
- the actual bucket occupation in either bytes or object count (see occupationAsBytes flag)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 long getCapacity()
public long getSoftCapacity()
public void setSoftCapacity(long softCapacity)
softCapacity
- the new soft capacity of this bucketpublic long getLowOccupation()
public void setLowOccupation(long lowOccupation)
lowOccupation
- the new minimal occupation for this bucketpublic 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 forjava.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 objectBucketStorageException
- 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 removedBucketStorageException
- 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 insertedBucketStorageException
- 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 insertedpublic 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 deleteObject(java.lang.String locatorURI, int deleteLimit) throws BucketStorageException
Bucket
locatorURI
.
If deleteLimit
is greater than zero, only the first deleteLimit
objects with the given locator are deleted.deleteObject
in class Bucket
locatorURI
- the object locator to matchdeleteLimit
- the maximal number of deleted objects (zero means unlimited)BucketStorageException
- if there was an object that cannot be deleted from the bucketprotected int deleteObjects(ModifiableSearch<LocalAbstractObject> search, int deleteLimit) throws BucketStorageException
search
- the search that supplies the objects to deletedeleteLimit
- 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(java.lang.String locator) throws java.util.NoSuchElementException
Bucket
public LocalAbstractObject getObject(AbstractObjectKey key) throws java.util.NoSuchElementException
Bucket
public AbstractObjectIterator<LocalAbstractObject> getAllObjects()
Bucket
getAllObjects
in class Bucket
public java.lang.String toString()
toString
in class java.lang.Object