Permalink
Browse files

removed test from boostrap, changed datastore for new msg format

  • Loading branch information...
1 parent 92b8f42 commit 471575890d0791b731ed58a56fc38e4cc5721ab4 mmeisinger committed Apr 17, 2010
Showing with 46 additions and 51 deletions.
  1. +9 −5 README.txt
  2. +4 −22 ion/core/bootstrap.py
  3. +8 −16 ion/services/coi/datastore.py
  4. +19 −2 ion/ts.py
  5. +6 −6 ion/util/procutils.py
View
@@ -1,14 +1,18 @@
This is the project for the OOI Release 1 LCA architecture prototype.
It contains the core services and their architectural dependencies, and relies on selected
-external pacakges, such as Magnet, etc.
+external packages, such as Magnet, etc.
-Start CC shell with:
-twistd -n magnet -h amoeba.ucsd.edu shell
+Get it with
+
+>git clone git://amoeba.ucsd.edu/lcaarch.git
+
+Start CC ("Magnet" Python Capability Container) shell in directory with:
+
+>twistd -n magnet -h amoeba.ucsd.edu shell
Start system by executing within the CC shell:
><> from ion.core import bootstrap
-><> spawn(bootstrap)
-><> send(1, '')
+><> bootstrap.start()
View
@@ -48,8 +48,8 @@
def start():
id = yield spawn(receiver)
store.put('bootstrap', id)
- op_bootstrap()
-
+ yield op_bootstrap()
+
@defer.inlineCallbacks
def op_bootstrap():
print "Bootstrapping now"
@@ -65,10 +65,10 @@ def op_bootstrap():
svc_mod = __import__(svc_import, globals(), locals(), [svc['module']])
svc['module_import'] = svc_mod
- # Spawn instance of a service
+ # Spawn instance of a service
svc_id = yield spawn(svc_mod)
svc['instance'] = svc_id
- store.put(svc['name'], svc_id)
+ yield store.put(svc['name'], svc_id)
print "Service "+svc['name']+" ID: ",svc_id
# Send a start message to service instance
@@ -77,24 +77,6 @@ def op_bootstrap():
# receiver.send(to, {'op':'START','args':{}})
print "Store: ", store.kvs
- # test_datastore()
-
-@defer.inlineCallbacks
-def test_datastore():
- print "===================================================================="
- print "===================================================================="
- print "Testing datastore"
-
- to = yield store.get('datastore')
-
- print "Send PUT to: ",to
- # receiver.send(to,{'op':'PUT','content':{'key':'key1','value':'val1'}})
- pu.send_message(receiver, '', to, 'PUT', {'key':'obj1','value':'999'}, {'some':'header'})
-
- print "===================================================================="
- print "Send GET to: ",to
- # receiver.send(to,{'op':'GET','args':{'key':'key1'}})
- pu.send_message(receiver, '', to, 'GET', {'key':'obj1'}, {})
def receive(content, msg):
pu.log_message(__name__, content, msg)
@@ -14,14 +14,16 @@
from magnet.spawnable import spawn
from magnet.store import Store
+import pycassa
import ion.util.procutils as pu
+# Store for locally know process ids (names)
store = Store()
+# Store
datastore = Store()
receiver = Receiver(__name__)
-selfid = None
class Store:
def started(self):
@@ -79,18 +81,18 @@ def receive(content, msg):
For this implementation, 'content' will be a dictionary:
content = {
"op": "operation name here",
- "args": {'key1':'arg1', 'key2':'arg2'}
+ "content": {'key1':'arg1', 'key2':'arg2'}
}
"""
try:
cmd = content['op']
- key = content['args']['key']
+ key = content['content']['key']
except KeyError:
log.err('Error parsing message!')
return
if cmd == 'PUT':
- value = content['args']['value']
+ value = content['content']['value']
datastore.put(key, value)
elif cmd == 'GET':
log.msg(datastore.get(key))
@@ -104,15 +106,5 @@ def receive(content, msg):
def pfh_test():
start()
- receive({'op':'PUT','args':{'key':'key1','value':'val1'}}, None)
- receive({'op':'GET','args':{'key':'key1'}}, None)
-
-
-def test_put():
- start()
- receiver.send(selfid, {'op':'PUT','args':{'key':'key1','value':'val1'}})
- # send(1,{'op':'PUT','args':{'key':'key1','value':'val1'}})
-
-def test_get():
- receiver.send(selfid, {'op':'GET','args':{'key':'key1'}})
- # send(1, {'op':'GET','args':{'key':'key1'}})
+ receive({'op':'PUT','content':{'key':'key1','value':'val1'}}, None)
+ receive({'op':'GET','content':{'key':'key1'}}, None)
View
@@ -14,6 +14,7 @@
from magnet.spawnable import spawn
from magnet.store import Store
+from ion.core import bootstrap
import ion.util.procutils as pu
store = Store()
@@ -24,10 +25,26 @@
def start():
id = yield spawn(receiver)
store.put('ts', id)
+
+ yield bootstrap.op_bootstrap()
+ yield test_datastore()
+
+@defer.inlineCallbacks
+def test_datastore():
+ print "===================================================================="
+ print "===================================================================="
+ print "Testing datastore"
+
+ to = yield bootstrap.store.get('datastore')
+
+ print "Send PUT to: ",to
+ pu.send_message(receiver, '', to, 'PUT', {'key':'obj1','value':'999'}, {'some':'header'})
+
+ print "===================================================================="
+ print "Send GET to: ",to
+ pu.send_message(receiver, '', to, 'GET', {'key':'obj1'}, {})
def receive(content, msg):
print 'in receive ', content, msg
- pu.print_attributes(msg)
-
receiver.handle(receive)
View
@@ -12,9 +12,9 @@
# Build a service properties dict
def service_deploy_factory(package,name):
scv_dict = {'name' : name,
- 'package' : package,
- 'module' : name,
- }
+ 'package' : package,
+ 'module' : name,
+ }
return scv_dict
# Print an object's attributes
@@ -34,10 +34,10 @@ def log_message(proc,content,msg):
# Returns the instance part of a long process id
def get_process_id(long_id):
- parts = str(long_id).rpartition('.')
- return parts[2]
+ parts = str(long_id).rpartition('.')
+ return parts[2]
-# Constructs a message with standard headers
+# Constructs a message with standard headers
def send_message(receiver,src,to,operation,content,headers):
msg = {}
msg.update(headers)

0 comments on commit 4715758

Please sign in to comment.