Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.8.2 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jivesoftware.openfire
Class Channel<T extends org.xmpp.packet.Packet>

    java.lang.Object
      org.jivesoftware.openfire.Channel<T>

    public class Channel<T extends org.xmpp.packet.Packet>

extends Object

A channel provides a mechanism to queue work units for processing. Each work unit is encapsulated as a ChannelMessage, and processing of each message is performed by a ChannelHandler.

As a request is handled by the system, it will travel through a sequence of channels. This architecture has a number of advantages:

- Each request doesn't need to correspond to a thread. Instead, a thread pool in each channel processes requests from a queue.
- Due to the queue at each channel, the system is much better able to respond to load spikes.

Channels are modeled after SEDA stages. For much much more in-depth architecture information, refer to the SEDA website.

Author:
  Matt Tucker

Constructor Summary
`Channel(String name, ChannelHandler<T> channelHandler)` Creates a new channel.

Method Summary
`void` | `add(T packet)` Enqueus a message to be handled by this channel.
`int` | `getMaxThreadCount()` Returns the max number of threads the channel will use for processing messages.
`int` | `getMinThreadCount()` Returns the min number of threads the channel will use for processing messages.
`String` | `getName()` Returns the name of the channel.
`int` | `getQueueSize()` Returns the current number of ChannelMessage objects waiting to be processed by the channel.
`int` | `getThreadCount()` Returns the number of currently active worker threads in the channel.
`boolean` | `isRunning()` Returns true if the channel is currently running.
`void` | `setMaxThreadCount(int maxThreadCount)` Sets the max number of threads the channel will use for processing messages.
`void` | `setMinThreadCount(int minThreadCount)` Sets the min number of threads the channel will use for processing messages.
`void` | `start()` Starts the channel, which means that worker threads will start processing messages from the queue.
`void` | `stop()` Stops the channel, which means that worker threads will stop processing messages from the queue.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### Channel

    public Channel(String name,
                   ChannelHandler<T> channelHandler)

  Creates a new channel. The channel should be registered after it's created.

  Parameters:
    `name` - the name of the channel.
    `channelHandler` - the handler for this channel.

Method Detail

### getName

    public String getName()

  Returns the name of the channel.

  Returns:
    the name of the channel.

### add

    public void add(T packet)

  Enqueus a message to be handled by this channel. After the ChannelHandler is done processing the message, it will be sent to the next channel. Messages with a higher priority will be handled first.

  Parameters:
    `packet` - an XMPP packet to add to the channel for processing.

### isRunning

    public boolean isRunning()

  Returns true if the channel is currently running. The channel can be started and stopped by calling the start() and stop() methods.

  Returns:
    true if the channel is running.

### start

    public void start()

  Starts the channel, which means that worker threads will start processing messages from the queue. If the server isn't running, messages can still be enqueued.

### stop

    public void stop()

  Stops the channel, which means that worker threads will stop processing messages from the queue. If the server isn't running, messages can still be enqueued.

### getThreadCount

    public int getThreadCount()

  Returns the number of currently active worker threads in the channel. This value will always fall in between the min a max thread count.

  Returns:
    the current number of worker threads.

### getMinThreadCount

    public int getMinThreadCount()

  Returns the min number of threads the channel will use for processing messages. The channel will automatically de-allocate worker threads as the queue load shrinks, down to the defined minimum. This lets the channel consume fewer resources when load is low.

  Returns:
    the min number of threads that can be used by the channel.

### setMinThreadCount

    public void setMinThreadCount(int minThreadCount)

  Sets the min number of threads the channel will use for processing messages. The channel will automatically de-allocate worker threads as the queue load shrinks, down to the defined minimum. This lets the channel consume fewer resources when load is low.

  Parameters:
    `minThreadCount` - the min number of threads that can be used by the channel.

### getMaxThreadCount

    public int getMaxThreadCount()

  Returns the max number of threads the channel will use for processing messages. The channel will automatically allocate new worker threads as the queue load grows, up to the defined maximum. This lets the channel meet higher concurrency needs, but prevents too many threads from being allocated, which decreases overall system performance.

  Returns:
    the max number of threads that can be used by the channel.

### setMaxThreadCount

    public void setMaxThreadCount(int maxThreadCount)

  Sets the max number of threads the channel will use for processing messages. The channel will automatically allocate new worker threads as the queue size grows, up to the defined maximum. This lets the channel meet higher concurrency needs, but prevents too many threads from being allocated, which decreases overall system performance.

  Parameters:
    `maxThreadCount` - the max number of threads that can be used by the channel.

### getQueueSize

    public int getQueueSize()

  Returns the current number of ChannelMessage objects waiting to be processed by the channel.

  Returns:
    the current number of elements in the processing queue.

Overview | Package | Class | Tree | Deprecated | Index | Help
| Openfire 3.8.2 Javadoc
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2003-2008 Jive Software.