org.jboss.invocation.pooled.interfaces
Class PooledInvokerProxy

java.lang.Object
  extended by org.jboss.invocation.pooled.interfaces.PooledInvokerProxy
All Implemented Interfaces:
Externalizable, Serializable, Remote, Invoker

public class PooledInvokerProxy
extends Object
implements Invoker, Externalizable

Client socket connections are pooled to avoid the overhead of making a connection. RMI seems to do a new connection with each request.

Version:
$Revision: 57209 $
Author:
Bill Burke, Scott.Stark@jboss.org
See Also:
Serialized Form

Nested Class Summary
protected static class PooledInvokerProxy.ClientSocket
          An encapsulation of a client connection
 
Field Summary
protected  ServerAddress address
          connection information
protected static Map connectionPools
          A class wide pool Map>
static long deserializeTime
           
static long getSocketTime
           
static int MAX_RETRIES
          Set number of retries in getSocket method
protected  int maxPoolSize
           
protected  LinkedList pool
          Pool for this invoker.
static long readTime
           
protected  int retryCount
          The number of times to retry after seeing a ConnectionException
static long serializeTime
           
protected static org.jboss.tm.TransactionPropagationContextFactory tpcFactory
          Factory for transaction propagation contexts.
static long usedPooled
          The number of times a connection has been obtained from a pool
static long writeTime
           
 
Fields inherited from interface org.jboss.invocation.Invoker
ID
 
Constructor Summary
PooledInvokerProxy()
          Exposed for externalization.
PooledInvokerProxy(ServerAddress sa, int maxPoolSize)
          Create a new Proxy.
PooledInvokerProxy(ServerAddress sa, int maxPoolSize, int retryCount)
           
 
Method Summary
static void clearPool(ServerAddress sa)
          Close all sockets in a specific pool.
static void clearPools()
          Close all sockets in all pools
static void clearStats()
          Clear all class level stats
protected  PooledInvokerProxy.ClientSocket getConnection()
           
static long getInUseCount()
           
 long getPoolCount()
           
protected  PooledInvokerProxy.ClientSocket getPooledConnection()
           
 String getServerHostName()
          The name of of the server.
static long getSocketCloseCount()
           
static long getSocketConnectCount()
           
static int getTotalPoolCount()
           
 Object getTransactionPropagationContext()
          ???
static long getUsedPooled()
           
protected  void initPool()
           
 Object invoke(Invocation invocation)
          The invocation on the delegate, calls the right invoker.
 void readExternal(ObjectInput in)
           
protected  boolean returnConnection(PooledInvokerProxy.ClientSocket socket)
          Return a socket to the pool
static void setTPCFactory(org.jboss.tm.TransactionPropagationContextFactory tpcf)
           
 void writeExternal(ObjectOutput out)
          Write out the serializable data
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tpcFactory

protected static org.jboss.tm.TransactionPropagationContextFactory tpcFactory
Factory for transaction propagation contexts.


getSocketTime

public static long getSocketTime

readTime

public static long readTime

writeTime

public static long writeTime

serializeTime

public static long serializeTime

deserializeTime

public static long deserializeTime

usedPooled

public static long usedPooled
The number of times a connection has been obtained from a pool


MAX_RETRIES

public static int MAX_RETRIES
Set number of retries in getSocket method


connectionPools

protected static final Map connectionPools
A class wide pool Map>


address

protected ServerAddress address
connection information


pool

protected LinkedList pool
Pool for this invoker. This is shared between all instances of proxies attached to a specific invoker This should not be serializable, but is for backward compatibility.


maxPoolSize

protected int maxPoolSize

retryCount

protected int retryCount
The number of times to retry after seeing a ConnectionException

Constructor Detail

PooledInvokerProxy

public PooledInvokerProxy()
Exposed for externalization.


PooledInvokerProxy

public PooledInvokerProxy(ServerAddress sa,
                          int maxPoolSize)
Create a new Proxy.


PooledInvokerProxy

public PooledInvokerProxy(ServerAddress sa,
                          int maxPoolSize,
                          int retryCount)
Method Detail

setTPCFactory

public static void setTPCFactory(org.jboss.tm.TransactionPropagationContextFactory tpcf)

clearStats

public static void clearStats()
Clear all class level stats


getInUseCount

public static long getInUseCount()
Returns:
the active number of client connections

getUsedPooled

public static long getUsedPooled()
Returns:
the number of times a connection was returned from a pool

getSocketConnectCount

public static long getSocketConnectCount()

getSocketCloseCount

public static long getSocketCloseCount()

getTotalPoolCount

public static int getTotalPoolCount()
Returns:
the total number of pooled connections across all ServerAddresses

getPoolCount

public long getPoolCount()
Returns:
the proxy local pool count

clearPool

public static void clearPool(ServerAddress sa)
Close all sockets in a specific pool.


clearPools

public static void clearPools()
Close all sockets in all pools


initPool

protected void initPool()

getConnection

protected PooledInvokerProxy.ClientSocket getConnection()
                                                 throws Exception
Throws:
Exception

getPooledConnection

protected PooledInvokerProxy.ClientSocket getPooledConnection()

returnConnection

protected boolean returnConnection(PooledInvokerProxy.ClientSocket socket)
Return a socket to the pool

Parameters:
socket -
Returns:
true if socket was added to the pool, false if the pool was full

getServerHostName

public String getServerHostName()
                         throws Exception
The name of of the server.

Specified by:
getServerHostName in interface Invoker
Throws:
Exception

getTransactionPropagationContext

public Object getTransactionPropagationContext()
                                        throws SystemException
???

Returns:
the transaction propagation context of the transaction associated with the current thread. Returns null if the transaction manager was never set, or if no transaction is associated with the current thread.
Throws:
SystemException

invoke

public Object invoke(Invocation invocation)
              throws Exception
The invocation on the delegate, calls the right invoker. Remote if we are remote, local if we are local.

Specified by:
invoke in interface Invoker
Parameters:
invocation - A pointer to the invocation object
Returns:
Return value of method invocation.
Throws:
Exception - Failed to invoke method.

writeExternal

public void writeExternal(ObjectOutput out)
                   throws IOException
Write out the serializable data

Specified by:
writeExternal in interface Externalizable
Parameters:
out -
Throws:
IOException

readExternal

public void readExternal(ObjectInput in)
                  throws IOException,
                         ClassNotFoundException
Specified by:
readExternal in interface Externalizable
Throws:
IOException
ClassNotFoundException


Copyright © 2002 JBoss Group, LLC. All Rights Reserved.