A channel represents something akin to a publish/subscribe topic,
or a radio station. These are used to segregate cluster operations
into a set of groups, where each group is represented by a channel.
Channel names are whatever you want then to be: use of dot notation
has proved useful in the past.
Channel maintain internal state in order to avoid heap activity. So
they should not be shared across threads without appropriate synchs
in place. One remedy is create another channel instance
- this(Cluster cluster, char[] name) ¶#
-
Construct a channel with the specified name. We cache
a number of session-related constructs here also, in
order to eliminate runtime overhead
- char[] name() [final] ¶#
-
Return the name of this channel. This is the name provided
when the channel was constructed.
- Cluster cluster() [final] ¶#
-
Return the assigned cluster
- Logger log() [final] ¶#
-
Return the assigned logger
- void write(IWriter writer) [final] ¶#
-
Output this channel via the provided IWriter
- void read(IReader reader) [final] ¶#
-
Input this channel via the provided IReader
- IMessage thaw(IMessage host = null) [final] ¶#
-
deserialize a message into a provided host, or via
the registered instance of the incoming message
- IConsumer createConsumer(ChannelListener notify) [final] ¶#
-
Create a listener of the specified type. Listeners are
run within their own thread, since they spend the vast
majority of their time blocked on a Socket read. Would
be good to support multiplexed reading instead, such
that a thread pool could be applied instead.
- IConsumer createBulletinConsumer(ChannelListener notify) [final] ¶#
-
Create a listener of the specified type. Listeners are
run within their own thread, since they spend the vast
majority of their time blocked on a Socket read. Would
be good to support multiplexed reading instead, such
that a thread pool could be applied instead.
- IMessage getCache(char[] key, bool remove, IMessage host = null) [final] ¶#
-
Return a entry from the network cache, and optionally
remove it. This is a synchronous operation as opposed
to the asynchronous nature of an invalidate broadcast.
- bool putCache(char[] key, IMessage message) [final] ¶#
-
Place an entry into the network cache, replacing the
entry with the identical key. Where message.time is
set, it will be used to test for newer cache entries
than the one being sent i.e. if someone else placed
a newer entry into the cache, that one will remain.
Note that this may cause the oldest entry in the cache
to be displaced if the cache is already full.
- bool loadCache(char[] key, IMessage message) [final] ¶#
-
Load a network cache entry remotely. This sends the given
IMessage over a network to the cache host, where it will
be executed locally. The benefit of doing so it that the
host may deny access to the cache entry for the duration
of the load operation. This, in turn, provides a mechanism
for gating/synchronizing multiple network clients over a
given cache entry; quite handy for those entries that are
relatively expensive to construct or access.
- IMessage getQueue(IMessage host = null) [final] ¶#
-
Query the cluster for queued entries on the corresponding
channel. Returns, and removes, the first matching entry
from the cluster. Note that this sweeps the cluster for
matching entries, and is synchronous in nature. The more
common approach is to setup a queue listener, which will
grab and dispatch queue entries asynchronously.
- bool scanQueue() [private] ¶#
-
Query the cluster for queued entries on the corresponding
channel. Returns, and removes, the first matching entry
from the cluster. Note that this sweeps the cluster for
matching entries, and is synchronous in nature. The more
common approach is to setup a queue listener, which will
grab and dispatch queue entries asynchronously.
- IMessage putQueue(IMessage message) [final] ¶#
-
Add an entry to the specified network queue. May throw a
QueueFullException if there's no room available.
- bool execute(IMessage message) [final] ¶#
-
Send a remote call request to a server, and place the result
back into the provided message
- void broadcast(IMessage message = null) [final] ¶#
-
Broadcast a message on the specified channel. This uses
IP/Multicast to scatter the message to all registered
listeners (on the same multicast group). Note that the
maximum message size is limited to that of an Ethernet
data frame, minus the IP/UDP header size (1472 bytes).