package org.jboss.remoting.transport.socket;
import org.jboss.logging.Logger;
import org.jboss.util.propertyeditor.PropertyEditors;
import EDU.oswego.cs.dl.util.concurrent.Semaphore;
SocketClientInvoker uses Sockets to remotely connect to the a remote ServerInvoker, which must be
a SocketServerInvoker.
- Author(s):
- Jeff Haynie
- Tom Elrod
- Ovidiu Feodorov
- Version:
- $Revision: 6179 $
Can be either true or false and will indicate if client socket should have TCP_NODELAY turned
on or off. TCP_NODELAY is for a specific purpose; to disable the Nagle buffering algorithm.
It should only be set for applications that send frequent small bursts of information without
getting an immediate response; where timely delivery of data is required (the canonical
example is mouse movements). The default is false.
The client side maximum number of threads. The default is MAX_POOL_SIZE.
Specifies the fully qualified class name for the custom SocketWrapper implementation to use on
the client. Note, will need to make sure this is marked as a client parameter (using the
'isParam' attribute). Making this change will not affect the marshaller/unmarshaller that is
used, which may also be a requirement.
Key for setting timeout used by OnewayConnectionTask
Key to determine if client side oneway invocations should wait to read version.
See JBREM-706.
Key for setting time to wait to get permission to get a connection
Key for setting socket write timeout
Default value for enable TCP nodelay. Value is false.
Default maximum number of times a invocation will be made when it gets a SocketException.
Default is 3.
Default maximum number of socket connections allowed at any point in time. Default is 50.
Default timeout value used by OnewayConnectionTask. Value is 2 seconds.
Default time to wait to get permission to get a connection
private static boolean trace = log.isTraceEnabled();
Used for debugging (tracing) connections leaks
private static final String patternString = "^.*(?:connection.*reset|connection.*closed|connection.*abort|broken.*pipe|connection.*shutdown).*$";
Close all sockets in a specific pool.
int size = thepool.size();
for (int i = 0; i < size; i++)
log.debug("Failure", ex);
Close all sockets in all pools.
if (trace) { log.trace("clearing pool for " + sa); }
Indicates if will check the socket connection when getting from pool by sending byte over the
connection to validate is still good.
If the TcpNoDelay option should be used on the socket.
Pool for this invoker. This is shared between all instances of proxies attached to a specific
invoker.
Socket configuration parameters.
If true, an IOException with message such as "Connection reset by peer: socket write error" will
be treated like a SocketException.
super(locator, configuration);
log.debug("Error setting up " + this, ex);
log.debug(this + " constructed");
Indicates if will check socket connection when returning from pool by sending byte to the
server. Default value will be false.
Returns if newly created sockets will have SO_REUSEADDR enabled. Default is for this to be
true.
Sets if newly created socket should have SO_REUSEADDR enable. Default is true.
log.debug(this + " disconnecting ...");
log.debug("Failed to close socket wrapper", e);
Sets the number of times an invocation will retry based on getting SocketException.
if (numberOfCallRetries < 1)
Sets the number of retries to get a socket connection.
- Parameters:
numberOfRetries
Must be a number greater than 0.
log.warn("numberOfRetries is no longer used");
log.warn("numberOfRetries is no longer used");
The name of of the server.
val + " to a boolean value.");
val + " to a int value");
val + " to an int value");
val + " to a boolean value");
val + " to an int value");
if (trace) log.trace(this + " able to contact server at: " + home);
log.debug(this + " unable to contact server at: " + home);
Each implementation of the remote client invoker should have a default data type that is used
in the case it is not specified in the invoker locator URI.
if (tempTimeoutString != null)
log.debug(this + " setting timeout to " + tempTimeout + " for this invocation");
tempTimeoutString + " to an integer value.");
boolean serverSideOneway = false;
if (trace) log.trace(this + " retryCount: " + retryCount);
socketWrapper = getConnection(marshaller, unmarshaller, tryPool, timeLeft);
log.trace(this + " got socketWrapper: " + socketWrapper);
"Can not get connection to server. Problem establishing " +
"socket connection for " + locator, e);
log.trace(this + "got outputStream: " + outputStream);
log.trace(this + " writing version");
log.trace(this + " wrote version");
if(trace) { log.trace(this + " sent oneway invocation, so not waiting for response, returning null"); }
int onewaySavedTimeout = socketWrapper.getTimeout();
log.trace(this + " received version 254: treating as end of file");
log.trace(this + " received version 254: treating as end of file");
if (response == null && tempTimeout > 0 && timeLeft <= 0)
"Can not get connection to server. Timed out establishing " +
"socket connection for " + locator);
if (trace) { log.trace(this + " returned " + socketWrapper + " to pool"); }
if (trace) { log.trace(this + "'s pool is full, will close the connection"); }
if (trace && !oneway) { log.trace(this + " received response " + response); }
log.debug("Error loading classes from remote call result.", ex);
if (trace) log.trace(this + "(" + socketWrapper + ") got Exception: " + e);
if (trace) { log.trace(this + " couldn't successfully close its socketWrapper", ex); }
About to run out of retries and
pool may be full of timed out sockets,
so want to flush the pool and try with
fresh socket as a last effort.
log.trace(this + " retries exhausted");
log.debug(this + " got exception: " + socketWrapper, ex);
if (trace) log.trace(this + " released semaphore: " + semaphore.permits());
log.trace(this + " using pool (" + pool + ") already defined for " + address);
boolean tryPool, int timeAllowed)
boolean timedout = !semaphore.attempt(timeToWait);
if (trace) log.trace(this + " reusing pooled connection: " + pooled);
if (trace) log.trace(this + " avoiding connection pool, creating new socket");
if (trace) { log.trace(this + " creating socket "); }
if (trace) log.trace(this + " created socket: " + socket);