com.sun.grizzly
Class RoundRobinSelectorHandler

java.lang.Object
  extended by com.sun.grizzly.TCPSelectorHandler
      extended by com.sun.grizzly.RoundRobinSelectorHandler
All Implemented Interfaces:
ComplexSelectorHandler, Handler, SelectorHandler, AttributeHolder, Copyable, SupportStateHolder<State>

public class RoundRobinSelectorHandler
extends TCPSelectorHandler
implements ComplexSelectorHandler

A SelectorHandler handles all java.nio.channels.Selector operations. One or more instance of a Selector are handled by SelectorHandler. The logic for processing of SelectionKey interest (OP_ACCEPT,OP_READ, etc.) is usually defined using an instance of SelectorHandler. This class represents a TCP implementation of a SelectorHandler, which handles "accept" events by registering newly accepted connections to auxiliary Controllers in a round robin fashion.

Author:
Alexey Stashok

Field Summary
 
Fields inherited from class com.sun.grizzly.TCPSelectorHandler
asyncQueueReader, asyncQueueWriter, attributes, connectorInstanceHandler, inet, instanceHandler, isClient, isShutDown, linger, logger, opToRegister, pipeline, port, reuseAddress, selectionKeyHandler, selector, selectTimeout, serverSocket, serverSocketChannel, serverTimeout, socketTimeout, ssBackLog, stateHolder, tcpNoDelay
 
Constructor Summary
RoundRobinSelectorHandler()
           
RoundRobinSelectorHandler(ReadController[] rrControllers)
           
 
Method Summary
 void addProtocolSupport(Controller.Protocol customProtocol)
          Add custom protocol support
 void copyTo(Copyable copy)
          Copies current object content to copy object
 boolean onAcceptInterest(SelectionKey key, Context context)
          Handle OP_ACCEPT.
 boolean supportsProtocol(Controller.Protocol protocol)
          Checks if protocol is supported by RoundRobinSelectorHandler
 
Methods inherited from class com.sun.grizzly.TCPSelectorHandler
acceptWithoutRegistration, acquireConnectorHandler, closeChannel, configureChannel, connect, getAsyncQueueReader, getAsyncQueueWriter, getAttribute, getAttributes, getConnectorInstanceHandlerDelegate, getInet, getLinger, getLogger, getPort, getPortLowLevel, getPreferredSelectionKeyHandler, getProtocolChainInstanceHandler, getSelectionKeyHandler, getSelector, getSelectTimeout, getServerTimeout, getSocketTimeout, getSsBackLog, getStateHolder, initOpRegistriesIfRequired, invokeAsyncQueueReader, invokeAsyncQueueWriter, invokeCallbackHandler, isOpen, isReuseAddress, isTcpNoDelay, keys, onConnectInterest, onConnectOp, onReadInterest, onReadOp, onWriteInterest, onWriteOp, pause, pipeline, pollContext, postSelect, preSelect, processPendingOperations, protocol, register, register, releaseConnectorHandler, removeAttribute, resume, select, setAttribute, setAttributes, setInet, setLinger, setLogger, setPipeline, setPort, setProtocolChainInstanceHandler, setReuseAddress, setSelectionKeyHandler, setSelector, setSelectTimeout, setServerTimeout, setSocketTimeout, setSsBackLog, setTcpNoDelay, shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.grizzly.SelectorHandler
acceptWithoutRegistration, acquireConnectorHandler, closeChannel, configureChannel, getAsyncQueueReader, getAsyncQueueWriter, getPreferredSelectionKeyHandler, getProtocolChainInstanceHandler, getSelectionKeyHandler, getSelector, isOpen, keys, onConnectInterest, onReadInterest, onWriteInterest, pause, pipeline, postSelect, preSelect, protocol, register, register, releaseConnectorHandler, resume, select, setPipeline, setProtocolChainInstanceHandler, setSelectionKeyHandler, setSelector, shutdown
 
Methods inherited from interface com.sun.grizzly.util.AttributeHolder
getAttribute, getAttributes, removeAttribute, setAttribute, setAttributes
 
Methods inherited from interface com.sun.grizzly.util.SupportStateHolder
getStateHolder
 

Constructor Detail

RoundRobinSelectorHandler

public RoundRobinSelectorHandler()

RoundRobinSelectorHandler

public RoundRobinSelectorHandler(ReadController[] rrControllers)
Method Detail

copyTo

public void copyTo(Copyable copy)
Description copied from interface: Copyable
Copies current object content to copy object

Specified by:
copyTo in interface Copyable
Overrides:
copyTo in class TCPSelectorHandler
Parameters:
copy - represents target object, where current object's content will be copied

onAcceptInterest

public boolean onAcceptInterest(SelectionKey key,
                                Context context)
                         throws IOException
Description copied from class: TCPSelectorHandler
Handle OP_ACCEPT.

Specified by:
onAcceptInterest in interface SelectorHandler
Overrides:
onAcceptInterest in class TCPSelectorHandler
Parameters:
key - SelectionKey
context - Context
Returns:
always returns false
Throws:
IOException

addProtocolSupport

public void addProtocolSupport(Controller.Protocol customProtocol)
Add custom protocol support

Parameters:
customProtocol - custom Protocol

supportsProtocol

public boolean supportsProtocol(Controller.Protocol protocol)
Checks if protocol is supported by RoundRobinSelectorHandler

Specified by:
supportsProtocol in interface ComplexSelectorHandler
Parameters:
protocol - Network protocol name
Returns:
true if protocol is supported, false otherwise


Copyright © 2011 SUN Microsystems. All Rights Reserved.