KickJava   Java API By Example, From Geeks To Geeks.

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


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: CommitEntry.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.Iterator JavaDoc;
12 import java.util.Map JavaDoc;
13 import java.util.Set JavaDoc;
14
15 /*
16  * A Commit entry signals that some records should be moved from the
17  * not-yet-committed sets to the expected set.
18  *
19  * Note that this uses key and data values rather than node ids to check
20  * existence, so a test which re-used the same key and data values may
21  * not work out correctly. This could be enhanced in the future to use
22  * node ids.
23  */

24
25 public class CommitEntry extends LogEntryInfo {
26     private long txnId;
27
28     CommitEntry(long lsn, long txnId) {
29         super(lsn, 0, 0);
30         this.txnId = txnId;
31     }
32
33     public void updateExpectedSet(Set JavaDoc useExpected,
34                                   Map JavaDoc newUncommittedRecords,
35                                   Map JavaDoc deletedUncommittedRecords) {
36
37         Long JavaDoc mapKey = new Long JavaDoc(txnId);
38
39         /* Add any new records to the expected set. */
40         Set JavaDoc records = (Set JavaDoc) newUncommittedRecords.get(mapKey);
41         if (records != null) {
42             Iterator JavaDoc iter = records.iterator();
43             while (iter.hasNext()) {
44                 useExpected.add((TestData) iter.next());
45             }
46         }
47
48         /* Remove any deleted records from expected set. */
49         records = (Set JavaDoc) deletedUncommittedRecords.get(mapKey);
50         if (records != null) {
51             Iterator JavaDoc iter = records.iterator();
52             while (iter.hasNext()) {
53                 useExpected.remove((TestData) iter.next());
54             }
55         }
56     }
57 }
58
Popular Tags