org.jboss.invocation.pooled.server
Class PooledInvoker

java.lang.Object
  extended byorg.jboss.mx.util.JBossNotificationBroadcasterSupport (src) 
      extended byorg.jboss.system.ServiceMBeanSupport (src) 
          extended byorg.jboss.invocation.pooled.server.PooledInvoker
All Implemented Interfaces:
MBeanRegistration (src) , NotificationBroadcaster (src) , NotificationEmitter (src) , java.lang.Runnable, Service (src) , ServiceMBean (src)
Direct Known Subclasses:
PooledInvokerHA (src)

public class PooledInvoker
extends ServiceMBeanSupport (src)
implements java.lang.Runnable

This invoker pools Threads and client connections to one server socket. The purpose is to avoid a bunch of failings of RMI. 1. Avoid making a client socket connection with every invocation call. This is very expensive. Also on windows if too many clients try to connect at the same time, you get connection refused exceptions. This invoker/proxy combo alleviates this. 2. Avoid creating a thread per invocation. The client/server connection is preserved and attached to the same thread. So we have connection pooling on the server and client side, and thread pooling on the server side. Pool, is an LRU pool, so resources should be cleaned up.


Field Summary
protected  java.lang.Thread[] acceptThreads
           
protected  int backlog
           
protected  java.lang.String clientConnectAddress
          The internet address client will use to connect to the sever.
protected  int clientConnectPort
          The port a client will use to connect to the sever.
protected  int clientMaxPoolSize
           
protected  LRUPool (src) clientpool
           
protected  boolean enableTcpNoDelay
          If the TcpNoDelay option should be used on the socket.
protected static Logger (src) log
          logger instance.
protected  int maxPoolSize
           
protected  int numAcceptThreads
           
protected  PooledInvokerProxy (src) optimizedInvokerProxy
           
protected  boolean running
           
protected  java.lang.String serverBindAddress
          The internet address to bind to by default.
protected  int serverBindPort
          The server port to bind to.
protected  java.net.ServerSocket serverSocket
           
protected  java.util.LinkedList threadpool
           
protected  int timeout
           
protected static TransactionPropagationContextFactory (src) tpcFactory
           
protected static TransactionPropagationContextImporter (src) tpcImporter
           
protected  boolean trace
          The logging trace level flag
protected  ObjectName (src) transactionManagerService
          ObjectName of the transactionManagerService we use.
 
Fields inherited from class org.jboss.system.ServiceMBeanSupport (src)
server, SERVICE_CONTROLLER_SIG, serviceName
 
Fields inherited from interface org.jboss.system.ServiceMBean (src)
CREATE_EVENT, CREATED, DESTROY_EVENT, DESTROYED, FAILED, REGISTERED, START_EVENT, STARTED, STARTING, states, STOP_EVENT, STOPPED, STOPPING, UNREGISTERED
 
Constructor Summary
PooledInvoker()
           
 
Method Summary
protected  void destroyService()
          Sub-classes should override this method to provide custum 'destroy' logic.
 int getBacklog()
           
 java.lang.String getClientConnectAddress()
           
 int getClientConnectPort()
           
 int getClientMaxPoolSize()
          Getter for property maxPoolSize;
 int getCurrentClientPoolSize()
           
 int getCurrentThreadPoolSize()
           
 int getMaxPoolSize()
          Getter for property maxPoolSize;
 int getNumAcceptThreads()
          Getter for property numAcceptThreads
 PooledInvokerProxy (src) getOptimizedInvokerProxy()
           
 java.lang.String getServerBindAddress()
           
 int getServerBindPort()
          Getter for property serverBindPort.
 int getSocketTimeout()
          Getter for property timeout
 ObjectName (src) getTransactionManagerService()
          mbean get-set pair for field transactionManagerService Get the value of transactionManagerService
protected  Transaction (src) importTPC(java.lang.Object tpc)
           
 java.lang.Object invoke(Invocation (src)  invocation)
          The ServerProtocol will use this method to service an invocation request.
 boolean isEnableTcpNoDelay()
           
protected  void jmxBind()
           
 void run()
           
 void setBacklog(int backlog)
           
 void setClientConnectAddress(java.lang.String clientConnectAddress)
           
 void setClientConnectPort(int clientConnectPort)
           
 void setClientMaxPoolSize(int clientMaxPoolSize)
          Setter for property maxPoolSize.
 void setEnableTcpNoDelay(boolean enableTcpNoDelay)
           
 void setMaxPoolSize(int maxPoolSize)
          Setter for property maxPoolSize.
 void setNumAcceptThreads(int size)
          Setter for property numAcceptThreads
 void setServerBindAddress(java.lang.String serverBindAddress)
           
 void setServerBindPort(int serverBindPort)
          Setter for property serverBindPort.
 void setSocketTimeout(int time)
          Setter for property timeout
 void setTransactionManagerService(ObjectName (src)  transactionManagerService)
          Set the value of transactionManagerService
 void startService()
          Starts this IL, and binds it to JNDI
 void stopService()
          Stops this service, and unbinds it from JNDI.
 
Methods inherited from class org.jboss.system.ServiceMBeanSupport (src)
create, createService, destroy, getLog, getName, getNextNotificationSequenceNumber, getObjectName, getServer, getServiceName, getState, getStateString, jbossInternalCreate, jbossInternalDescription, jbossInternalDestroy, jbossInternalLifecycle, jbossInternalStart, jbossInternalStop, postDeregister, postRegister, preDeregister, preRegister, start, stop
 
Methods inherited from class org.jboss.mx.util.JBossNotificationBroadcasterSupport (src)
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

log

protected static final Logger (src)  log
logger instance.


enableTcpNoDelay

protected boolean enableTcpNoDelay
If the TcpNoDelay option should be used on the socket.


serverBindAddress

protected java.lang.String serverBindAddress
The internet address to bind to by default.


serverBindPort

protected int serverBindPort
The server port to bind to.


clientConnectAddress

protected java.lang.String clientConnectAddress
The internet address client will use to connect to the sever.


clientConnectPort

protected int clientConnectPort
The port a client will use to connect to the sever.


backlog

protected int backlog

serverSocket

protected java.net.ServerSocket serverSocket

timeout

protected int timeout

maxPoolSize

protected int maxPoolSize

clientMaxPoolSize

protected int clientMaxPoolSize

numAcceptThreads

protected int numAcceptThreads

acceptThreads

protected java.lang.Thread[] acceptThreads

clientpool

protected LRUPool (src)  clientpool

threadpool

protected java.util.LinkedList threadpool

running

protected boolean running

trace

protected boolean trace
The logging trace level flag


transactionManagerService

protected ObjectName (src)  transactionManagerService
ObjectName of the transactionManagerService we use. Probably should not be here -- used to set txInterceptor tx mananger.


optimizedInvokerProxy

protected PooledInvokerProxy (src)  optimizedInvokerProxy

tpcFactory

protected static TransactionPropagationContextFactory (src)  tpcFactory

tpcImporter

protected static TransactionPropagationContextImporter (src)  tpcImporter
Constructor Detail

PooledInvoker

public PooledInvoker()
Method Detail

jmxBind

protected void jmxBind()

startService

public void startService()
                  throws java.lang.Exception
Starts this IL, and binds it to JNDI

Overrides:
startService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception - Description of Exception

run

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

stopService

public void stopService()
                 throws java.lang.Exception
Stops this service, and unbinds it from JNDI.

Overrides:
stopService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

destroyService

protected void destroyService()
                       throws java.lang.Exception
Description copied from class: ServiceMBeanSupport (src)
Sub-classes should override this method to provide custum 'destroy' logic.

This method is empty, and is provided for convenience when concrete service classes do not need to perform anything specific for this state change.

Overrides:
destroyService in class ServiceMBeanSupport (src)
Throws:
java.lang.Exception

invoke

public java.lang.Object invoke(Invocation (src)  invocation)
                        throws java.lang.Exception
The ServerProtocol will use this method to service an invocation request.

Throws:
java.lang.Exception

importTPC

protected Transaction (src)  importTPC(java.lang.Object tpc)

getNumAcceptThreads

public int getNumAcceptThreads()
Getter for property numAcceptThreads

Returns:
Value of property numAcceptThreads

setNumAcceptThreads

public void setNumAcceptThreads(int size)
Setter for property numAcceptThreads

Parameters:
size - New value of property numAcceptThreads.

getMaxPoolSize

public int getMaxPoolSize()
Getter for property maxPoolSize;

Returns:
Value of property maxPoolSize.

setMaxPoolSize

public void setMaxPoolSize(int maxPoolSize)
Setter for property maxPoolSize.

Parameters:
maxPoolSize - New value of property serverBindPort.

getClientMaxPoolSize

public int getClientMaxPoolSize()
Getter for property maxPoolSize;

Returns:
Value of property maxPoolSize.

setClientMaxPoolSize

public void setClientMaxPoolSize(int clientMaxPoolSize)
Setter for property maxPoolSize.

Parameters:
clientMaxPoolSize - New value of property serverBindPort.

getSocketTimeout

public int getSocketTimeout()
Getter for property timeout

Returns:
Value of property timeout

setSocketTimeout

public void setSocketTimeout(int time)
Setter for property timeout

Parameters:
time - New value of property timeout

getCurrentClientPoolSize

public int getCurrentClientPoolSize()
Returns:
Value of property serverBindPort.

getCurrentThreadPoolSize

public int getCurrentThreadPoolSize()
Returns:
Value of property serverBindPort.

getServerBindPort

public int getServerBindPort()
Getter for property serverBindPort.

Returns:
Value of property serverBindPort.

setServerBindPort

public void setServerBindPort(int serverBindPort)
Setter for property serverBindPort.

Parameters:
serverBindPort - New value of property serverBindPort.

getClientConnectAddress

public java.lang.String getClientConnectAddress()

setClientConnectAddress

public void setClientConnectAddress(java.lang.String clientConnectAddress)

getClientConnectPort

public int getClientConnectPort()

setClientConnectPort

public void setClientConnectPort(int clientConnectPort)

getBacklog

public int getBacklog()

setBacklog

public void setBacklog(int backlog)

isEnableTcpNoDelay

public boolean isEnableTcpNoDelay()

setEnableTcpNoDelay

public void setEnableTcpNoDelay(boolean enableTcpNoDelay)

getServerBindAddress

public java.lang.String getServerBindAddress()

setServerBindAddress

public void setServerBindAddress(java.lang.String serverBindAddress)

getTransactionManagerService

public ObjectName (src)  getTransactionManagerService()
mbean get-set pair for field transactionManagerService Get the value of transactionManagerService

Returns:
value of transactionManagerService

setTransactionManagerService

public void setTransactionManagerService(ObjectName (src)  transactionManagerService)
Set the value of transactionManagerService

Parameters:
transactionManagerService - Value to assign to transactionManagerService

getOptimizedInvokerProxy

public PooledInvokerProxy (src)  getOptimizedInvokerProxy()