1 21 22 package org.apache.derby.impl.store.raw.xact; 23 24 import org.apache.derby.iapi.services.io.FormatIdUtil; 25 import org.apache.derby.iapi.services.io.StoredFormatIds; 26 import org.apache.derby.iapi.services.sanity.SanityManager; 27 28 import org.apache.derby.iapi.store.raw.Transaction; 29 import org.apache.derby.iapi.store.raw.Loggable; 30 import org.apache.derby.iapi.store.raw.GlobalTransactionId; 31 32 import org.apache.derby.iapi.store.raw.log.LogInstant; 33 import org.apache.derby.iapi.store.raw.xact.RawTransaction; 34 35 import org.apache.derby.iapi.util.ByteArray; 36 37 import java.io.OutputStream ; 38 import java.io.InputStream ; 39 import java.io.ObjectOutput ; 40 import java.io.ObjectInput ; 41 import java.io.IOException ; 42 import org.apache.derby.iapi.services.io.LimitObjectInput; 43 44 48 49 public class BeginXact implements Loggable { 50 51 protected int transactionStatus; 52 protected GlobalTransactionId xactId; 53 54 55 public BeginXact(GlobalTransactionId xid, int s) 56 { 57 xactId = xid; 58 transactionStatus = s; 59 } 60 61 64 public BeginXact() 65 { super() ; } 66 67 public void writeExternal(ObjectOutput out) throws IOException 68 { 69 out.writeInt(transactionStatus); 70 out.writeObject(xactId); 71 } 72 73 public void readExternal(ObjectInput in) throws IOException , ClassNotFoundException 74 { 75 transactionStatus = in.readInt(); 76 xactId = (GlobalTransactionId)in.readObject(); 77 } 78 79 82 public int getTypeFormatId() { 83 return StoredFormatIds.LOGOP_BEGIN_XACT; 84 } 85 86 90 91 99 public void doMe(Transaction xact, LogInstant instant, LimitObjectInput in) 100 { 101 RawTransaction rt = (RawTransaction)xact; 102 103 if (instant != null) 105 { 106 rt.setFirstLogInstant(instant); 107 108 rt.addUpdateTransaction(transactionStatus); 111 } 112 } 113 114 123 public ByteArray getPreparedLog() 124 { 125 return (ByteArray) null; 126 } 127 128 134 public boolean needsRedo(Transaction xact) 135 { 136 return true; } 138 139 140 143 public void releaseResource(Transaction xact) 144 {} 145 146 147 150 public int group() 151 { 152 int group = Loggable.FIRST | Loggable.RAWSTORE; 153 return group; 154 } 155 156 159 public String toString() 160 { 161 if (SanityManager.DEBUG) 162 return "BeginXact " + xactId + " transactionStatus " + Integer.toHexString(transactionStatus); 163 else 164 return null; 165 166 } 167 168 171 public GlobalTransactionId getGlobalId() 172 { 173 return xactId; 174 } 175 176 177 } 178 179 | Popular Tags |