EMMA Coverage Report (generated Wed Jun 28 22:15:27 PDT 2006)
[all classes][org.apache.derby.impl.store.raw.log]

COVERAGE SUMMARY FOR SOURCE FILE [CheckpointOperation.java]

nameclass, %method, %block, %line, %
CheckpointOperation.java100% (1/1)93%  (13/14)91%  (135/149)90%  (37/41)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CheckpointOperation100% (1/1)93%  (13/14)91%  (135/149)90%  (37/41)
CheckpointOperation (): void 100% (1/1)100% (3/3)100% (1/1)
CheckpointOperation (long, long, Formatable): void 100% (1/1)100% (12/12)100% (5/5)
doMe (Transaction, LogInstant, LimitObjectInput): void 100% (1/1)100% (11/11)100% (3/3)
getPreparedLog (): ByteArray 100% (1/1)100% (3/3)100% (1/1)
getTransactionTable (): Formatable 0%   (0/1)0%   (0/3)0%   (0/1)
getTypeFormatId (): int 100% (1/1)100% (2/2)100% (1/1)
group (): int 100% (1/1)100% (2/2)100% (1/1)
needsRedo (Transaction): boolean 100% (1/1)75%  (6/8)67%  (2/3)
readExternal (ObjectInput): void 100% (1/1)86%  (24/28)88%  (7/8)
redoLWM (): long 100% (1/1)100% (3/3)100% (1/1)
releaseResource (Transaction): void 100% (1/1)100% (1/1)100% (1/1)
toString (): String 100% (1/1)100% (39/39)100% (6/6)
undoLWM (): long 100% (1/1)100% (3/3)100% (1/1)
writeExternal (ObjectOutput): void 100% (1/1)84%  (26/31)88%  (7/8)

1/*
2 
3   Derby - Class org.apache.derby.impl.store.raw.log.CheckpointOperation
4 
5   Copyright 1997, 2004 The Apache Software Foundation or its licensors, as applicable.
6 
7   Licensed under the Apache License, Version 2.0 (the "License");
8   you may not use this file except in compliance with the License.
9   You may obtain a copy of the License at
10 
11      http://www.apache.org/licenses/LICENSE-2.0
12 
13   Unless required by applicable law or agreed to in writing, software
14   distributed under the License is distributed on an "AS IS" BASIS,
15   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   See the License for the specific language governing permissions and
17   limitations under the License.
18 
19 */
20 
21package org.apache.derby.impl.store.raw.log;
22 
23import org.apache.derby.iapi.services.sanity.SanityManager;
24import org.apache.derby.iapi.services.io.Formatable;
25import org.apache.derby.iapi.services.io.FormatIdUtil;
26import org.apache.derby.iapi.services.io.StoredFormatIds;
27import org.apache.derby.catalog.UUID;
28 
29import org.apache.derby.iapi.store.raw.Transaction;
30import org.apache.derby.iapi.store.raw.Loggable;
31import org.apache.derby.iapi.store.raw.log.LogInstant;
32import org.apache.derby.iapi.store.raw.log.LogFactory;
33import org.apache.derby.iapi.store.raw.xact.RawTransaction;
34 
35import org.apache.derby.iapi.error.StandardException;
36 
37import org.apache.derby.iapi.services.io.CompressedNumber;
38import org.apache.derby.iapi.util.ByteArray;
39 
40import java.io.Externalizable;
41import java.io.OutputStream;
42import java.io.InputStream;
43import java.io.ObjectInput;
44import java.io.ObjectOutput;
45import java.io.IOException;
46import org.apache.derby.iapi.services.io.LimitObjectInput;
47 
48/**
49        A Log Operation that represents a checkpoint.
50        @see Loggable
51*/
52 
53public class CheckpointOperation implements Loggable 
54{
55 
56        // redo LWM
57        protected long        redoLWM;
58 
59        // undo LWM
60        protected long        undoLWM;
61 
62        protected Formatable transactionTable;
63 
64        public CheckpointOperation(long redoLWM, long undoLWM, Formatable ttab)
65        {
66                this.redoLWM = redoLWM;
67                this.undoLWM = undoLWM;
68                this.transactionTable = ttab;
69        }
70 
71        /*
72         * Formatable methods
73         */
74 
75        // no-arg constructor, required by Formatable 
76        public CheckpointOperation() { super(); }
77 
78        public void writeExternal(ObjectOutput out) throws IOException 
79        {
80                CompressedNumber.writeLong(out, redoLWM);
81                CompressedNumber.writeLong(out, undoLWM);
82                // RESOLVE: Following write Not needed, keeping it to avoid upgrade/downgrade issues.
83                CompressedNumber.writeInt(out, 0);        // no other truncation LWM
84 
85                if (transactionTable == null)
86                        CompressedNumber.writeInt(out, 0);
87                else
88                {
89                        CompressedNumber.writeInt(out, 1);
90                        out.writeObject(transactionTable);
91                }
92        }
93 
94        public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException
95        {
96                redoLWM = CompressedNumber.readLong(in);
97                undoLWM = CompressedNumber.readLong(in);
98 
99                // RESOLVE: Following read Not required, keeping it to avoid upgrade/downgrade issues.
100                int tsize = CompressedNumber.readInt(in); // is there any truncationLWM?
101 
102                int haveTTab = CompressedNumber.readInt(in);
103                if (haveTTab == 1)
104                        transactionTable = (Formatable)in.readObject();
105                else
106                        transactionTable = (Formatable)null;
107        }
108 
109        /**
110                Return my format identifier.
111        */
112        public int getTypeFormatId() {
113                return StoredFormatIds.LOGOP_CHECKPOINT;
114        }
115 
116        /**
117                Loggable methods
118        */
119 
120        /**
121         *        Nothing to do unless we are rollforward recovery;
122         *  Redoing of checkpoints during rollforward recovery allows us to restart
123         *  the  roll-forward recovery from the last checkpoint redone during rollforward recovery, if
124         *  we happen to crash during the roll-forward recovery process.
125         *  Another reason why we need to do this is dropped table stub files
126         *  removed at checkpoint because the containerids may have been reused
127         *  after a checkpoint if the system was rebooted.
128        */
129        public void doMe(Transaction xact, LogInstant instant, LimitObjectInput in) throws StandardException
130        {
131                //redo the checkpoint if we are in roll-forward recovery only
132                if(((RawTransaction)xact).inRollForwardRecovery())
133                {
134                        ((RawTransaction)xact).checkpointInRollForwardRecovery(instant, redoLWM);
135                }
136                return;
137        }
138 
139        /**
140                the default for prepared log is always null for all the operations
141                that don't have optionalData.  If an operation has optional data,
142                the operation need to prepare the optional data for this method.
143 
144                Checkpoint has no optional data to write out
145        */
146        public ByteArray getPreparedLog()
147        {
148                return (ByteArray) null;
149        }
150 
151        /**
152                Checkpoint does not need to be redone unless
153                we are doing rollforward recovery.
154        */
155        public boolean needsRedo(Transaction xact)
156        {
157                
158                if(((RawTransaction)xact).inRollForwardRecovery())
159                        return true;
160                else
161                        return false;
162        }
163 
164 
165        /**
166          Checkpoint has not resource to release
167        */
168        public void releaseResource(Transaction xact)
169        {}
170 
171        /**
172                Checkpoint is a raw store operation
173        */
174        public int group()
175        {
176                return Loggable.RAWSTORE;
177        }
178 
179        /**
180                Access attributes of the checkpoint record
181        */
182        public long redoLWM() 
183        {
184                return redoLWM;
185        }
186 
187        public long undoLWM() 
188        {
189                return undoLWM;
190        }
191 
192 
193        public Formatable getTransactionTable()
194        {
195                return transactionTable;
196        }
197 
198        /**
199          DEBUG: Print self.
200        */
201        public String toString()
202        {
203                if (SanityManager.DEBUG)
204                {
205                        LogCounter undolwm = new LogCounter(undoLWM);
206                        LogCounter redolwm = new LogCounter(redoLWM);
207 
208                        StringBuffer str = new StringBuffer(1000)
209                                .append("Checkpoint : \tredoLWM ")
210                                .append(redolwm.toString())
211                                .append("\n\t\tundoLWM ").append(undolwm.toString());
212 
213                        if (transactionTable != null)
214                        {
215                                str.append(transactionTable.toString());
216                        }
217 
218                        return str.toString();
219                }
220                else
221                        return null;
222        }
223}
224 
225 
226 
227 
228 
229 
230 
231 
232 
233 
234 
235 

[all classes][org.apache.derby.impl.store.raw.log]
EMMA 2.0.5312 (C) Vladimir Roubtsov