This repository has been archived by the owner on Sep 23, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
base service and process, service startup
- Loading branch information
mmeisinger
committed
Apr 19, 2010
1 parent
79ff0f4
commit ab3d9bb
Showing
9 changed files
with
279 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,63 @@ | ||
This is the project for the OOI Release 1 LCA architecture prototype. | ||
================================================== | ||
LCAARCH - OOI Release 1 LCA architecture prototype | ||
================================================== | ||
|
||
It contains the core services and their architectural dependencies, and relies on selected | ||
external packages, such as Magnet, etc. | ||
April 2010 | ||
|
||
This project defines the services of the OOI release 1 system with their | ||
architectural dependencies. | ||
|
||
This project and relies on selected external packages, such as Magnet, etc. | ||
|
||
Get it with | ||
:: | ||
git clone git@amoeba.ucsd.edu:lcaarch.git | ||
|
||
>git clone git://amoeba.ucsd.edu/lcaarch.git | ||
Usage | ||
===== | ||
|
||
Start CC ("Magnet" Python Capability Container) shell in directory with: | ||
|
||
>twistd -n magnet -h amoeba.ucsd.edu shell | ||
:: | ||
twistd -n magnet -h amoeba.ucsd.edu shell | ||
|
||
Start system by executing within the CC shell: | ||
|
||
><> from ion.core import bootstrap | ||
><> bootstrap.start() | ||
|
||
><> | ||
from ion.core import bootstrap | ||
bootstrap.start() | ||
|
||
Start a test case by executing within the CC shell: | ||
><> | ||
from ion import ts | ||
ts.start() | ||
|
||
Install the dependencies: Magnet (see Magnet's Readme) | ||
====================================================== | ||
Recommendation: | ||
Create a virtualenv for installing Magnet and its dependencies. | ||
|
||
Twisted Python | ||
-------------- | ||
:: | ||
easy_install twisted | ||
|
||
txAMQP | ||
------ | ||
:: | ||
easy_install txamqp | ||
|
||
carrot (use txamqp branch) | ||
---------------------- | ||
:: | ||
git clone git://amoeba.ucsd.edu/carrot.git | ||
(cd carrot; git checkout -b txamqp origin/txamqp) | ||
(cd carrot; python setup.py install) | ||
|
||
Install the Magnet package: | ||
--------------------------- | ||
Get the latest version of the repository, if you haven't already. | ||
:: | ||
git clone git://amoeba.ucsd.edu/magnet.git # no ooi credential | ||
# OR | ||
git clone git@amoeba.ucsd.edu:magnet.git # need ooi credential | ||
(cd magnet; git checkout -b space origin/space) | ||
(cd magnet; python setup.py install) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
#!/usr/bin/env python | ||
|
||
""" | ||
@file ion/services/base_svcproc.py | ||
@author Michael Meisinger | ||
@brief base class for all service processes within Magnet | ||
""" | ||
|
||
import logging | ||
|
||
from twisted.internet import defer | ||
|
||
from ion.core.base_process import BaseProcess | ||
|
||
logging.basicConfig(level=logging.DEBUG) | ||
logging.debug('Loaded: '+__name__) | ||
|
||
class BaseServiceProcess(BaseProcess): | ||
""" | ||
This is the base class for all service processes. | ||
A service process is a Capability Container process that can be spawned | ||
anywhere in the network and that provides a service. | ||
""" | ||
|
||
# Name of the spawnable of the executed process | ||
processName = None | ||
|
||
# Fully qualified name of the service module | ||
serviceModule = None | ||
|
||
# Name of the service class within service module | ||
serviceName = None | ||
|
||
# An instance of the service class | ||
serviceInstance = None | ||
|
||
def __init__(self, procName, svcMod, svcName): | ||
"""Constructor. | ||
@param procName public name of the spawnable process | ||
@param svcMod qualified name of the module in which the service class | ||
is, e.g. 'ion.services.coi.resource_registry' | ||
@param svcName name of the service class, e.g. 'ResourceRegistryService' | ||
""" | ||
logging.info('BaseServiceProcess.__init__('+procName+','+svcMod+','+svcName+')') | ||
BaseProcess.__init__(self, procName) | ||
|
||
self.processName = procName | ||
self.serviceModule = svcMod | ||
self.serviceName = svcName | ||
|
||
localMod = svcMod.rpartition('.')[2] | ||
logging.info('BaseServiceProcess.__init__: from '+self.serviceModule+' import '+localMod+', '+svcName) | ||
|
||
svc_mod = __import__(self.serviceModule, globals(), locals(), [localMod,svcName]) | ||
#logging.debug('Module: '+str(svc_mod)) | ||
|
||
svc_class = getattr(svc_mod, svcName) | ||
#logging.debug('Class: '+str(svc_class)) | ||
|
||
self.serviceInstance = svc_class() | ||
self.serviceInstance.receiver = self.receiver | ||
logging.info('BaseServiceProcess.__init__: created service instance '+str(self.serviceInstance) ) | ||
|
||
|
||
def receive(self, content, msg): | ||
logging.info('BaseServiceProcess.receive()') | ||
self._dispatch_message(content, msg, self.serviceInstance) | ||
|
||
# Code below is for starting this base class directly as a process | ||
|
||
@defer.inlineCallbacks | ||
def start(svcMod, svcName): | ||
"""Starts a new process and tries to instantiate the given service class | ||
in the given module. | ||
@param svcMod qualified name of the module in which the service class is, | ||
e.g. 'ion.services.coi.resource_registry' | ||
@param svcName name of the service class, e.g. 'ResourceRegistryService' | ||
""" | ||
|
||
logging.info('BaseServiceProcess.start: '+svcMod+':'+svcName+' in proc '+__name__) | ||
procInst = BaseServiceProcess(__name__, svcMod, svcName) | ||
procInst.receiver.handle(procInst.receive) | ||
|
||
yield procInst.plc_start() | ||
#logging.debug('procInst: '+str(procInst.__dict__)) | ||
|
||
|
||
""" | ||
from ion.services import base_svcproc as b | ||
b.start('ion.services.hello_service','HelloService') | ||
send(1, {'op':'hello','content':'Hello you there!'}) | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.