directory-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Directory SandBox > TxnLogManager class
Date Thu, 15 Mar 2012 16:34:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/5/_/styles/combined.css?spaceKey=DIRxSBOX&amp;forWysiwyg=true"
type="text/css">
    </head>
<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="https://cwiki.apache.org/confluence/display/DIRxSBOX/TxnLogManager+class">TxnLogManager
class</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~elecharny">Emmanuel
L├ęcharny</a>
    </h4>
        <br/>
                         <h4>Changes (8)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. merge methods <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >The merge methods (_mergeExistence_,
_mergeForwardLookup_, _mergeReversLookup_ and _mergeUpdates_) are just proxies on top of <span
class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">_</span>Transaction<span
class="diff-added-chars"style="background-color: #dfd;">_</span></span> merge
methods <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h2. wrap methods <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. log methods <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">We
store LogEdit instances, serialized into UserLogRecord. Here is the hierarchy for LogEdit
: <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">We
store _LogEdit_ instances, serialized into _UserLogRecord_. Here is the hierarchy for _LogEdit_
: <br></td></tr>
            <tr><td class="diff-unchanged" > <br>!LogEdit.png|border=1!
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >When an operation is executed (a modification,
we don&#39;t log anything for searches), we will store two or three records : <br>-
a TXN_BEGIN record, to mark the beginning of a transaction <br></td></tr>
            <tr><td class="diff-changed-lines" >- an optional <span class="diff-changed-words"><span
class="diff-added-chars"style="background-color: #dfd;">_</span>DataChangeContainer<span
class="diff-added-chars"style="background-color: #dfd;">_</span>,</span> which
will contain all the modified index and entries <br></td></tr>
            <tr><td class="diff-unchanged" >- a TXN_COMMIT or TXN_ABORT, depending
on the success or failure of the operation. <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Those
elements will be serialized into a UserLogRecord, following these structures (the UserLogRecord
will contains either a TxnStateChange or a DataChangeContainer) : <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Those
elements will be serialized into a _UserLogRecord_, following these structures (the _UserLogRecord_
will contains either a _TxnStateChange_ or a _DataChangeContainer_) : <br></td></tr>
            <tr><td class="diff-unchanged" > <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >Note that a _UserLogRecord_ always
has a type, a data length, a buffer length and an _LogAnchor_ encapsulating the stored data.
<br> <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">The
contained elements are : <br>- (1 byte) a flag indicating that we are storing a _TxnStateChange_
or a _DataChangeContainer_ : either *TXN* or *DATA* <br>- (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 <br>- (int, 4 bytes) the length of the buffer. It&#39;s
always superior of the length of the data <br>- a byte[], containing the serialized
Transaction or _DataChangeContainer_ <br>- (3 longs, 24 bytes) the _LogAnchor_, a position
in the log file. <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >All those structure will be serialized
with the minimal size, so we use <span class="diff-changed-words"><span class="diff-added-chars"style="background-color:
#dfd;">_</span>Externizable<span class="diff-added-chars"style="background-color:
#dfd;">_</span></span> classes and we use <span class="diff-changed-words"><span
class="diff-added-chars"style="background-color: #dfd;">_</span>readExternal()<span
class="diff-added-chars"style="background-color: #dfd;">_</span></span> and
<span class="diff-changed-words"><span class="diff-added-chars"style="background-color:
#dfd;">_</span>writeExternal()<span class="diff-added-chars"style="background-color:
#dfd;">_</span></span> directly, to save some bytes and time (this serialization
is done in a locked section). <br></td></tr>
    
            </table>
    </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
transaction.</p>

<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>
</ul>


<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=3&amp;modificationDate=1331828524252"
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>
</ul>


<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>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/DIRxSBOX/TxnLogManager+class">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=27841171&revisedVersion=5&originalVersion=4">View
Changes</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message