1 21 22 package org.apache.derby.impl.store.raw.log; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 import org.apache.derby.iapi.services.io.Formatable; 26 import org.apache.derby.iapi.services.io.FormatIdUtil; 27 import org.apache.derby.iapi.services.io.StoredFormatIds; 28 import org.apache.derby.catalog.UUID; 29 30 import org.apache.derby.iapi.store.raw.Transaction; 31 import org.apache.derby.iapi.store.raw.Loggable; 32 import org.apache.derby.iapi.store.raw.log.LogInstant; 33 import org.apache.derby.iapi.store.raw.log.LogFactory; 34 import org.apache.derby.iapi.store.raw.xact.RawTransaction; 35 36 import org.apache.derby.iapi.error.StandardException; 37 38 import org.apache.derby.iapi.services.io.CompressedNumber; 39 import org.apache.derby.iapi.util.ByteArray; 40 41 import java.io.Externalizable ; 42 import java.io.OutputStream ; 43 import java.io.InputStream ; 44 import java.io.ObjectInput ; 45 import java.io.ObjectOutput ; 46 import java.io.IOException ; 47 import org.apache.derby.iapi.services.io.LimitObjectInput; 48 49 53 54 public class CheckpointOperation implements Loggable 55 { 56 57 protected long redoLWM; 59 60 protected long undoLWM; 62 63 protected Formatable transactionTable; 64 65 public CheckpointOperation(long redoLWM, long undoLWM, Formatable ttab) 66 { 67 this.redoLWM = redoLWM; 68 this.undoLWM = undoLWM; 69 this.transactionTable = ttab; 70 } 71 72 75 76 public CheckpointOperation() { super(); } 78 79 public void writeExternal(ObjectOutput out) throws IOException 80 { 81 CompressedNumber.writeLong(out, redoLWM); 82 CompressedNumber.writeLong(out, undoLWM); 83 CompressedNumber.writeInt(out, 0); 86 if (transactionTable == null) 87 CompressedNumber.writeInt(out, 0); 88 else 89 { 90 CompressedNumber.writeInt(out, 1); 91 out.writeObject(transactionTable); 92 } 93 } 94 95 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException 96 { 97 redoLWM = CompressedNumber.readLong(in); 98 undoLWM = CompressedNumber.readLong(in); 99 100 int tsize = CompressedNumber.readInt(in); 103 int haveTTab = CompressedNumber.readInt(in); 104 if (haveTTab == 1) 105 transactionTable = (Formatable)in.readObject(); 106 else 107 transactionTable = (Formatable)null; 108 } 109 110 113 public int getTypeFormatId() { 114 return StoredFormatIds.LOGOP_CHECKPOINT; 115 } 116 117 120 121 130 public void doMe(Transaction xact, LogInstant instant, LimitObjectInput in) throws StandardException 131 { 132 if(((RawTransaction)xact).inRollForwardRecovery()) 134 { 135 ((RawTransaction)xact).checkpointInRollForwardRecovery(instant, redoLWM); 136 } 137 return; 138 } 139 140 147 public ByteArray getPreparedLog() 148 { 149 return (ByteArray) null; 150 } 151 152 156 public boolean needsRedo(Transaction xact) 157 { 158 159 if(((RawTransaction)xact).inRollForwardRecovery()) 160 return true; 161 else 162 return false; 163 } 164 165 166 169 public void releaseResource(Transaction xact) 170 {} 171 172 175 public int group() 176 { 177 return Loggable.RAWSTORE; 178 } 179 180 183 public long redoLWM() 184 { 185 return redoLWM; 186 } 187 188 public long undoLWM() 189 { 190 return undoLWM; 191 } 192 193 194 public Formatable getTransactionTable() 195 { 196 return transactionTable; 197 } 198 199 202 public String toString() 203 { 204 if (SanityManager.DEBUG) 205 { 206 LogCounter undolwm = new LogCounter(undoLWM); 207 LogCounter redolwm = new LogCounter(redoLWM); 208 209 StringBuffer str = new StringBuffer (1000) 210 .append("Checkpoint : \tredoLWM ") 211 .append(redolwm.toString()) 212 .append("\n\t\tundoLWM ").append(undolwm.toString()); 213 214 if (transactionTable != null) 215 { 216 str.append(transactionTable.toString()); 217 } 218 219 return str.toString(); 220 } 221 else 222 return null; 223 } 224 } 225 226 227 228 229 230 231 232 233 234 235 236 237 | Popular Tags |