directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: rev 56612 - in incubator/directory/seda/trunk/src/java/org/apache/seda: decoder encoder listener
Date Thu, 04 Nov 2004 17:12:50 GMT
Author: trustin
Date: Thu Nov  4 09:12:49 2004
New Revision: 56612

Modified:
   incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java
Log:
Fixed: EncoderManager and DecoderManager didn't clean up encoder/decoder which is created
by UDPClientKeys.
Solution: ClientKey.stateful property was added, and EM and DM creates and forget new encoder
and decoder for stateless client keys.

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
Thu Nov  4 09:12:49 2004
@@ -215,15 +215,21 @@
      */
     StatefulDecoder getDecoder(ClientKey key)
     {
-        StatefulDecoder decoder = (StatefulDecoder) decoders.get(key);
-        if (decoder == null) {
-        	synchronized (decoders) {
-                decoder = (StatefulDecoder) decoders.get(key);
-        		if (decoder == null) {
-        			decoder = createClientDecoder(key);
-        			decoders.put(key, decoder);
-        		}
-        	}
+        StatefulDecoder decoder;
+        
+        if (key.isStateful()) {
+	        decoder = (StatefulDecoder) decoders.get(key);
+	        if (decoder == null) {
+	        	synchronized (decoders) {
+	                decoder = (StatefulDecoder) decoders.get(key);
+	        		if (decoder == null) {
+	        			decoder = createClientDecoder(key);
+	        			decoders.put(key, decoder);
+	        		}
+	        	}
+	        }
+        } else {
+            decoder = (StatefulDecoder) decoders.get(key);
         }
 
         return decoder;

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/encoder/DefaultEncoderManager.java
Thu Nov  4 09:12:49 2004
@@ -169,15 +169,20 @@
 
     StatefulEncoder getEncoder(ClientKey key)
     {
-    	StatefulEncoder encoder = (StatefulEncoder) encoders.get(key);
-    	if (encoder == null) {
-    		synchronized (encoders) {
-    			encoder = (StatefulEncoder) encoders.get(key);
-    			if (encoder == null) {
-    				encoder = createClientEncoder(key);
-    				encoders.put(key, encoder);
-    			}
-    		}
+    	StatefulEncoder encoder;
+    	if (key.isStateful()) {
+	    	encoder = (StatefulEncoder) encoders.get(key);
+	    	if (encoder == null) {
+	    		synchronized (encoders) {
+	    			encoder = (StatefulEncoder) encoders.get(key);
+	    			if (encoder == null) {
+	    				encoder = createClientEncoder(key);
+	    				encoders.put(key, encoder);
+	    			}
+	    		}
+	    	}
+    	} else {
+			encoder = (StatefulEncoder) encoders.get(key);
     	}
     	
         return encoder;

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/ClientKey.java	Thu Nov
 4 09:12:49 2004
@@ -20,6 +20,7 @@
 import java.io.IOException;
 
 import java.net.InetSocketAddress;
+
 import java.util.Observable;
 
 
@@ -50,9 +51,10 @@
 
     /** Unique key or client id */
     private final String clientId;
+    private final boolean stateful;
     private final InetSocketAddress localAddress;
     private final InetSocketAddress remoteAddress;
-	
+
     // ----------------------------------------------
     // Constructors
     // ----------------------------------------------
@@ -70,11 +72,13 @@
      *
      * @param clientId the id of this client key
      */
-    ClientKey(String clientId, InetSocketAddress localAddress, InetSocketAddress remoteAddress)
+    ClientKey(String clientId, InetSocketAddress localAddress,
+              InetSocketAddress remoteAddress, boolean stateful)
     {
         this.clientId = clientId;
         this.localAddress = localAddress;
         this.remoteAddress = remoteAddress;
+        this.stateful = stateful;
     }
 
     // ----------------------------------------------
@@ -101,8 +105,9 @@
      *
      * @return the local socket address
      */
-    public final InetSocketAddress getLocalAddress() {
-    	return localAddress;
+    public final InetSocketAddress getLocalAddress()
+    {
+        return localAddress;
     }
 
     /**
@@ -110,8 +115,17 @@
      *
      * @return the client's socket address.
      */
-    public final InetSocketAddress getRemoteAddress() {
-    	return remoteAddress;
+    public final InetSocketAddress getRemoteAddress()
+    {
+        return remoteAddress;
+    }
+
+    /**
+     * Returns <code>true</code> if this client channel is stateful.
+     */
+    public boolean isStateful()
+    {
+        return stateful;
     }
 
     // ----------------------------------------------

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/TCPClientKey.java	Thu
Nov  4 09:12:49 2004
@@ -78,7 +78,7 @@
               new InetSocketAddress(a_socket.getLocalAddress(),
                                     a_socket.getLocalPort()),
               new InetSocketAddress(a_socket.getInetAddress(),
-                                    a_socket.getPort()));
+                                    a_socket.getPort()), true);
         socket = a_socket;
     }
 

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/listener/UDPClientKey.java	Thu
Nov  4 09:12:49 2004
@@ -77,7 +77,8 @@
     {
         super(getClientId(a_socket, clientAddress),
               new InetSocketAddress(a_socket.getLocalAddress(),
-                                    a_socket.getLocalPort()), clientAddress);
+                                    a_socket.getLocalPort()), clientAddress,
+              false);
 
         socket = a_socket;
     }

Mime
View raw message