KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sleepycat > je > log > SyncedLogManager


1 /*-
2  * See the file LICENSE for redistribution information.
3  *
4  * Copyright (c) 2002,2006 Oracle. All rights reserved.
5  *
6  * $Id: SyncedLogManager.java,v 1.17 2006/11/03 03:07:51 mark Exp $
7  */

8
9 package com.sleepycat.je.log;
10
11 import java.io.IOException JavaDoc;
12 import java.nio.ByteBuffer JavaDoc;
13 import java.util.List JavaDoc;
14
15 import com.sleepycat.je.DatabaseException;
16 import com.sleepycat.je.cleaner.TrackedFileSummary;
17 import com.sleepycat.je.cleaner.UtilizationTracker;
18 import com.sleepycat.je.dbi.EnvironmentImpl;
19
20 /**
21  * The SyncedLogManager uses the synchronized keyword to implement protected
22  * regions.
23  */

24 public class SyncedLogManager extends LogManager {
25
26     /**
27      * There is a single log manager per database environment.
28      */

29     public SyncedLogManager(EnvironmentImpl envImpl,
30                             boolean readOnly)
31         throws DatabaseException {
32
33         super(envImpl, readOnly);
34     }
35
36     protected LogResult logItem(LoggableObject item,
37                                 boolean isProvisional,
38                                 boolean flushRequired,
39                                 boolean forceNewLogFile,
40                                 long oldNodeLsn,
41                                 int oldNodeSize,
42                                 boolean marshallOutsideLatch,
43                                 ByteBuffer JavaDoc marshalledBuffer,
44                                 UtilizationTracker tracker)
45         throws IOException JavaDoc, DatabaseException {
46
47         synchronized (logWriteLatch) {
48             return logInternal
49                 (item, isProvisional, flushRequired, forceNewLogFile,
50                  oldNodeLsn, oldNodeSize, marshallOutsideLatch,
51                  marshalledBuffer, tracker);
52         }
53     }
54
55     protected void flushInternal()
56         throws LogException, DatabaseException {
57
58         try {
59             synchronized (logWriteLatch) {
60                 logBufferPool.writeBufferToFile(0);
61             }
62         } catch (IOException JavaDoc e) {
63             throw new LogException(e.getMessage());
64         }
65     }
66     
67     /**
68      * @see LogManager#getUnflushableTrackedSummary
69      */

70     public TrackedFileSummary getUnflushableTrackedSummary(long file)
71         throws DatabaseException {
72
73         synchronized (logWriteLatch) {
74             return getUnflushableTrackedSummaryInternal(file);
75         }
76     }
77
78     /**
79      * @see LogManager#countObsoleteLNs
80      */

81     public void countObsoleteNode(long lsn, LogEntryType type, int size)
82         throws DatabaseException {
83
84         UtilizationTracker tracker = envImpl.getUtilizationTracker();
85         synchronized (logWriteLatch) {
86             countObsoleteNodeInternal(tracker, lsn, type, size);
87         }
88     }
89
90     /**
91      * @see LogManager#countObsoleteNodes
92      */

93     public void countObsoleteNodes(TrackedFileSummary[] summaries)
94         throws DatabaseException {
95
96         UtilizationTracker tracker = envImpl.getUtilizationTracker();
97         synchronized (logWriteLatch) {
98             countObsoleteNodesInternal(tracker, summaries);
99         }
100     }
101
102     /**
103      * @see LogManager#countObsoleteINs
104      */

105     public void countObsoleteINs(List JavaDoc lsnList)
106         throws DatabaseException {
107
108         synchronized (logWriteLatch) {
109             countObsoleteINsInternal(lsnList);
110         }
111     }
112 }
113
Popular Tags