Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

Cluster Class Reference

Inheritance diagram for Cluster:

ICluster IEventListener List of all members.

Public Member Functions

 this (ILogger logger=null)
 this (ILogger logger, IConduit conduit)
 this (ILogger logger, uint serverPort)
void notify (IEvent event, IPayload payload)
IChannel createChannel (char[] channel)
ILogger getLogger ()
synchronized void broadcast (IChannel channel, IPayload payload=null)
IConsumer createConsumer (IChannel channel, IEvent.Style style, IEventListener notify)
IPayload getCache (IChannel channel, char[] key, bool remove)
IPayload putCache (IChannel channel, char[] key, IPayload payload)
IPayload putQueue (IChannel channel, IPayload payload)
IPayload getQueue (IChannel channel)
void loadCache (IChannel channel, char[] key, IPayload payload)
synchronized InternetAddress getGroup (char[] channel)

Static Public Member Functions

 this ()

Private Attributes

ILogger logger
NodeSet nodeSet
Buffer mBuffer
ProtocolWriter mWriter
MulticastSocket mSocket
ushort groupTTL = 1
ushort groupPort = 3333
ubyte groupPrefix = 225

Static Private Attributes

HashMap groups

Detailed Description

QOS implementation for sockets. All cluster-client activity is gated through here by the higher level classes; NetworkQueue & NetworkCache for example. You gain access to the cluster by creating an instance of the QOS (quality of service) you desire and mapping client classes onto it. For example:

import mango.cluster.NetworkCache; import mango.cluster.qos.socket.Cluster; ICluster cluster = new Cluster (...); NetworkCache cache = new NetworkCache (cluster, ...); cache.put (...); cache.get (...); cache.invalidate (...);

Please see the cluster clients for additional details. Currently these include CacheInvalidator, CacheInvalidatee, NetworkMessage, NetworkTask, NetworkQueue, NetworkCache, NetworkCombo, plus the Client base-class.

Definition at line 95 of file Cluster.d.


Member Function Documentation

this  )  [inline, static]
 

Setup a hashmap for multicast group addresses

Definition at line 114 of file Cluster.d.

References groups, and HashMap.

this ILogger  logger = null  )  [inline]
 

Setup a Cluster instance. Currently the buffer & writer are shared for all bulletin serialization; this should probably change at some point such that we can support multiple threads broadcasting concurrently to different output ports.

Definition at line 129 of file Cluster.d.

References Buffer, mBuffer, mSocket, mWriter, nodeSet, and ProtocolWriter.

this ILogger  logger,
IConduit  conduit
[inline]
 

Setup a Cluster instance. Currently the buffer & writer are shared for all bulletin serialization; this should probably change at some point such that we can support multiple threads broadcasting concurrently to different output ports.

Definition at line 148 of file Cluster.d.

this ILogger  logger,
uint  serverPort
[inline]
 

Setup a Cluster instance. Currently the buffer & writer are shared for all bulletin serialization; this should probably change at some point such that we can support multiple threads broadcasting concurrently to different output ports.

Definition at line 202 of file Cluster.d.

void notify IEvent  event,
IPayload  payload
[inline]
 

IEventListener interface method for listening to RollCall responses. These are sent out by cluster servers both when they get a RollCall request, and when they begin execution.

Reimplemented from IEventListener.

Definition at line 224 of file Cluster.d.

References NodeSet::enable(), RollCall::name, nodeSet, RollCall::port1, RollCall::port2, and RollCall::request.

IChannel createChannel char[]  channel  )  [inline]
 

Create a channel instance. Our channel implementation includes a number of cached IO helpers (ProtolcolWriter and so on) which simplifies and speeds up execution.

Reimplemented from ICluster.

Definition at line 241 of file Cluster.d.

Referenced by ClusterQueue::put(), and ClusterServer::this().

ILogger getLogger  )  [inline]
 

Return the logger instance provided during construction.

Reimplemented from ICluster.

Definition at line 252 of file Cluster.d.

Referenced by ClusterServer::addCacheLoader(), and ClusterQueue::this().

synchronized void broadcast IChannel  channel,
IPayload  payload = null
[inline]
 

Broadcast a payload on the specified channel. This uses IP/Multicast to scatter the payload to all registered listeners (on the same multicast group). Note that the maximum payload size is limited to that of an Ethernet data frame, minus the IP/UDP header size (1472 bytes).

Reimplemented from ICluster.

Definition at line 267 of file Cluster.d.

References Buffer::clear(), getGroup(), IChannel::getName(), Buffer::getPosition(), mBuffer, mSocket, mWriter, ProtocolWriter::put(), and DatagramSocket::write().

Referenced by ClusterServer::notify(), ClusterQueue::run(), and ClusterServer::start().

IConsumer createConsumer IChannel  channel,
IEvent.Style  style,
IEventListener  notify
[inline]
 

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.

Reimplemented from ICluster.

Definition at line 291 of file Cluster.d.

References ClusterEvent, IChannel::getName(), IEvent::getStyleName(), and ILogger::info().

Referenced by ClusterServer::this().

IPayload getCache IChannel  channel,
char[]  key,
bool  remove
[inline]
 

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.

Reimplemented from ICluster.

Definition at line 318 of file Cluster.d.

References Channel::getName(), nodeSet, ProtocolWriter::put(), Channel::reader, NodeSet::request(), and Channel::writer.

IPayload putCache IChannel  channel,
char[]  key,
IPayload  payload
[inline]
 

Place an entry into the network cache, replacing the entry with the identical key. Note that this may cause the oldest entry in the cache to be displaced if the cache is already full.

Reimplemented from ICluster.

Definition at line 336 of file Cluster.d.

References Channel::getName(), nodeSet, ProtocolWriter::put(), Channel::reader, NodeSet::request(), and Channel::writer.

IPayload putQueue IChannel  channel,
IPayload  payload
[inline]
 

Add an entry to the specified network queue. May throw a QueueFullException if there's no room available.

Reimplemented from ICluster.

Definition at line 351 of file Cluster.d.

References Channel::getName(), nodeSet, ProtocolWriter::put(), Channel::reader, NodeSet::request(), and Channel::writer.

IPayload getQueue IChannel  channel  )  [inline]
 

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.

Reimplemented from ICluster.

Definition at line 372 of file Cluster.d.

References Node::cache, Channel::getName(), nodeSet, ProtocolWriter::put(), Channel::reader, Node::request(), NodeSet::scan(), and Channel::writer.

Referenced by MessageConsumer::invoke().

void loadCache IChannel  channel,
char[]  key,
IPayload  payload
[inline]
 

Load a network cache entry remotely. This sends the given Payload over the 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 an elegant mechanism for gating/synchronizing multiple network clients over a given cache entry; handy for those entries that are relatively expensive to construct or access.

Reimplemented from ICluster.

Definition at line 405 of file Cluster.d.

References Channel::getName(), nodeSet, ProtocolWriter::put(), Channel::reader, Node::request(), NodeSet::selectNode(), Node::tasks, and Channel::writer.

synchronized InternetAddress getGroup char[]  channel  )  [inline]
 

Return an internet address representing the multicast group for the specified channel. We use three of the four address segments to represent the channel itself (via a hash on the channel name), and set the primary segment to be that of the broadcast prefix (above).

Definition at line 424 of file Cluster.d.

References HashMap::get(), groupPort, groupPrefix, groups, HashMap::jhash(), and HashMap::put().

Referenced by broadcast(), and BulletinConsumer::this().


Member Data Documentation

HashMap groups [static, private]
 

Definition at line 97 of file Cluster.d.

Referenced by getGroup(), and this().

ILogger logger [private]
 

Definition at line 98 of file Cluster.d.

NodeSet nodeSet [private]
 

Definition at line 99 of file Cluster.d.

Referenced by getCache(), getQueue(), loadCache(), notify(), putCache(), putQueue(), and this().

Buffer mBuffer [private]
 

Definition at line 100 of file Cluster.d.

Referenced by broadcast(), and this().

ProtocolWriter mWriter [private]
 

Definition at line 101 of file Cluster.d.

Referenced by broadcast(), and this().

MulticastSocket mSocket [private]
 

Definition at line 102 of file Cluster.d.

Referenced by broadcast(), and this().

ushort groupTTL = 1 [private]
 

Definition at line 104 of file Cluster.d.

ushort groupPort = 3333 [private]
 

Definition at line 105 of file Cluster.d.

Referenced by getGroup().

ubyte groupPrefix = 225 [private]
 

Definition at line 106 of file Cluster.d.

Referenced by getGroup().


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:00 2004 for Mango by doxygen 1.3.6