Class PartitionDistributor
java.lang.Object
org.simpleframework.transport.reactor.PartitionDistributor
- All Implemented Interfaces:
OperationDistributor
The
PartitionDistributor
object is a distributor that
partitions the selection process in to several threads. Each of
the threads has a single selector, and operations are distributed
amongst the threads using the hash code of the socket. Partitions
ensure that several selector threads can share a higher load and
respond to a more I/O events.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final OperationDistributor[]
This contains the distributors that represent a partition. -
Constructor Summary
ConstructorsConstructorDescriptionPartitionDistributor
(Executor executor, int count) Constructor for thePartitionDistributor
object.PartitionDistributor
(Executor executor, int count, long expiry) Constructor for thePartitionDistributor
object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
This is used to close the distributor such that it cancels all of the registered channels and closes down the selector.void
This is used to process theOperation
object.private void
This is used to process theOperation
object.private void
This is used to create the partitions that represent a thread used for selection.
-
Field Details
-
list
This contains the distributors that represent a partition.
-
-
Constructor Details
-
PartitionDistributor
Constructor for thePartitionDistributor
object. This will create a distributor that partitions the operations amongst a pool of selectors using the channels hash code.- Parameters:
executor
- this is the executor used to run operationscount
- this is the number of partitions to be used- Throws:
IOException
-
PartitionDistributor
Constructor for thePartitionDistributor
object. This will create a distributor that partitions the operations amongst a pool of selectors using the channels hash code.- Parameters:
executor
- this is the executor used to run operationscount
- this is the number of partitions to be usedexpiry
- this is the expiry duration that is to be used- Throws:
IOException
-
-
Method Details
-
start
This is used to create the partitions that represent a thread used for selection. Operations will index to a particular one using the hash code of the operations channel. If there is only one partition all operations will index to the partition.- Parameters:
executor
- the executor used to run the operationsexpiry
- this is the expiry duration that is to be used- Throws:
IOException
-
process
This is used to process theOperation
object. This will wake up the selector if it is currently blocked selecting and register the operations associated channel. Once the selector is awake it will acquire the operation from the queue and register the associatedSelectableChannel
for selection. The operation will then be executed when the channel is ready for the interested I/O events.- Specified by:
process
in interfaceOperationDistributor
- Parameters:
task
- this is the task that is scheduled for distributionrequire
- this is the bit-mask value for interested events- Throws:
IOException
-
process
This is used to process theOperation
object. This will wake up the selector if it is currently blocked selecting and register the operations associated channel. Once the selector is awake it will acquire the operation from the queue and register the associatedSelectableChannel
for selection. The operation will then be executed when the channel is ready for the interested I/O events.- Parameters:
task
- this is the task that is scheduled for distributionrequire
- this is the bit-mask value for interested eventslength
- this is the number of distributors to hash with- Throws:
IOException
-
close
This is used to close the distributor such that it cancels all of the registered channels and closes down the selector. This is used when the distributor is no longer required, after the close further attempts to process operations will fail.- Specified by:
close
in interfaceOperationDistributor
- Throws:
IOException
-