messif.buckets.impl
Class VirtualStorageBucket<C>

java.lang.Object
  extended by messif.buckets.Bucket
      extended by messif.buckets.LocalBucket
          extended by messif.buckets.OrderedLocalBucket<C>
              extended by messif.buckets.impl.VirtualStorageBucket<C>
Type Parameters:
C - type of the keys that this bucket's objects are ordered by
All Implemented Interfaces:
java.io.Serializable, ObjectProvider<LocalAbstractObject>

public final class VirtualStorageBucket<C>
extends OrderedLocalBucket<C>

Encapsulating bucket for generic indices and storages.

See Also:
Serialized Form

Field Summary
 
Fields inherited from class messif.buckets.LocalBucket
counterBucketAddObject, counterBucketDelObject, counterBucketRead
 
Constructor Summary
VirtualStorageBucket(long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes, ModifiableOrderedIndex<C,LocalAbstractObject> index)
          Constructs a new MemoryStorageBucket instance
 
Method Summary
 void destroy()
          Destroy this bucket.
 void finalize()
          Finalize this bucket.
static VirtualStorageBucket<?> getBucket(long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes, java.util.Map<java.lang.String,java.lang.Object> parameters)
          Creates a bucket.
static
<T> VirtualStorageBucket<T>
getBucket(long capacity, long softCapacity, long lowOccupation, boolean occupationAsBytes, Storage<LocalAbstractObject> storage, IndexComparator<T,LocalAbstractObject> comparator)
          Creates a bucket for the given storage and comparator.
protected  ModifiableOrderedIndex<C,LocalAbstractObject> getModifiableIndex()
          Returns the index (including storage) for this bucket.
 
Methods inherited from class messif.buckets.OrderedLocalBucket
getIndex
 
Methods inherited from class messif.buckets.LocalBucket
addObject, addObject, addObjectErrCode, deleteAllObjects, deleteObject, deleteObject, deleteObject, deregisterFilter, getAllObjects, getBucketID, getCapacity, getFilter, getLowOccupation, getObject, getObject, getObject, getObjectCount, getOccupation, getOccupationRatio, getSoftCapacity, isBucketStandalone, isSoftCapacityExceeded, registerFilter, setLowOccupation, setSoftCapacity, toString
 
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
 

Constructor Detail

VirtualStorageBucket

public VirtualStorageBucket(long capacity,
                            long softCapacity,
                            long lowOccupation,
                            boolean occupationAsBytes,
                            ModifiableOrderedIndex<C,LocalAbstractObject> index)
Constructs a new MemoryStorageBucket instance

Parameters:
capacity - maximal capacity of the bucket - cannot be exceeded
softCapacity - maximal soft capacity of the bucket
lowOccupation - a minimal occupation for deleting objects - cannot be lowered
occupationAsBytes - flag whether the occupation (and thus all the limits) are in bytes or number of objects
index - the index to encapsulate
Method Detail

finalize

public void finalize()
              throws java.lang.Throwable
Description copied from class: LocalBucket
Finalize this bucket. All transient resources associated with this bucket are released. After this method is called, the bucket methods' behavior is unpredictable. This method is called by the BucketDispatcher when it is finalized.

Overrides:
finalize in class LocalBucket
Throws:
java.lang.Throwable - if there was an error while cleaning

destroy

public void destroy()
             throws java.lang.Throwable
Description copied from class: LocalBucket
Destroy this bucket. This method releases all resources (transient and persistent) associated with this bucket (e.g. the statistics and all objects are deleted). After this method is called, the bucket methods' behavior is unpredictable. This method is called by the BucketDispatcher when the bucket is removed from the dispatcher.

Overrides:
destroy in class LocalBucket
Throws:
java.lang.Throwable - if there was an error while cleaning

getModifiableIndex

protected ModifiableOrderedIndex<C,LocalAbstractObject> getModifiableIndex()
Description copied from class: LocalBucket
Returns the index (including storage) for this bucket. The index provides the access to the underlying storage of objects in this bucket.

Specified by:
getModifiableIndex in class OrderedLocalBucket<C>
Returns:
the index for this bucket

getBucket

public static VirtualStorageBucket<?> getBucket(long capacity,
                                                long softCapacity,
                                                long lowOccupation,
                                                boolean occupationAsBytes,
                                                java.util.Map<java.lang.String,java.lang.Object> parameters)
                                         throws java.io.IOException,
                                                java.lang.IllegalArgumentException,
                                                java.lang.ClassNotFoundException
Creates a bucket. The additional parameters are specified in the parameters map with the following recognized key names:

If any of the comparatorInstance, comparatorClass, localAbstractObjectOrder is specified, an index is created using this comparator. Otherwise, the storage is used in internal order.

Note that additional parameters may be required according to the specified storageClass. See the documentation of that storage.

Parameters:
capacity - maximal capacity of the bucket - cannot be exceeded
softCapacity - maximal soft capacity of the bucket
lowOccupation - a minimal occupation for deleting objects - cannot be lowered
occupationAsBytes - flag whether the occupation (and thus all the limits) are in bytes or number of objects
parameters - list of named parameters (see above)
Returns:
a new SimpleDiskBucket instance
Throws:
java.io.IOException - if something goes wrong when working with the filesystem
java.lang.IllegalArgumentException - if the parameters specified are invalid (non existent directory, null values, etc.)
java.lang.ClassNotFoundException - if the parameter class could not be resolved or is not a descendant of LocalAbstractObject

getBucket

public static <T> VirtualStorageBucket<T> getBucket(long capacity,
                                                    long softCapacity,
                                                    long lowOccupation,
                                                    boolean occupationAsBytes,
                                                    Storage<LocalAbstractObject> storage,
                                                    IndexComparator<T,LocalAbstractObject> comparator)
                                         throws java.io.IOException,
                                                java.lang.IllegalArgumentException,
                                                java.lang.ClassNotFoundException
Creates a bucket for the given storage and comparator.

Type Parameters:
T - type of the keys that the new bucket's objects will be ordered by
Parameters:
capacity - maximal capacity of the bucket - cannot be exceeded
softCapacity - maximal soft capacity of the bucket
lowOccupation - a minimal occupation for deleting objects - cannot be lowered
occupationAsBytes - flag whether the occupation (and thus all the limits) are in bytes or number of objects
storage - the underlying storage for object persistence
comparator - the comparator that imposes order on the indexed objects
Returns:
a new SimpleDiskBucket instance
Throws:
java.io.IOException - if something goes wrong when working with the filesystem
java.lang.IllegalArgumentException - if the parameters specified are invalid (non existent directory, null values, etc.)
java.lang.ClassNotFoundException - if the parameter class could not be resolved or is not a descendant of LocalAbstractObject