directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From trus...@apache.org
Subject svn commit: rev 56232 - in incubator/directory/seda/trunk/src: java/org/apache/seda java/org/apache/seda/decoder test/org/apache/seda
Date Mon, 01 Nov 2004 13:49:13 GMT
Author: trustin
Date: Mon Nov  1 05:49:12 2004
New Revision: 56232

Modified:
   incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
   incubator/directory/seda/trunk/src/java/org/apache/seda/decoder/DefaultDecoderManager.java
   incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
   incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
Log:
* Made DefaultFrontend and DefalutFrontendFactory UDP-aware
* Fixed: DefaultDecoderManager.createDecoder() throws NPE.

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontend.java	Mon Nov 
1 05:49:12 2004
@@ -28,8 +28,10 @@
 import org.apache.seda.input.TCPInputManager;
 import org.apache.seda.listener.ListenerManager;
 import org.apache.seda.listener.TCPListenerManager;
+import org.apache.seda.listener.UDPListenerManager;
 import org.apache.seda.output.OutputManager;
 import org.apache.seda.output.TCPOutputManager;
+import org.apache.seda.output.UDPOutputManager;
 import org.apache.seda.protocol.DefaultRequestProcessor;
 import org.apache.seda.protocol.InetServicesDatabase;
 import org.apache.seda.protocol.ProtocolProvider;
@@ -51,25 +53,31 @@
     private final DecoderManager decMan;
     private final EncoderManager encMan;
     private final EventRouter router;
-    private final InputManager inMan;
-    private final ListenerManager srvMan;
-    private final OutputManager outMan;
+    private final TCPListenerManager tcpListenerMan;
+    private final UDPListenerManager udpListenerMan;
+    private final TCPInputManager tcpInMan;
+    private final TCPOutputManager tcpOutMan;
+    private final UDPOutputManager udpOutMan;
     private final RequestProcessor reqProc;
     private final InetServicesDatabase inetDb;
 
     DefaultFrontend(
                     BufferPool bp, DecoderManager decMan, EncoderManager encMan,
-                    EventRouter router, InputManager inMan,
-                    ListenerManager srvMan, OutputManager outMan,
+                    EventRouter router, TCPInputManager tcpInMan,
+                    TCPListenerManager tcpListenerMan,
+					UDPListenerManager udpListenerMan,
+					TCPOutputManager outMan, UDPOutputManager udpOutMan,
                     RequestProcessor reqProc, InetServicesDatabase inetDb)
     {
         this.bp = bp;
         this.decMan = decMan;
         this.encMan = encMan;
         this.router = router;
-        this.inMan = inMan;
-        this.srvMan = srvMan;
-        this.outMan = outMan;
+        this.tcpInMan = tcpInMan;
+        this.tcpListenerMan = tcpListenerMan;
+        this.udpListenerMan = udpListenerMan;
+        this.tcpOutMan = outMan;
+        this.udpOutMan = udpOutMan;
         this.reqProc = reqProc;
         this.inetDb = inetDb;
     }
@@ -82,9 +90,12 @@
 
     public void stop() throws Exception
     {
-        ((TCPListenerManager) srvMan).stop();
-        ((TCPInputManager) inMan).stop();
-        ((TCPOutputManager) outMan).stop();
+        tcpListenerMan.stop();
+        udpListenerMan.stop();
+        tcpInMan.stop();
+        tcpOutMan.stop();
+        udpOutMan.stop();
+
         ((DefaultRequestProcessor) reqProc).stop();
         ((DefaultDecoderManager) decMan).stop();
         ((DefaultEncoderManager) encMan).stop();
@@ -110,19 +121,29 @@
         return router;
     }
 
-    public InputManager getInputManager()
+    public InputManager getTCPInputManager()
+    {
+        return tcpInMan;
+    }
+
+    public ListenerManager getTCPListenerManager()
+    {
+        return tcpListenerMan;
+    }
+    
+    public ListenerManager getUDPListenerManager()
     {
-        return inMan;
+    	return udpListenerMan;
     }
 
-    public ListenerManager getListenerManager()
+    public OutputManager getTCPOutputManager()
     {
-        return srvMan;
+        return tcpOutMan;
     }
 
-    public OutputManager getOutputManager()
+    public OutputManager getUDPOutputManager()
     {
-        return outMan;
+        return udpOutMan;
     }
 
     public RequestProcessor getRequestProcessor()

Modified: incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java
==============================================================================
--- incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java	(original)
+++ incubator/directory/seda/trunk/src/java/org/apache/seda/DefaultFrontendFactory.java	Mon
Nov  1 05:49:12 2004
@@ -32,12 +32,11 @@
 import org.apache.seda.event.DefaultEventRouter;
 import org.apache.seda.event.EventRouter;
 import org.apache.seda.event.EventRouterMonitorAdapter;
-import org.apache.seda.input.InputManager;
 import org.apache.seda.input.TCPInputManager;
-import org.apache.seda.listener.ListenerManager;
 import org.apache.seda.listener.TCPListenerManager;
-import org.apache.seda.output.OutputManager;
+import org.apache.seda.listener.UDPListenerManager;
 import org.apache.seda.output.TCPOutputManager;
+import org.apache.seda.output.UDPOutputManager;
 import org.apache.seda.protocol.DefaultInetServicesDatabase;
 import org.apache.seda.protocol.DefaultRequestProcessor;
 import org.apache.seda.protocol.InetServiceEntry;
@@ -68,17 +67,21 @@
         InetServicesDatabase inetDb = createServicesDatabase();
 
         // create dependent services in order
-        ListenerManager listMan = createListenerManager(router);
-        InputManager inMan = createInputManager(router, bp);
-        OutputManager outMan = createOutputManager(router);
+        TCPListenerManager tcpListenerMan = createTCPListenerManager(router);
+        UDPListenerManager udpListenerMan = createUDPListenerManager(router, bp);
+        TCPInputManager tcpInMan = createTCPInputManager(router, bp);
+        TCPOutputManager tcpOutMan = createTCPOutputManager(router);
+        UDPOutputManager udpOutMan = createUDPOutputManager(router);
+        
         DecoderManager decMan = createDecoderManager(router, inetDb);
         EncoderManager encMan = createEncoderManager(router, inetDb);
         RequestProcessor reqProc = createRequestProcessor(router, inetDb);
 
         DefaultFrontend fe =
             new DefaultFrontend(
-                                bp, decMan, encMan, router, inMan, listMan,
-                                outMan, reqProc, inetDb);
+                                bp, decMan, encMan, router, tcpInMan,
+								tcpListenerMan, udpListenerMan, 
+                                tcpOutMan, udpOutMan, reqProc, inetDb);
         return fe;
     }
 
@@ -160,7 +163,7 @@
         return encMan;
     }
 
-    private ListenerManager createListenerManager(EventRouter router)
+    private TCPListenerManager createTCPListenerManager(EventRouter router)
                                            throws IOException
     {
         TCPListenerManager listMan = new TCPListenerManager(router);
@@ -168,7 +171,15 @@
         return listMan;
     }
 
-    private InputManager createInputManager(EventRouter router, BufferPool bp)
+    private UDPListenerManager createUDPListenerManager(EventRouter router, BufferPool bp)
+    								 throws IOException
+	{
+    	UDPListenerManager listMan = new UDPListenerManager(router, bp);
+    	listMan.start();
+    	return listMan;
+	}
+
+    private TCPInputManager createTCPInputManager(EventRouter router, BufferPool bp)
                                      throws IOException
     {
         TCPInputManager inMan = new TCPInputManager(router, bp);
@@ -176,11 +187,20 @@
         return inMan;
     }
 
-    private OutputManager createOutputManager(EventRouter router)
+    private TCPOutputManager createTCPOutputManager(EventRouter router)
     {
         DefaultStageConfig config =
-            new DefaultStageConfig("outputManager", createThreadPool(3, true));
+            new DefaultStageConfig("tcpOutputManager", createThreadPool(3, true));
         TCPOutputManager outMan = new TCPOutputManager(router, config);
+        outMan.start();
+        return outMan;
+    }
+
+    private UDPOutputManager createUDPOutputManager(EventRouter router)
+    {
+        DefaultStageConfig config =
+            new DefaultStageConfig("udpOutputManager", createThreadPool(3, true));
+        UDPOutputManager outMan = new UDPOutputManager(router, config);
         outMan.start();
         return outMan;
     }

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
Mon Nov  1 05:49:12 2004
@@ -170,7 +170,11 @@
                                    throws KeyExpiryException
     {
         String proto = inetdb.getProtoByPort(key.getLocalAddress().getPort());
-        DecoderFactory factory = (DecoderFactory) factories.get(proto);
+        
+        // FIXME Better synchronization implementation or non asynchronous event firing
+        DecoderFactory factory;
+        while ((factory = (DecoderFactory) factories.get(proto)) == null)
+        	continue;
         return factory.createDecoder();
     }
 

Modified: incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
==============================================================================
--- incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
(original)
+++ incubator/directory/seda/trunk/src/test/org/apache/seda/DefaultFrontendFactoryTest.java
Mon Nov  1 05:49:12 2004
@@ -77,9 +77,9 @@
         assertNotNull(fe.getEncoderManager());
         assertNotNull(fe.getEventRouter());
         assertNotNull(fe.getInetServicesDatabase());
-        assertNotNull(fe.getInputManager());
-        assertNotNull(fe.getListenerManager());
-        assertNotNull(fe.getOutputManager());
+        assertNotNull(fe.getTCPInputManager());
+        assertNotNull(fe.getTCPListenerManager());
+        assertNotNull(fe.getTCPOutputManager());
         assertNotNull(fe.getRequestProcessor());
     }
 
@@ -96,8 +96,8 @@
             new TCPListenerConfig(
                                   InetAddress.getLocalHost(),
                                   new InetServiceEntry("ldap", port));
-        fe.getListenerManager().bind(config);
-        fe.getListenerManager().unbind(config);
+        fe.getTCPListenerManager().bind(config);
+        fe.getTCPListenerManager().unbind(config);
     }
 
     public void testEcho() throws IOException
@@ -110,7 +110,7 @@
 
         ListenerConfig config = null;
         config = new TCPListenerConfig(InetAddress.getLocalHost(), srvEntry);
-        fe.getListenerManager().bind(config);
+        fe.getTCPListenerManager().bind(config);
         fe.register(new EchoProtocolProvider());
 
         EchoTCPClient client = new EchoTCPClient();
@@ -122,6 +122,6 @@
         client.getInputStream().read(recieved);
         client.disconnect();
         assertEquals(new String(toSend), new String(recieved));
-        fe.getListenerManager().unbind(config);
+        fe.getTCPListenerManager().unbind(config);
     }
 }

Modified: incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java
==============================================================================
--- incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java	(original)
+++ incubator/directory/seda/trunk/src/test/org/apache/seda/ProtocolTestCase.java	Mon Nov
 1 05:49:12 2004
@@ -63,7 +63,7 @@
     protected void tearDown() throws Exception
     {
         super.tearDown();
-        fe.getListenerManager().unbind(config);
+        fe.getTCPListenerManager().unbind(config);
         fe.stop();
         fe = null;
     }
@@ -84,7 +84,7 @@
             new InetServiceEntry(proto.getName(), port);
         ((DefaultInetServicesDatabase) fe.getInetServicesDatabase()).addEntry(srvEntry);
         config = new TCPListenerConfig(InetAddress.getLocalHost(), srvEntry);
-        fe.getListenerManager().bind(config);
+        fe.getTCPListenerManager().bind(config);
         fe.register(proto);
 
     }

Mime
View raw message