KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > jts > CosTransactions > LogExtent


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23
24 /*
25  * Copyright 2004-2005 Sun Microsystems, Inc. All rights reserved.
26  * Use is subject to license terms.
27  */

28 //----------------------------------------------------------------------------
29
//
30
// Module: LogExtent.java
31
//
32
// Description: Log extent file interface.
33
//
34
// Product: com.sun.jts.CosTransactions
35
//
36
// Author: Simon Holdsworth
37
//
38
// Date: March, 1997
39
//
40
// Copyright (c): 1995-1997 IBM Corp.
41
//
42
// The source code for this program is not published or otherwise divested
43
// of its trade secrets, irrespective of what has been deposited with the
44
// U.S. Copyright Office.
45
//
46
// This software contains confidential and proprietary information of
47
// IBM Corp.
48
//----------------------------------------------------------------------------
49

50 package com.sun.jts.CosTransactions;
51
52 // Import required definitions.
53

54 import java.io.*;
55
56 //------------------------------------------------------------------------------
57
// LogExtent class
58
//------------------------------------------------------------------------------
59
/**A structure containing information for an open log file extent.
60  *
61  * @version 0.01
62  *
63  * @author Simon Holdsworth, IBM Corporation
64  *
65  * @see
66  */

67 //----------------------------------------------------------------------------
68
// CHANGE HISTORY
69
//
70
// Version By Change Description
71
// 0.01 SAJH Initial implementation.
72
//-----------------------------------------------------------------------------
73

74 class LogExtent extends Object JavaDoc {
75
76     // The type of access last made to an extent file is stored in the extent
77
// descriptor block. This is used to save doing uneccessary fseeks.
78

79     /**Type of last access is unknown (forces fseek to required cursor pos'n)
80      */

81     final static int ACCESSTYPE_UNKNOWN = 0;
82
83     /**Last access was for reading
84      */

85     final static int ACCESSTYPE_READ = 1;
86
87     /**Last access was for writing
88      */

89     final static int ACCESSTYPE_WRITE = 2;
90
91     /**The radix used to convert extent numbers to strings.
92      */

93     final static int EXTENT_RADIX = 36;
94
95     /**The maximum number of extent files that can be allocated to a single
96      * log at any one time. Extent names are made up of <logfilename>.nnn
97      * Hence this value is restricted by the .nnn extension (3 characters
98      * only, to support the FAT file system.
99      */

100     final static int MAX_NO_OF_EXTENTS = EXTENT_RADIX*EXTENT_RADIX*EXTENT_RADIX;
101
102     /**This value is used to validate the LogExtent object.
103      */

104     LogExtent blockValid = null;
105
106     /**The extent number.
107      */

108     int extentNumber = -1;
109
110     /**The file handle for the log extent file.
111      */

112     LogFileHandle fileHandle = null;
113
114     /**The file for the log extent file.
115      */

116     File file = null;
117
118     /**Indicates whether any information has been written since the last force.
119      */

120     boolean writtenSinceLastForce = false;
121
122     /**The cursor position in the log extent.
123      */

124     int cursorPosition = 0;
125
126     /**The last type of access to the extent.
127      */

128     int lastAccess = ACCESSTYPE_UNKNOWN;
129
130     /**LogExtent constructor
131      *
132      * @param extent The number of the extent.
133      * @param extentFH The handle of the extent file.
134      *
135      * @return
136      *
137      * @see
138      */

139     LogExtent( int extent,
140                LogFileHandle extentFH,
141                File extentFile ) {
142         extentNumber = extent;
143         fileHandle = extentFH;
144         file = extentFile;
145     }
146
147     /**Default LogExtent destructor.
148      *
149      * @param
150      *
151      * @return
152      *
153      * @see
154      */

155     public void finalize() {
156         try {
157             fileHandle.finalize();
158         } catch( Throwable JavaDoc e ) {};
159
160         blockValid = null;
161         file = null;
162     }
163
164     /**Modulates the extent number using the maximum extent number.
165      *
166      * @param ext The extent number
167      *
168      * @return The modulated extent number.
169      *
170      * @see
171      */

172     final static int modExtent( int ext ) {
173         return (ext % MAX_NO_OF_EXTENTS);
174     }
175 }
176
Popular Tags