KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > recovery > stepwise > TxnalDeletedEntry


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: TxnalDeletedEntry.java,v 1.4 2006/10/30 21:14:49 bostic Exp $
7  */

8
9 package com.sleepycat.je.recovery.stepwise;
10
11 import java.util.HashSet JavaDoc;
12 import java.util.Map JavaDoc;
13 import java.util.Set JavaDoc;
14
15 import com.sleepycat.bind.tuple.IntegerBinding;
16 import com.sleepycat.je.DatabaseEntry;
17
18 /*
19  * A Transactional log entry should add put itself
20  * into the not-yet-committed set.
21  */

22
23 public class TxnalDeletedEntry extends LogEntryInfo {
24     private long txnId;
25
26     TxnalDeletedEntry(long lsn,
27                       int key,
28                       int data,
29                       long txnId) {
30         super(lsn, key, data);
31         this.txnId = txnId;
32     }
33
34     /* Implement this accordingly. For example, a LogEntryInfo which
35      * represents a non-txnal LN record would add that key/data to the
36      * expected set. A txnal delete LN record would delete the record
37      * from the expecte set at commit time.
38      */

39     public void updateExpectedSet(Set JavaDoc useExpected,
40                                   Map JavaDoc newUncommittedRecords,
41                                   Map JavaDoc deletedUncommittedRecords) {
42         DatabaseEntry keyEntry = new DatabaseEntry();
43         DatabaseEntry dataEntry = new DatabaseEntry();
44
45         IntegerBinding.intToEntry(key, keyEntry);
46         IntegerBinding.intToEntry(data, dataEntry);
47
48         Long JavaDoc mapKey = new Long JavaDoc(txnId);
49         Set JavaDoc records = (Set JavaDoc) deletedUncommittedRecords.get(mapKey);
50         if (records == null) {
51             records = new HashSet JavaDoc();
52            deletedUncommittedRecords.put(mapKey, records);
53         }
54         records.add(new TestData(keyEntry, dataEntry));
55     }
56 }
57
Popular Tags