1 / 11

An SDK for SSS Component Development

An SDK for SSS Component Development. One Vision for SSS in Action. Lots of components, open ended Not just getting existing components to talk to each other Either by wrapping or embedding SSS syntax into existing components Therefore it is crucial to make component development easy

zeno
Download Presentation

An SDK for SSS Component Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. An SDK for SSS Component Development

  2. One Vision for SSS in Action • Lots of components, open ended • Not just getting existing components to talk to each other • Either by wrapping or embedding SSS syntax into existing components • Therefore it is crucial to make component development easy • The SSSlib and infrastructure (service directory, event manager, etc.) form the foundation for the quick integration of new components. • Classes can be identified that encapsulate much of the functionality of an abstract component • Here we demonstrate the concept with some predefined classes in Python • Other languages, especially those with support for OO programming, could be used to implement similar classes • This amounts to a prototype “Software Development Kit” for SSS components • Expect will be useful in developing new or experimental system software configurations • E.g., BG/L, FastOS experiments

  3. Lower Levels of SSS-SDK • The communication library with multiple wire protocols, easy way to add new wire protocols • Some infrastructure components, including the Service Directory and Event Manager • The SSSlib communication library, with bindings for multiple languages

  4. Upper Level of SSS-SDK • Server and Event Receiver classes provided by server.py • Services independent of component • Registers/deregisters with Service Directory • Sets up logging • Sets up error reporting • Socket setup/cleanup • XML parsing (uses Elementtree) • XML validation • Message parsing of messages in (RS format) • Examples • Echo server, client • Job submitter • Simple scheduler

  5. Echo Client #!/usr/bin/python from os import getpid from sss.ssslib import comm_lib c = comm_lib() h = c.ClientInit('echo') c.SendMessage(h, "<echo><pid id='%s'/></echo>"%(getpid())) response = c.RecvMessage(h) c.ClientClose(h) print response

  6. Echo Server #!/usr/bin/env python from sss.server import Server class Echo(Server):     __implementation__ = 'echo'     # set log name     __component__ = 'echo' #component answers to 'echo'     __dispatch__ = {'echo':'HandleEcho'} # call HandleEcho method # for echo messages     __validate__ = 0 # don't have schema for this component def HandleEcho(self, xml, (peer,port)):         return xml if __name__ == '__main__':     e = Echo()     e.ServeForever()

  7. Personal Job Submitter #! /usr/bin/env python from elementtree.ElementTree import Element, SubElement, XML, tostring from os import environ, getuid, fork from time import sleep from pwd import getpwuid from sss.ssslib import comm_lib from sss.server import EventReceiver from sys import argv, exit class procevent(EventReceiver):     def __setup__(self):         self.__subscriptions__ = [('process-manager','process_end', self.kwargs['pgid'])]     def HandleEvent(self, xe, (peer, port)):         for event in xe.getchildren():             if event.attrib['msg'] == 'process_end':                 self.shut = 1                 print tostring(event)         return Element("event-ok")

  8. Job Submitter 2 if __name__ == '__main__':     executable = argv[1]     numprocs   = argv[2]     # submitter = environ['USER']     submitter = getpwuid(getuid())[0]     path = environ['PATH']     cwd = environ['PWD']     msg = Element("create-process-group", pgid='*', submitter=submitter, totalprocs=numprocs, output='merged')     ps = Element("process-spec", user=submitter, path=path, cwd=cwd)     ps.attrib['exec'] = executable     msg.append(ps) print tostring(msg)

  9. Job submitter 3    comm = comm_lib(debug='-d' in argv)     process_manager = comm.ClientInit('process-manager')     comm.SendMessage(process_manager,tostring(msg))     ack = comm.RecvMessage(process_manager)     comm.ClientClose(process_manager)     print ack     r = XML(ack)     pgid = r.attrib.get('pgid',None)     if not pgid:         exit(1)     else:         print "Got PGID %s\nwaiting for event data"%(pgid)

  10. Job Submitter 4     debug=argv.count('-d')     server=procevent(pgid=pgid,debug=debug)     server.ServeForever() # Now we pm-wait     msg = XML("<wait-process-group><process-group pgid='%s' submitter='*'><output/><exit-status><exit-code host='*'/></exit-status></process-group></wait-process-group>"%(pgid))     pm = comm.ClientInit('process-manager')     comm.SendMessage(pm,tostring(msg))     ack = comm.RecvMessage(pm)     comm.ClientClose(pm) print ack

  11. Conclusion • There is now enough infrastructure so that new components can be invented as needed and implemented in the SSS environment without redoing work that is not specific to the new components. • Currently for Python components, but one can envision bindings for other languages • Easier to maintain design if language has explicit OO support

More Related