[jboss-cvs] JBossRemoting/src/main/org/jboss/remoting/transport/socket ...
Ovidiu Feodorov
ovidiu.feodorov at jboss.com
Tue Jan 23 04:39:03 EST 2007
User: ovidiu
Date: 07/01/23 04:39:03
Modified: src/main/org/jboss/remoting/transport/socket Tag:
remoting_2_x ClientSocketWrapper.java
MicroSocketClientInvoker.java ServerThread.java
SocketClientInvoker.java
Log:
various reformatting and logging improvments
Revision Changes Path
No revision
No revision
1.15.10.4 +44 -33 JBossRemoting/src/main/org/jboss/remoting/transport/socket/ClientSocketWrapper.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ClientSocketWrapper.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/ClientSocketWrapper.java,v
retrieving revision 1.15.10.3
retrieving revision 1.15.10.4
diff -u -b -r1.15.10.3 -r1.15.10.4
--- ClientSocketWrapper.java 16 Jan 2007 00:29:29 -0000 1.15.10.3
+++ ClientSocketWrapper.java 23 Jan 2007 09:39:03 -0000 1.15.10.4
@@ -35,13 +35,21 @@
*/
public class ClientSocketWrapper extends SocketWrapper
{
+ // Constants ------------------------------------------------------------------------------------
+
private static final Logger log = Logger.getLogger(ClientSocketWrapper.class);
+ // Static ---------------------------------------------------------------------------------------
+
private static boolean trace = log.isTraceEnabled();
+ // Attributes -----------------------------------------------------------------------------------
+
private InputStream in;
private OutputStream out;
+ // Constructors ---------------------------------------------------------------------------------
+
public ClientSocketWrapper(Socket socket) throws IOException
{
super(socket);
@@ -54,6 +62,40 @@
createStreams(socket, metadata);
}
+ // SocketWrapper overrides ----------------------------------------------------------------------
+
+ public OutputStream getOutputStream()
+ {
+ return out;
+ }
+
+ public InputStream getInputStream()
+ {
+ return in;
+ }
+
+ public void checkConnection() throws IOException
+ {
+ // Test to see if socket is alive by send ACK message
+ final byte ACK = 1;
+
+ out.write(ACK);
+ out.flush();
+ int i = in.read();
+ if (trace) { log.trace(this + " got " + i + " while checking connection"); }
+ }
+
+ // Public ---------------------------------------------------------------------------------------
+
+ public String toString()
+ {
+ return "ClientSocketWrapper[" + getSocket() + "]";
+ }
+
+ // Package protected ----------------------------------------------------------------------------
+
+ // Protected ------------------------------------------------------------------------------------
+
protected void createStreams(Socket socket, Map metadata) throws IOException
{
@@ -79,9 +121,6 @@
protected InputStream createInputStream(String serializationType, Socket socket)
throws IOException
{
-// BufferedInputStream bin = new BufferedInputStream(socket.getInputStream());
-// ObjectInputStream oin = SerializationStreamFactory.getManagerInstance(serializationType).createInput(bin, null);
-// return oin;
if (trace) { log.trace(this + " getting input stream from " + socket); }
return socket.getInputStream();
}
@@ -89,40 +128,12 @@
protected OutputStream createOutputStream(String serializationType, Socket socket)
throws IOException
{
-// BufferedOutputStream bout = new BufferedOutputStream(socket.getOutputStream());
-// ObjectOutputStream oout = SerializationStreamFactory.getManagerInstance(serializationType).createOutput(bout);
-// return oout;
if (trace) { log.trace(this + " getting output stream from " + socket); }
return socket.getOutputStream();
}
- public OutputStream getOutputStream()
- {
- return out;
- }
+ // Private --------------------------------------------------------------------------------------
- public InputStream getInputStream()
- {
- return in;
- }
+ // Inner classes --------------------------------------------------------------------------------
- public void checkConnection() throws IOException
- {
- // Test to see if socket is alive by send ACK message
- final byte ACK = 1;
-
-// out.reset();
-// out.writeByte(ACK);
-// out.flush();
-// in.readByte();
-
- out.write(ACK);
- out.flush();
- in.read();
- }
-
- public String toString()
- {
- return "ClientSocketWrapper[" + getSocket() + "]";
- }
}
1.16.2.11 +13 -23 JBossRemoting/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: MicroSocketClientInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/MicroSocketClientInvoker.java,v
retrieving revision 1.16.2.10
retrieving revision 1.16.2.11
diff -u -b -r1.16.2.10 -r1.16.2.11
--- MicroSocketClientInvoker.java 23 Jan 2007 03:03:38 -0000 1.16.2.10
+++ MicroSocketClientInvoker.java 23 Jan 2007 09:39:03 -0000 1.16.2.11
@@ -32,7 +32,7 @@
*
* @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
* @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
- * @version $Revision: 1.16.2.10 $
+ * @version $Revision: 1.16.2.11 $
*/
public class MicroSocketClientInvoker extends RemoteClientInvoker
{
@@ -297,15 +297,6 @@
return SerializableMarshaller.DATATYPE;
}
- /**
- * @param sessionId
- * @param invocation
- * @param marshaller
- * @return
- * @throws java.io.IOException
- * @throws org.jboss.remoting.ConnectionFailedException
- *
- */
protected Object transport(String sessionId, Object invocation, Map metadata,
Marshaller marshaller, UnMarshaller unmarshaller)
throws IOException, ConnectionFailedException, ClassNotFoundException
@@ -315,9 +306,11 @@
long start = System.currentTimeMillis();
SocketWrapper socketWrapper = null;
- int x = 0;
+ int retryCount = 0;
+ boolean oneway = false;
SocketException sockEx = null;
- for (; x < numberOfCallRetries; x++)
+
+ for (; retryCount < numberOfCallRetries; retryCount++)
{
try
{
@@ -351,7 +344,6 @@
start = System.currentTimeMillis();
// check to see if is one way invocation and return if is
- boolean oneway = false;
if(metadata != null)
{
Object val = metadata.get(org.jboss.remoting.Client.ONEWAY_FLAG);
@@ -400,7 +392,7 @@
* so want to flush the pool and try with
* fresh socket as a last effort.
*/
- if (x == (numberOfCallRetries - 2))
+ if (retryCount == (numberOfCallRetries - 2))
{
flushConnectionPool();
}
@@ -427,7 +419,7 @@
}
// need to check if ran out of retries
- if (x >= numberOfCallRetries)
+ if (retryCount >= numberOfCallRetries)
{
handleException(sockEx, socketWrapper);
}
@@ -442,13 +434,11 @@
{
usedPooled--;
}
+ if (trace) { log.trace(this + " returned " + socketWrapper + " to pool"); }
}
else
{
- if (trace)
- {
- log.trace("Pool was already full, will close the connection");
- }
+ if (trace) { log.trace(this + "'s pool is full, will close the connection"); }
try
{
socketWrapper.close();
@@ -459,7 +449,7 @@
}
}
- if (trace) { log.trace(this + " received " + response); }
+ if (trace && !oneway) { log.trace(this + " received response " + response); }
return response;
}
@@ -504,7 +494,7 @@
case Version.VERSION_1:
case Version.VERSION_2:
{
- if (trace) { log.trace(this + " reading response from input stream"); }
+ if (trace) { log.trace(this + " reading response from unmarshaller"); }
return unmarshaller.read(inputStream, null);
}
default:
@@ -522,9 +512,9 @@
case Version.VERSION_1:
case Version.VERSION_2:
{
- if (trace) { log.trace(this + " writing invocation on output stream"); }
+ if (trace) { log.trace(this + " writing invocation to marshaller"); }
marshaller.write(invocation, outputStream);
- if (trace) { log.trace(this + " done writing invocation on output stream"); }
+ if (trace) { log.trace(this + " done writing invocation to marshaller"); }
return;
}
1.29.2.10 +19 -14 JBossRemoting/src/main/org/jboss/remoting/transport/socket/ServerThread.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: ServerThread.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/ServerThread.java,v
retrieving revision 1.29.2.9
retrieving revision 1.29.2.10
diff -u -b -r1.29.2.9 -r1.29.2.10
--- ServerThread.java 16 Jan 2007 14:17:15 -0000 1.29.2.9
+++ ServerThread.java 23 Jan 2007 09:39:03 -0000 1.29.2.10
@@ -28,6 +28,7 @@
import org.jboss.remoting.InvocationResponse;
import org.jboss.remoting.ServerInvoker;
import org.jboss.remoting.Version;
+import org.jboss.remoting.Client;
import org.jboss.remoting.serialization.ClassLoaderUtility;
import org.jboss.remoting.marshal.MarshalFactory;
import org.jboss.remoting.marshal.Marshaller;
@@ -61,7 +62,7 @@
* @author <a href="mailto:tom at jboss.org">Tom Elrod</a>
* @author <a href="mailto:ovidiu at jboss.org">Ovidiu Feodorov</a>
*
- * @version $Revision: 1.29.2.9 $
+ * @version $Revision: 1.29.2.10 $
*/
public class ServerThread extends Thread
{
@@ -475,7 +476,7 @@
protected void processInvocation(SocketWrapper socketWrapper) throws Exception
{
- if(trace) { log.trace("processing invocation"); }
+ if(trace) { log.trace("preparing to process next invocation invocation"); }
handlingResponse = true;
@@ -519,6 +520,7 @@
InvocationRequest req = null;
boolean createdInvocationRequest = false;
boolean isError = false;
+
if(obj instanceof InvocationRequest)
{
req = (InvocationRequest)obj;
@@ -537,28 +539,32 @@
// Make absolutely sure thread interrupted is cleared.
Thread.interrupted();
- if(trace) { log.trace("about to call ServerInvoker.invoke()"); }
+ if(trace) { log.trace("about to call " + invoker + ".invoke()"); }
// call transport on the subclass, get the result to handback
resp = invoker.invoke(req);
- if(trace) { log.trace("returned from ServerInvoker.invoke()"); }
+ if(trace) { log.trace(invoker + ".invoke() returned " + resp); }
}
catch (Throwable ex)
{
resp = ex;
isError = true;
-
- if(trace) { log.trace("ServerInvoker.invoke() call generated an exception", ex); }
+ if(trace) { log.trace(invoker + ".invoke() call generated an exception", ex); }
}
Thread.interrupted(); // clear interrupted state so we don't fail on socket writes
- if(!isOneway(req.getRequestPayload()))
+ if(isOneway(req.getRequestPayload()))
+ {
+ if(trace) { log.trace("oneway request, writing no reply on the wire"); }
+ }
+ else
{
if(!createdInvocationRequest)
{
// need to return invocation response
+ if(trace) { log.trace("creating response instance"); }
resp = new InvocationResponse(req.getSessionId(), resp, isError, req.getReturnPayload());
}
@@ -570,7 +576,9 @@
versionedWrite(outputStream, invoker, this.getClass().getClassLoader(), resp, version);
}
+
handlingResponse = false;
+
// set the timestamp for last successful processed request
lastRequestHandledTimestamp = System.currentTimeMillis();
}
@@ -629,11 +637,11 @@
getUnMarshaller(invoker.getDataType(), invoker.getSerializationType());
}
- if(trace) { log.trace("blocking to read invocation from the input stream"); }
+ if(trace) { log.trace("blocking to read invocation from unmarshaller"); }
Object o = unmarshaller.read(inputStream, null);
- if(trace) { log.trace("read " + o + " from input stream"); }
+ if(trace) { log.trace("read " + o + " from unmarshaller"); }
return o;
}
@@ -692,13 +700,9 @@
if (metadata != null)
{
- Object val = metadata.get(org.jboss.remoting.Client.ONEWAY_FLAG);
+ Object val = metadata.get(Client.ONEWAY_FLAG);
if (val != null && val instanceof String && Boolean.valueOf((String) val).booleanValue())
{
- if (trace)
- {
- log.trace("Oneway invocation, so not waiting for response. Returning null.");
- }
isOneway = true;
}
}
@@ -740,6 +744,7 @@
}
marshaller.write(resp, outputStream);
+ if (trace) { log.trace("wrote response to the output stream"); }
return;
}
default:
1.38.2.3 +1 -3 JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: SocketClientInvoker.java
===================================================================
RCS file: /cvsroot/jboss/JBossRemoting/src/main/org/jboss/remoting/transport/socket/SocketClientInvoker.java,v
retrieving revision 1.38.2.2
retrieving revision 1.38.2.3
diff -u -b -r1.38.2.2 -r1.38.2.3
--- SocketClientInvoker.java 11 Jan 2007 20:34:50 -0000 1.38.2.2
+++ SocketClientInvoker.java 23 Jan 2007 09:39:03 -0000 1.38.2.3
@@ -40,7 +40,7 @@
*
* @author <a href="mailto:jhaynie at vocalocity.net">Jeff Haynie</a>
* @author <a href="mailto:telrod at e2technologies.net">Tom Elrod</a>
- * @version $Revision: 1.38.2.2 $
+ * @version $Revision: 1.38.2.3 $
*/
public class SocketClientInvoker extends MicroSocketClientInvoker
{
@@ -62,13 +62,11 @@
* Set number of retries in getSocket method
*/
public SocketClientInvoker(InvokerLocator locator)
- throws IOException
{
this(locator, null);
}
public SocketClientInvoker(InvokerLocator locator, Map configuration)
- throws IOException
{
super(locator, configuration);
configureParameters();
More information about the jboss-cvs-commits
mailing list