Author: ron.sigal(a)jboss.com
Date: 2011-02-28 17:00:42 -0500 (Mon, 28 Feb 2011)
New Revision: 6261
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
Log:
JBREM-1275: Made number of threads and timeout configurable in
SecondaryServerSocketThread.
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
---
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2011-02-28
21:44:13 UTC (rev 6260)
+++
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2011-02-28
22:00:42 UTC (rev 6261)
@@ -87,6 +87,8 @@
protected boolean isCallbackServer = false;
protected int secondaryBindPort = -1;
protected int secondaryConnectPort = -1;
+ protected int dosMaxThreads = Bisocket.DOS_MAX_THREADS_DEFAULT;
+ protected int dosTimeout = Bisocket.DOS_TIMEOUT_DEFAULT;
public static BisocketServerInvoker getBisocketServerInvoker(String listenerId)
@@ -360,6 +362,30 @@
}
+ public int getDosMaxThreads()
+ {
+ return dosMaxThreads;
+ }
+
+
+ public void setDosMaxThreads(int dosMaxThreads)
+ {
+ this.dosMaxThreads = dosMaxThreads;
+ }
+
+
+ public int getDosTimeout()
+ {
+ return dosTimeout;
+ }
+
+
+ public void setDosTimeout(int dosTimeout)
+ {
+ this.dosTimeout = dosTimeout;
+ }
+
+
public int getPingFrequency()
{
return pingFrequency;
@@ -511,6 +537,42 @@
log.warn("\"" + Bisocket.SECONDARY_CONNECT_PORT + "\"
must be specified as a String");
}
+ o = configuration.get(Bisocket.DOS_MAX_THREADS);
+ if (o instanceof String && ((String) o).length() > 0)
+ {
+ try
+ {
+ dosMaxThreads = Integer.valueOf(((String) o)).intValue();
+ log.debug(this + " setting dosMaxThreads to " + dosMaxThreads);
+ }
+ catch (NumberFormatException e)
+ {
+ log.warn("Invalid format for " + "\"" +
Bisocket.DOS_MAX_THREADS + "\": " + o);
+ }
+ }
+ else if (o != null)
+ {
+ log.warn("\"" + Bisocket.DOS_MAX_THREADS + "\" must be
specified as a String");
+ }
+
+ o = configuration.get(Bisocket.DOS_TIMEOUT);
+ if (o instanceof String && ((String) o).length() > 0)
+ {
+ try
+ {
+ dosTimeout = Integer.valueOf(((String) o)).intValue();
+ log.debug(this + " setting dosTimeout to " + dosTimeout);
+ }
+ catch (NumberFormatException e)
+ {
+ log.warn("Invalid format for " + "\"" +
Bisocket.DOS_TIMEOUT + "\": " + o);
+ }
+ }
+ else if (o != null)
+ {
+ log.warn("\"" + Bisocket.DOS_TIMEOUT + "\" must be
specified as a String");
+ }
+
if (isCallbackServer)
{
socketFactory = createSocketFactory(configuration);
@@ -863,7 +925,8 @@
{
private ServerSocket secondaryServerSocket;
boolean running = true;
- Semaphore maxThreads = new Semaphore(maxPoolSize);
+ Semaphore maxThreads = new Semaphore(dosMaxThreads);
+ int localDosTimeout = dosTimeout;
SecondaryServerSocketThread(ServerSocket secondaryServerSocket) throws IOException
{
@@ -920,7 +983,7 @@
if (log.isTraceEnabled()) log.trace(this + " processing socket:
" + socket);
try
{
- socket.setSoTimeout(DEFAULT_TIMEOUT_PERIOD);
+ socket.setSoTimeout(localDosTimeout);
DataInputStream dis = new DataInputStream(socket.getInputStream());
int action = dis.read();
String listenerId = dis.readUTF();