ome / omero-blitz

Gradle project containing Ice remoting code for OMERO
https://www.openmicroscopy.org/omero
GNU General Public License v2.0
0 stars 15 forks source link

Add TableCloserI for stateful cleanup (fix #56) #57

Closed joshmoore closed 5 years ago

joshmoore commented 5 years ago

TablePrx instances from the Tables-0 process are not registered in a session as a stateful service. Clients can't know or discover that they are open. The TableCloser implements StatefulServiceInterface to allow clients to call close().

Tested via this script:

$ cat t.py
import omero
import omero.grid
c=omero.client("localhost")
c.createSession("root", "omero")
try:
    s = c.sf.sharedResources()
    t = s.newTable(1, "foo.h5")
    l = omero.grid.LongColumn("foo")
    t.initialize([l])
    services = c.getStatefulServices()
    print services[0].ice_ids()
    services[0].close()
finally:
    c.__del__()

which prints:

$ PYTHONPATH=lib/python python t.py
['::Ice::Object', '::omero::api::ServiceInterface', '::omero::api::StatefulServiceInterface']

Opening now to get it into regular testing. ~Additional integration tests will be needed in openmicroscopy/openmicroscopy.~ This PR prevents calling getOriginalFile() after close() has been called, which has clearly been proven throughout the code base.

joshmoore commented 5 years ago

https://merge-ci.openmicroscopy.org/jenkins/job/OMERO-test-integration/60/testReport/OmeroPy.test.integration.tablestest.test_service/TestTables/testCallContext/ needs updating now that a stateful service is present for each table:

    def setSecurityContext(self, obj, _ctx=None):
>       return _M_omero.api.ServiceFactory._op_setSecurityContext.invoke(self, ((obj, ), _ctx))
E       SecurityViolation: exception ::omero::SecurityViolation
E       {
E           serverStackTrace = ome.conditions.SecurityViolation: SecurityContext change cancelled:
E       fde941e0-a25a-45b6-9060-e0f594a90a83 has active stateful services:
E       
E       Table-1e2bf983-0d99-440f-b5c4-8277ae98193d
E       
E           at ome.services.sessions.events.ChangeSecurityContextEvent.throwIfCancelled(ChangeSecurityContextEvent.java:59)
E           at ome.services.sessions.SessionManagerImpl.setSecurityContext(SessionManagerImpl.java:1240)
E           at ome.services.blitz.impl.ServiceFactoryI.setSecurityContext(ServiceFactoryI.java:236)
E           at omero.api._ServiceFactoryTie.setSecurityContext(_ServiceFactoryTie.java:269)
E           at omero.api._ServiceFactoryDisp.___setSecurityContext(_ServiceFactoryDisp.java:472)
E           at omero.api._ServiceFactoryDisp.__dispatch(_ServiceFactoryDisp.java:1375)
E           at IceInternal.Incoming.invoke(Incoming.java:221)
E           at Ice.ConnectionI.invokeAll(ConnectionI.java:2536)
E           at Ice.ConnectionI.dispatch(ConnectionI.java:1145)
E           at Ice.ConnectionI.message(ConnectionI.java:1056)
E           at IceInternal.ThreadPool.run(ThreadPool.java:395)
E           at IceInternal.ThreadPool.access$300(ThreadPool.java:12)
E           at IceInternal.ThreadPool$EventHandlerThread.run(ThreadPool.java:832)
E           at java.lang.Thread.run(Thread.java:748)
E       
E           serverExceptionClass = ome.conditions.SecurityViolation
E           message = SecurityContext change cancelled:
E       fde941e0-a25a-45b6-9060-e0f594a90a83 has active stateful services:
E       
E       Table-1e2bf983-0d99-440f-b5c4-8277ae98193d
joshmoore commented 5 years ago

Merging for release as 5.5.3. This will be deployed on pub-omero for a bit of extended use.