Author: ron.sigal(a)jboss.com
Date: 2009-03-20 02:34:57 -0400 (Fri, 20 Mar 2009)
New Revision: 4880
Modified:
remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
Log:
JBREM-1082: (1) Can get parameters from InvokerLocator; (2) correctly configures
validatorPingTimeout.
Modified: remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java
===================================================================
--- remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2009-03-20
06:32:05 UTC (rev 4879)
+++ remoting2/branches/2.x/src/main/org/jboss/remoting/ConnectionValidator.java 2009-03-20
06:34:57 UTC (rev 4880)
@@ -57,6 +57,9 @@
/** Default ping timeout period. Value is 1 second. */
public static final String DEFAULT_PING_TIMEOUT = "1000";
+
+ /** Default ping timeout period. Value is 1 second. */
+ public static final int DEFAULT_PING_TIMEOUT_INT = 1000;
/**
* Default number of ping retries. Value is 1.
@@ -258,6 +261,7 @@
{
this.client = client;
pingPeriod = DEFAULT_PING_PERIOD;
+ pingTimeout = DEFAULT_PING_TIMEOUT_INT;
listeners = new ArrayList();
stopped = false;
this.metadata = new HashMap(metadata);
@@ -415,6 +419,10 @@
private void getParameters(Client client, Map metadata)
{
+ if (checkUseParametersFromLocator(client, metadata))
+ {
+ getParametersFromMap(client.getInvoker().getLocator().getParameters());
+ }
getParametersFromMap(client.getConfiguration());
getParametersFromMap(metadata);
@@ -429,6 +437,54 @@
}
}
+ private boolean checkUseParametersFromLocator(Client client, Map metadata)
+ {
+ if (client.getInvoker() == null)
+ {
+ return false;
+ }
+ Object o =
client.getInvoker().getLocator().getParameters().get(Client.USE_ALL_PARAMS);
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ return Boolean.valueOf(((String) o)).booleanValue();
+ }
+ else
+ {
+ log.warn(this + " could not convert " + Client.USE_ALL_PARAMS +
" value" +
+ " in InvokerLocator to a boolean: must be a String");
+ }
+ }
+ o = client.getConfiguration().get(Client.USE_ALL_PARAMS);
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ return Boolean.valueOf(((String) o)).booleanValue();
+ }
+ else
+ {
+ log.warn(this + " could not convert " + Client.USE_ALL_PARAMS +
" value" +
+ " in Client configuration map to a boolean: must be a
String");
+ }
+ }
+ o = metadata.get(Client.USE_ALL_PARAMS);
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ return Boolean.valueOf(((String) o)).booleanValue();
+ }
+ else
+ {
+ log.warn(this + " could not convert " + Client.USE_ALL_PARAMS +
" value" +
+ " in metadata map to a boolean: must be a String");
+ }
+ }
+ return false;
+ }
+
private void getParametersFromMap(Map config)
{
if (config != null)
@@ -455,6 +511,28 @@
}
}
+ o = config.get(VALIDATOR_PING_TIMEOUT);
+ if (o != null)
+ {
+ if (o instanceof String)
+ {
+ try
+ {
+ pingTimeout = Integer.parseInt((String)o);
+ }
+ catch (Exception e)
+ {
+ log.warn(this + " could not convert " +
VALIDATOR_PING_TIMEOUT +
+ " value of " + o + " to a long value");
+ }
+ }
+ else
+ {
+ log.warn(this + " could not convert " + VALIDATOR_PING_TIMEOUT
+
+ " value of " + o + " to a long value: must be a
String");
+ }
+ }
+
o = config.get(TIE_TO_LEASE);
if (o != null)
{
@@ -503,8 +581,8 @@
private void start()
{
+ metadata.put(ServerInvoker.TIMEOUT, Integer.toString(pingTimeout));
configMap = createPingConfig(client.getConfiguration(), metadata);
- pingTimeout = Integer.parseInt((String) configMap.get(ServerInvoker.TIMEOUT));
log.debug(this + " timeout: " + pingTimeout);
log.debug(this + " ping retries: " +
configMap.get("NumberOfCallRetries"));
log.debug(this + " connection retries: " +
configMap.get("NumberOfRetries"));