Show
Ignore:
Timestamp:
01/12/09 08:49:32 (19 months ago)
Author:
jmoore
Message:

OmeroClustering : Moving away from jgroups to straight multicast/jdbc approach

The ReplicatedHashMap implementation used from the org.jgroups.blocks
package had issues with our usage of the map. Since we are already
guaranteed a share storage (the db) for all blitz instances within
a single cluster, we are now using Ice's multicast support (from 3.3)
as well as simpleJdbcTemplate to manage the same information that was
previously in jgroups.
(cherry-pick from commit e50eed4204c2a1d360c2b261b5e6a7618573ba65)

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/components/blitz/test/ome/services/blitz/test/utests/RingTest.java

    r3264 r3266  
    77package ome.services.blitz.test.utests; 
    88 
     9import javax.sql.DataSource; 
     10 
    911import ome.services.blitz.fire.Ring; 
     12import ome.system.OmeroContext; 
    1013 
    11 import org.jgroups.blocks.ReplicatedTree; 
    1214import org.jmock.Mock; 
    1315import org.jmock.MockObjectTestCase; 
    14 import org.testng.annotations.AfterClass; 
    15 import org.testng.annotations.BeforeClass; 
     16import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; 
    1617import org.testng.annotations.BeforeTest; 
    1718import org.testng.annotations.Test; 
     
    2324public class RingTest extends MockObjectTestCase { 
    2425 
    25     ReplicatedTree tree1, tree2; 
     26    OmeroContext ctx; 
     27    SimpleJdbcTemplate jdbc; 
     28    Ice.ObjectAdapter oa; 
    2629    Ice.Communicator ic; 
    27     Mock mockIc;  
    28      
    29     @BeforeClass 
    30     public void setup() throws Exception { 
    31         tree1 = new ReplicatedTree("test", "session_ring.xml", 1000); 
    32         tree2= new ReplicatedTree("test", "session_ring.xml", 1000); 
    33         tree1.start(); 
    34         tree2.start(); 
    35     } 
    36      
     30    Mock mockIc, mockOa; 
     31 
    3732    @BeforeTest 
    3833    public void setupMethod() throws Exception { 
    3934        mockIc = mock(Ice.Communicator.class); 
    4035        ic = (Ice.Communicator) mockIc.proxy(); 
     36        mockOa = mock(Ice.ObjectAdapter.class); 
     37        oa = (Ice.ObjectAdapter) mockOa.proxy(); 
     38        ctx = new OmeroContext(new String[] { 
     39                "classpath:ome/config.xml", 
     40                "classpath:ome/services/datalayer.xml" }); 
     41        DataSource dataSource = (DataSource) ctx.getBean("dataSource"); 
     42        jdbc = new SimpleJdbcTemplate(dataSource); 
     43 
    4144    } 
    42      
    43     @AfterClass 
    44     public void tearDown() { 
    45         tree1.stop(); 
    46         tree2.stop(); 
    47     } 
    48      
    49     //@Test 
    50     public void testMain() throws Exception { 
    51         Ring.main(new String[]{}); 
    52     } 
    53      
     45 
    5446    @Test 
    5547    public void testFirstTakesOver() throws Exception { 
    56         Ring one = new Ring("takeover", "session_ring.xml"); 
    57         one.init(ic, "one"); 
     48        Ring one = new Ring(jdbc); 
     49        one.setApplicationEventPublisher(ctx); 
     50        one.init(oa, "one"); 
    5851        assertEquals("one", one.getRedirect()); 
    59         Ring two = new Ring("takeover", "session_ring.xml"); 
    60         two.init(ic, "two"); 
     52        Ring two = new Ring(jdbc); 
     53        two.setApplicationEventPublisher(ctx); 
     54        two.init(oa, "two"); 
    6155        assertEquals("one", two.getRedirect()); 
    6256    } 
     
    6660        fail(); 
    6761    } 
    68      
     62 
    6963    @Test 
    7064    public void testHandlesMissingServers() throws Exception { 
    7165        fail(); 
    7266    } 
    73      
     67 
    7468    @Test 
    7569    public void testRemovesUnreachable() throws Exception { 
    7670        fail(); 
    7771    } 
    78      
     72 
    7973    @Test 
    8074    public void testReaddsSelfIfTemporarilyUnreachable() throws Exception { 
    8175        fail(); 
    8276    } 
    83      
     77 
    8478    @Test 
    85     public void testLotsOfCalls() throws Exception { 
    86         int i = 0; 
    87         int j = 0; 
    88         long start = System.currentTimeMillis(); 
    89         for (int k = 0; k < 100; k++) { 
    90             i++; j++; 
    91             tree1.put("/1", i+"", i+""); 
    92             tree2.put("/2", j+"", j+""); 
    93         } 
    94  
    95  
    96         assertEquals(100, tree2.getKeys("/1").size()); 
    97         assertEquals(100, tree1.getKeys("/2").size()); 
    98      
    99     } 
    100      
    101     @Test 
    102     public void testPrintSessions() throws Exception { 
    103         Ring ring = new Ring("test", "session_ring.xml"); 
    104         ring.printTree("/SESSIONS"); 
    105         ring.destroy(); 
     79    public void testAllSessionRemovedIfDiscoveryFails() throws Exception { 
     80        fail(); 
    10681    } 
    10782 
     83    @Test 
     84    public void testAllSessionsReassertedIfSessionComesBackOnline() 
     85            throws Exception { 
     86        fail(); 
     87    } 
    10888} 

1.2.1-PRO © 2008-2009 agile42 all rights reserved (this page was served in: 0.76429 sec.)