Causeway Platform Developer

From Erights

(Difference between revisions)
Jump to: navigation, search
(Logging Promise-based Messaging in Waterken)
(Logging Promise-based Messaging in Waterken)
Line 173: Line 173:
<pre>
<pre>
-
  "class" : [ "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
+
    "class" : [ "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 1,
+
       "number" : 2,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/",
         "loop" : "http://localhost:8080/-/buyer/",
-
         "number" : 2
+
         "number" : 3
       }
       }
     },
     },
-
     "message" : "3t4ubiwssjzuy2-2-0",
+
     "message" : "jisyrc633lurdq-2-0",
     "trace" : {
     "trace" : {
       "calls" : [ {
       "calls" : [ {
           "name" : "Buyer.Buy.fulfill",
           "name" : "Buyer.Buy.fulfill",
           "source" : "org/waterken/purchase_promise/Buyer.java",
           "source" : "org/waterken/purchase_promise/Buyer.java",
-
           "span" : [ [ 39 ] ]
+
           "span" : [ [ 59 ] ]
         }, {
         }, {
           "name" : "Buyer.Buy.fulfill",
           "name" : "Buyer.Buy.fulfill",
           "source" : "org/waterken/purchase_promise/Buyer.java",
           "source" : "org/waterken/purchase_promise/Buyer.java",
-
           "span" : [ [ 24 ] ]
+
           "span" : [ [ 44 ] ]
         } ]
         } ]
     }
     }
Line 198: Line 198:
     "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 0,
+
       "number" : 1,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/product/",
         "loop" : "http://localhost:8080/-/buyer/product/",
-
         "number" : 1
+
         "number" : 2
       }
       }
     },
     },
-
     "message" : "3t4ubiwssjzuy2-2-0",
+
     "message" : "jisyrc633lurdq-2-0",
     "trace" : {
     "trace" : {
       "calls" : [ {
       "calls" : [ {
Line 216: Line 216:
     "class" : [ "org.ref_send.log.Returned", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.Returned", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 1,
+
       "number" : 2,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/product/",
         "loop" : "http://localhost:8080/-/buyer/product/",
-
         "number" : 1
+
         "number" : 2
       }
       }
     },
     },
-
     "message" : "3t4ubiwssjzuy2-2-0-return"
+
     "message" : "jisyrc633lurdq-2-0-return",
</pre>
</pre>
Line 228: Line 228:
     "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 0,
+
       "number" : 1,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/",
         "loop" : "http://localhost:8080/-/buyer/",
-
         "number" : 5
+
         "number" : 6
       }
       }
     },
     },
-
     "message" : "3t4ubiwssjzuy2-2-0-return"
+
     "message" : "jisyrc633lurdq-2-0-return",
</pre>
</pre>
Line 240: Line 240:
     "class" : [ "org.ref_send.log.Fulfilled", "org.ref_send.log.Resolved", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.Fulfilled", "org.ref_send.log.Resolved", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 1,
+
       "number" : 2,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/",
         "loop" : "http://localhost:8080/-/buyer/",
-
         "number" : 5
+
         "number" : 6
       }
       }
     },
     },
-
     "condition" : "http://localhost:8080/-/buyer/#p3"
+
     "condition" : "http://localhost:8080/-/buyer/#p3",
</pre>
</pre>
Line 252: Line 252:
     "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 0,
+
       "number" : 1,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/",
         "loop" : "http://localhost:8080/-/buyer/",
-
         "number" : 8
+
         "number" : 9
       }
       }
     },
     },
Line 270: Line 270:
     "class" : [ "org.ref_send.log.Progressed", "org.ref_send.log.Resolved", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.Progressed", "org.ref_send.log.Resolved", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 1,
+
       "number" : 2,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/",
         "loop" : "http://localhost:8080/-/buyer/",
-
         "number" : 8
+
         "number" : 9
       }
       }
     },
     },
Line 281: Line 281:
           "name" : "AsyncAnd.DoAnswer.fulfill",
           "name" : "AsyncAnd.DoAnswer.fulfill",
           "source" : "org/waterken/purchase_promise/AsyncAnd.java",
           "source" : "org/waterken/purchase_promise/AsyncAnd.java",
-
           "span" : [ [ 34 ] ]
+
           "span" : [ [ 52 ] ]
         }, {
         }, {
           "name" : "AsyncAnd.DoAnswer.fulfill",
           "name" : "AsyncAnd.DoAnswer.fulfill",
           "source" : "org/waterken/purchase_promise/AsyncAnd.java",
           "source" : "org/waterken/purchase_promise/AsyncAnd.java",
-
           "span" : [ [ 16 ] ]
+
           "span" : [ [ 26 ] ]
         } ]
         } ]
     }
     }
Line 293: Line 293:
     "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 0,
+
       "number" : 1,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/",
         "loop" : "http://localhost:8080/-/buyer/",
-
         "number" : 14
+
         "number" : 15
       }
       }
     },
     },
Line 317: Line 317:
     "class" : [ "org.ref_send.log.SentIf", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.SentIf", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 7,
+
       "number" : 8,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/",
         "loop" : "http://localhost:8080/-/buyer/",
-
         "number" : 2
+
         "number" : 3
       }
       }
     },
     },
Line 329: Line 329:
           "name" : "Buyer.Buy.fulfill",
           "name" : "Buyer.Buy.fulfill",
           "source" : "org/waterken/purchase_promise/Buyer.java",
           "source" : "org/waterken/purchase_promise/Buyer.java",
-
           "span" : [ [ 46 ] ]
+
           "span" : [ [ 72 ] ]
         }, {
         }, {
           "name" : "Buyer.Buy.fulfill",
           "name" : "Buyer.Buy.fulfill",
           "source" : "org/waterken/purchase_promise/Buyer.java",
           "source" : "org/waterken/purchase_promise/Buyer.java",
-
           "span" : [ [ 24 ] ]
+
           "span" : [ [ 44 ] ]
         } ]
         } ]
     }
     }
Line 341: Line 341:
     "class" : [ "org.ref_send.log.SentIf", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
     "class" : [ "org.ref_send.log.SentIf", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
     "anchor" : {
     "anchor" : {
-
       "number" : 4,
+
       "number" : 5,
       "turn" : {
       "turn" : {
         "loop" : "http://localhost:8080/-/buyer/",
         "loop" : "http://localhost:8080/-/buyer/",
-
         "number" : 2
+
         "number" : 3
       }
       }
     },
     },
Line 353: Line 353:
           "name" : "AsyncAnd.run",
           "name" : "AsyncAnd.run",
           "source" : "org/waterken/purchase_promise/AsyncAnd.java",
           "source" : "org/waterken/purchase_promise/AsyncAnd.java",
-
           "span" : [ [ 60 ] ]
+
           "span" : [ [ 87 ] ]
         }, {
         }, {
           "name" : "Buyer.Buy.fulfill",
           "name" : "Buyer.Buy.fulfill",
           "source" : "org/waterken/purchase_promise/Buyer.java",
           "source" : "org/waterken/purchase_promise/Buyer.java",
-
           "span" : [ [ 43 ] ]
+
           "span" : [ [ 63 ] ]
         }, {
         }, {
           "name" : "Buyer.Buy.fulfill",
           "name" : "Buyer.Buy.fulfill",
           "source" : "org/waterken/purchase_promise/Buyer.java",
           "source" : "org/waterken/purchase_promise/Buyer.java",
-
           "span" : [ [ 24 ] ]
+
           "span" : [ [ 44 ] ]
         } ]
         } ]
     }
     }

Revision as of 00:50, 26 May 2010

Contents

Instrumenting a Platform to Generate Causeway Trace Logs

See Causeway for user documentation, which includes instructions for launching Causeway from a command line shell.

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.

$ rune -Dcauseway_debug=true causeway.e-swt 


Image:debug-view.png


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.

  1. The text field string. This field is required for Comment records; it is optional for Sent, SentIf, and Resolved records. (e.g. # Order placed for West Coast Buyers)
  2. 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. _._(inventory).partInStock(partNo, teller);)
  3. If there's no span, source file name and function name specified in the top stack entry. (e.g. [buyer, 8] AsyncAnd.run)
  4. If nothing else, a Causeway comment. (e.g. ## unknown sender)

Causeway's Trace Log Format

Causeway supports the trace log format defined by Tyler Close at waterken.sourceforge.net/debug/.

Trace log event types


When causality tracing is on the events are logged as follows.

Event Record type
An eventual send to an object Sent
A message delivery, starting a new turn Got
Registration of a when-block, to execute when a promise resolves SentIf
Returned result from a remote object, for local promise resolution Returned
A state-based event contributes to promise resolution Progressed
A promise resolves Fulfilled or Rejected
Programmer logs a comment Comment


Logging Ajax-style Messaging in Waterken

Consider the sequence of events shown below.

Ajax-style message send

  • a remote inventory object is queried for the availability of a part
  • the inventory object reports true to teller, a callback object


The eventual send to the inventory object has two log entries: a Sent and its corresponding Got.

    "class" : [ "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 3,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 3
      }
    },
    "message" : "lqhjpwbbeemozk-2-0",
    "timestamp" : 1274238401772,
    "trace" : {
      "calls" : [ {
          "name" : "Main.Buy.fulfill",
          "source" : "org/waterken/purchase_ajax/Main.java",
          "span" : [ [ 68 ] ]
        }, {
          "name" : "Main.Buy.fulfill",
          "source" : "org/waterken/purchase_ajax/Main.java",
          "span" : [ [ 48 ] ]
        } ]
    }

The anchor uniquely identifies the origin of this message send as the 3rd messaging event from the buyer vat, turn 3.

The message is a generated string which uniquely identifies a message.

The trace is the stack capture at the point of the message send.

Note: The loop field identifies the vat by URI. By convention, Causeway picks up the part following "/-/", in this case buyer, for a short display name.

Note: The timestamp field is optional. Currently, it is ignored by Causeway, so it's not shown in the remaining trace records.

    "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 1,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/product/",
        "number" : 2
      }
    },
    "message" : "lqhjpwbbeemozk-2-0",
    "trace" : {
      "calls" : [ {
          "name" : "InventoryMaker.InventoryX.partInStock",
          "source" : "org/waterken/purchase_ajax/InventoryMaker.java"
        } ]
    }

The corresponding Got record matches on message. 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.

Reporting true to teller has two log entries: a Sent and its corresponding Got.

    "class" : [ "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 2,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/product/",
        "number" : 2
      }
    },
    "message" : "ewrigzpctikrhk-1-0",
    "trace" : {
      "calls" : [ {
          "name" : "InventoryMaker.InventoryX.partInStock",
          "source" : "org/waterken/purchase_ajax/InventoryMaker.java",
          "span" : [ [ 19 ] ]
        } ]
    }

The anchor uniquely identifies the origin of this message send as the 2nd messaging event from the product vat, turn 2.

    "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 1,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 10
      }
    },
    "message" : "ewrigzpctikrhk-1-0",
    "trace" : {
      "calls" : [ {
          "name" : "AsyncAnd.run",
          "source" : "org/waterken/purchase_ajax/AsyncAnd.java"
        } ]
    }

The corresponding Got record matches on message. The message delivery in the buyer vat starts a new turn, turn 10.

Logging Promise-based Messaging in Waterken

(Note: This section on promises is incomplete and will be updated soon. tstanley 5/24/10)

Consider the sequence of events shown below.

Promise-based message send


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.


Waterken promise messaging


    "class" : [ "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 2,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 3
      }
    },
    "message" : "jisyrc633lurdq-2-0",
    "trace" : {
      "calls" : [ {
          "name" : "Buyer.Buy.fulfill",
          "source" : "org/waterken/purchase_promise/Buyer.java",
          "span" : [ [ 59 ] ]
        }, {
          "name" : "Buyer.Buy.fulfill",
          "source" : "org/waterken/purchase_promise/Buyer.java",
          "span" : [ [ 44 ] ]
        } ]
    }
    "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 1,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/product/",
        "number" : 2
      }
    },
    "message" : "jisyrc633lurdq-2-0",
    "trace" : {
      "calls" : [ {
          "name" : "InventoryMaker.InventoryX.partInStock",
          "source" : "org/waterken/purchase_promise/InventoryMaker.java"
        } ]
    }
    "class" : [ "org.ref_send.log.Returned", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 2,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/product/",
        "number" : 2
      }
    },
    "message" : "jisyrc633lurdq-2-0-return",
    "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 1,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 6
      }
    },
    "message" : "jisyrc633lurdq-2-0-return",
    "class" : [ "org.ref_send.log.Fulfilled", "org.ref_send.log.Resolved", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 2,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 6
      }
    },
    "condition" : "http://localhost:8080/-/buyer/#p3",
    "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 1,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 9
      }
    },
    "message" : "http://localhost:8080/-/buyer/#w3",
    "trace" : {
      "calls" : [ {
          "name" : "AsyncAnd.DoAnswer.fulfill",
          "source" : "org/waterken/purchase_promise/AsyncAnd.java"
        } ]
    }
    "class" : [ "org.ref_send.log.Progressed", "org.ref_send.log.Resolved", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 2,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 9
      }
    },
    "condition" : "http://localhost:8080/-/buyer/#p6",
    "trace" : {
      "calls" : [ {
          "name" : "AsyncAnd.DoAnswer.fulfill",
          "source" : "org/waterken/purchase_promise/AsyncAnd.java",
          "span" : [ [ 52 ] ]
        }, {
          "name" : "AsyncAnd.DoAnswer.fulfill",
          "source" : "org/waterken/purchase_promise/AsyncAnd.java",
          "span" : [ [ 26 ] ]
        } ]
    }
    "class" : [ "org.ref_send.log.Got", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 1,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 15
      }
    },
    "message" : "http://localhost:8080/-/buyer/#w6",
    "trace" : {
      "calls" : [ {
          "name" : "Buyer.CheckAnswers.fulfill",
          "source" : "org/waterken/purchase_promise/Buyer.java"
        } ]
    }

The registration of when-blocks, logged as SentIf 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.


Buyer events in process order


    "class" : [ "org.ref_send.log.SentIf", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 8,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 3
      }
    },
    "condition" : "http://localhost:8080/-/buyer/#p6",
    "message" : "http://localhost:8080/-/buyer/#w6",
    "trace" : {
      "calls" : [ {
          "name" : "Buyer.Buy.fulfill",
          "source" : "org/waterken/purchase_promise/Buyer.java",
          "span" : [ [ 72 ] ]
        }, {
          "name" : "Buyer.Buy.fulfill",
          "source" : "org/waterken/purchase_promise/Buyer.java",
          "span" : [ [ 44 ] ]
        } ]
    }
    "class" : [ "org.ref_send.log.SentIf", "org.ref_send.log.Sent", "org.ref_send.log.Event" ],
    "anchor" : {
      "number" : 5,
      "turn" : {
        "loop" : "http://localhost:8080/-/buyer/",
        "number" : 3
      }
    },
    "condition" : "http://localhost:8080/-/buyer/#p3",
    "message" : "http://localhost:8080/-/buyer/#w3",
    "trace" : {
      "calls" : [ {
          "name" : "AsyncAnd.run",
          "source" : "org/waterken/purchase_promise/AsyncAnd.java",
          "span" : [ [ 87 ] ]
        }, {
          "name" : "Buyer.Buy.fulfill",
          "source" : "org/waterken/purchase_promise/Buyer.java",
          "span" : [ [ 63 ] ]
        }, {
          "name" : "Buyer.Buy.fulfill",
          "source" : "org/waterken/purchase_promise/Buyer.java",
          "span" : [ [ 44 ] ]
        } ]
    }

Performance Issues in Waterken

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.

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.

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.)

Note: Resending a message after a connection is re-established can result in 2 identical Sent events being logged. Causeway notices when the event records are identical and ignores the duplicate.


Logging Ajax-style Messaging in AmbientTalk

Logging Futures-based Messaging in AmbientTalk

Performance Issues in AmbientTalk

Personal tools
more tools