Permalink
Browse files

package init, ts test

  • Loading branch information...
1 parent 7ad723b commit d9eb8b771c9662fdd618b178a6607fb8916c690e Michael Meisinger committed Apr 25, 2010
View
@@ -5,3 +5,4 @@
.*.*.swo
*.log
twistd.pid
+_trial_temp
View
@@ -16,21 +16,30 @@ Get it with
Usage
=====
+(all subsequent steps assume start from lcaarch/ dir)
+
Start CC ("Magnet" Python Capability Container) shell with:
-Note: it is important to start from the root of the lcaarch/ dir.
::
- cd lcaarch
- twistd -n magnet -h amoeba.ucsd.edu shell
+ twistd -n magnet -h amoeba.ucsd.edu
Start system by executing within the CC shell:
><>
from ion.core import bootstrap
bootstrap.start()
+Alternatively from shell executing a script:
+::
+ twistd -n magnet -h amoeba.ucsd.edu res/scripts/bootstrap.py
+
Start a test case by executing within the CC shell:
><>
from ion import ts
ts.start()
+
+Run all test cases
+::
+ trial ion
+
Install the dependencies: Magnet (see Magnet's Readme)
======================================================
View
@@ -0,0 +1,6 @@
+# Make sure the init code in ioninit (e.g. logging settings) executes before
+# anything else in the system
+from .core import ioninit
+from .core import ionconst
+
+__version__ = ionconst.VERSION
View
@@ -15,10 +15,10 @@
from magnet.spawnable import spawn
from magnet.store import Store
-from ion.core import ionconst as ic
+from ion.core import ioninit
import ion.util.procutils as pu
-CONF = ic.config(__name__)
+CONF = ioninit.config(__name__)
CF_conversation_log = CONF['conversation_log']
# Static store (kvs) to register process instances with names
View
@@ -15,13 +15,13 @@
from magnet.spawnable import spawn
from magnet.store import Store
-from ion.core import ionconst as ic
+from ion.core import ioninit
from ion.core.supervisor import Supervisor, ChildProcess
from ion.core.base_process import procRegistry
from ion.util.config import Config
import ion.util.procutils as pu
-CONF = ic.config(__name__)
+CONF = ioninit.config(__name__)
# Static definition of message queues
ion_queues = {}
View
@@ -16,13 +16,13 @@
from magnet.container import Container
from magnet.store import Store
-from ion.core import ionconst as ic
+from ion.core import ioninit
from ion.core.supervisor import Supervisor, ChildProcess
from ion.core.base_process import procRegistry
from ion.util.config import Config
import ion.util.procutils as pu
-CONF = ic.config(__name__)
+CONF = ioninit.config(__name__)
# Static definition of message queues
ion_messaging = Config(CONF.getValue('messaging_cfg')).getObject()
View
@@ -3,18 +3,12 @@
"""
@file ion/core/ionconst.py
@author Michael Meisinger
-@brief definitions of constants and static code that should be executed in any system run
+@brief definitions of ION packages wide constants
"""
-import logging
-import logging.config
-from ion.util.config import Config
+LOGCONF_FILENAME = 'res/logging/ionlogging.conf'
-LOGCONF_FILENAME = 'res/ionlogging.conf'
-logging.config.fileConfig(LOGCONF_FILENAME)
+ION_CONF_FILENAME = 'res/config/ion.config'
-ION_CONF_FILENAME = 'res/ion.config'
-ion_config = Config(ION_CONF_FILENAME)
-
-def config(name):
- return Config(name, ion_config)
+# @todo use magnet version system
+VERSION = "ion 0.1.0"
View
@@ -11,13 +11,9 @@
from magnet.spawnable import Receiver
from magnet.spawnable import spawn
-from ion.core import ionconst as ic
import ion.util.procutils as pu
from ion.core.base_process import BaseProcess, RpcClient
-logging.basicConfig(level=logging.DEBUG)
-logging.debug('Loaded: '+__name__)
-
class Supervisor(BaseProcess):
"""
Base class for a supervisor process
@@ -43,10 +43,7 @@ def op_get(self, content, headers, msg):
value = yield self.datastore.get(key)
logging.info('Datastore.get('+key+') = '+str(value))
- replyto = msg.reply_to
- logging.info('Datastore.get() replyto='+replyto)
- yield pu.send_message(receiver, '', pu.get_process_id(replyto),
- 'result', {'value':value}, {})
+ yield self.reply_message(msg, 'result', {'value':value}, {})
# Direct start of the service as a process with its default name
View
@@ -35,7 +35,7 @@ def test_datastore():
print "===================================================================="
print "Testing datastore"
- to = yield bootstrap.store.get('datastore')
+ to = yield bootstrap.process_ids.get('datastore')
print "Send PUT to: ",to
yield pu.send_message(receiver, '', to, 'put', {'key':'obj1','value':'999'}, {'some':'header'})
View
@@ -6,6 +6,7 @@
@brief utility helper functions for processes in capability containers
"""
+import sys, traceback, re
import logging
from twisted.python import log
from twisted.internet import defer
@@ -21,18 +22,32 @@ def log_attributes(obj):
lstr = lstr + str(attr) + ": " +str(value) + ", "
logging.info(lstr)
-def log_message(proc,content,msg):
+def log_message(proc, body, msg):
"""Log an incoming message with all headers
"""
- logging.info("===Message=== @" + str(proc))
+ #mkeys = sorted(msg.__dict__.keys)
+ mkeys = msg.__dict__.keys().sort()
lstr = ""
- for attr, value in msg.__dict__.iteritems():
- if attr != 'content':
- lstr = lstr + str(attr) + ": " +str(value) + ", "
+ lstr += "===Message=== RECEIVED @" + str(proc) + "\n"
+ amqpm = str(msg._amqp_message)
+ amqpm = re.sub("body='[^']*'","*BODY*", amqpm)
+ lstr += '---AMQP--- ' + amqpm
+ lstr += "\n---CARROT--- "
+ for attr,value in msg.__dict__.iteritems():
+ if attr == '_amqp_message': pass
+ elif attr == 'body': pass
+ elif attr == '_decoded_cache': pass
+ else:
+ lstr += str(attr) + ": " +str(value) + ", "
+ lstr += "\n---HEADERS--- "
+ mbody = {}
+ mbody.update(body)
+ content = mbody.pop('content')
+ lstr += str(mbody)
+ lstr += "\n---CONTENT---\n"
+ lstr += str(content)
+ lstr += "\n============="
logging.info(lstr)
- logging.info("-------------")
- logging.info(content)
- logging.info("=============")
def get_process_id(long_id):
"""Returns the instance part of a long process id
@@ -57,7 +72,7 @@ def send_message(receiver, send, recv, operation, content, headers):
msg['sender'] = str(send)
msg['receiver'] = str(recv)
msg['reply-to'] = str(send)
- msg['encoding'] = 'ion1'
+ msg['encoding'] = 'json_1'
msg['language'] = 'ion1'
msg['format'] = 'raw'
msg['ontology'] = ''
@@ -81,22 +96,28 @@ def dispatch_message(content, msg, dispatchIn):
"content": ('arg1', 'arg2')
}
"""
+ try:
+ log_message(__name__, content, msg)
+
+ if "op" in content:
+ op = content['op']
+ logging.info('dispatch_message() OP=' + str(op))
- log_message(__name__, content, msg)
+ cont = content.get('content','')
+ opname = 'op_' + str(op)
- if "op" in content:
- op = content['op']
- logging.info('dispatch_message() OP=' + str(op))
-
- cont = content.get('content','')
- opname = 'op_' + str(op)
-
- # dynamically invoke the operation
- if hasattr(dispatchIn, opname):
- getattr(dispatchIn, opname)(cont, content, msg)
- elif hasattr(dispatchIn,'op_noop_catch'):
- dispatchIn.op_noop_catch(cont, content, msg)
+ # dynamically invoke the operation
+ if hasattr(dispatchIn, opname):
+ getattr(dispatchIn, opname)(cont, content, msg)
+ elif hasattr(dispatchIn,'op_noop_catch'):
+ dispatchIn.op_noop_catch(cont, content, msg)
+ else:
+ logging.error("Receive() failed. Cannot dispatch to catch")
else:
- logging.error("Receive() failed. Cannot dispatch to catch")
- else:
- logging.error("Receive() failed. Bad message", content)
+ logging.error("Receive() failed. Bad message", content)
+ except Exception as e:
+ logging.error('Exception while dispatching: '+repr(e))
+ (type, value, trace) = sys.exc_info()
+ traceback.print_tb(trace)
+
+ # logging.error('Traceback: '+trace.format_exc())
File renamed without changes.
@@ -2,14 +2,14 @@
keys=root,logServer,convRepos
[handlers]
-keys=consoleHandler,logfileHandler,msgfileHandler
+keys=consoleHandler,tracefileHandler,logfileHandler,msgfileHandler
[formatters]
keys=simpleFormatter,fileFormatter,msgfileFormatter
[logger_root]
level=DEBUG
-handlers=consoleHandler
+handlers=consoleHandler,tracefileHandler
[logger_logServer]
level=DEBUG
@@ -27,24 +27,32 @@ level=DEBUG
formatter=simpleFormatter
args=(sys.stdout,)
+[handler_tracefileHandler]
+class=FileHandler
+level=DEBUG
+formatter=fileFormatter
+args=('logs/ioncontainer.log', 'w')
+filename=logs/ioncontainer.log
+mode=w
+
[handler_logfileHandler]
class=FileHandler
level=DEBUG
formatter=fileFormatter
-args=('logs/ionsystem.log', 'w')
+args=('logs/ionsystem.log', 'a')
filename=logs/ionsystem.log
-mode=w
+mode=a
[handler_msgfileHandler]
class=FileHandler
level=DEBUG
formatter=msgfileFormatter
-args=('logs/ionmessages.log', 'w')
+args=('logs/ionmessages.log', 'a')
filename=logs/ionmessages.log
-mode=w
+mode=a
[formatter_simpleFormatter]
-format=%(asctime)s,%(msecs)d [%(module)s:%(lineno)d] %(levelname)s:%(message)s
+format=[%(module)s:%(lineno)d] %(levelname)s:%(message)s
datefmt=%Y-%m-%d %H:%M:%S
[formatter_fileFormatter]

0 comments on commit d9eb8b7

Please sign in to comment.