public class ReplicationBucket extends LocalBucket
Modifier and Type | Field and Description |
---|---|
protected ReplicationNetworkBucketDispatcher |
bucketDispatcher |
protected static StatisticCounter |
distanceComputations
Statistics counter
|
protected LocalBucket |
encapsulatedBucket |
protected java.util.concurrent.atomic.AtomicInteger |
nextReplicaForGet |
protected java.util.concurrent.locks.ReadWriteLock |
replicaManipulationLock |
protected java.util.List<RemoteBucket> |
replicas |
counterBucketAddObject, counterBucketDelObject, counterBucketRead
Modifier | Constructor and Description |
---|---|
protected |
ReplicationBucket(ReplicationNetworkBucketDispatcher bucketDispatcher,
LocalBucket encapsulatedBucket)
Creates a new instance of ReplicationBucket
|
Modifier and Type | Method and Description |
---|---|
void |
addObject(LocalAbstractObject object)
Insert a new object into this bucket.
|
int |
addObjects(java.util.Collection<? extends LocalAbstractObject> objects)
Insert several new objects into this bucket.
|
int |
addObjects(java.util.Iterator<? extends LocalAbstractObject> objects)
Insert several new objects to this bucket.
|
void |
createReplica(NetworkNode atNetworkNode) |
AbstractObjectIterator<LocalAbstractObject> |
getAllObjects()
Returns iterator over all objects from this bucket.
|
java.util.Set<NetworkNode> |
getAllReplicaNodes()
Return set of all network nodes where this bucket has replicas
|
int |
getBucketID()
Returns the unique ID of this bucket.
|
long |
getCapacity()
Returns the maximal capacity of this bucket.
|
long |
getLowOccupation()
Returns the minimal occupation of this bucket.
|
protected 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.
|
protected Bucket |
getOperatingBucket() |
long |
getSoftCapacity()
Returns the soft capacity of this bucket.
|
boolean |
isSoftCapacityExceeded()
Returns true if the soft-capacity of the bucket has been exceeded.
|
int |
processQuery(QueryOperation<?> query)
Process a query operation on objects from this bucket.
|
AbstractObjectIterator<LocalAbstractObject> |
provideObjects()
The iterator for provided objects for ObjectProvider interface.
|
boolean |
removeReplica(NetworkNode atNetworkNode)
Remove replica of this bucket from given node.
|
void |
replicaMigrated(NetworkNode origNode,
NetworkNode newNode)
Indicate that one of the replica was migrated
|
java.lang.String |
toString()
Returns a string representation of this bucket.
|
addObject, addObjectErrCode, deleteAllObjects, deleteObject, deleteObject, deleteObject, deleteObjects, deregisterFilter, destroy, finalize, getFilter, getIndex, isBucketStandalone, registerFilter, setLowOccupation, setSoftCapacity
deleteObject, deleteObject, split
protected static StatisticCounter distanceComputations
protected final ReplicationNetworkBucketDispatcher bucketDispatcher
protected final LocalBucket encapsulatedBucket
protected final java.util.List<RemoteBucket> replicas
protected final java.util.concurrent.atomic.AtomicInteger nextReplicaForGet
protected final java.util.concurrent.locks.ReadWriteLock replicaManipulationLock
protected ReplicationBucket(ReplicationNetworkBucketDispatcher bucketDispatcher, LocalBucket encapsulatedBucket)
public void createReplica(NetworkNode atNetworkNode) throws BucketStorageException, java.lang.IllegalStateException
BucketStorageException
java.lang.IllegalStateException
public boolean removeReplica(NetworkNode atNetworkNode) throws java.io.IOException
java.io.IOException
public void replicaMigrated(NetworkNode origNode, NetworkNode newNode)
public java.util.Set<NetworkNode> getAllReplicaNodes()
public int getBucketID()
LocalBucket
getBucketID
in class LocalBucket
public int getObjectCount()
LocalBucket
getObjectCount
in class LocalBucket
public long getCapacity()
LocalBucket
getCapacity
in class LocalBucket
public long getSoftCapacity()
LocalBucket
getSoftCapacity
in class LocalBucket
public long getLowOccupation()
LocalBucket
getLowOccupation
in class LocalBucket
public long getOccupation()
LocalBucket
getOccupation
in class LocalBucket
public double getOccupationRatio()
LocalBucket
getOccupationRatio
in class LocalBucket
public boolean isSoftCapacityExceeded()
LocalBucket
isSoftCapacityExceeded
in class LocalBucket
public java.lang.String toString()
LocalBucket
toString
in class LocalBucket
public int addObjects(java.util.Iterator<? extends LocalAbstractObject> objects) throws BucketStorageException
Bucket
addObjects
in class Bucket
objects
- iterator that provides the new objects to insertBucketStorageException
- if there was an object that cannot be inserted into the bucketpublic int addObjects(java.util.Collection<? extends LocalAbstractObject> objects) throws BucketStorageException
Bucket
addObjects
in class Bucket
objects
- the collection of new objectsBucketStorageException
- if there was an object that cannot be inserted into the bucketpublic void addObject(LocalAbstractObject object) throws BucketStorageException
Bucket
addObject
in class LocalBucket
object
- a new object to be insertedBucketStorageException
- if the object cannot be inserted into the bucketprotected Bucket getOperatingBucket()
public int processQuery(QueryOperation<?> query)
Bucket
processQuery
in class Bucket
query
- query operation that is to be processed on this bucketpublic AbstractObjectIterator<LocalAbstractObject> getAllObjects()
Bucket
getAllObjects
in class LocalBucket
public LocalAbstractObject getObject(AbstractObjectKey key) throws java.util.NoSuchElementException
Bucket
getObject
in class LocalBucket
key
- the key of the object to retrievejava.util.NoSuchElementException
- This exception is thrown if there is no object with the specified key in this bucketpublic LocalAbstractObject getObject(java.lang.String locator) throws java.util.NoSuchElementException
Bucket
getObject
in class LocalBucket
locator
- the locator URI of the object to retrievejava.util.NoSuchElementException
- This exception is thrown if there is no object with the specified locator in this bucketpublic AbstractObjectIterator<LocalAbstractObject> provideObjects()
Bucket
provideObjects
in interface ObjectProvider<LocalAbstractObject>
provideObjects
in class Bucket
protected ModifiableIndex<LocalAbstractObject> getModifiableIndex()
LocalBucket
getModifiableIndex
in class LocalBucket