geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gdam...@apache.org
Subject cvs commit: incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/remotenode RemoteNodeManagerImplTest.java
Date Mon, 05 Jul 2004 07:03:50 GMT
gdamour     2004/07/05 00:03:50

  Modified:    sandbox/messaging/src/test/org/apache/geronimo/messaging
                        NodeImplTest.java
               sandbox/messaging/src/java/org/apache/geronimo/messaging
                        NodeTopology.java NodeImpl.java
               sandbox/messaging/src/test/org/apache/geronimo/messaging/admin/deployment
                        AdminServerTest.java
               sandbox/messaging/src/java/org/apache/geronimo/messaging/remotenode
                        LogicalCompression.java
               sandbox/messaging/src/java/org/apache/geronimo/messaging/cluster/topology
                        RingTopologyManager.java
               sandbox/messaging/src/test/org/apache/geronimo/messaging/remotenode
                        RemoteNodeManagerImplTest.java
  Log:
  o NodeTopology defines now a version; and
  o Re-enables LogicalCompression, which yields a performance improvement of 15%.
  
  Revision  Changes    Path
  1.4       +6 -5      incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/NodeImplTest.java
  
  Index: NodeImplTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/NodeImplTest.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NodeImplTest.java	10 Jun 2004 23:12:24 -0000	1.3
  +++ NodeImplTest.java	5 Jul 2004 07:03:50 -0000	1.4
  @@ -109,7 +109,7 @@
           
           // Sets the topology.
           NodeTopology topology =
  -                new MockTopology(nodeInfo1, nodeInfo2, nodeInfo3, nodeInfo4);
  +            new MockTopology(nodeInfo1, nodeInfo2, nodeInfo3, nodeInfo4);
           node1.setTopology(topology);
       }
   
  @@ -145,9 +145,7 @@
       public static void main(String[] args) throws Exception {
           NodeImplTest test = new NodeImplTest();
           test.setUp();
  -        while ( true ) {
  -            test.testInputStreamPerformance();
  -        }
  +        test.testSendRawPerformance();
       }
       
       public void testSendRawPerformance() throws Exception {
  @@ -313,6 +311,9 @@
           }
           public Set getNodes() {
               throw new IllegalArgumentException("Not expected");
  +        }
  +        public int getVersion() {
  +            return 0;
           }
       }
       
  
  
  
  1.4       +8 -1      incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/NodeTopology.java
  
  Index: NodeTopology.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/NodeTopology.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- NodeTopology.java	10 Jun 2004 23:12:24 -0000	1.3
  +++ NodeTopology.java	5 Jul 2004 07:03:50 -0000	1.4
  @@ -31,6 +31,13 @@
   {
   
       /**
  +     * Gets the version of this topology.
  +     * 
  +     * @return version number.
  +     */
  +    public int getVersion();
  +    
  +    /**
        * Gets the neighbours of the specified node. They are the nodes directly
        * reachable from aRoot. 
        * 
  
  
  
  1.6       +22 -8     incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/NodeImpl.java
  
  Index: NodeImpl.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/NodeImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- NodeImpl.java	10 Jun 2004 23:12:24 -0000	1.5
  +++ NodeImpl.java	5 Jul 2004 07:03:50 -0000	1.6
  @@ -119,6 +119,11 @@
       private NodeTopology nodeTopology;
       
       /**
  +     * To serialize the topology changes.
  +     */
  +    private final Object topologyMonitor;
  +    
  +    /**
        * Creates a Node.
        * 
        * @param aNodeInfo Node meta-data.
  @@ -142,6 +147,7 @@
           clockPool = aClockPool;
           
           replacerResolver = new MsgReplacerResolver();
  +        topologyMonitor = new Object();
   
           streamManager = newStreamManager();
           referenceableManager = newReferenceableManager();
  @@ -177,10 +183,16 @@
       }
       
       public void setTopology(NodeTopology aTopology) {
  -        cascadeTopology(aTopology, Collections.EMPTY_SET);
  +        synchronized(topologyMonitor) {
  +            cascadeTopology(aTopology, Collections.EMPTY_SET);
  +        }
       }
  -
  +    
       private void cascadeTopology(NodeTopology aTopology, Set aSetOfProcessed) {
  +        // Registers a future topology here. This way neighbours can start to
  +        // send Msgs compressed with the new topology.
  +        compression.registerFutureTopology(aTopology);
  +        
           // Applies the new topology.
           nodeManager.setTopology(aTopology);
   
  @@ -211,15 +223,11 @@
           try {
               // Cascades the new topology to all of them.
               topologyEndPoint.cascadeTopology(aTopology, processed);
  -        } catch (Throwable e) {
  -            e.printStackTrace();
           } finally {
               endPointProxyFactory.releaseProxy(topologyEndPoint);
           }
           
  -        // TODO re-introduces logical compression when dynamic reconfiguration
  -        // of topology will support 2PC.
  -//        compression.setTopology(aTopology);
  +        compression.registerTopology(aTopology);
           nodeTopology = aTopology;
       }
       
  @@ -270,6 +278,12 @@
                   Set result = new HashSet();
                   result.add(nodeInfo);
                   return result;
  +            }
  +            public int getVersion() {
  +                return 0;
  +            }
  +            public void setVersion(int aVersion) {
  +                throw new UnsupportedOperationException();
               }
           };
           setTopology(topology);
  
  
  
  1.3       +4 -1      incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/admin/deployment/AdminServerTest.java
  
  Index: AdminServerTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/admin/deployment/AdminServerTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AdminServerTest.java	10 Jun 2004 23:12:24 -0000	1.2
  +++ AdminServerTest.java	5 Jul 2004 07:03:50 -0000	1.3
  @@ -91,6 +91,9 @@
                   nodes.add(nodeInfo2);
                   return nodes;
               }
  +            public int getVersion() {
  +                return 0;
  +            }
           });
           
           Map factories = node.getMockFactoryEndPointProxy();
  
  
  
  1.3       +39 -10    incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/remotenode/LogicalCompression.java
  
  Index: LogicalCompression.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/remotenode/LogicalCompression.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LogicalCompression.java	24 Jun 2004 23:52:12 -0000	1.2
  +++ LogicalCompression.java	5 Jul 2004 07:03:50 -0000	1.3
  @@ -46,9 +46,14 @@
   {
   
       /**
  -     * Topology shared knowledge.   
  +     * Future topology.
        */
  -    private NodeTopology topology;
  +    private NodeTopology futTopology;
  +    
  +    /**
  +     * Current registered topology.
  +     */
  +    private NodeTopology curTopology;
       
       /**
        * No logical compression.
  @@ -70,12 +75,25 @@
        */
       private final static byte RESPONSE = (byte) 1;
   
  -    public NodeTopology getTopology() {
  -        return topology;
  +    /**
  +     * Registers a future topology. It is only used to uncompress Msgs which
  +     * have not been compressed by the current topology. 
  +     * 
  +     * @param aTopology Future topology.
  +     */
  +    public void registerFutureTopology(NodeTopology aTopology) {
  +        futTopology = aTopology;
       }
  -
  -    public void setTopology(NodeTopology aTopology) {
  -        topology = aTopology;
  +    
  +    /**
  +     * Registers the current topology. It is used to compress and uncompress
  +     * Msgs. If it is not possible to uncompress a Msg with the current
  +     * topology, then the future topology is used.
  +     * 
  +     * @param aTopology Current topology.
  +     */
  +    public void registerTopology(NodeTopology aTopology) {
  +        curTopology = aTopology;
       }
       
       public Object beforePop(StreamInputStream anIn)
  @@ -93,8 +111,17 @@
           if ( type == NULL ) {
               return result;
           }
  +        int version = anIn.readInt();
  +        NodeTopology topology = null;
  +        if ( null != curTopology && version == curTopology.getVersion() ) {
  +            topology = curTopology;
  +        } else if ( null != futTopology &&
  +            version == futTopology.getVersion() ) {
  +            topology = futTopology;
  +        }
           if ( null == topology ) {
  -            throw new IllegalArgumentException("No topology is defined.");
  +            throw new IllegalArgumentException("No topology with version {" +
  +                version + "} is defined.");
           }
           int id = anIn.readInt();
           NodeInfo nodeInfo = topology.getNodeById(id);
  @@ -107,7 +134,7 @@
           id = anIn.readInt();
           nodeInfo = topology.getNodeById(id);
           result.add(nodeInfo);
  -        return result.toArray();
  +        return result;
       }
       
       public void afterPop(StreamInputStream anIn, Msg aMsg, Object anOpaque)
  @@ -137,11 +164,13 @@
           RequestSender.RequestID reqID  = (RequestSender.RequestID)
               header.resetHeader(MsgHeaderConstants.CORRELATION_ID);
           anOut.writeByte(reqID.getID());
  +        NodeTopology topology = curTopology;
           if ( null == topology ) {
               anOut.writeByte(NULL);
               return null;
           }
           anOut.writeByte(TOPOLOGY);
  +        anOut.writeInt(topology.getVersion());
           
           NodeInfo info =
               (NodeInfo) header.resetHeader(MsgHeaderConstants.SRC_NODE);
  
  
  
  1.2       +11 -2     incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/cluster/topology/RingTopologyManager.java
  
  Index: RingTopologyManager.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/java/org/apache/geronimo/messaging/cluster/topology/RingTopologyManager.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- RingTopologyManager.java	10 Jun 2004 23:12:25 -0000	1.1
  +++ RingTopologyManager.java	5 Jul 2004 07:03:50 -0000	1.2
  @@ -72,10 +72,14 @@
   
       private static class RingTopology implements NodeTopology {
   
  +        private static int versionSeq = 0;
  +        
           private final List nodes;
           private final Set nodeSet;
           private final NodeInfo[] nodeArray;
           private final NodeInfo[] nodeArrayInv;
  +        private final int version;
  +        
           
           private RingTopology(List aNodes) {
               nodes = aNodes;
  @@ -86,6 +90,7 @@
               for (int i = 0; i < length; i++) {
                   nodeArrayInv[i] = nodeArray[length - i - 1];
               }
  +            version = versionSeq++;
           }
           
           public Set getNeighbours(NodeInfo aRoot) {
  @@ -146,7 +151,11 @@
           public Set getNodes() {
               return nodeSet;
           }
  -        
  +
  +        public int getVersion() {
  +            return version;
  +        }
  +
       }
       
   }
  
  
  
  1.3       +4 -25     incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/remotenode/RemoteNodeManagerImplTest.java
  
  Index: RemoteNodeManagerImplTest.java
  ===================================================================
  RCS file: /home/cvs/incubator-geronimo/sandbox/messaging/src/test/org/apache/geronimo/messaging/remotenode/RemoteNodeManagerImplTest.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RemoteNodeManagerImplTest.java	10 Jun 2004 23:12:25 -0000	1.2
  +++ RemoteNodeManagerImplTest.java	5 Jul 2004 07:03:50 -0000	1.3
  @@ -127,6 +127,9 @@
               public Set getNodes() {
                   return null;
               }
  +            public int getVersion() {
  +                return 0;
  +            }
           };
           manager.setTopology(topology);
   
  @@ -170,30 +173,6 @@
           public void fireRemoteNodeEvent(RemoteNodeEvent anEvent) {
               event = anEvent;
           }
  -    }
  -
  -    private class MockTopology implements NodeTopology {
  -
  -        public Set getNeighbours(NodeInfo aRoot) {
  -            return null;
  -        }
  -
  -        public NodeInfo[] getPath(NodeInfo aSource, NodeInfo aTarget) {
  -            return null;
  -        }
  -
  -        public int getIDOfNode(NodeInfo aNodeInfo) {
  -            return 0;
  -        }
  -
  -        public NodeInfo getNodeById(int anId) {
  -            return null;
  -        }
  -
  -        public Set getNodes() {
  -            return null;
  -        }
  -
       }
       
   }
  
  
  

Mime
View raw message