- 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:
-
Legend:
- Unmodified
- Added
- Removed
-
|
r3264
|
r3266
|
|
| 7 | 7 | package ome.services.blitz.test.utests; |
| 8 | 8 | |
| | 9 | import javax.sql.DataSource; |
| | 10 | |
| 9 | 11 | import ome.services.blitz.fire.Ring; |
| | 12 | import ome.system.OmeroContext; |
| 10 | 13 | |
| 11 | | import org.jgroups.blocks.ReplicatedTree; |
| 12 | 14 | import org.jmock.Mock; |
| 13 | 15 | import org.jmock.MockObjectTestCase; |
| 14 | | import org.testng.annotations.AfterClass; |
| 15 | | import org.testng.annotations.BeforeClass; |
| | 16 | import org.springframework.jdbc.core.simple.SimpleJdbcTemplate; |
| 16 | 17 | import org.testng.annotations.BeforeTest; |
| 17 | 18 | import org.testng.annotations.Test; |
| … |
… |
|
| 23 | 24 | public class RingTest extends MockObjectTestCase { |
| 24 | 25 | |
| 25 | | ReplicatedTree tree1, tree2; |
| | 26 | OmeroContext ctx; |
| | 27 | SimpleJdbcTemplate jdbc; |
| | 28 | Ice.ObjectAdapter oa; |
| 26 | 29 | 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 | |
| 37 | 32 | @BeforeTest |
| 38 | 33 | public void setupMethod() throws Exception { |
| 39 | 34 | mockIc = mock(Ice.Communicator.class); |
| 40 | 35 | 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 | |
| 41 | 44 | } |
| 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 | |
| 54 | 46 | @Test |
| 55 | 47 | 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"); |
| 58 | 51 | 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"); |
| 61 | 55 | assertEquals("one", two.getRedirect()); |
| 62 | 56 | } |
| … |
… |
|
| 66 | 60 | fail(); |
| 67 | 61 | } |
| 68 | | |
| | 62 | |
| 69 | 63 | @Test |
| 70 | 64 | public void testHandlesMissingServers() throws Exception { |
| 71 | 65 | fail(); |
| 72 | 66 | } |
| 73 | | |
| | 67 | |
| 74 | 68 | @Test |
| 75 | 69 | public void testRemovesUnreachable() throws Exception { |
| 76 | 70 | fail(); |
| 77 | 71 | } |
| 78 | | |
| | 72 | |
| 79 | 73 | @Test |
| 80 | 74 | public void testReaddsSelfIfTemporarilyUnreachable() throws Exception { |
| 81 | 75 | fail(); |
| 82 | 76 | } |
| 83 | | |
| | 77 | |
| 84 | 78 | @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(); |
| 106 | 81 | } |
| 107 | 82 | |
| | 83 | @Test |
| | 84 | public void testAllSessionsReassertedIfSessionComesBackOnline() |
| | 85 | throws Exception { |
| | 86 | fail(); |
| | 87 | } |
| 108 | 88 | } |
Download in other formats:
1.2.1-PRO © 2008-2009
agile42 all
rights reserved
(this page was served in: 0.76429 sec.)