Changeset 2597
- Timestamp:
- 07/05/08 22:16:06 (3 months ago)
- Location:
- trunk/components
- Files:
-
- 10 modified
-
blitz/resources/beanRefContext.xml (modified) (2 diffs)
-
blitz/resources/omero/test.xml (modified) (2 diffs)
-
blitz/src/ome/services/blitz/fire/SessionManagerI.java (modified) (3 diffs)
-
blitz/src/ome/services/blitz/impl/ServiceFactoryI.java (modified) (5 diffs)
-
blitz/test/ome/icy/model/utests/ServiceFactoryServiceCreationDestructionTest.java (modified) (1 diff)
-
server/resources/beanRefContext.xml (modified) (2 diffs)
-
server/src/ome/services/sessions/SessionManager.java (modified) (1 diff)
-
tools/OmeroPy/src/omero/__init__.py (modified) (1 diff)
-
tools/OmeroPy/test/integration/isession.py (modified) (3 diffs)
-
tools/OmeroPy/test/integration/library.py (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/components/blitz/resources/beanRefContext.xml
r2142 r2597 24 24 <constructor-arg index="0"> 25 25 <list> 26 <value>classpath:ome/services/messaging.xml</value> 26 27 <value>classpath:omero/server.xml</value> 27 28 <value>classpath:omero/constants.xml</value> … … 55 56 <constructor-arg index="0"> 56 57 <list> 58 <value>classpath:ome/services/messaging.xml</value> 57 59 <value>classpath:omero/server.xml</value> 58 60 <value>classpath:omero/constants.xml</value> -
trunk/components/blitz/resources/omero/test.xml
r2142 r2597 37 37 <bean id="methodSecurity" factory-bean="methodMock" factory-method="proxy"/> 38 38 <bean id="sessionManager" factory-bean="sessionsMock" factory-method="proxy"/> 39 39 <bean id="executor" factory-bean="executorMock" factory-method="proxy"/> 40 40 <!-- Here it is necessary to specify the HardWiredInterceptors instances 41 41 even if they are *not* specified in Spring --> … … 77 77 </bean> 78 78 79 80 <bean id="executorMock" class="ome.icy.fixtures.ExecutorMockFactory"/> 81 79 82 </beans> -
trunk/components/blitz/src/ome/services/blitz/fire/SessionManagerI.java
r2596 r2597 128 128 log.debug(String.format("Created session %s for user %s", 129 129 id.name, userId)); 130 } else { 131 sessionToClientIds.get(s.getUuid()).add(session.clientId); 132 if (log.isDebugEnabled()) { 133 log.debug(String.format("Rejoined session %s for user %s", 134 id.name, userId)); 135 } 136 137 } 130 } 131 sessionToClientIds.get(s.getUuid()).add(session.clientId); 132 if (log.isDebugEnabled()) { 133 log.debug(String.format("Rejoined session %s for user %s", 134 id.name, userId)); 135 } 136 138 137 return Glacier2.SessionPrxHelper.uncheckedCast(_prx); 139 138 140 139 } catch (Exception t) { 140 141 if (t instanceof ApiUsageException) { 142 ApiUsageException aue = (ApiUsageException) t; 143 throw new CannotCreateSessionException(aue.message); 144 } 145 141 146 ConvertToBlitzExceptionMessage convert = new ConvertToBlitzExceptionMessage( 142 147 this, t); … … 150 155 if (convert.to instanceof CannotCreateSessionException) { 151 156 throw (CannotCreateSessionException) convert.to; 152 } else if (convert.to instanceof ApiUsageException) {153 ApiUsageException aue = (ApiUsageException) convert.to;154 throw new CannotCreateSessionException(aue.message);155 157 } 156 158 … … 207 209 * {@link Ice.ObjectAdapter} 208 210 */ 209 p rivatevoid reapSessions(Ice.Current cantUseThisCurrent) {211 public void reapSessions(Ice.Current cantUseThisCurrent) { 210 212 Ice.ObjectAdapter adapter = cantUseThisCurrent.adapter; 211 213 synchronized (sessionsForReaping) { 212 List<String> ids = new ArrayList<String>(sessionsForReaping); 213 for (String id : ids) { 214 for (String clientId : sessionToClientIds.get(id)) { 214 List<String> sessionIds = new ArrayList<String>(sessionsForReaping); 215 for (String sessionId : sessionIds) { 216 Set<String> clientIds = sessionToClientIds.keySet(); 217 for (String clientId : clientIds) { 215 218 try { 216 219 Ice.Identity iid = ServiceFactoryI.sessionId(clientId, 217 id);220 sessionId); 218 221 Ice.Object obj = adapter.find(iid); 219 222 if (obj == null) { 220 log.debug(id + " already removed."); 223 log.debug(Ice.Util.identityToString(iid) 224 + " already removed."); 221 225 } else { 222 226 ServiceFactoryI sf = (ServiceFactoryI) obj; 223 227 sf.doDestroy(adapter); 224 228 } 225 sessionsForReaping.remove(id);226 229 } catch (Exception e) { 227 log.error("Error reaping session " + id230 log.error("Error reaping session " + sessionId 228 231 + " from client " + clientId, e); 229 232 } 230 233 } 234 sessionToClientIds.remove(sessionId); 235 sessionsForReaping.remove(sessionId); 231 236 } 232 237 } -
trunk/components/blitz/src/ome/services/blitz/impl/ServiceFactoryI.java
r2596 r2597 21 21 import ome.api.JobHandle; 22 22 import ome.api.ServiceInterface; 23 import ome.conditions.InternalException;24 23 import ome.logic.HardWiredInterceptor; 25 24 import ome.services.blitz.fire.AopContextInitializer; … … 516 515 517 516 } 517 518 // All resources cleaned up or not based on the reference count. 519 // Now we can remove the current session. If an exception if thrown, 520 // there's not much we can do. 521 try { 522 current.adapter.remove(sessionId(principal.getName())); 523 } catch (Throwable t) { 524 // FIXME 525 log.error("Possible memory leak: can't remove service factory", t); 526 } 527 518 528 } 519 529 520 530 /** 521 * Performs the actual cleanup operation. Since {@link #destroy()} is called 522 * non-discriminantly by the router, even when a client has just died, we 523 * have this internal method for handling the actual closing of resources. 531 * Performs the actual cleanup operation on all the resources shared between 532 * this and other {@link ServiceFactoryI} instances in the same 533 * {@link Session}. Since {@link #destroy()} is called regardless by the 534 * router, even when a client has just died, we have this internal method 535 * for handling the actual closing of resources. 524 536 */ 525 537 public void doDestroy(Ice.ObjectAdapter adapter) { … … 534 546 Set<String> ipIds = interactiveSlots.keySet(); 535 547 for (String id : ipIds) { 536 InteractiveProcessorI ip = (InteractiveProcessorI) interactiveSlots 537 .get(id); 538 ip.stop(); 539 adapter.remove(Ice.Util.stringToIdentity(id)); 540 interactiveSlots.remove(id); 548 InteractiveProcessorI ip = null; 549 try { 550 ip = (InteractiveProcessorI) interactiveSlots.get(id); 551 ip.stop(); 552 } catch (Exception e) { 553 log.error("Error stopping interactive processor: " + ip); 554 } finally { 555 adapter.remove(Ice.Util.stringToIdentity(id)); 556 interactiveSlots.remove(id); 557 } 541 558 } 542 559 … … 568 585 } 569 586 570 // All resources cleaned up to the best of our ability,571 // now we can remove the current session. If an exception if thrown,572 // there's not much we can do.573 try {574 adapter.remove(sessionId(principal.getName()));575 } catch (Throwable t) {576 // FIXME577 InternalException ie = new InternalException(t.getMessage());578 ie.setStackTrace(t.getStackTrace());579 }580 587 } 581 588 … … 710 717 if (null == already) { 711 718 current.adapter.add(servant, id); 719 if (log.isInfoEnabled()) { 720 log.info("Created servant:" + servantString(id, servant)); 721 } 712 722 } else { 713 723 current.adapter.remove(id); 714 724 current.adapter.add(servant, id); 715 } 716 if (log.isInfoEnabled()) { 717 log.info("Created servant:" + servantString(id, servant)); 725 if (already.hashCode() != servant.hashCode()) { 726 log.info(String.format("Replacing %s with %s", 727 servantString(id, already), servantString(id, 728 servant))); 729 } 718 730 } 719 731 } catch (Exception e) { -
trunk/components/blitz/test/ome/icy/model/utests/ServiceFactoryServiceCreationDestructionTest.java
r2383 r2597 165 165 callsActiveServices(Collections.singletonList(reServiceId)); 166 166 String id = sf.activeServices(curr).get(0).toString(); 167 Ice.Current curr = new Ice.Current();168 curr.id = Ice.Util.stringToIdentity("username/sessionid");169 curr.adapter = adapter;170 167 // Events now called by SessionManagerI 171 sf.unregisterServant(Ice.Util.stringToIdentity(id), curr);168 sf.unregisterServant(Ice.Util.stringToIdentity(id), adapter); 172 169 } 173 170 -
trunk/components/server/resources/beanRefContext.xml
r2128 r2597 24 24 <constructor-arg index="0"> 25 25 <list> 26 <value>classpath:ome/services/messaging.xml</value> 26 27 <value>classpath:ome/model.xml</value> 27 28 </list> … … 34 35 <constructor-arg index="0"> 35 36 <list> 37 <value>classpath:ome/services/messaging.xml</value> 36 38 <!-- Arranged roughly in stack order --> 37 39 <value>classpath:ome/services/config-local.xml</value> -
trunk/components/server/src/ome/services/sessions/SessionManager.java
r2594 r2597 70 70 71 71 /** 72 * Return the number of client which are presumed to be attached to this 73 * session. 74 */ 75 int getReferenceCount(String uuid); 76 77 /** 72 78 * @param sessionId 73 79 * @return A current session. Null if the session id is not found. -
trunk/components/tools/OmeroPy/src/omero/__init__.py
r2595 r2597 219 219 """ 220 220 221 # If 'sf' exists we remove it. 221 # If 'sf' exists we remove it, but save it for the weird chance that ic is None 222 sf = None 222 223 if hasattr(self, 'sf'): 224 sf = self.sf 223 225 self.sf = None 224 226 225 227 # If 'ic' does not exist we don't have anything to do 226 228 if not hasattr(self, 'ic') or not self.ic: 227 return 229 if sf: 230 self.ic = sf.ice_getCommunicator() 231 else: 232 return 228 233 229 234 try: -
trunk/components/tools/OmeroPy/test/integration/isession.py
r2592 r2597 9 9 10 10 """ 11 import unittest 11 12 import test.integration.library as lib 12 13 import omero 13 14 import omero_RTypes_ice 15 import omero_Constants_ice 14 16 from omero_model_PixelsI import PixelsI 15 17 from omero_model_ImageI import ImageI … … 44 46 45 47 def testCreateSessionForUser(self): 46 user = self.root.sf.getQueryService().findAllByQuery(""" 48 p = omero.sys.Parameters() 49 p.theFilter = omero.sys.Filter() 50 p.theFilter.limit = omero.RInt(1) 51 user = self.root.sf.getQueryService().findByQuery(""" 47 52 select e from Experimenter e where e.id > 0 and e.omeName != 'guest' 48 """, None)[0]53 """, p) 49 54 p = omero.sys.Principal() 50 55 p.name = user.omeName.val … … 71 76 72 77 def testCreationDestructionClosing(self): 73 self.client.detachOnDestroy() 74 sess = self.client.sf.ice_getIdentity().category 75 self.client.destroyConnection() 78 c1 = omero.client() 79 s1 = c1.createSession() 80 s1.detachOnDestroy() 81 uuid = s1.ice_getIdentity().name 76 82 77 self.client = omero.client() 78 self.client.createSession(sess, sess) 79 self.client.closeOnDestroy() 80 self.client.destroyConnection() 83 # Intermediate "disrupter" 84 c2 = omero.client() 85 s2 = c2.createSession(uuid, uuid) 86 s2.closeOnDestroy() 87 s2.getAdminService().getEventContext() 88 c2.closeSession() 89 90 # 1 should still be able to continue 91 s1.getAdminService().getEventContext() 92 93 # Now if s1 exists another session should be able to connect 94 c1.closeSession() 95 c3 = omero.client() 96 s3 = c3.createSession(uuid, uuid) 97 s3.closeOnDestroy() 98 s3.getAdminService().getEventContext() 99 c3.closeSession() 100 101 # Now a connection should not be possible 102 c4 = omero.client() 103 s4 = c4.createSession(uuid, uuid); 104 105 def testSimpleDestruction(self): 106 c = omero.client() 107 c.ic.getImplicitContext().put(omero.constants.CLIENTUUID,"SimpleDestruction") 108 s = c.createSession() 109 s.closeOnDestroy() 110 c.closeSession() 81 111 82 112 if __name__ == '__main__': -
trunk/components/tools/OmeroPy/test/integration/library.py
r2397 r2597 12 12 import omero 13 13 import tempfile 14 import traceback 15 import exceptions 14 16 15 17 class ITest(unittest.TestCase): … … 32 34 33 35 def tearDown(self): 34 self.client.closeSession() 36 failure = False 37 try: 38 self.client.closeSession() 39 except: 40 traceback.print_exc() 41 failure = True 35 42 if self.root: 36 self.root.closeSession() 43 try: 44 self.root.closeSession() 45 except: 46 traceback.print_exc() 47 failure = True 37 48 for tmpfile in self.tmpfiles: 38 49 try: … … 40 51 except: 41 52 print "Error closing:"+tmpfile 53 if failure: 54 raise exceptions.Exception("Exception on client.closeSession")
