public class NetworkBucketDispatcher extends BucketDispatcher
log, UNASSIGNED_BUCKET_ID
Constructor and Description |
---|
NetworkBucketDispatcher(MessageDispatcher messageDisp,
int maxBuckets,
long bucketCapacity,
java.lang.Class<? extends LocalBucket> defaultBucketClass)
Creates a new instance of NetworkBucketDispatcher only with a maximal capacity specification.
|
NetworkBucketDispatcher(MessageDispatcher messageDisp,
int maxBuckets,
long bucketCapacity,
long bucketSoftCapacity,
long bucketLowOccupation,
boolean bucketOccupationAsBytes,
java.lang.Class<? extends LocalBucket> defaultBucketClass)
Creates a new instance of NetworkBucketDispatcher with full specification of default values.
|
NetworkBucketDispatcher(MessageDispatcher messageDisp,
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 NetworkBucketDispatcher with full specification of default values.
|
Modifier and Type | Method and Description |
---|---|
boolean |
copyAllObjects(RemoteBucket remoteBucket,
RemoteBucket sourceRemoteBucket)
Copies all objects from the
sourceRemoteBucket to the remoteBucket on their network node. |
RemoteBucket |
createRemoteBucket(NetworkNode atNetworkNode)
Creates a bucket on a remote network node.
|
RemoteBucket |
createRemoteBucket(NetworkNode atNetworkNode,
java.lang.Class<? extends LocalBucket> storageClass,
java.util.Map<java.lang.String,java.lang.Object> storageClassParams,
long capacity,
long softCapacity)
Creates a bucket on a remote network node.
|
RemoteBucket |
createRemoteBucket(NetworkNode atNetworkNode,
long capacity,
long softCapacity)
Creates a bucket on a remote network node with default class and params is created
but with specified capacity and soft capacity.
|
void |
finalize()
Finalize all buckets managed by this dispatcher.
|
NetworkNode |
getCurrentNetworkNode()
Returns the network node of this dispatcher.
|
protected void |
receive(BucketRequestMessage<?> msg)
Receiving method for bucket request messages.
|
boolean |
removeRemoteBucket(RemoteBucket remoteBucket)
Removes a bucket on a remote network node.
|
protected <T extends BucketReplyMessage> |
send(BucketRequestMessage<T> msg,
NetworkNode networkNode)
Sending method for bucket request messages.
|
SplitResult |
splitBucket(RemoteBucket remoteBucket,
SplitPolicy policy,
int whoStays)
Splits a given bucket on the remote node creating the new buckets in situ.
|
addBucket, closeTemporarilyIfIdle, createAutoPivotChooser, createBucket, createBucket, createBucket, createBucket, createBucket, createBucket, destroy, getAllBucketIDs, getAllBuckets, getAutoPivotChooser, getAutoPivotChooserClass, getBucket, getBucketCapacity, getBucketCount, getBucketLowOccupation, getBucketOccupationAsBytes, getBucketSoftCapacity, getDefaultBucketClass, getDefaultBucketClassParams, getMaxBuckets, getObjectCount, getOccupation, getOverloadedBucketCount, moveBucket, removeBucket, removeBucket, setAllBucketLowOccupation, setAllBucketSoftCapacity, setAutoPivotChooser, setAutoPivotChooser, setBucketCapacity, setBucketLowOccupation, setBucketOccupationAsBytes, setBucketSoftCapacity, setDefaultBucketClass, setDefaultBucketClassParams, setTemporaryClosePeriod, toString
public NetworkBucketDispatcher(MessageDispatcher messageDisp, 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)
messageDisp
- the message dispatcher used by this network bucket dispatchermaxBuckets
- 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 NetworkBucketDispatcher(MessageDispatcher messageDisp, int maxBuckets, long bucketCapacity, long bucketSoftCapacity, long bucketLowOccupation, boolean bucketOccupationAsBytes, java.lang.Class<? extends LocalBucket> defaultBucketClass)
messageDisp
- the message dispatcher used by this network bucket dispatchermaxBuckets
- 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 NetworkBucketDispatcher(MessageDispatcher messageDisp, int maxBuckets, long bucketCapacity, java.lang.Class<? extends LocalBucket> defaultBucketClass)
MemoryStorageBucket
is used as default bucket class.messageDisp
- the message dispatcher used by this network bucket dispatchermaxBuckets
- the maximal number of buckets maintained by this dispatcherbucketCapacity
- the default bucket hard capacity for newly created bucketsdefaultBucketClass
- the default class for newly created bucketspublic void finalize() throws java.lang.Throwable
BucketDispatcher
finalize
in class BucketDispatcher
java.lang.Throwable
- if there was an error during releasing resourcespublic NetworkNode getCurrentNetworkNode()
protected void receive(BucketRequestMessage<?> msg) throws java.io.IOException
msg
- the bucket request message to processjava.io.IOException
- if there was an error processing the messageprotected <T extends BucketReplyMessage> T send(BucketRequestMessage<T> msg, NetworkNode networkNode) throws java.io.IOException, java.lang.RuntimeException, BucketStorageException
networkNode
and the returned
reply message of class T
is returned.T
- the class of the reply message that is returnedmsg
- the bucket request message to processnetworkNode
- the destination node where the message is sentjava.io.IOException
- if there was an error processing the messagejava.lang.RuntimeException
- if there was a RuntimeException
when processing the bucket requestBucketStorageException
- if there was a storage error when processing the bucket requestpublic RemoteBucket createRemoteBucket(NetworkNode atNetworkNode) throws java.io.IOException, BucketStorageException
atNetworkNode
- the network node at which to create a bucketBucketStorageException
- if the bucket cannot be created on the remote network nodejava.io.IOException
- if there was an error communicating with the remote nodepublic RemoteBucket createRemoteBucket(NetworkNode atNetworkNode, long capacity, long softCapacity) throws java.io.IOException, BucketStorageException
atNetworkNode
- the network node at which to create a bucketcapacity
- capacity of the new bucketsoftCapacity
- soft capacity of the new bucketBucketStorageException
- if the bucket cannot be created on the remote network nodejava.io.IOException
- if there was an error communicating with the remote nodepublic RemoteBucket createRemoteBucket(NetworkNode atNetworkNode, java.lang.Class<? extends LocalBucket> storageClass, java.util.Map<java.lang.String,java.lang.Object> storageClassParams, long capacity, long softCapacity) throws java.io.IOException, BucketStorageException
atNetworkNode
- the network node at which to create a bucketstorageClass
- storage classstorageClassParams
- parameters of the new storagecapacity
- capacity of the new bucketsoftCapacity
- soft capacity of the new bucketBucketStorageException
- if the bucket cannot be created on the remote network nodejava.io.IOException
- if there was an error communicating with the remote nodepublic boolean removeRemoteBucket(RemoteBucket remoteBucket) throws java.io.IOException, java.util.NoSuchElementException
remoteBucket
- the bucket to removejava.io.IOException
- if there was an error communicating with the remote nodejava.util.NoSuchElementException
- if the bucket was not found on the remote network nodepublic SplitResult splitBucket(RemoteBucket remoteBucket, SplitPolicy policy, int whoStays) throws BucketStorageException, java.io.IOException
remoteBucket
- bucket to splitpolicy
- split policy according to which the bucket is to be splitwhoStays
- Identification of a partition whose objects stay in the split bucketBucketStorageException
- if the bucket cannot be created on the remote network nodejava.io.IOException
- if there was an error communicating with the remote nodepublic boolean copyAllObjects(RemoteBucket remoteBucket, RemoteBucket sourceRemoteBucket) throws java.io.IOException, BucketStorageException
sourceRemoteBucket
to the remoteBucket
on their network node.
Nothing is done if the remote nodes of thee two buckets are not identical.remoteBucket
- specification of the destination bucketsourceRemoteBucket
- specification of the source bucketBucketStorageException
- if the data could not have been copied on the remote nodejava.io.IOException
- if there was an error communicating with the remote node