<?xml version="1.0"?>
<?xml-stylesheet type="text/css" href="http://50.77.162.165/mediawiki/skins/common/feed.css?207"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
	<channel>
		<title>Erights - User contributions [en]</title>
		<link>http://50.77.162.165/wiki/Special:Contributions/Tstanley</link>
		<description>From Erights</description>
		<language>en</language>
		<generator>MediaWiki 1.15.5-7</generator>
		<lastBuildDate>Sat, 25 Apr 2026 20:28:10 GMT</lastBuildDate>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Instrumenting a Platform to Generate Causeway Trace Logs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs. For concreteness, we show the trace log records generated for a simple distributed program. We discuss three different versions of the purchase-order example program, starting with the simplest implementation: Simple Ajax-style (below). If your platform supports promises, continue with [[Causeway Platform Developer: Ajax|Ajax with promotion]] and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view. Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record from the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
* Open the purchase-order example program in the Causeway viewer. The examples, under the Help menu, are written for the AmbientTalk and Waterken platforms and they implement different message-passing styles. Select Help &amp;gt;&amp;gt; Open Waterken Example (Simple Ajax-style). &lt;br /&gt;
&lt;br /&gt;
('''Note:''' Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.)&lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purchase-order example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
If instrumenting a platform, your first test case should be the purchase-order example, ported to run on your platform. Start with Ajax-style using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
The simple Ajax-style example logs the event types indicated by the colored boxes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events from the message-order view shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
# a remote inventory object is queried for the availability of a part&lt;br /&gt;
# the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
:: &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection is not yet supported.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by a unique string. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the logged record for the event. To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Wed, 16 Jun 2010 23:48:42 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs. For concreteness, we show the trace log records generated for a simple distributed program. We discuss three different versions of the purchase-order example program, starting with the simplest implementation: Simple Ajax-style, below. If your platform supports promises, continue with [[Causeway Platform Developer: Ajax|Ajax with promotion]] and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view. Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record from the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
* Open the purchase-order example program in the Causeway viewer. The examples, under the Help menu, are written for the AmbientTalk and Waterken platforms and they implement different message-passing styles. Select Help &amp;gt;&amp;gt; Open Waterken Example (Simple Ajax-style). &lt;br /&gt;
&lt;br /&gt;
('''Note:''' Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.)&lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purchase-order example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
If instrumenting a platform, your first test case should be the purchase-order example, ported to run on your platform. Start with Ajax-style using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
The simple Ajax-style example logs the event types indicated by the colored boxes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events from the message-order view shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
# a remote inventory object is queried for the availability of a part&lt;br /&gt;
# the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
:: &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection is not yet supported.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by a unique string. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the logged record for the event. To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Wed, 16 Jun 2010 23:46:32 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Instrumenting a Platform to Generate Causeway Trace Logs */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs. For concreteness, we show the trace log records generated for a simple distributed program. We discuss three different versions of the purchase-order example program, starting with the simplest implementation: Simple Ajax-style, below. If your platform supports promises, continue with [[Causeway Platform Developer: Ajax|Ajax with promotion]] and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view. Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
* Open the purchase-order example program in the Causeway viewer. The example is written for the AmbientTalk and Waterken platforms. Select Help &amp;gt;&amp;gt; Open Waterken Example (Simple Ajax-style). &lt;br /&gt;
&lt;br /&gt;
('''Note:''' Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.)&lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purchase-order example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
If instrumenting a platform, your first test case should be the purchase-order example, ported to run on your platform. Start with Ajax-style using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
The simple Ajax-style example logs the event types indicated by the colored boxes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events from the message-order view shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
# a remote inventory object is queried for the availability of a part&lt;br /&gt;
# the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
:: &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection is not yet supported.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by a unique string. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the logged record for the event. To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Wed, 16 Jun 2010 23:41:04 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs. For concreteness, we show the trace log records generated for a simple distributed program. We start with the simplest implementation (Simple Ajax-style, below) then describe [[Causeway Platform Developer: Ajax|Ajax with promotion]] and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view. Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
* Open the purchase-order example program in the Causeway viewer. The example is written for the AmbientTalk and Waterken platforms. Select Help &amp;gt;&amp;gt; Open Waterken Example (Simple Ajax-style). &lt;br /&gt;
&lt;br /&gt;
('''Note:''' Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.)&lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purchase-order example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
If instrumenting a platform, your first test case should be the purchase-order example, ported to run on your platform. Start with Ajax-style using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
The simple Ajax-style example logs the event types indicated by the colored boxes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events from the message-order view shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
# a remote inventory object is queried for the availability of a part&lt;br /&gt;
# the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
:: &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection is not yet supported.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by a unique string. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the logged record for the event. To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 14 Jun 2010 04:35:06 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Logging Ajax-style Messaging in Waterken */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs. For concreteness, we show the trace log records generated for a simple distributed program. We start with the simplest implementation (Simple Ajax-style, below) then describe [[Causeway Platform Developer: Ajax|Ajax with promotion]] and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view. Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
* Open the purchase-order example program in the Causeway viewer. The example is written for the AmbientTalk and Waterken platforms. Select Help &amp;gt;&amp;gt; Open Waterken Example (Simple Ajax-style). &lt;br /&gt;
&lt;br /&gt;
('''Note:''' Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.)&lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purchase-order example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
If instrumenting a platform, your first test case should be the purchase-order example, ported to run on your platform. Start with Ajax-style using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
The simple Ajax-style example logs the event types indicated by the colored boxes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events from the message-order view shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
# a remote inventory object is queried for the availability of a part&lt;br /&gt;
# the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
:: &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection is not yet supported.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by a unique string. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the logged record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 14 Jun 2010 04:32:34 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs. For concreteness, we show the trace log records generated for a simple distributed program. We start with the simplest implementation (Simple Ajax-style, below) then describe [[Causeway Platform Developer: Ajax|Ajax with promotion]] and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view. Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
* Open the purchase-order example program in the Causeway viewer. The example is written for the AmbientTalk and Waterken platforms. Select Help &amp;gt;&amp;gt; Open Waterken Example (Simple Ajax-style). &lt;br /&gt;
&lt;br /&gt;
('''Note:''' Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.)&lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The purchase-order example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
If instrumenting a platform, your first test case should be the purchase-order example, ported to run on your platform. Start with Ajax-style using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
The simple Ajax-style example logs the event types indicated by the colored boxes.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events from the message-order view shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
# a remote inventory object is queried for the availability of a part&lt;br /&gt;
# the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
:: &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection is not yet supported.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by a unique string. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 14 Jun 2010 04:25:05 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs.&lt;br /&gt;
&lt;br /&gt;
For concreteness, we show the trace log records generated for a simple distributed program. Our example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view.&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Open the purchase-order example program in the Causeway viewer. &lt;br /&gt;
&lt;br /&gt;
The example is written for the AmbientTalk and Waterken platforms. Select Help &amp;gt;&amp;gt; Open Waterken Example (Simple Ajax-style). This is the simplest implementation, i.e., Causeway's &amp;quot;Hello World&amp;quot;. We start here and work up to the promise-based implementation.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.)&lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If instrumenting a platform, your first test case should be the purchase-order example, ported to run on your platform. Start with the Ajax-style using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
# a remote inventory object is queried for the availability of a part&lt;br /&gt;
# the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
:: &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
:: &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection is not yet supported.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by a unique string. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
: The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
: The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 14 Jun 2010 02:56:52 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs.&lt;br /&gt;
&lt;br /&gt;
For concreteness, we show the trace log records generated for a simple distributed program. Our example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view.&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Open the purchase-order example program in the Causeway viewer. &lt;br /&gt;
&lt;br /&gt;
The example is written for the AmbientTalk and Waterken platforms. Select Help &amp;gt;&amp;gt; Open Waterken Example (Simple Ajax-style). This is the simplest implementation, i.e., Causeway's &amp;quot;Hello World&amp;quot;. We start here and work up to the promise-based implementation.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.)&lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If instrumenting a platform, your first test case should be the purchase-order example, ported to run on your platform. Start with the Ajax-style using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sat, 12 Jun 2010 21:57:00 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs.&lt;br /&gt;
&lt;br /&gt;
For concreteness, we show the trace log records generated for a simple distributed program. Our example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
Waterken, AmbientTalk and Causeway support both styles of response handling.&lt;br /&gt;
&lt;br /&gt;
This program is one of the examples that can be browsed in the Causeway viewer. It is implemented in AmbientTalk and Waterken/Java. Here, we use the Waterken version. Starting with the simplest case, i.e., Causeway's &amp;quot;Hello World&amp;quot;, we build up to a promise-based implementation. &lt;br /&gt;
&lt;br /&gt;
It is written in Java and ran on the Waterken web server.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sat, 12 Jun 2010 21:18:44 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports debugging distributed programs built on the communicating event loops concurrency model. This document describes Causeway's language-neutral trace log format and explains how to instrument a platform to generate trace logs.&lt;br /&gt;
&lt;br /&gt;
For concreteness, we show the trace log records generated for a simple distributed program. &lt;br /&gt;
&lt;br /&gt;
Our example program implements a procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the &amp;quot;buyer&amp;quot; process (or vat) has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. The answers from the asynchronous inquiries must be collected and examined. The order is placed only if all requirements are satisfied.&lt;br /&gt;
&lt;br /&gt;
Starting with one-way asynchronous messages, two patterns for handling responses are ''continuation-passing'' and ''promises''. In continuation-passing a request carries a callback argument to which a response should be sent. &lt;br /&gt;
We refer to this as ''Ajax-style'' messaging, as it is the dominant pattern for web application development. A promise (''future'', in AmbientTalk) is a place-holder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
Waterken, AmbientTalk and Causeway support both styles of response handling.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Fri, 11 Jun 2010 23:58:02 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. &lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. All 3 answers must be examined before the order is placed. Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. To collect the three answers, teller is passed as an argument to each of the remote queries, serving as a callback function.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Callback teller = new AsyncAnd(_, 3, checkAnswers(_, inventory));&lt;br /&gt;
&lt;br /&gt;
    _._(inventory).partInStock(partNo, teller);&lt;br /&gt;
    _._(creditBureau).checkCredit(name, teller);&lt;br /&gt;
    _._(shipper).canDeliver(profile, teller);&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 23:45:36 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 23:34:03 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 23:32:25 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Causeway's Trace Log Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:simple-event-types.png|alt=Simple event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 23:22:12 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>File:Simple-event-types.png</title>
			<link>http://50.77.162.165/wiki/File:Simple-event-types.png</link>
			<guid>http://50.77.162.165/wiki/File:Simple-event-types.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 23:20:37 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Simple-event-types.png</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Support Tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
('''Note:''' When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 22:49:47 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>File:Simple-pov-mov.png</title>
			<link>http://50.77.162.165/wiki/File:Simple-pov-mov.png</link>
			<guid>http://50.77.162.165/wiki/File:Simple-pov-mov.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 22:44:30 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Simple-pov-mov.png</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Logging Promise-based Messaging in Waterken */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:simple-pov-mov.png|alt=Simple process-order view and message-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 22:43:55 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022120,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;qvet6lrs4zsfpv-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1275338022291,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;4qjohg533s6cjn-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/simple_purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. &lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 22:04:57 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report at www.hpl.hp.com/techreports/2009/HPL-2009-78.html for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;tt&amp;gt;partInStock&amp;lt;/tt&amp;gt;. Then we'll look at how &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
The graph below describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sequence of graphs below describe transformations on Causeway's message graph to better represent promise semantics, rather than the mechanics of promise resolution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution, i.e., the resolving of the promise had 3 causes. But without event promotion, the message-order view would show only 1 cause.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. The registration of when-blocks are filtered from message-order as they don't contribute to the understanding of message flow; however, they do appear in process-order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 21:40:02 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer: Promises</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer:_Promises</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer:_Promises</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Placeholder -- ignore for now&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;tt&amp;gt;partInStock&amp;lt;/tt&amp;gt;. Then we'll look at how &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
The graph below describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sequence of graphs below describe transformations on Causeway's message graph to better represent promise semantics, rather than the mechanics of promise resolution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution, i.e., the resolving of the promise had 3 causes. But without event promotion, the message-order view would show only 1 cause.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. The registration of when-blocks are filtered from message-order as they don't contribute to the understanding of message flow; however, they do appear in process-order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 21:35:03 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer:_Promises</comments>		</item>
		<item>
			<title>Causeway Platform Developer: Ajax</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer:_Ajax</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer:_Ajax</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Placeholder -- ignore for now&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;tt&amp;gt;partInStock&amp;lt;/tt&amp;gt;. Then we'll look at how &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
The graph below describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sequence of graphs below describe transformations on Causeway's message graph to better represent promise semantics, rather than the mechanics of promise resolution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution, i.e., the resolving of the promise had 3 causes. But without event promotion, the message-order view would show only 1 cause.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. The registration of when-blocks are filtered from message-order as they don't contribute to the understanding of message flow; however, they do appear in process-order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 21:34:48 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer:_Ajax</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Causeway's Trace Log Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
We will explain this format, and how to get your platform to generate it, in three steps: Simple Ajax (below), [[Causeway Platform Developer: Ajax|Ajax with promotion]], and [[Causeway Platform Developer: Promises|full promises]].&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;tt&amp;gt;partInStock&amp;lt;/tt&amp;gt;. Then we'll look at how &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
The graph below describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sequence of graphs below describe transformations on Causeway's message graph to better represent promise semantics, rather than the mechanics of promise resolution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution, i.e., the resolving of the promise had 3 causes. But without event promotion, the message-order view would show only 1 cause.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. The registration of when-blocks are filtered from message-order as they don't contribute to the understanding of message flow; however, they do appear in process-order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 21:34:00 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;tt&amp;gt;partInStock&amp;lt;/tt&amp;gt;. Then we'll look at how &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
The graph below describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sequence of graphs below describe transformations on Causeway's message graph to better represent promise semantics, rather than the mechanics of promise resolution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution, i.e., the resolving of the promise had 3 causes. But without event promotion, the message-order view would show only 1 cause.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. The registration of when-blocks are filtered from message-order as they don't contribute to the understanding of message flow; however, they do appear in process-order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 21:26:21 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Logging Promise-based Messaging in Waterken */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; object. The &amp;lt;tt&amp;gt;run&amp;lt;/tt&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;tt&amp;gt;checkAnswers&amp;lt;/tt&amp;gt; is synchronized with the completion of the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;tt&amp;gt;partInStock&amp;lt;/tt&amp;gt;. Then we'll look at how &amp;lt;tt&amp;gt;AsyncAnd&amp;lt;/tt&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
The graph below describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The sequence of graphs below describe transformations on Causeway's message graph to better represent promise semantics, rather than the mechanics of promise resolution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution, i.e., the resolving of the promise had 3 causes. But without event promotion, the message-order view would show only 1 cause.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. The registration of when-blocks are filtered from message-order as they don't contribute to the understanding of message flow; however, they do appear in process-order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 02:50:17 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* In the &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; trace record:&lt;br /&gt;
** &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
** &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
**&amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)&lt;br /&gt;
&lt;br /&gt;
('''Note:''' The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2. Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The reply to the query is the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; has a matching &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This graph describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution of the promise. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The resulting process-order view and message-order view are shown below. The registration of when-blocks are filtered from message-order as they don't contribute to the understanding of message flow. However, they do appear in process-order.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 01:29:14 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Logging Promise-based Messaging in Waterken */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)''&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This graph describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution of the promise. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The process-order view and message-order view.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-pov-mov.png|alt=Waterken promise process-order and message-order views]]&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 00:46:15 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>File:Wk-promise-pov-mov.png</title>
			<link>http://50.77.162.165/wiki/File:Wk-promise-pov-mov.png</link>
			<guid>http://50.77.162.165/wiki/File:Wk-promise-pov-mov.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Mon, 31 May 2010 00:45:16 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Wk-promise-pov-mov.png</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Causeway's Trace Log Format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the Causeway viewer, individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:tree-item-labels.png|alt=Tree item labels]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To present the most useful information available, Causeway labels tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# User comments specified in the &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field, prefixed with &amp;quot;#&amp;quot;.&lt;br /&gt;
# Source code specified in the top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;span&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# Source file and function name specified in top call stack object. The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; object must include a &amp;lt;tt&amp;gt;name&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;source&amp;lt;/tt&amp;gt;.&lt;br /&gt;
# If none of the above, the label is a Causeway-generated comment, prefixed with &amp;quot;##&amp;quot;, e.g., ## unknown sender.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)''&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This graph describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution of the promise. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 23:09:48 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>File:Tree-item-labels.png</title>
			<link>http://50.77.162.165/wiki/File:Tree-item-labels.png</link>
			<guid>http://50.77.162.165/wiki/File:Tree-item-labels.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 22:41:21 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Tree-item-labels.png</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
=== Support Tools ===&lt;br /&gt;
&lt;br /&gt;
* Enable Causeway's debug view&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a debug view. As events are selected in the viewer, the debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;tt&amp;gt;getTwine()&amp;lt;/tt&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Support for visualizing graph filter algorithm&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Individual tree items represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.)''&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, Causeway ignores it, so it's not shown in the remaining trace records.)''&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This graph describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution of the promise. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 21:55:45 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Logging Promise-based Messaging in Waterken */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;code&amp;gt;getTwine()&amp;lt;/code&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:wk-promise-mechanics.png|alt=Waterken promise resolution]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This graph describes the mechanics of Waterken promise resolution.&lt;br /&gt;
&lt;br /&gt;
# buyer does an eventual send to product and registers a when-block on the resolution of that promise&lt;br /&gt;
# product receives the message and returns a result&lt;br /&gt;
# buyer receives the result and resolves the promise locally&lt;br /&gt;
# buyer executes the when-block&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution of the promise. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 20:46:06 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>File:Wk-promise-mechanics.png</title>
			<link>http://50.77.162.165/wiki/File:Wk-promise-mechanics.png</link>
			<guid>http://50.77.162.165/wiki/File:Wk-promise-mechanics.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 20:13:59 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Wk-promise-mechanics.png</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;code&amp;gt;getTwine()&amp;lt;/code&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality. Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution of the promise. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 04:27:55 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;code&amp;gt;getTwine()&amp;lt;/code&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
Your first traces are likely to be noisy and Causeway's views, baffling. It can take some careful consideration and cleverness to figure out why and what to do about it. &lt;br /&gt;
&lt;br /&gt;
Simple filters (e.g., hiding stack frames, options for more or less detail) are necessary but not sufficient. The right abstractions must be found to enhance program understanding, while maintaining causality.&lt;br /&gt;
&lt;br /&gt;
Currently, Causeway does not support user-specified filters that manipulate the message graph (DAG) structure. Our approach to debugging our filtering algorithm is described HERE. Once we have more experience, we expect to support user-specified filters.&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution of the promise. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 04:25:58 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Logging Promise-based Messaging in Waterken */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;code&amp;gt;getTwine()&amp;lt;/code&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message captures a stack trace and logs a &amp;lt;tt&amp;gt;Progressed&amp;lt;/tt&amp;gt; record to indicate that a state-based event contributed to the resolution of a promise. (If logging is off, it is a semantic no-op.)&lt;br /&gt;
&lt;br /&gt;
Let's say all 3 answers are true and the promise eventually resolves to true. It's reasonable to think of all 3 answers as contributing to the resolution of the promise. The &amp;lt;code&amp;gt;progress()&amp;lt;/code&amp;gt; message is used to promote state-based events to message order.&lt;br /&gt;
&lt;br /&gt;
The arrival of the first 2 answers causes a local state change (a counter is decremented), while the last answer causes a message send. Without event promotion, the promise resolution would have a single cause: the last answer.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a no-op.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Trace Log Records for Waterken Promise Resolution ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 04:20:09 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Logging Promise-based Messaging in Waterken */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;code&amp;gt;getTwine()&amp;lt;/code&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Our example program implements a promise-based distributed procedure for handling new purchase orders. Before an order is placed, certain conditions must be met: the item is in stock and available, the customer's account is in good standing, and the delivery options are up to date.&lt;br /&gt;
&lt;br /&gt;
An object residing in the &amp;quot;buyer&amp;quot; vat has remote references to objects residing in the &amp;quot;product&amp;quot; and &amp;quot;accounts&amp;quot; vats. &lt;br /&gt;
&lt;br /&gt;
The buyer queries the remote objects with asynchronous (non-blocking) message sends. A promise is a placeholder for the answer to a query; when the answer becomes available the promise resolves to that value.&lt;br /&gt;
&lt;br /&gt;
The code snippet below shows the 3 queries being fired off. The order of the incoming answers cannot be known. All 3 answers must be examined before the order is placed.&lt;br /&gt;
&lt;br /&gt;
Collecting the answers is handled by an &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; object. The &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method returns a promise for the result. By registering a when-block on the resolution of that promise, the invocation of &amp;lt;code&amp;gt;checkAnswers&amp;lt;/code&amp;gt; is synchronized with the collection of the answers.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=Raw, then filtered graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now, we can say more about the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; logic.&lt;br /&gt;
&lt;br /&gt;
In &amp;lt;code&amp;gt;AsyncAnd.run()&amp;lt;/code&amp;gt; a promise-resolver pair implements the communication synchronization. &lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a noop.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 02:54:33 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and can be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;code&amp;gt;getTwine()&amp;lt;/code&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
(Note: This section on promises is incomplete and will be updated soon. tstanley 5/24/10)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=foo]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a noop.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 01:26:53 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Getting Started */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file. This is a very useful option, especially in the beginning, when things aren't quite working. &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
''(''&lt;br /&gt;
'''Note:''' &lt;br /&gt;
''When this debug option is set, Causeway's JSON parser uses &amp;lt;code&amp;gt;getTwine()&amp;lt;/code&amp;gt;. This is an inefficient algorithm which is not likely to change anytime soon. The trace logs for the example programs are roughly 20K; the poor performance is noticed with logs &amp;gt; 250K.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
(Note: This section on promises is incomplete and will be updated soon. tstanley 5/24/10)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=foo]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a noop.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sun, 30 May 2010 01:25:42 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
Introduction, communicating events loops&lt;br /&gt;
&lt;br /&gt;
* Waterken&lt;br /&gt;
** promises&lt;br /&gt;
* AmbientTalk&lt;br /&gt;
** futures&lt;br /&gt;
&lt;br /&gt;
=== Getting Started ===&lt;br /&gt;
&lt;br /&gt;
* See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
* See HP Labs Technical Report for a more in-depth discussion of the material presented here. A careful read is not necessary but a quick skim to see what's there is a good idea.&lt;br /&gt;
&lt;br /&gt;
This documentation assumes an understanding of the purchase-order example program. &lt;br /&gt;
&lt;br /&gt;
* Read the source code. It's part of the E distribution and be found here.&lt;br /&gt;
&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/waterken/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
    &amp;lt;code&amp;gt;e/src/esrc/scripts/test/causeway/ambientTalk/sources&amp;lt;/code&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Also, we're asking that you write a version of the purchase-order example that runs on your platform, as one of your first test cases. It's best to start with the Ajax-style continuation-passing, using callbacks. This approach is less expressive than promises, but generating the trace log is more straightforward. &lt;br /&gt;
&lt;br /&gt;
* Browse the example programs in Causeway, e.g., Help &amp;gt;&amp;gt; Open Waterken Example (Ajax-style).&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
(Note: This section on promises is incomplete and will be updated soon. tstanley 5/24/10)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=foo]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a noop.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sat, 29 May 2010 22:16:26 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>Causeway Platform Developer</title>
			<link>http://50.77.162.165/wiki/Causeway_Platform_Developer</link>
			<guid>http://50.77.162.165/wiki/Causeway_Platform_Developer</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Logging Promise-based Messaging in Waterken */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Instrumenting a Platform to Generate Causeway Trace Logs ==&lt;br /&gt;
&lt;br /&gt;
See [[Causeway]] for user documentation, which includes instructions for launching Causeway from a command line shell.&lt;br /&gt;
&lt;br /&gt;
Setting Causeway's debug flag enables a Debug view. As events are selected in the viewer, the Debug view shows the corresponding trace record in the log file.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dcauseway_debug=true causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:debug-view.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Individual tree items (e.g. shown in the Message-order view above) represent events and their descriptive labels depend on the information available in the trace record for the event. Causeway labels the tree items according to the following priority.&lt;br /&gt;
&lt;br /&gt;
# The &amp;lt;tt&amp;gt;text&amp;lt;/tt&amp;gt; field string. This field is required for &amp;lt;tt&amp;gt;Comment&amp;lt;/tt&amp;gt; records; it is optional for &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt;, &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt;, and &amp;lt;tt&amp;gt;Resolved&amp;lt;/tt&amp;gt; records. (e.g. # Order placed for West Coast Buyers)&lt;br /&gt;
# If the trace record has at least one stack entry with a source and span, a single line of source code from the source file specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;_._(inventory).partInStock(partNo, teller);&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If there's no span, source file name and function name specified in the top stack entry. (e.g. &amp;lt;code&amp;gt;[buyer, 8] AsyncAnd.run&amp;lt;/code&amp;gt;)&lt;br /&gt;
# If nothing else, a Causeway comment. (e.g. &amp;lt;code&amp;gt;## unknown sender&amp;lt;/code&amp;gt;)&lt;br /&gt;
&lt;br /&gt;
== Causeway's Trace Log Format ==&lt;br /&gt;
&lt;br /&gt;
Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/. &lt;br /&gt;
&lt;br /&gt;
[[Image:event-types.png|alt=Trace log event types]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
When causality tracing is on the events are logged as follows.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
! Event !!     Record type&lt;br /&gt;
|-&lt;br /&gt;
| An eventual send to an object || Sent&lt;br /&gt;
|-&lt;br /&gt;
| A message delivery, starting a new turn || Got&lt;br /&gt;
|-&lt;br /&gt;
| Registration of a when-block, to execute when a promise resolves || SentIf&lt;br /&gt;
|-&lt;br /&gt;
| Returned result from a remote object, for local promise resolution || Returned&lt;br /&gt;
|-&lt;br /&gt;
| A state-based event contributes to promise resolution || Progressed&lt;br /&gt;
|-&lt;br /&gt;
| A promise resolves || Fulfilled or Rejected&lt;br /&gt;
|-&lt;br /&gt;
| Programmer logs a comment || Comment&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
[[Image:part-in-stock.png|alt=Ajax-style message send]]&lt;br /&gt;
&lt;br /&gt;
* a remote inventory object is queried for the availability of a part&lt;br /&gt;
* the inventory object reports true to &amp;lt;code&amp;gt;teller&amp;lt;/code&amp;gt;, a callback object&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The eventual send to the inventory object has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 3,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;timestamp&amp;quot; : 1274238401772,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 68 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Main.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/Main.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 48 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt; is a generated string which uniquely identifies a message.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;trace&amp;lt;/tt&amp;gt; is the stack capture at the point of the message send.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;loop&amp;lt;/tt&amp;gt; field identifies the vat by URI. By convention, Causeway picks up the part following &amp;quot;/-/&amp;quot;, in this case buyer, for a short display name.&lt;br /&gt;
&lt;br /&gt;
Note: The &amp;lt;tt&amp;gt;timestamp&amp;lt;/tt&amp;gt; field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;lqhjpwbbeemozk-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the product vat starts a new turn, turn 2.&lt;br /&gt;
Being at the top of a new turn, there is limited stack capture and getting a source span through Java reflection, is not practical.&lt;br /&gt;
&lt;br /&gt;
Reporting true to &amp;lt;tt&amp;gt;teller&amp;lt;/tt&amp;gt; has two log entries: a &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; and its corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/InventoryMaker.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 19 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;anchor&amp;lt;/tt&amp;gt; uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 10&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;ewrigzpctikrhk-1-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The corresponding &amp;lt;tt&amp;gt;Got&amp;lt;/tt&amp;gt; record matches on &amp;lt;tt&amp;gt;message&amp;lt;/tt&amp;gt;. The message delivery in the buyer vat starts a new turn, turn 10.&lt;br /&gt;
&lt;br /&gt;
=== Logging Promise-based Messaging in Waterken ===&lt;br /&gt;
&lt;br /&gt;
(Note: This section on promises is incomplete and will be updated soon. tstanley 5/24/10)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; partP = _._(inventory).partInStock(partNo);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; creditP = _._(creditBureau).checkCredit(name);&lt;br /&gt;
    Promise&amp;lt;Boolean&amp;gt; deliverP = _._(shipper).canDeliver(profile);&lt;br /&gt;
&lt;br /&gt;
    final Promise&amp;lt;Boolean&amp;gt; allOkP = &lt;br /&gt;
        new AsyncAnd(_).run(partP, creditP, deliverP);&lt;br /&gt;
&lt;br /&gt;
    /*&lt;br /&gt;
     * Register a when-block on promise returned by AsyncAnd. &lt;br /&gt;
     * The block executes when the promise resolves (either &lt;br /&gt;
     * fulfilled or rejected).&lt;br /&gt;
     */&lt;br /&gt;
&lt;br /&gt;
    _.when(allOkP, checkAnswers(_, inventory));&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Promise&amp;lt;Boolean&amp;gt; run(Promise&amp;lt;Boolean&amp;gt;... answers) {&lt;br /&gt;
        final Channel&amp;lt;Boolean&amp;gt; result = _.defer();&lt;br /&gt;
        final int[] expected = {answers.length};&lt;br /&gt;
        for (Promise&amp;lt;Boolean&amp;gt; answerP : answers) {&lt;br /&gt;
&lt;br /&gt;
            /*&lt;br /&gt;
             * Register a when-block on each promise. The block executes&lt;br /&gt;
             * when the promise resolves (either fulfilled or rejected).&lt;br /&gt;
             */&lt;br /&gt;
&lt;br /&gt;
            _.when(answerP, new DoAnswer(expected, result.resolver));&lt;br /&gt;
        }&lt;br /&gt;
        return result.promise;&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
We start with a detailed description of a single message, &amp;lt;code&amp;gt;partInStock&amp;lt;/code&amp;gt;. Then we'll look at how &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; collects the answers and reports a final result.&lt;br /&gt;
&lt;br /&gt;
* The graph structure representing the message send and resolution&lt;br /&gt;
* The events logged&lt;br /&gt;
* The graph filter&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:raw-d1-d2.png|alt=foo]]&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    public Void fulfill(Boolean answer) {&lt;br /&gt;
        if (answer) {&lt;br /&gt;
            myExpected[0]--;&lt;br /&gt;
            if (myExpected[0] == 0) {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Resolve the promise with true.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.apply(true);&lt;br /&gt;
            } else {&lt;br /&gt;
                /*&lt;br /&gt;
                 * Progress had been made in resolving the promise.&lt;br /&gt;
                 * If logging is on, a Progressed event record is written.&lt;br /&gt;
                 * If logging is off, this is a noop.&lt;br /&gt;
                 */&lt;br /&gt;
                myResolver.progress();&lt;br /&gt;
            }&lt;br /&gt;
        } else {&lt;br /&gt;
            /*&lt;br /&gt;
             * Resolve the promise with false. Notice that this &lt;br /&gt;
             * short-circuits the logic: any remaining expected answers&lt;br /&gt;
             * are ignored.&lt;br /&gt;
             */&lt;br /&gt;
            myResolver.apply(false);&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 59 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;InventoryMaker.InventoryX.partInStock&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/InventoryMaker.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Returned&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/product/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 2&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;jisyrc633lurdq-2-0-return&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Fulfilled&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 6&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Progressed&amp;quot;, &amp;quot;org.ref_send.log.Resolved&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 2,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 9&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 52 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.DoAnswer.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 26 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.Got&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 1,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 15&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.CheckAnswers.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Consider the sequence of events shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:promise-part-in-stock.png|alt=Promise-based message send]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Note: For the purpose of describing the trace records the screenshot shows events that actually will be filtered by Causeway and do not appear in the message-order view.&lt;br /&gt;
&lt;br /&gt;
The registration of when-blocks, logged as &amp;lt;tt&amp;gt;SentIf&amp;lt;/tt&amp;gt; records, are filtered from the message-order view, as they don't contribute to the understanding of message flow. However, they do appear in process-order, as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:sentifs-po-view.png|alt=SentIf events in process-order view]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 8,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p6&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w6&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 72 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
    &amp;quot;class&amp;quot; : [ &amp;quot;org.ref_send.log.SentIf&amp;quot;, &amp;quot;org.ref_send.log.Sent&amp;quot;, &amp;quot;org.ref_send.log.Event&amp;quot; ],&lt;br /&gt;
    &amp;quot;anchor&amp;quot; : {&lt;br /&gt;
      &amp;quot;number&amp;quot; : 5,&lt;br /&gt;
      &amp;quot;turn&amp;quot; : {&lt;br /&gt;
        &amp;quot;loop&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/&amp;quot;,&lt;br /&gt;
        &amp;quot;number&amp;quot; : 3&lt;br /&gt;
      }&lt;br /&gt;
    },&lt;br /&gt;
    &amp;quot;condition&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#p3&amp;quot;,&lt;br /&gt;
    &amp;quot;message&amp;quot; : &amp;quot;http://localhost:8080/-/buyer/#w3&amp;quot;,&lt;br /&gt;
    &amp;quot;trace&amp;quot; : {&lt;br /&gt;
      &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/AsyncAnd.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 87 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 63 ] ]&lt;br /&gt;
        }, {&lt;br /&gt;
          &amp;quot;name&amp;quot; : &amp;quot;Buyer.Buy.fulfill&amp;quot;,&lt;br /&gt;
          &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_promise/Buyer.java&amp;quot;,&lt;br /&gt;
          &amp;quot;span&amp;quot; : [ [ 44 ] ]&lt;br /&gt;
        } ]&lt;br /&gt;
    }&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in Waterken ===&lt;br /&gt;
&lt;br /&gt;
Due to the expense of stack capture in Java, tracing in Waterken incurs roughly, an order of magnitude performance penalty. If tracing is off, there is no penalty.&lt;br /&gt;
&lt;br /&gt;
Waterken guarantees message order delivery and in addition, if a connection is dropped, there's enough information to know about partial success. For example, if 2 messages (msg1, msg2) are sent from vat A to vat B, they are guaranteed to be processed in the order sent. If the connection is dropped after msg1 is successfully sent, when the connection is re-established, it is known that only msg2 must be resent.&lt;br /&gt;
&lt;br /&gt;
The identifiers used to support these guarantees are also used for tracing. The advantage of these multi-purpose identifiers is there is no overhead when tracing is off (i.e., unique message identifiers, just for tracing, are not sent out over the wire.)&lt;br /&gt;
&lt;br /&gt;
Note: Resending a message after a connection is re-established can result in 2 identical &amp;lt;tt&amp;gt;Sent&amp;lt;/tt&amp;gt; events being logged. Causeway notices when the event records are identical and ignores the duplicate.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Logging Ajax-style Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Logging Futures-based Messaging in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
=== Performance Issues in AmbientTalk ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Sat, 29 May 2010 00:50:32 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway_Platform_Developer</comments>		</item>
		<item>
			<title>File:Raw-d1-d2.png</title>
			<link>http://50.77.162.165/wiki/File:Raw-d1-d2.png</link>
			<guid>http://50.77.162.165/wiki/File:Raw-d1-d2.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Fri, 28 May 2010 23:55:33 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Raw-d1-d2.png</comments>		</item>
		<item>
			<title>File:Wk-promise-d2.png</title>
			<link>http://50.77.162.165/wiki/File:Wk-promise-d2.png</link>
			<guid>http://50.77.162.165/wiki/File:Wk-promise-d2.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Fri, 28 May 2010 21:12:30 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Wk-promise-d2.png</comments>		</item>
		<item>
			<title>File:Wk-promise-d1.png</title>
			<link>http://50.77.162.165/wiki/File:Wk-promise-d1.png</link>
			<guid>http://50.77.162.165/wiki/File:Wk-promise-d1.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Fri, 28 May 2010 21:11:33 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Wk-promise-d1.png</comments>		</item>
		<item>
			<title>File:Wk-promise-raw.png</title>
			<link>http://50.77.162.165/wiki/File:Wk-promise-raw.png</link>
			<guid>http://50.77.162.165/wiki/File:Wk-promise-raw.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Fri, 28 May 2010 21:10:51 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Wk-promise-raw.png</comments>		</item>
		<item>
			<title>Causeway</title>
			<link>http://50.77.162.165/wiki/Causeway</link>
			<guid>http://50.77.162.165/wiki/Causeway</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Menu Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Causeway: A message-oriented distributed debugger ==&lt;br /&gt;
&lt;br /&gt;
Causeway is an open source postmortem distributed debugger for examining the behavior of distributed programs built as communicating event loops. Its message-oriented approach follows the flow of messages across process and machine boundaries.&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
The simplest way to get started is to launch Causeway from a command line shell and then open one of the examples.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd e/src/esrc/scripts&lt;br /&gt;
$ rune causeway.e-swt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From the Welcome view select an example program from the Help menu.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Welcome-help.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Optionally, the sources and trace logs can be specified on the command line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dsrc=&amp;lt;srcRootDir&amp;gt; causeway.e-swt &amp;lt;logs&amp;gt;...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Java's default memory settings are sufficient for the examples but larger programs need more stack and heap space.&lt;br /&gt;
Use the -Xss (stack) and -Xmx (heap) options to increase Java default memory sizes. Follow the amount with m for Mb or k for Kb. &lt;br /&gt;
Notice the format does not follow the name=value convention. The J option tells rune to pass the option to Java.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -J-Xss128m -J-Xmx128m causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Waterken Example (Ajax-style) ==&lt;br /&gt;
&lt;br /&gt;
This Java program ran on the Waterken server instrumented to generate Causeway's trace log format. The program is a distributed implementation of a procedure for handling new purchase orders.&lt;br /&gt;
&lt;br /&gt;
Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the “buyer” process (or vat) has remote references to objects &lt;br /&gt;
residing in the “product” and “accounts” processes. The buyer queries the remote objects with asynchronous message sends. This example uses Ajax-style continuation-passing: a request carries a callback argument to which a response should be sent.&lt;br /&gt;
&lt;br /&gt;
The screenshot below shows the principal views from Causeway's postmortem display for this example.&lt;br /&gt;
&lt;br /&gt;
== Causeway Viewer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:viewer.png|alt=Causeway Viewer|Causeway Viewer]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Search view (leftmost): This view lists bookmarks and results of search commands.&lt;br /&gt;
&lt;br /&gt;
* Process-order view: This view lists events in chronological order, organized by vat. For example, clicking the &amp;quot;buyer&amp;quot; tab shows all events logged by the buyer vat. The events are ordered by turn number and within each turn, an intra-turn number.&lt;br /&gt;
&lt;br /&gt;
* Message-order view: This view shows the order in which events caused other events by sending messages. Message order is reflected in the outline structure: nested events were caused by the parent event. Causeway assigns each vat a color so we can see when message flow crosses vat boundaries. &lt;br /&gt;
&lt;br /&gt;
* Stack Explorer and Source view: These views are familiar from sequential debugging.&lt;br /&gt;
&lt;br /&gt;
=== Menu Commands ===&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Set Source Root...''' point at the root directory of the sources.&lt;br /&gt;
&lt;br /&gt;
For example, for the trace record pathname shown below,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;trace&amp;quot; : {&lt;br /&gt;
  &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
      &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
      &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
    } ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
set the source root to the underlined prefix.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;~/Desktop/waterken/example/src/&amp;lt;/u&amp;gt;org/waterken/purchase_ajax/AsyncAnd.java&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Cannot set multiple source roots.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Open''' select log files to open.&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Cannot select a folder. Must go into the folder and select the multiple files.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Export...''' translates Causeway's message graph (DAG) to the GraphViz DOT format and writes the dot file to a local disk. The dot file is a human-readable text file. It specifies a graph using the DOT language. [http://www.graphviz.org/ GraphViz] must be downloaded and installed to see the graph visualization. The graph below was generated for the Waterken example described above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:messageGraph.png|alt=Causeway's DAG as GraphViz graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Search &amp;gt;&amp;gt; Find Lost Messages''' reports sent messages that were apparently not received.&lt;br /&gt;
&lt;br /&gt;
'''Tools &amp;gt;&amp;gt; Set Filter Options...''' presents all source files seen during parsing of the trace logs. Individual files can be filtered out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:filter-async-and.png|alt=Filter options dialog]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Filtering &amp;lt;code&amp;gt;AsyncAnd.java&amp;lt;/code&amp;gt; hides all stack frames whose source is in the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; class, resulting in simpler, more abstract message-order view and GraphViz graph (as shown below).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:filtered-mov.png|alt=Message-order view with AsyncAnd.java filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:filtered-mg.png|alt=Message graph with AsyncAnd.java filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''(Limitation: These settings are not persistent across launches.)''&lt;br /&gt;
&lt;br /&gt;
=== Context Menu Commands ===&lt;br /&gt;
&lt;br /&gt;
'''Bookmark''' bookmarks the currently selected event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:bookmark.png|alt=Bookmark menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Find Multiples''' finds the multiple causes of a joining event, e.g., finds the multiple sends to a target showing a multiples icon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:find-multiples.png|alt=Find multiples menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Search Stacks''' finds all events that contain a stack frame for this source line, e.g., all events passing through this source code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:search-stacks.png|alt=Search stacks menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Matching events must match exactly on source and line position as specified in the trace logs. Not all lines in the source view can be searched and currently, there is no visual indication identifying the lines that can be searched.)''&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[[Causeway Platform Developer]] to understand how to instrument a platform to generate Causeway trace logs.&lt;br /&gt;
&lt;br /&gt;
[http://www.hpl.hp.com/techreports/2009/HPL-2009-78.html HP Labs Technical Report] presents our experience with the Waterken web server which we have instrumented to generate Causeway's language-neutral trace log format.&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=QeqcGa7HlBk Screencast] presents a brief demonstration of Causeway, using the example from the HP Tech Report.&lt;br /&gt;
&lt;br /&gt;
[http://waterken.sourceforge.net/debug/ Debugging a Waterken application] explains how to configure the Waterken server to emit the [[wikipedia:JSON|JSON]] debugging records understood by Causeway.&lt;br /&gt;
&lt;br /&gt;
[http://code.google.com/p/ambienttalk/wiki/Debugging Debugging AmbientTalk using Causeway] explains how to emit Causeway debugging records, in order to use Causeway to debug AmbientTalk applications.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Wed, 26 May 2010 22:50:38 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway</comments>		</item>
		<item>
			<title>Causeway</title>
			<link>http://50.77.162.165/wiki/Causeway</link>
			<guid>http://50.77.162.165/wiki/Causeway</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Menu Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Causeway: A message-oriented distributed debugger ==&lt;br /&gt;
&lt;br /&gt;
Causeway is an open source postmortem distributed debugger for examining the behavior of distributed programs built as communicating event loops. Its message-oriented approach follows the flow of messages across process and machine boundaries.&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
The simplest way to get started is to launch Causeway from a command line shell and then open one of the examples.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd e/src/esrc/scripts&lt;br /&gt;
$ rune causeway.e-swt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From the Welcome view select an example program from the Help menu.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Welcome-help.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Optionally, the sources and trace logs can be specified on the command line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dsrc=&amp;lt;srcRootDir&amp;gt; causeway.e-swt &amp;lt;logs&amp;gt;...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Java's default memory settings are sufficient for the examples but larger programs need more stack and heap space.&lt;br /&gt;
Use the -Xss (stack) and -Xmx (heap) options to increase Java default memory sizes. Follow the amount with m for Mb or k for Kb. &lt;br /&gt;
Notice the format does not follow the name=value convention. The J option tells rune to pass the option to Java.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -J-Xss128m -J-Xmx128m causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Waterken Example (Ajax-style) ==&lt;br /&gt;
&lt;br /&gt;
This Java program ran on the Waterken server instrumented to generate Causeway's trace log format. The program is a distributed implementation of a procedure for handling new purchase orders.&lt;br /&gt;
&lt;br /&gt;
Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the “buyer” process (or vat) has remote references to objects &lt;br /&gt;
residing in the “product” and “accounts” processes. The buyer queries the remote objects with asynchronous message sends. This example uses Ajax-style continuation-passing: a request carries a callback argument to which a response should be sent.&lt;br /&gt;
&lt;br /&gt;
The screenshot below shows the principal views from Causeway's postmortem display for this example.&lt;br /&gt;
&lt;br /&gt;
== Causeway Viewer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:viewer.png|alt=Causeway Viewer|Causeway Viewer]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Search view (leftmost): This view lists bookmarks and results of search commands.&lt;br /&gt;
&lt;br /&gt;
* Process-order view: This view lists events in chronological order, organized by vat. For example, clicking the &amp;quot;buyer&amp;quot; tab shows all events logged by the buyer vat. The events are ordered by turn number and within each turn, an intra-turn number.&lt;br /&gt;
&lt;br /&gt;
* Message-order view: This view shows the order in which events caused other events by sending messages. Message order is reflected in the outline structure: nested events were caused by the parent event. Causeway assigns each vat a color so we can see when message flow crosses vat boundaries. &lt;br /&gt;
&lt;br /&gt;
* Stack Explorer and Source view: These views are familiar from sequential debugging.&lt;br /&gt;
&lt;br /&gt;
=== Menu Commands ===&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Set Source Root...''' point at the root directory of the sources.&lt;br /&gt;
&lt;br /&gt;
For example, for the trace record pathname shown below,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;trace&amp;quot; : {&lt;br /&gt;
  &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
      &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
      &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
    } ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
set the source root to the underlined prefix.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;~/Desktop/waterken/example/src/&amp;lt;/u&amp;gt;org/waterken/purchase_ajax/AsyncAnd.java&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Cannot set multiple source roots.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Open''' select log files to open.&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Cannot select a folder. Must go into the folder and select the multiple files.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Export...''' translates Causeway's message graph (DAG) to the GraphViz DOT format and writes the dot file to a local disk. The dot file is a human-readable text file. It specifies a graph using the DOT language. [http://www.graphviz.org/ GraphViz] must be downloaded and installed to see the graph visualization. The graph below was generated for the Waterken example described above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:messageGraph.png|alt=Causeway's DAG as GraphViz graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Search &amp;gt;&amp;gt; Find Lost Messages''' reports sent messages that were apparently not received.&lt;br /&gt;
&lt;br /&gt;
'''Tools &amp;gt;&amp;gt; Set Filter Options...''' presents all source files seen during parsing of the trace logs. Individual files can be filtered out.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:filter-async-and.png|alt=Filter options dialog]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here, &amp;lt;code&amp;gt;AsyncAnd.java&amp;lt;/code&amp;gt; is selected and all stack frames whose source is in the &amp;lt;code&amp;gt;AsyncAnd&amp;lt;/code&amp;gt; class are hidden. The resulting message-order view and GraphViz graph are simpler and more abstract.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:filtered-mov.png|alt=Message-order view with AsyncAnd.java filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:filtered-mg.png|alt=Message graph with AsyncAnd.java filter]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''(Limitation: These settings are not persistent across launches.)''&lt;br /&gt;
&lt;br /&gt;
=== Context Menu Commands ===&lt;br /&gt;
&lt;br /&gt;
'''Bookmark''' bookmarks the currently selected event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:bookmark.png|alt=Bookmark menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Find Multiples''' finds the multiple causes of a joining event, e.g., finds the multiple sends to a target showing a multiples icon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:find-multiples.png|alt=Find multiples menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Search Stacks''' finds all events that contain a stack frame for this source line, e.g., all events passing through this source code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:search-stacks.png|alt=Search stacks menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Matching events must match exactly on source and line position as specified in the trace logs. Not all lines in the source view can be searched and currently, there is no visual indication identifying the lines that can be searched.)''&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[[Causeway Platform Developer]] to understand how to instrument a platform to generate Causeway trace logs.&lt;br /&gt;
&lt;br /&gt;
[http://www.hpl.hp.com/techreports/2009/HPL-2009-78.html HP Labs Technical Report] presents our experience with the Waterken web server which we have instrumented to generate Causeway's language-neutral trace log format.&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=QeqcGa7HlBk Screencast] presents a brief demonstration of Causeway, using the example from the HP Tech Report.&lt;br /&gt;
&lt;br /&gt;
[http://waterken.sourceforge.net/debug/ Debugging a Waterken application] explains how to configure the Waterken server to emit the [[wikipedia:JSON|JSON]] debugging records understood by Causeway.&lt;br /&gt;
&lt;br /&gt;
[http://code.google.com/p/ambienttalk/wiki/Debugging Debugging AmbientTalk using Causeway] explains how to emit Causeway debugging records, in order to use Causeway to debug AmbientTalk applications.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Wed, 26 May 2010 22:44:19 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway</comments>		</item>
		<item>
			<title>File:Filtered-mg.png</title>
			<link>http://50.77.162.165/wiki/File:Filtered-mg.png</link>
			<guid>http://50.77.162.165/wiki/File:Filtered-mg.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Wed, 26 May 2010 21:53:59 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Filtered-mg.png</comments>		</item>
		<item>
			<title>File:Filtered-mov.png</title>
			<link>http://50.77.162.165/wiki/File:Filtered-mov.png</link>
			<guid>http://50.77.162.165/wiki/File:Filtered-mov.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Wed, 26 May 2010 21:53:31 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Filtered-mov.png</comments>		</item>
		<item>
			<title>Causeway</title>
			<link>http://50.77.162.165/wiki/Causeway</link>
			<guid>http://50.77.162.165/wiki/Causeway</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;/* Menu Commands */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Causeway: A message-oriented distributed debugger ==&lt;br /&gt;
&lt;br /&gt;
Causeway is an open source postmortem distributed debugger for examining the behavior of distributed programs built as communicating event loops. Its message-oriented approach follows the flow of messages across process and machine boundaries.&lt;br /&gt;
&lt;br /&gt;
== Getting Started ==&lt;br /&gt;
&lt;br /&gt;
The simplest way to get started is to launch Causeway from a command line shell and then open one of the examples.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ cd e/src/esrc/scripts&lt;br /&gt;
$ rune causeway.e-swt&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
From the Welcome view select an example program from the Help menu.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:Welcome-help.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Optionally, the sources and trace logs can be specified on the command line.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -Dsrc=&amp;lt;srcRootDir&amp;gt; causeway.e-swt &amp;lt;logs&amp;gt;...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Java's default memory settings are sufficient for the examples but larger programs need more stack and heap space.&lt;br /&gt;
Use the -Xss (stack) and -Xmx (heap) options to increase Java default memory sizes. Follow the amount with m for Mb or k for Kb. &lt;br /&gt;
Notice the format does not follow the name=value convention. The J option tells rune to pass the option to Java.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$ rune -J-Xss128m -J-Xmx128m causeway.e-swt &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Waterken Example (Ajax-style) ==&lt;br /&gt;
&lt;br /&gt;
This Java program ran on the Waterken server instrumented to generate Causeway's trace log format. The program is a distributed implementation of a procedure for handling new purchase orders.&lt;br /&gt;
&lt;br /&gt;
Before an order is placed, certain conditions must be met: the item is in stock and available, the customer’s account is in good standing, and the delivery options are up to date. An object residing in the “buyer” process (or vat) has remote references to objects &lt;br /&gt;
residing in the “product” and “accounts” processes. The buyer queries the remote objects with asynchronous message sends. This example uses Ajax-style continuation-passing: a request carries a callback argument to which a response should be sent.&lt;br /&gt;
&lt;br /&gt;
The screenshot below shows the principal views from Causeway's postmortem display for this example.&lt;br /&gt;
&lt;br /&gt;
== Causeway Viewer ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:viewer.png|alt=Causeway Viewer|Causeway Viewer]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* Search view (leftmost): This view lists bookmarks and results of search commands.&lt;br /&gt;
&lt;br /&gt;
* Process-order view: This view lists events in chronological order, organized by vat. For example, clicking the &amp;quot;buyer&amp;quot; tab shows all events logged by the buyer vat. The events are ordered by turn number and within each turn, an intra-turn number.&lt;br /&gt;
&lt;br /&gt;
* Message-order view: This view shows the order in which events caused other events by sending messages. Message order is reflected in the outline structure: nested events were caused by the parent event. Causeway assigns each vat a color so we can see when message flow crosses vat boundaries. &lt;br /&gt;
&lt;br /&gt;
* Stack Explorer and Source view: These views are familiar from sequential debugging.&lt;br /&gt;
&lt;br /&gt;
=== Menu Commands ===&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Set Source Root...''' point at the root directory of the sources.&lt;br /&gt;
&lt;br /&gt;
For example, for the trace record pathname shown below,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;quot;trace&amp;quot; : {&lt;br /&gt;
  &amp;quot;calls&amp;quot; : [ {&lt;br /&gt;
      &amp;quot;name&amp;quot; : &amp;quot;AsyncAnd.run&amp;quot;,&lt;br /&gt;
      &amp;quot;source&amp;quot; : &amp;quot;org/waterken/purchase_ajax/AsyncAnd.java&amp;quot;&lt;br /&gt;
    } ]&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
set the source root to the underlined prefix.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;~/Desktop/waterken/example/src/&amp;lt;/u&amp;gt;org/waterken/purchase_ajax/AsyncAnd.java&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Cannot set multiple source roots.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Open''' select log files to open.&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Cannot select a folder. Must go into the folder and select the multiple files.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''File &amp;gt;&amp;gt; Export...''' translates Causeway's message graph (DAG) to the GraphViz DOT format and writes the dot file to a local disk. The dot file is a human-readable text file. It specifies a graph using the DOT language. [http://www.graphviz.org/ GraphViz] must be downloaded and installed to see the graph visualization. The graph below was generated for the Waterken example described above.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:messageGraph.png|alt=Causeway's DAG as GraphViz graph]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Search &amp;gt;&amp;gt; Find Lost Messages''' reports sent messages that were apparently not received.&lt;br /&gt;
&lt;br /&gt;
'''Tools &amp;gt;&amp;gt; Set Filter Options...''' presents all source files seen during parsing of the trace logs. Individual files can be filtered out.&lt;br /&gt;
&lt;br /&gt;
''(Limitation: These settings are not persistent across launches.)''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:filter-async-and.png|alt=Filter options dialog]]&lt;br /&gt;
&lt;br /&gt;
=== Context Menu Commands ===&lt;br /&gt;
&lt;br /&gt;
'''Bookmark''' bookmarks the currently selected event.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:bookmark.png|alt=Bookmark menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Find Multiples''' finds the multiple causes of a joining event, e.g., finds the multiple sends to a target showing a multiples icon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:find-multiples.png|alt=Find multiples menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Search Stacks''' finds all events that contain a stack frame for this source line, e.g., all events passing through this source code.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Image:search-stacks.png|alt=Search stacks menu item]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
''(Limitation: Matching events must match exactly on source and line position as specified in the trace logs. Not all lines in the source view can be searched and currently, there is no visual indication identifying the lines that can be searched.)''&lt;br /&gt;
&lt;br /&gt;
== See Also ==&lt;br /&gt;
&lt;br /&gt;
[[Causeway Platform Developer]] to understand how to instrument a platform to generate Causeway trace logs.&lt;br /&gt;
&lt;br /&gt;
[http://www.hpl.hp.com/techreports/2009/HPL-2009-78.html HP Labs Technical Report] presents our experience with the Waterken web server which we have instrumented to generate Causeway's language-neutral trace log format.&lt;br /&gt;
&lt;br /&gt;
[http://www.youtube.com/watch?v=QeqcGa7HlBk Screencast] presents a brief demonstration of Causeway, using the example from the HP Tech Report.&lt;br /&gt;
&lt;br /&gt;
[http://waterken.sourceforge.net/debug/ Debugging a Waterken application] explains how to configure the Waterken server to emit the [[wikipedia:JSON|JSON]] debugging records understood by Causeway.&lt;br /&gt;
&lt;br /&gt;
[http://code.google.com/p/ambienttalk/wiki/Debugging Debugging AmbientTalk using Causeway] explains how to emit Causeway debugging records, in order to use Causeway to debug AmbientTalk applications.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Applications]]&lt;/div&gt;</description>
			<pubDate>Wed, 26 May 2010 21:51:56 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/Talk:Causeway</comments>		</item>
		<item>
			<title>File:Filter-async-and.png</title>
			<link>http://50.77.162.165/wiki/File:Filter-async-and.png</link>
			<guid>http://50.77.162.165/wiki/File:Filter-async-and.png</guid>
			<description>&lt;p&gt;Tstanley:&amp;#32;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&lt;/div&gt;</description>
			<pubDate>Wed, 26 May 2010 21:50:42 GMT</pubDate>			<dc:creator>Tstanley</dc:creator>			<comments>http://50.77.162.165/wiki/File_talk:Filter-async-and.png</comments>		</item>
	</channel>
</rss>