The DRM is composed of a Request Scheduler, an optional Query Cache, and a Load Balancer and an optional Recovery Log. Unlike a non-dsitributed Request Manager, this implementation is responsible for synchronizing the different controllers components (schedulers, ...). Functions that are RAIDb level dependent are implemented in sub-classes.
Definition at line 68 of file DistributedRequestManager.java.
|
Builds a new
Definition at line 94 of file DistributedRequestManager.java. 00099 { 00100 super(vdb, scheduler, cache, loadBalancer, recoveryLog, beginTimeout, 00101 commitTimeout, rollbackTimeout); 00102 dvdb = vdb; 00103 failedOnAllBackends = new Vector(); 00104 writeTransactions = new ArrayList(); 00105 }
|
|
Add a request that failed on all backends.
Definition at line 185 of file DistributedRequestManager.java. 00186 { 00187 failedOnAllBackends.add(request); 00188 }
|
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 251 of file DistributedRequestManager.java. References org.objectweb.cjdbc.controller.recoverylog.AbstractRecoveryLog.begin(), org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer.begin(), org.objectweb.cjdbc.controller.scheduler.AbstractScheduler.begin(), org.objectweb.cjdbc.controller.scheduler.AbstractScheduler.beginCompleted(), org.objectweb.cjdbc.common.log.Trace.debug(), org.objectweb.cjdbc.common.log.Trace.fatal(), org.objectweb.cjdbc.common.log.Trace.isDebugEnabled(), and org.objectweb.cjdbc.controller.requestmanager.TransactionMarkerMetaData.setTransactionId(). 00252 { 00253 try 00254 { 00255 TransactionMarkerMetaData tm = new TransactionMarkerMetaData(0, 00256 beginTimeout, login); 00257 00258 // Wait for the scheduler to give us the authorization to execute 00259 long tid = scheduler.begin(tm); 00260 // 2 first bytes are used for controller id 00261 // 6 right-most bytes are used for transaction id 00262 tid = tid & 0x0000ffffffffffffL; 00263 tid = tid | controllerId; 00264 tm.setTransactionId(tid); 00265 00266 if (logger.isDebugEnabled()) 00267 logger.debug(Translate.get("transaction.begin", String.valueOf(tid))); 00268 00269 try 00270 { 00271 // Send to load balancer 00272 loadBalancer.begin(tm); 00273 00274 // Log the begin 00275 if (recoveryLog != null) 00276 { 00277 recoveryLog.begin(tm); 00278 } 00279 } 00280 catch (SQLException e) 00281 { 00282 throw e; 00283 } 00284 finally 00285 { 00286 // Notify scheduler for completion in any case 00287 scheduler.beginCompleted(tid); 00288 } 00289 00290 tidLoginTable.put(new Long(tid), tm); 00291 return tid; 00292 } 00293 catch (RuntimeException e) 00294 { 00295 logger.fatal(Translate.get( 00296 "fatal.runtime.exception.requestmanager.begin", e)); 00297 throw new SQLException(e.getMessage()); 00298 } 00299 }
|
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 304 of file DistributedRequestManager.java. References org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.distributedCommit(). 00305 { 00306 Long lTid = new Long(transactionId); 00307 boolean isAWriteTransaction; 00308 synchronized (writeTransactions) 00309 { 00310 isAWriteTransaction = writeTransactions.remove(lTid); 00311 } 00312 if (isAWriteTransaction) 00313 distributedCommit(transactionId); 00314 else 00315 // read-only transaction, it is local 00316 super.commit(transactionId); 00317 }
|
|
Notify completion of a request that failed on all backends. If completion was successful, all local backends are disabled.
Definition at line 197 of file DistributedRequestManager.java. References org.objectweb.cjdbc.common.log.Trace.error(), org.objectweb.cjdbc.common.sql.AbstractRequest.getSQLShortForm(), org.objectweb.cjdbc.controller.scheduler.AbstractScheduler.notifyWriteCompleted(), and org.objectweb.cjdbc.common.log.Trace.warn(). 00199 { 00200 if (!failedOnAllBackends.remove(request)) 00201 { 00202 logger.warn("Unable to find request " 00203 + request.getSQLShortForm(dvdb.getSQLShortFormLength()) 00204 + " in list of requests that failed on all backends."); 00205 return; 00206 } 00207 if (success) 00208 { // We have to invalidate all backends 00209 logger 00210 .error("Request " 00211 + request.getSQLShortForm(dvdb.getSQLShortFormLength()) 00212 + " failed on all local backends but succeeded on other controllers. Disabling all local backends."); 00213 try 00214 { 00215 dvdb.disableAllBackends(); 00216 } 00217 catch (VirtualDatabaseException e) 00218 { 00219 logger.error("An error occured while disabling all backends", e); 00220 } 00221 } 00222 else 00223 // Notify scheduler now, the notification was postponed in 00224 // ExecWriteRequest or ExecWriteRequestWithKeys 00225 scheduler.notifyWriteCompleted((AbstractWriteRequest) request); 00226 }
|
|
Distributed implementation of a commit
Implemented in org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb1DistributedRequestManager, and org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb2DistributedRequestManager. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.commit(). |
|
Distributed implementation of a rollback
Implemented in org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb1DistributedRequestManager, and org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb2DistributedRequestManager. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.rollback(). |
|
Enable a backend that has been previously added to this virtual database and that is in the disabled state. We check we the other controllers if this backend must be enabled in read-only or read-write. The current policy is that the first one to enable this backend will have read-write access to it and others will be in read-only.
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 151 of file DistributedRequestManager.java. References org.objectweb.cjdbc.common.log.Trace.debug(), org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer.enableBackend(), org.objectweb.cjdbc.common.log.Trace.error(), org.objectweb.cjdbc.common.log.Trace.info(), and org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.logger. 00152 { 00153 int size = dvdb.getAllMemberButUs().size(); 00154 if (size > 0) 00155 { 00156 logger.debug(Translate 00157 .get("virtualdatabase.distributed.enable.backend.check")); 00158 00159 try 00160 { 00161 // Notify other controllers that we enable this backend. 00162 // No answer is expected. 00163 dvdb.getMulticastRequestAdapter().multicastMessage( 00164 dvdb.getAllMemberButUs(), new EnableBackend(new BackendInfo(db)), 00165 MulticastRequestAdapter.WAIT_NONE, 00166 CJDBCGroupMessage.defaultCastTimeOut); 00167 } 00168 catch (Exception e) 00169 { 00170 String msg = "Error while enabling backend " + db.getName(); 00171 logger.error(msg, e); 00172 throw new SQLException(msg + "(" + e + ")"); 00173 } 00174 } 00175 00176 loadBalancer.enableBackend(db, true); 00177 vdb.logger.info("Database backend " + db.getName() + " enabled"); 00178 }
|
|
Distributed implementation of a read stored procedure execution.
Implemented in org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb1DistributedRequestManager, and org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb2DistributedRequestManager. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execReadStoredProcedure(). |
|
Once the request has been dispatched, it can be executed using the code from
Definition at line 589 of file DistributedRequestManager.java. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execReadStoredProcedure(). 00591 {
00592 return super.execReadStoredProcedure(proc);
00593 }
|
|
Distributed implementation of a write request execution.
Implemented in org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb1DistributedRequestManager, and org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb2DistributedRequestManager. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execWriteRequest(). |
|
Distributed implementation of a write request execution that returns auto-generated keys.
Implemented in org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb1DistributedRequestManager, and org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb2DistributedRequestManager. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execWriteRequestWithKeys(). |
|
Distributed implementation of a write stored procedure execution.
Implemented in org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb1DistributedRequestManager, and org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb2DistributedRequestManager. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execWriteStoredProcedure(). |
|
Once the request has been dispatched, it can be executed using the code from
Definition at line 603 of file DistributedRequestManager.java. 00605 {
00606 return super.execWriteStoredProcedure(proc);
00607 }
|
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 414 of file DistributedRequestManager.java. References org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execRemoteReadRequest(). 00416 { 00417 try 00418 { 00419 return super.execReadRequest(request); 00420 } 00421 catch (SQLException e) 00422 { 00423 if (!(e instanceof NoMoreBackendException)) 00424 throw e; 00425 } 00426 // At this point, we don't have any backend available to execute this query 00427 // on this controller. Let's forward the query to another controller. 00428 return execRemoteReadRequest(controllerId, request); 00429 }
|
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 482 of file DistributedRequestManager.java. References org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedReadStoredProcedure(), and org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedReadStoredProcedureLocally(). 00484 { 00485 // If connection is read-only, we don't broadcast 00486 if (proc.isReadOnly()) 00487 return execDistributedReadStoredProcedureLocally(proc); 00488 00489 if (!proc.isAutoCommit()) 00490 { // Add this transaction to the list of write transactions 00491 Long lTid = new Long(proc.getTransactionId()); 00492 synchronized (writeTransactions) 00493 { 00494 if (!writeTransactions.contains(lTid)) 00495 writeTransactions.add(lTid); 00496 } 00497 } 00498 return execDistributedReadStoredProcedure(proc); 00499 }
|
|
Execute a read request on a remote controller because the local controller don't have any backend available to execute it (usually it already failed locally).
Implemented in org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb1DistributedRequestManager, and org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb2DistributedRequestManager. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execReadRequest(). |
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 447 of file DistributedRequestManager.java. 00448 { 00449 if (!request.isAutoCommit()) 00450 { // Add this transaction to the list of write transactions 00451 Long lTid = new Long(request.getTransactionId()); 00452 synchronized (writeTransactions) 00453 { 00454 if (!writeTransactions.contains(lTid)) 00455 writeTransactions.add(lTid); 00456 } 00457 } 00458 return execDistributedWriteRequest(request); 00459 }
|
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 464 of file DistributedRequestManager.java. 00466 { 00467 if (!request.isAutoCommit()) 00468 { // Add this transaction to the list of write transactions 00469 Long lTid = new Long(request.getTransactionId()); 00470 synchronized (writeTransactions) 00471 { 00472 if (!writeTransactions.contains(lTid)) 00473 writeTransactions.add(lTid); 00474 } 00475 } 00476 return execDistributedWriteRequestWithKeys(request); 00477 }
|
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 504 of file DistributedRequestManager.java. 00505 { 00506 if (!proc.isAutoCommit()) 00507 { // Add this transaction to the list of write transactions 00508 Long lTid = new Long(proc.getTransactionId()); 00509 synchronized (writeTransactions) 00510 { 00511 if (!writeTransactions.contains(lTid)) 00512 writeTransactions.add(lTid); 00513 } 00514 } 00515 return execDistributedWriteStoredProcedure(proc); 00516 }
|
|
Returns the unique controller identifier.
Definition at line 112 of file DistributedRequestManager.java. Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb2DistributedRequestManager.execRemoteReadRequest(), and org.objectweb.cjdbc.controller.requestmanager.distributed.RAIDb1DistributedRequestManager.execRemoteReadRequest(). 00113 {
00114 return controllerId;
00115 }
|
|
Get the trace logger of this DistributedRequestManager
Definition at line 122 of file DistributedRequestManager.java. 00123 {
00124 return logger;
00125 }
|
|
Returns the vdb value.
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 132 of file DistributedRequestManager.java. 00133 {
00134 return dvdb;
00135 }
|
|
Check if the transaction corresponding to the given query has been started remotely and start the transaction locally in a lazy manner if needed.
Definition at line 354 of file DistributedRequestManager.java. References org.objectweb.cjdbc.controller.recoverylog.AbstractRecoveryLog.begin(), org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer.begin(), org.objectweb.cjdbc.controller.scheduler.AbstractScheduler.begin(), org.objectweb.cjdbc.controller.scheduler.AbstractScheduler.beginCompleted(), org.objectweb.cjdbc.common.log.Trace.debug(), org.objectweb.cjdbc.common.log.Trace.fatal(), org.objectweb.cjdbc.common.log.Trace.isDebugEnabled(), and org.objectweb.cjdbc.controller.requestmanager.TransactionMarkerMetaData.setTransactionId(). Referenced by org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.scheduleExecWriteRequest(). 00355 { 00356 // Check if this is a remotely started transaction that we need to lazyly 00357 // start locally 00358 if (!request.isAutoCommit()) 00359 { 00360 long tid = request.getTransactionId(); 00361 if ((tid & 0x0000ffffffffffffL) != controllerId) 00362 { // Remote transaction, check that it is started 00363 if (!tidLoginTable.containsKey(new Long(tid))) 00364 { // Begin this transaction 00365 try 00366 { 00367 TransactionMarkerMetaData tm = new TransactionMarkerMetaData(0, 00368 beginTimeout, request.getLogin()); 00369 tm.setTransactionId(tid); 00370 00371 if (logger.isDebugEnabled()) 00372 logger.debug(Translate.get("transaction.begin.lazy", String 00373 .valueOf(tid))); 00374 00375 try 00376 { 00377 scheduler.begin(tm); 00378 00379 // Send to load balancer 00380 loadBalancer.begin(tm); 00381 00382 // Log the begin 00383 if (recoveryLog != null) 00384 { 00385 recoveryLog.begin(tm); 00386 } 00387 } 00388 catch (SQLException e) 00389 { 00390 throw e; 00391 } 00392 finally 00393 { 00394 // Notify scheduler for completion in any case 00395 scheduler.beginCompleted(tid); 00396 } 00397 00398 tidLoginTable.put(new Long(tid), tm); 00399 } 00400 catch (RuntimeException e) 00401 { 00402 logger.fatal(Translate.get( 00403 "fatal.runtime.exception.requestmanager.begin", e)); 00404 throw new SQLException(e.getMessage()); 00405 } 00406 } 00407 } 00408 } 00409 }
|
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 322 of file DistributedRequestManager.java. References org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.distributedRollback(). 00323 { 00324 Long lTid = new Long(transactionId); 00325 boolean isAWriteTransaction; 00326 synchronized (writeTransactions) 00327 { 00328 isAWriteTransaction = writeTransactions.remove(lTid); 00329 } 00330 if (isAWriteTransaction) 00331 distributedRollback(transactionId); 00332 else 00333 // read-only transaction, it is local 00334 super.rollback(transactionId); 00335 }
|
|
Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager. Definition at line 340 of file DistributedRequestManager.java. References org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.lazyTransactionStart(). 00342 { 00343 lazyTransactionStart(request); 00344 super.scheduleExecWriteRequest(request); 00345 }
|
|
Sets the controller identifier value (this id must be unique).
Definition at line 237 of file DistributedRequestManager.java. References org.objectweb.cjdbc.common.log.Trace.error(). 00238 { 00239 if (id > 0xffff) 00240 { 00241 String msg = "Out of range controller id (" + id + ")"; 00242 logger.error(msg); 00243 throw new RuntimeException(msg); 00244 } 00245 this.controllerId = (0x000000000000ffff & id) << 12; 00246 }
|