org.jboss.remoting.transport.multiplex
Class MultiplexServerInvoker

java.lang.Object
  extended by org.jboss.remoting.AbstractInvoker
      extended by org.jboss.remoting.ServerInvoker
          extended by org.jboss.remoting.transport.socket.SocketServerInvoker
              extended by org.jboss.remoting.transport.multiplex.MultiplexServerInvoker
All Implemented Interfaces:
java.lang.Runnable, Invoker, ServerInvokerMBean, VirtualSocket.DisconnectListener, SocketServerInvokerMBean
Direct Known Subclasses:
SSLMultiplexServerInvoker

public class MultiplexServerInvoker
extends SocketServerInvoker
implements java.lang.Runnable, VirtualSocket.DisconnectListener

MultiplexServerInvoker is the server side of the Multiplex transport. For more information, see Remoting documentation on labs.jboss.org.

Author:
Tom Elrod, Ron Sigal

Nested Class Summary
protected static class MultiplexServerInvoker.InternalHandshakeListener
           
static class MultiplexServerInvoker.SocketGroupInfo
          SocketGroupInfo holds all of the information for a single virtual socket group.
 
Nested classes/interfaces inherited from class org.jboss.remoting.transport.socket.SocketServerInvoker
SocketServerInvoker.IdleTimerTask, SocketServerInvoker.ServerSocketRefresh
 
Nested classes/interfaces inherited from class org.jboss.remoting.ServerInvoker
ServerInvoker.InvalidStateException
 
Nested classes/interfaces inherited from class org.jboss.remoting.AbstractInvoker
AbstractInvoker.CallbackLocatorHolder
 
Field Summary
protected static org.jboss.logging.Logger log
           
 
Fields inherited from class org.jboss.remoting.transport.socket.SocketServerInvoker
acceptThreads, backlog, CHECK_CONNECTION_KEY, clientpool, idleTimeout, idleTimerTask, MAX_POOL_SIZE_DEFAULT, maxPoolSize, newServerSocketFactory, numAcceptThreads, reuseAddress, running, SERVER_SOCKET_CLASS_FLAG, serverSocket, serverSocketClass, serverSocketFactoryLock, threadpool
 
Fields inherited from class org.jboss.remoting.ServerInvoker
BLOCKING, BLOCKING_MODE, BLOCKING_TIMEOUT, callbackHandlers, CLIENT_CONNECT_ADDRESS_KEY, CLIENT_CONNECT_PORT_KEY, CLIENT_LEASE_PERIOD, clientCallbackListener, CONNECTION_LISTENER, connectionNotifier, DEFAULT_BLOCKING_TIMEOUT, DEFAULT_CLIENT_LEASE_PERIOD, DEFAULT_TIMEOUT_PERIOD, handlers, INVOKER_SESSION_ID, MAX_NUM_ONEWAY_THREADS, MAX_NUM_ONEWAY_THREADS_KEY, MAX_ONEWAY_THREAD_POOL_QUEUE_SIZE, NONBLOCKING, ONEWAY_THREAD_POOL_CLASS_KEY, REGISTER_CALLBACK_LISTENER, registerCallbackListeners, SERVER_BIND_ADDRESS_KEY, SERVER_BIND_PORT_KEY, SERVER_SOCKET_FACTORY, serverSocketFactory, singleCallbackContainer, singleHandler, started, TIMEOUT, useClientConnectionIdentity
 
Fields inherited from class org.jboss.remoting.AbstractInvoker
classbyteloader, configuration, localServerLocators, locator, passConfigMapToMarshalFactory, serializationType, socketFactory, socketFactoryCreatedFromSSLParameters
 
Constructor Summary
  MultiplexServerInvoker(InvokerLocator locator)
          Create a new MultiplexServerInvoker.
  MultiplexServerInvoker(InvokerLocator locator, java.util.Map configuration)
          Create a new MultiplexServerInvoker.
protected MultiplexServerInvoker(InvokerLocator locator, java.util.Map configuration, java.net.ServerSocket serverSocket, java.net.Socket socket, java.util.Map virtualServerInvokers)
          Create a new MultiplexServerInvoker.
 
Method Summary
protected  void cleanup()
           
protected  void configureSocketGroupParameters(java.util.Map parameters)
           
protected static void createPrimingSocket(MultiplexServerInvoker.SocketGroupInfo socketGroupInfo, java.lang.String connectHost, int connectPort, java.net.InetAddress bindAddress, int bindPort, java.util.Map configuration, int timeout)
           
protected static void createPrimingSocket(MultiplexServerInvoker.SocketGroupInfo socketGroupInfo, java.lang.String connectHost, int connectPort, java.util.Map configuration, int timeout)
           
protected  java.net.ServerSocket createServerSocket(int bindPort, int backlog, java.net.InetAddress bindAddress)
          In creating the server socket, createServerSocket() determines whether multiplexing will be supported by this ServerInvoker.
protected  void finishStart()
          Finishes start up process when suitable bind and connect information is available.
static java.util.Map getAddressPairMap()
           
protected  java.lang.String getDefaultDataType()
          Each implementation of the remote client invoker should have a default data type that is uses in the case it is not specified in the invoker locator uri.
 int getInputBufferSize()
           
 int getInputMaxErrors()
           
 int getMaxAcceptErrors()
           
 java.lang.String getMultiplexConnectHost()
           
 int getMultiplexConnectPort()
           
 int getOutputMaxChunkSize()
           
 int getOutputMaxDataSlice()
           
 int getOutputMaxTimeSlice()
           
 int getOutputMessagePoolSize()
           
 int getOutputMessageSize()
           
protected  void getParameters()
           
 MultiplexServerInvoker getServerInvoker(java.net.InetSocketAddress address)
          Provides access to a virtual MultiplexServerInvoker in a master MultiplexServerInvoker's invoker farm.
 java.util.Collection getServerInvokers()
          Provides access to all virtual MultiplexServerInvokers in a master MultiplexServerInvoker's invoker farm.
 java.lang.String getServerMultiplexId()
           
 java.net.ServerSocket getServerSocket()
          Returns ServerSocket used to accept invocation requests.
 int getShutdownMonitorPeriod()
           
 int getShutdownRefusalsMaximum()
           
 int getShutdownRequestTimeout()
           
static java.util.Map getSocketGroupMap()
           
 int getStaticThreadsMonitorPeriod()
           
protected  java.lang.String getThreadName(int i)
           
 boolean isSafeToShutdown()
           
 void notifyDisconnected(VirtualSocket virtualSocket)
           
protected  void processInvocation(java.net.Socket socket)
          The acceptor thread should spend as little time as possbile doing any kind of operation, and under no circumstances should perform IO on the new socket, which can potentially block and lock up the server.
protected  void refreshServerSocket()
          refreshes the serverSocket by closing old one and creating a new ServerSocket from new ServerSocketFactory
protected  void resetLocator(int bindPort)
          Called by MultiplexClientInvoker.createSocket() when it finds connection is broken and binds virtual socket group to new bind port.
protected  void rule1()
           
protected  void rule2(java.lang.String connectHost, int connectPort)
           
protected  void rule3()
           
protected  void rule4()
           
 void run()
           
protected  void setBindingInfo()
           
 void setInputBufferSize(int inputBufferSize)
           
 void setInputMaxErrors(int inputMaxErrors)
           
 void setMaxAcceptErrors(int maxAcceptErrors)
           
 void setOutputMaxChunkSize(int outputMaxChunkSize)
           
 void setOutputMaxDataSlice(int outputMaxDataSlice)
           
 void setOutputMaxTimeSlice(int outputMaxTimeSlice)
           
 void setOutputMessagePoolSize(int outputMessagePoolSize)
           
 void setOutputMessageSize(int outputMessageSize)
           
 void setShutdownMonitorPeriod(int shutdownMonitorPeriod)
           
 void setShutdownRefusalsMaximum(int shutdownRefusalsMaximum)
           
 void setShutdownRequestTimeout(int shutdownRequestTimeout)
           
 void setStaticThreadsMonitorPeriod(int staticThreadsMonitorPeriod)
           
protected  void setup()
           
 void start()
          Starts the invoker.
 void stop()
          Stops the invoker.
 java.lang.String toString()
           
 
Methods inherited from class org.jboss.remoting.transport.socket.SocketServerInvoker
destroy, finalize, getBacklog, getCurrentClientPoolSize, getCurrentThreadPoolSize, getIdleTimeout, getMaxPoolSize, getNumAcceptThreads, getReuseAddress, isTransportBiDirectional, setBacklog, setIdleTimeout, setMaxPoolSize, setNewServerSocketFactory, setNumAcceptThreads, setReuseAddress
 
Methods inherited from class org.jboss.remoting.ServerInvoker
addConnectionListener, addInvocationHandler, assignPort, create, createServerSocketFactory, findInvocationHandler, getClientConnectAddress, getClientConnectPort, getConfiguration, getConnectionNotifier, getDataType, getDefaultServerSocketFactory, getInvocationHandler, getInvocationHandlers, getLease, getLeasePeriod, getMaxNumberOfOnewayThreads, getMBeanObjectName, getMBeanServer, getOnewayThreadPool, getServerBindAddress, getServerBindPort, getServerSocketFactory, getSupportedSubsystems, getTimeout, handleInternalInvocation, hasInvocationHandler, invoke, invoke, isLeaseActivated, isRegisterCallbackListeners, isStarted, isUseClientConnectionIdentity, justNeedsSSLClientMode, postProcess, preProcess, removeCallbackHandler, removeCallbackListener, removeConnectionListener, removeInvocationHandler, setClientConnectAddress, setClientConnectPort, setConfiguration, setConnectionListener, setLeasePeriod, setMaxNumberOfOnewayThreads, setMBeanServer, setOnewayThreadPool, setRegisterCallbackListeners, setServerSocketFactory, setTimeout, setUseClientConnectionIdentity, shutdownCallbackHandler, wrapServerSocketFactory
 
Methods inherited from class org.jboss.remoting.AbstractInvoker
addClientLocator, createSocketFactory, getClassLoader, getClientLocator, getClientLocators, getLocator, getSerializationType, getSocketFactory, isCompleteSocketFactory, isSocketFactoryCreatedFromSSLParameters, needsCustomSSLConfiguration, setClassLoader, setSerializationType, setSocketFactory, wrapSocketFactory
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.jboss.remoting.transport.socket.SocketServerInvokerMBean
getServerBindPort
 
Methods inherited from interface org.jboss.remoting.ServerInvokerMBean
create, getClientConnectAddress, getClientConnectPort, getConfiguration, getDataType, getServerBindAddress, getTimeout, isStarted, setClientConnectAddress, setClientConnectPort, setConfiguration, setTimeout
 

Field Detail

log

protected static final org.jboss.logging.Logger log
Constructor Detail

MultiplexServerInvoker

public MultiplexServerInvoker(InvokerLocator locator)
Create a new MultiplexServerInvoker.

Parameters:
locator -

MultiplexServerInvoker

public MultiplexServerInvoker(InvokerLocator locator,
                              java.util.Map configuration)
Create a new MultiplexServerInvoker.


MultiplexServerInvoker

protected MultiplexServerInvoker(InvokerLocator locator,
                                 java.util.Map configuration,
                                 java.net.ServerSocket serverSocket,
                                 java.net.Socket socket,
                                 java.util.Map virtualServerInvokers)
Create a new MultiplexServerInvoker.

Method Detail

getAddressPairMap

public static java.util.Map getAddressPairMap()

getSocketGroupMap

public static java.util.Map getSocketGroupMap()

getDefaultDataType

protected java.lang.String getDefaultDataType()
Each implementation of the remote client invoker should have a default data type that is uses in the case it is not specified in the invoker locator uri.

Overrides:
getDefaultDataType in class SocketServerInvoker

start

public void start()
           throws java.io.IOException
Description copied from class: SocketServerInvoker
Starts the invoker.

Specified by:
start in interface ServerInvokerMBean
Specified by:
start in interface SocketServerInvokerMBean
Overrides:
start in class SocketServerInvoker
Throws:
java.io.IOException

run

public void run()
Specified by:
run in interface java.lang.Runnable
Overrides:
run in class SocketServerInvoker

isSafeToShutdown

public boolean isSafeToShutdown()

notifyDisconnected

public void notifyDisconnected(VirtualSocket virtualSocket)
Specified by:
notifyDisconnected in interface VirtualSocket.DisconnectListener

stop

public void stop()
Description copied from class: SocketServerInvoker
Stops the invoker.

Specified by:
stop in interface ServerInvokerMBean
Specified by:
stop in interface SocketServerInvokerMBean
Overrides:
stop in class SocketServerInvoker

toString

public java.lang.String toString()
Overrides:
toString in class SocketServerInvoker

setup

protected void setup()
              throws java.lang.Exception
Overrides:
setup in class SocketServerInvoker
Throws:
java.lang.Exception

finishStart

protected void finishStart()
                    throws java.io.IOException
Finishes start up process when suitable bind and connect information is available. For more information, see the Multiplex subsystem documentation at labs.jboss.org.

Throws:
java.io.IOException

resetLocator

protected void resetLocator(int bindPort)
Called by MultiplexClientInvoker.createSocket() when it finds connection is broken and binds virtual socket group to new bind port.

Parameters:
bindPort -

configureSocketGroupParameters

protected void configureSocketGroupParameters(java.util.Map parameters)
                                       throws java.io.IOException
Throws:
java.io.IOException

createPrimingSocket

protected static void createPrimingSocket(MultiplexServerInvoker.SocketGroupInfo socketGroupInfo,
                                          java.lang.String connectHost,
                                          int connectPort,
                                          java.util.Map configuration,
                                          int timeout)
                                   throws java.io.IOException
Throws:
java.io.IOException

createPrimingSocket

protected static void createPrimingSocket(MultiplexServerInvoker.SocketGroupInfo socketGroupInfo,
                                          java.lang.String connectHost,
                                          int connectPort,
                                          java.net.InetAddress bindAddress,
                                          int bindPort,
                                          java.util.Map configuration,
                                          int timeout)
                                   throws java.io.IOException
Throws:
java.io.IOException

getThreadName

protected java.lang.String getThreadName(int i)
Overrides:
getThreadName in class SocketServerInvoker

processInvocation

protected void processInvocation(java.net.Socket socket)
                          throws java.lang.Exception
Description copied from class: SocketServerInvoker
The acceptor thread should spend as little time as possbile doing any kind of operation, and under no circumstances should perform IO on the new socket, which can potentially block and lock up the server. For this reason, the acceptor thread should grab a worker thread and delegate all subsequent work to it.

Overrides:
processInvocation in class SocketServerInvoker
Throws:
java.lang.Exception

cleanup

protected void cleanup()
Overrides:
cleanup in class SocketServerInvoker

createServerSocket

protected java.net.ServerSocket createServerSocket(int bindPort,
                                                   int backlog,
                                                   java.net.InetAddress bindAddress)
                                            throws java.io.IOException
In creating the server socket, createServerSocket() determines whether multiplexing will be supported by this ServerInvoker. The determination is made according to the presence or absence of certain parameters in the ServerInvoker's locator. In particular, a VirtualServerSocket, which supports multiplexing, needs to connect to a remote MasterServerSocket before it can begin to accept connection requests. In order to know which MasterServerSocket to connect to, it looks for parameters "connectHost" and "connectPort" in the locator. The presence of these parameters indicates that a VirtualServerSocket should be created, and their absence indicates that a MasterServerSocket, which does not support multiplexing, should be created.

Overrides:
createServerSocket in class SocketServerInvoker
Parameters:
bindPort -
backlog -
bindAddress -
Returns:
Throws:
java.io.IOException

rule1

protected void rule1()
              throws java.io.IOException
Throws:
java.io.IOException

rule2

protected void rule2(java.lang.String connectHost,
                     int connectPort)
              throws java.io.IOException
Throws:
java.io.IOException

rule3

protected void rule3()
              throws java.io.IOException
Throws:
java.io.IOException

rule4

protected void rule4()

refreshServerSocket

protected void refreshServerSocket()
                            throws java.io.IOException
Description copied from class: SocketServerInvoker
refreshes the serverSocket by closing old one and creating a new ServerSocket from new ServerSocketFactory

Overrides:
refreshServerSocket in class SocketServerInvoker
Throws:
java.io.IOException

getServerSocket

public java.net.ServerSocket getServerSocket()
Returns ServerSocket used to accept invocation requests. It is added to facilitate unit tests.

Returns:
ServerSocket used to accept invocation requests.

getServerInvoker

public MultiplexServerInvoker getServerInvoker(java.net.InetSocketAddress address)
Provides access to a virtual MultiplexServerInvoker in a master MultiplexServerInvoker's invoker farm.


getServerInvokers

public java.util.Collection getServerInvokers()
Provides access to all virtual MultiplexServerInvokers in a master MultiplexServerInvoker's invoker farm.


setBindingInfo

protected void setBindingInfo()
                       throws java.io.IOException
Throws:
java.io.IOException

getParameters

protected void getParameters()
                      throws java.lang.Exception
Throws:
java.lang.Exception

getInputBufferSize

public int getInputBufferSize()

setInputBufferSize

public void setInputBufferSize(int inputBufferSize)

getInputMaxErrors

public int getInputMaxErrors()

setInputMaxErrors

public void setInputMaxErrors(int inputMaxErrors)

getMaxAcceptErrors

public int getMaxAcceptErrors()

setMaxAcceptErrors

public void setMaxAcceptErrors(int maxAcceptErrors)

getMultiplexConnectHost

public java.lang.String getMultiplexConnectHost()

getMultiplexConnectPort

public int getMultiplexConnectPort()

getOutputMaxChunkSize

public int getOutputMaxChunkSize()

setOutputMaxChunkSize

public void setOutputMaxChunkSize(int outputMaxChunkSize)

getOutputMaxDataSlice

public int getOutputMaxDataSlice()

setOutputMaxDataSlice

public void setOutputMaxDataSlice(int outputMaxDataSlice)

getOutputMaxTimeSlice

public int getOutputMaxTimeSlice()

setOutputMaxTimeSlice

public void setOutputMaxTimeSlice(int outputMaxTimeSlice)

getOutputMessagePoolSize

public int getOutputMessagePoolSize()

setOutputMessagePoolSize

public void setOutputMessagePoolSize(int outputMessagePoolSize)

getOutputMessageSize

public int getOutputMessageSize()

setOutputMessageSize

public void setOutputMessageSize(int outputMessageSize)

getServerMultiplexId

public java.lang.String getServerMultiplexId()

getShutdownMonitorPeriod

public int getShutdownMonitorPeriod()

setShutdownMonitorPeriod

public void setShutdownMonitorPeriod(int shutdownMonitorPeriod)

getShutdownRefusalsMaximum

public int getShutdownRefusalsMaximum()

setShutdownRefusalsMaximum

public void setShutdownRefusalsMaximum(int shutdownRefusalsMaximum)

getShutdownRequestTimeout

public int getShutdownRequestTimeout()

setShutdownRequestTimeout

public void setShutdownRequestTimeout(int shutdownRequestTimeout)

getStaticThreadsMonitorPeriod

public int getStaticThreadsMonitorPeriod()

setStaticThreadsMonitorPeriod

public void setStaticThreadsMonitorPeriod(int staticThreadsMonitorPeriod)


Copyright © 1998-2005 JBoss Inc . All Rights Reserved.