Changeset 3270
- Timestamp:
- 01/12/09 08:49:34 (6 months ago)
- Location:
- trunk/components/blitz
- Files:
-
- 5 modified
-
src/ome/services/blitz/fire/Ring.java (modified) (4 diffs)
-
src/ome/services/blitz/util/BlitzConfiguration.java (modified) (1 diff)
-
test/ome/services/blitz/test/ClusteredRingTest.java (modified) (2 diffs)
-
test/ome/services/blitz/test/mock/MockFixture.java (modified) (3 diffs)
-
test/omero/test.xml (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/blitz/src/ome/services/blitz/fire/Ring.java
r3269 r3270 11 11 import java.sql.SQLException; 12 12 import java.util.ArrayList; 13 import java.util.HashMap; 13 14 import java.util.HashSet; 14 15 import java.util.List; 16 import java.util.Map; 15 17 import java.util.Set; 16 18 import java.util.UUID; … … 213 215 } 214 216 remove(MANAGERS + uuid); 215 int count = jdbc.update("delete from session_ring where value = ?", uuid); 216 log.info("Removed "+count+" entries for "+uuid); 217 int count = jdbc.update("delete from session_ring where value = ?", 218 uuid); 219 log.info("Removed " + count + " entries for " + uuid); 217 220 log.info("Disconnected from OMERO.cluster"); 218 221 } catch (Exception e) { … … 359 362 } 360 363 } 364 // Now removing any stale sessions 365 StringBuilder sb = new StringBuilder(); 366 sb.append("delete from session_ring "); 367 sb.append("where key like 'session-%' "); 368 sb.append("and ("); 369 sb.append(" value != "); 370 sb.append(" '"); 371 sb.append(uuid); // Self 372 sb.append("' "); 373 for (String nodeUuid : nodeUuids) { 374 sb.append(" and "); 375 sb.append("value != '"); 376 sb.append(nodeUuid); 377 sb.append("' "); 378 } 379 sb.append(")"); 380 int count = jdbc.update(sb.toString()); 381 if (count != 0) { 382 log.info("Removed " + count + " stale sessions"); 383 } 361 384 } 362 385 363 386 protected void purgeNode(String manager) { 364 387 log.info("Purging node: " + manager); 365 int count = jdbc.update("delete from session_ring where key like '"366 + SESSIONS + "' and value = ?",manager);367 log.info("Removed " + count + " sessions with value " + manager);388 int count = jdbc.update("delete from session_ring where value = ?", 389 manager); 390 log.info("Removed " + count + " entries with value " + manager); 368 391 count = jdbc.update("delete from session_ring where key = ?", MANAGERS 369 392 + manager); 370 393 log.info("Removed " + MANAGERS + manager); 371 count = jdbc.update( 372 "delete from session_ring where key = ? and value = ?", CONFIG 373 + "redirect", manager); 374 if (count != 0) { 375 log.info("Removed redirect to " + manager); 376 } 377 putRedirect(uuid); 394 putIfAbsent(CONFIG + "redirect", uuid); 378 395 } 379 396 … … 384 401 if (arg0 instanceof CreateSessionMessage) { 385 402 String session = ((CreateSessionMessage) arg0).getSessionId(); 403 log.info("Adding session " + session + " to manager " + uuid); 386 404 put(SESSIONS + session, uuid); // Use our uuid rather than proxy 387 405 } else if (arg0 instanceof DestroySessionMessage) { 388 406 String session = ((DestroySessionMessage) arg0).getSessionId(); 389 407 remove(SESSIONS + session); 408 log.info("Removing session " + session + " from manager " + uuid); 390 409 } else if (arg0 instanceof ContextClosedEvent) { 391 410 // This happens 3 times for each nested context. Perhaps we -
trunk/components/blitz/src/ome/services/blitz/util/BlitzConfiguration.java
r3266 r3270 120 120 121 121 } catch (RuntimeException e) { 122 destroy(); 122 try { 123 destroy(); 124 } catch (Exception e2) { 125 logger.error("Error destroying configuration after " 126 + "initialization exception. " 127 + "Throwing initialization exception", e2); 128 } 123 129 throw e; 124 130 } -
trunk/components/blitz/test/ome/services/blitz/test/ClusteredRingTest.java
r3269 r3270 12 12 import ome.services.blitz.fire.Ring; 13 13 import ome.services.blitz.test.mock.MockFixture; 14 import ome.services.messages.CreateSessionMessage; 14 15 import ome.system.OmeroContext; 15 16 … … 123 124 124 125 @Test 126 public void testAddedSessionGetsUuidOfManager() throws Exception { 127 fixture1.ctx.publishEvent(new CreateSessionMessage(this, "test-for-uuid")); 128 assertTrue(fixture1.blitz.getRing().checkPassword("test-for-uuid")); 129 String value = fixture1.jdbc.queryForObject("select value from session_ring where key = ?", String.class, "session-test-for-uuid"); 130 assertEquals(fixture1.blitz.getRing().uuid, value); 131 } 132 133 @Test 125 134 public void testHandlesMissingServers() throws Exception { 126 135 fail(); -
trunk/components/blitz/test/ome/services/blitz/test/mock/MockFixture.java
r3266 r3270 39 39 40 40 public final BlitzConfiguration blitz; 41 public final OmeroContext ctx;41 public final SimpleJdbcTemplate jdbc; 42 42 public final SessionManagerI sm; 43 public final Executor ex;44 43 public final SessionManager mgr; 45 44 public final SecuritySystem ss; 46 public final SimpleJdbcTemplate jdbc; 45 public final OmeroContext ctx; 46 public final Executor ex; 47 public final Ring ring; 47 48 48 49 public static OmeroContext basicContext() { … … 71 72 this.test = test; 72 73 this.ctx = ctx; 74 this.ring = (Ring) ctx.getBean("ring"); 73 75 this.ex = (Executor) ctx.getBean("executor"); 74 76 this.ss = (SecuritySystem) ctx.getBean("securitySystem"); … … 101 103 id.properties.setProperty("ClusterProxy","Cluster:udp -h 224.0.0.5 -p 10000"); 102 104 103 104 Ring ring = new Ring(jdbc);105 ring.setApplicationEventPublisher(ctx);106 107 105 blitz = new BlitzConfiguration(id, ring, mgr, ss, ex); 108 106 this.sm = (SessionManagerI) blitz.getBlitzManager(); -
trunk/components/blitz/test/omero/test.xml
r3239 r3270 110 110 </bean> 111 111 112 <!-- Defined here since it is an application listener. --> 113 <bean id="ring" class="ome.services.blitz.fire.Ring"> 114 <constructor-arg ref="simpleJdbcTemplate"/> 115 </bean> 112 116 </beans>
