KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > derby > impl > store > raw > log > StreamLogScan


1 /*
2
3    Derby - Class org.apache.derby.impl.store.raw.log.StreamLogScan
4
5    Licensed to the Apache Software Foundation (ASF) under one or more
6    contributor license agreements. See the NOTICE file distributed with
7    this work for additional information regarding copyright ownership.
8    The ASF licenses this file to you under the Apache License, Version 2.0
9    (the "License"); you may not use this file except in compliance with
10    the License. You may obtain a copy of the License at
11
12       http://www.apache.org/licenses/LICENSE-2.0
13
14    Unless required by applicable law or agreed to in writing, software
15    distributed under the License is distributed on an "AS IS" BASIS,
16    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17    See the License for the specific language governing permissions and
18    limitations under the License.
19
20  */

21
22 package org.apache.derby.impl.store.raw.log;
23
24 import org.apache.derby.iapi.store.raw.log.LogInstant;
25 import org.apache.derby.iapi.store.raw.log.LogScan;
26 import org.apache.derby.iapi.store.raw.xact.TransactionId;
27 import org.apache.derby.iapi.error.StandardException;
28
29 import org.apache.derby.iapi.services.io.ArrayInputStream;
30
31 import java.io.InputStream JavaDoc;
32 import java.io.IOException JavaDoc;
33
34 /**
35     LogScan provides methods to read a log record and get its LogInstant
36     in an already defined scan. A logscan also needs to know how to advance to
37     the next log record.
38 */

39
40 public interface StreamLogScan extends LogScan {
41
42     /**
43         Get the next record in the scan and place its data in the passed in
44         array. The scan is advanced to the next log record.
45         If the input array is of insufficient size, getNextRecord must expand
46         the array to accomodate the log record. User can optionally pass in a
47         transaction Id and a group mask. If provided, only log record that
48         matches the transaction Id and the group mask is returned.
49
50         @param input the ArrayInputStream to put the log record
51         @param tranId if non-null, only log record that equals tranId
52                             will be returned. If null, log records are not
53                             filtered on transaction Id.
54         @param groupmask if non-zero, only log record whose Loggable's group
55                             value is included in the groupmask is returned.
56                             groupmask can be a bit wise OR of many Loggable
57                             groups. If zero, log records are not filtered on
58                             the Loggable's group.
59
60         @return an object that represents the log record, return null if the
61         scan has completed.
62
63         @exception StandardException Standard Clooudscape error policy
64         @exception IOException Some I/O exception raised during reading
65                                      the log record.
66     */

67     public LogRecord getNextRecord(ArrayInputStream input,
68                                    TransactionId tranId,
69                                    int groupmask)
70          throws StandardException, IOException JavaDoc;
71
72
73     /**
74         Get the instant of the record just retrieved with getNextRecord().
75         @return INVALID_LOG_INSTANT if no records have been returned yet or
76         the scan has completed.
77     */

78     public long getInstant();
79
80     /**
81         Get the log instant that is right after the record just retrieved with
82         getNextRecord(). Only valid for a forward scan and on a successful
83         retrieval.
84
85         @return INVALID_LOG_INSTANT if this is not a FORWARD scan or, no
86         record have been returned yet or the scan has completed.
87     */

88     public long getLogRecordEnd();
89     
90     /**
91        @return true if fuzzy log end found during forward scan, this happens
92        if there was a partially written log records before the crash.
93     */

94     public boolean isLogEndFuzzy();
95
96     /**
97         Get the LogInstant for the record just retrieved with getNextRecord().
98         @return null if no records have been returned yet or the scan has
99         completed.
100         */

101     public LogInstant getLogInstant();
102
103     /**
104         Reset the scan to the given LogInstant so that getNextRecord get the
105         log record AFTER the given LogInstant.
106
107         @param instant the log instant to reset to
108
109         @exception IOException Some I/O exception raised when accessing
110                                      the log file
111         @exception StandardException reset to illegal position or beyond the
112                                      limit of the scan.
113     */

114     public void resetPosition(LogInstant instant)
115          throws IOException JavaDoc, StandardException;
116
117     /**
118         Close this log scan.
119     */

120     public void close();
121 }
122
Popular Tags