Author: ron.sigal(a)jboss.com
Date: 2011-02-28 16:42:51 -0500 (Mon, 28 Feb 2011)
New Revision: 6259
Modified:
remoting2/branches/2.x/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.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java
===================================================================
---
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2011-02-24
04:44:34 UTC (rev 6258)
+++
remoting2/branches/2.x/src/main/org/jboss/remoting/transport/bisocket/BisocketServerInvoker.java 2011-02-28
21:42:51 UTC (rev 6259)
@@ -96,6 +96,8 @@
protected boolean isCallbackServer = false;
protected List secondaryBindPorts = new ArrayList();
protected List secondaryConnectPorts = new ArrayList();
+ protected int dosMaxThreads = Bisocket.DOS_MAX_THREADS_DEFAULT;
+ protected int dosTimeout = Bisocket.DOS_TIMEOUT_DEFAULT;
public static BisocketServerInvoker getBisocketServerInvoker(String listenerId)
@@ -502,6 +504,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;
@@ -729,6 +755,42 @@
secondaryConnectPorts = new ArrayList(secondaryBindPorts);
}
+ 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);
@@ -1094,7 +1156,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
{
@@ -1166,7 +1229,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();