Author: ron.sigal(a)jboss.com
Date: 2009-08-18 21:53:51 -0400 (Tue, 18 Aug 2009)
New Revision: 5364
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/ClientSocketWrapper.java
Log:
JBREM-1120: Added writeTimeout variable.
Modified:
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/ClientSocketWrapper.java
===================================================================
---
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/ClientSocketWrapper.java 2009-08-19
01:52:55 UTC (rev 5363)
+++
remoting2/branches/2.2/src/main/org/jboss/remoting/transport/socket/ClientSocketWrapper.java 2009-08-19
01:53:51 UTC (rev 5364)
@@ -51,6 +51,7 @@
private InputStream in;
private OutputStream out;
+ private int writeTimeout = -1;
// Constructors
---------------------------------------------------------------------------------
@@ -78,6 +79,16 @@
return in;
}
+ public int getWriteTimeout()
+ {
+ return writeTimeout;
+ }
+
+ public void setWriteTimeout(int writeTimeout)
+ {
+ this.writeTimeout = writeTimeout;
+ }
+
public void checkConnection() throws IOException
{
// Test to see if socket is alive by send ACK message
@@ -98,7 +109,7 @@
public void checkOpenConnection() throws IOException
{
- log.trace("checking open connection");
+ if (trace) log.trace("checking open connection");
if (in.available() > 1)
{
log.trace("remote endpoint has closed");
@@ -156,6 +167,15 @@
log.trace("set temp timeout to: " + tempTimeout);
}
}
+ o = metadata.get(WRITE_TIMEOUT);
+ if (o instanceof Integer)
+ {
+ writeTimeout = ((Integer) o).intValue();
+ if (writeTimeout != -1)
+ {
+ log.trace("set writeTimeout to: " + writeTimeout);
+ }
+ }
}
out = createOutputStream(serializationType, socket, marshaller);
@@ -192,6 +212,11 @@
log.warn("got null marshaller");
OutputStream os = socket.getOutputStream();
+ if (writeTimeout > 0)
+ {
+ os = new TimedOutputStream(os, writeTimeout);
+ }
+
if (marshaller instanceof PreferredStreamMarshaller)
{
PreferredStreamMarshaller psm = (PreferredStreamMarshaller) marshaller;
Show replies by thread