1 24 25 package org.objectweb.cjdbc.controller.scheduler.raidb1; 26 27 import java.sql.SQLException ; 28 import java.util.LinkedList ; 29 30 import org.objectweb.cjdbc.common.exceptions.RollbackException; 31 import org.objectweb.cjdbc.common.sql.AbstractWriteRequest; 32 import org.objectweb.cjdbc.common.sql.ParsingGranularities; 33 import org.objectweb.cjdbc.common.sql.SelectRequest; 34 import org.objectweb.cjdbc.common.sql.StoredProcedure; 35 import org.objectweb.cjdbc.common.xml.DatabasesXmlTags; 36 import org.objectweb.cjdbc.controller.requestmanager.RAIDbLevels; 37 import org.objectweb.cjdbc.controller.scheduler.AbstractScheduler; 38 import org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase; 39 import org.objectweb.cjdbc.controller.virtualdatabase.protocol.Commit; 40 import org.objectweb.cjdbc.controller.virtualdatabase.protocol.ReleaseSavepoint; 41 import org.objectweb.cjdbc.controller.virtualdatabase.protocol.Rollback; 42 import org.objectweb.cjdbc.controller.virtualdatabase.protocol.RollbackToSavepoint; 43 import org.objectweb.cjdbc.controller.virtualdatabase.protocol.SetSavepoint; 44 45 54 public class RAIDb1PassThroughScheduler extends AbstractScheduler 55 { 56 57 67 private long requestId; 68 private LinkedList totalOrderQueue = null; 69 70 74 80 public RAIDb1PassThroughScheduler(VirtualDatabase vdb) 81 { 82 super(RAIDbLevels.RAIDb1, ParsingGranularities.NO_PARSING); 83 requestId = 0; 84 if (vdb.isDistributed()) 85 { 86 totalOrderQueue = new LinkedList (); 87 vdb.setTotalOrderQueue(totalOrderQueue); 88 } 89 } 90 91 95 98 public final synchronized void scheduleReadRequest(SelectRequest request) 99 { 100 request.setId(requestId++); 101 } 102 103 106 public final void readCompletedNotify(SelectRequest request) 107 { 108 } 109 110 113 public final synchronized void scheduleNonSuspendedWriteRequest( 114 AbstractWriteRequest request) 115 { 116 request.setId(requestId++); 117 if (totalOrderQueue != null) 118 { 119 synchronized (totalOrderQueue) 120 { 121 totalOrderQueue.addLast(request); 122 } 123 } 124 } 125 126 129 public final void notifyWriteCompleted(AbstractWriteRequest request) 130 { 131 } 132 133 136 public final synchronized void scheduleNonSuspendedStoredProcedure( 137 StoredProcedure proc) throws SQLException , RollbackException 138 { 139 proc.setId(requestId++); 140 if (totalOrderQueue != null) 141 { 142 synchronized (totalOrderQueue) 143 { 144 totalOrderQueue.addLast(proc); 145 } 146 } 147 } 148 149 152 public final void notifyStoredProcedureCompleted(StoredProcedure proc) 153 { 154 } 155 156 160 163 protected final void commitTransaction(long transactionId) 164 { 165 if (totalOrderQueue != null) 166 { 167 synchronized (totalOrderQueue) 168 { 169 totalOrderQueue.addLast(new Commit("", transactionId)); 170 } 171 } 172 } 173 174 177 protected final void rollbackTransaction(long transactionId) 178 { 179 if (totalOrderQueue != null) 180 { 181 synchronized (totalOrderQueue) 182 { 183 totalOrderQueue.addLast(new Rollback("", transactionId)); 184 } 185 } 186 } 187 188 192 protected final void rollbackTransaction(long transactionId, 193 String savepointName) 194 { 195 if (totalOrderQueue != null) 196 { 197 synchronized (totalOrderQueue) 198 { 199 totalOrderQueue.addLast(new RollbackToSavepoint(transactionId, 200 savepointName)); 201 } 202 } 203 } 204 205 209 protected final void setSavepointTransaction(long transactionId, String name) 210 { 211 if (totalOrderQueue != null) 212 { 213 synchronized (totalOrderQueue) 214 { 215 totalOrderQueue.addLast(new SetSavepoint(transactionId, name)); 216 } 217 } 218 } 219 220 224 protected final void releaseSavepointTransaction(long transactionId, 225 String name) 226 { 227 if (totalOrderQueue != null) 228 { 229 synchronized (totalOrderQueue) 230 { 231 totalOrderQueue.addLast(new ReleaseSavepoint(transactionId, name)); 232 } 233 } 234 } 235 236 242 public String getXmlImpl() 243 { 244 return "<" + DatabasesXmlTags.ELT_RAIDb1Scheduler + " " 245 + DatabasesXmlTags.ATT_level + "=\"" + DatabasesXmlTags.VAL_passThrough 246 + "\"/>"; 247 } 248 } 249 | Popular Tags |