1 21 22 package org.apache.derby.impl.store.raw.xact; 23 24 import org.apache.derby.iapi.services.sanity.SanityManager; 25 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.GlobalTransactionId; 31 import org.apache.derby.iapi.store.access.GlobalXact; 32 33 import org.apache.derby.iapi.util.ByteArray; 34 35 import java.io.ObjectOutput ; 36 import java.io.ObjectInput ; 37 import java.io.IOException ; 38 39 public class GlobalXactId extends GlobalXact implements GlobalTransactionId 40 { 41 45 46 50 public GlobalXactId( 51 int format_id, 52 byte[] global_id, 53 byte[] branch_id) 54 { 55 this.format_id = format_id; 56 this.global_id = new byte[global_id.length]; 57 System.arraycopy(global_id, 0, this.global_id, 0, global_id.length); 58 this.branch_id = new byte[branch_id.length]; 59 System.arraycopy(branch_id, 0, this.branch_id, 0, branch_id.length); 60 } 61 62 66 67 public GlobalXactId() 69 { 70 } 71 72 76 public void writeExternal(ObjectOutput out) throws IOException 77 { 78 out.writeInt(format_id); 79 80 if (SanityManager.DEBUG) 81 { 82 SanityManager.ASSERT(global_id.length <= 64); 83 SanityManager.ASSERT(global_id != null); 84 SanityManager.ASSERT(branch_id != null); 85 } 86 87 out.write(global_id.length); 89 if (global_id.length > 0) 90 out.write(global_id); 91 92 out.write(branch_id.length); 94 if (branch_id.length > 0) 95 out.write(branch_id); 96 } 97 98 103 public void readExternal(ObjectInput in) 104 throws IOException , ClassNotFoundException 105 { 106 format_id = in.readInt(); 107 108 int array_len = in.read(); 110 111 if (SanityManager.DEBUG) 112 { 113 SanityManager.ASSERT(array_len >= 0); 114 } 115 116 global_id = new byte[array_len]; 117 if (array_len > 0) 118 in.read(global_id); 119 120 array_len = in.read(); 122 123 if (SanityManager.DEBUG) 124 { 125 SanityManager.ASSERT(array_len >= 0); 126 } 127 128 branch_id = new byte[array_len]; 129 if (array_len > 0) 130 in.read(branch_id); 131 } 132 133 136 public int getTypeFormatId() { 137 return StoredFormatIds.RAW_STORE_GLOBAL_XACT_ID_NEW; 138 } 139 140 144 145 149 public int getFormat_Id() 150 { 151 return(format_id); 152 } 153 154 public byte[] getGlobalTransactionId() 155 { 156 return(global_id); 157 } 158 159 public byte[] getBranchQualifier() 160 { 161 return(branch_id); 162 } 163 } 164 | Popular Tags |