1 24 25 package org.objectweb.cjdbc.controller.scheduler.raidb1; 26 27 import java.sql.SQLException ; 28 import java.util.HashSet ; 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 39 50 public class RAIDb1OptimisticQueryLevelScheduler extends AbstractScheduler 51 { 52 53 63 private long requestId; 64 private HashSet completedWrites = new HashSet (); 66 70 73 public RAIDb1OptimisticQueryLevelScheduler() 74 { 75 super(RAIDbLevels.RAIDb1, ParsingGranularities.NO_PARSING); 76 requestId = 0; 77 } 78 79 83 89 public synchronized void scheduleReadRequest(SelectRequest request) 90 throws SQLException 91 { 92 request.setId(requestId++); 93 } 94 95 98 public final void readCompletedNotify(SelectRequest request) 99 { 100 } 101 102 108 public synchronized void scheduleNonSuspendedWriteRequest( 109 AbstractWriteRequest request) throws SQLException 110 { 111 request.setId(requestId++); 112 request.setBlocking(completedWrites.contains(new Long (request 116 .getTransactionId()))); 117 } 118 119 122 public final synchronized void notifyWriteCompleted( 123 AbstractWriteRequest request) 124 { 125 if (!request.isAutoCommit()) 126 completedWrites.add(new Long (request.getTransactionId())); 127 } 128 129 132 public final synchronized void scheduleNonSuspendedStoredProcedure( 133 StoredProcedure proc) throws SQLException , RollbackException 134 { 135 proc.setId(requestId++); 136 proc.setBlocking(completedWrites 137 .contains(new Long (proc.getTransactionId()))); 138 } 139 140 143 public final void notifyStoredProcedureCompleted(StoredProcedure proc) 144 { 145 if (!proc.isAutoCommit()) 146 completedWrites.add(new Long (proc.getTransactionId())); 147 } 148 149 153 156 protected final void commitTransaction(long transactionId) 157 { 158 completedWrites.remove(new Long (transactionId)); 159 } 160 161 164 protected final void rollbackTransaction(long transactionId) 165 { 166 completedWrites.remove(new Long (transactionId)); 167 } 168 169 173 protected final void rollbackTransaction(long transactionId, 174 String savepointName) 175 { 176 } 177 178 182 protected final void setSavepointTransaction(long transactionId, String name) 183 { 184 } 185 186 190 protected final void releaseSavepointTransaction(long transactionId, 191 String name) 192 { 193 } 194 195 199 202 public String getXmlImpl() 203 { 204 return "<" + DatabasesXmlTags.ELT_RAIDb1Scheduler + " " 205 + DatabasesXmlTags.ATT_level + "=\"" 206 + DatabasesXmlTags.VAL_optimisticQuery + "\"/>"; 207 } 208 } 209 | Popular Tags |