directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Directory SandBox > TxnLogManager class
Date Fri, 16 Mar 2012 12:42:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/2042/9/5/_/styles/combined.css?spaceKey=DIRxSBOX&amp;forWysiwyg=true"
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="">TxnLogManager
    <h4>Page <b>edited</b> by             <a href="">Emmanuel
                         <h4>Changes (0)</h4>
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <p>This class is used to manage the transaction, and to log them in a file,
the <b>WAL</b> (Write Ahead Log). </p>

<h2><a name="TxnLogManagerclass-addmethods"></a>add methods</h2>
<p>We use two methods, <em>addRead</em> and <em>addWrite</em>,
to store the set of *DN*s which will be affected by a read or a write, assuming we are inside
a pending transaction. </p>

<p>It's just a matter of storing the couple of &lt;Dn, scope&gt; into the current

<h2><a name="TxnLogManagerclass-mergemethods"></a>merge methods</h2>

<p>The merge methods (<em>mergeExistence</em>, <em>mergeForwardLookup</em>,
<em>mergeReversLookup</em> and <em>mergeUpdates</em>) are just proxies
on top of <em>Transaction</em> merge methods</p>

<h2><a name="TxnLogManagerclass-wrapmethods"></a>wrap methods</h2>
<p>The wrap methods construct wrappers around the target objects (<em>Index</em>,
<em>IndexCursor</em> and <em>MasterTable</em>).</p>

<h2><a name="TxnLogManagerclass-logmethods"></a>log methods</h2>

<p>We store <em>LogEdit</em> instances, serialized into <em>UserLogRecord</em>.
Here is the hierarchy for <em>LogEdit</em> :</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/27841171/LogEdit.png?version=1&amp;modificationDate=1331826367000"
style="border: 1px solid black" /></span></p>

<p>When an operation is executed (a modification, we don't log anything for searches),
we will store two or three records :</p>
<ul class="alternate" type="square">
	<li>a TXN_BEGIN record, to mark the beginning of a transaction</li>
	<li>an optional <em>DataChangeContainer</em>, which will contain all the
modified index and entries</li>
	<li>a TXN_COMMIT or TXN_ABORT, depending on the success or failure of the operation.</li>

<p>Those elements will be serialized into a <em>UserLogRecord</em>, following
these structures (the <em>UserLogRecord</em> will contains either a <em>TxnStateChange</em>
or a <em>DataChangeContainer</em>) :</p>

<p><span class="image-wrap" style=""><img src="/confluence/download/attachments/27841171/UserLogRecord.png?version=4&amp;modificationDate=1331901684879"
style="border: 1px solid black" /></span></p>

<p>Note that a <em>UserLogRecord</em> always has a type, a data length,
a buffer length and an <em>LogAnchor</em> encapsulating the stored data.</p>

<p>The contained elements are :</p>
<ul class="alternate" type="square">
	<li>(1 byte) a flag indicating that we are storing a <em>TxnStateChange</em>
or a <em>DataChangeContainer</em> : either <b>TXN</b> or <b>DATA</b></li>
	<li>(int, 4 bytes) the length of the data contained into the buffer. As the buffer
might be wider than the data, we keep this information around</li>
	<li>(int, 4 bytes) the length of the buffer. It's always superior of the length of
the data</li>
	<li>a byte[], containing the serialized Transaction or <em>DataChangeContainer</em></li>
	<li>(3 longs, 24 bytes) the <em>LogAnchor</em>, a position in the log file.</li>

<p>All those structure will be serialized with the minimal size, so we use <em>Externizable</em>
classes and we use <em>readExternal()</em> and <em>writeExternal()</em>
directly, to save some bytes and time (this serialization is done in a locked section).</p>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>
        <a href="">View
        <a href="">View

View raw message