Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager Class Reference

Inheritance diagram for org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager:

Inheritance graph
[legend]
Collaboration diagram for org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 DistributedRequestManager (DistributedVirtualDatabase vdb, AbstractScheduler scheduler, AbstractResultCache cache, AbstractLoadBalancer loadBalancer, AbstractRecoveryLog recoveryLog, long beginTimeout, long commitTimeout, long rollbackTimeout) throws SQLException, NotCompliantMBeanException
long getControllerId ()
Trace getLogger ()
VirtualDatabase getVirtualDatabase ()
void enableBackend (DatabaseBackend db) throws SQLException
void addFailedOnAllBackends (AbstractRequest request)
void completeFailedOnAllBackends (AbstractRequest request, boolean success)
void setControllerId (int id)
long begin (String login) throws SQLException
void commit (long transactionId) throws SQLException
void rollback (long transactionId) throws SQLException
void scheduleExecWriteRequest (AbstractWriteRequest request) throws SQLException
void lazyTransactionStart (AbstractRequest request) throws SQLException
ControllerResultSet execReadRequest (SelectRequest request) throws SQLException
abstract ControllerResultSet execRemoteReadRequest (long controllerUniqueId, SelectRequest request) throws SQLException
int execWriteRequest (AbstractWriteRequest request) throws SQLException
ControllerResultSet execWriteRequestWithKeys (AbstractWriteRequest request) throws SQLException
ControllerResultSet execReadStoredProcedure (StoredProcedure proc) throws SQLException
int execWriteStoredProcedure (StoredProcedure proc) throws SQLException
abstract void distributedCommit (long transactionId) throws SQLException
abstract void distributedRollback (long transactionId) throws SQLException
abstract int execDistributedWriteRequest (AbstractWriteRequest request) throws SQLException
abstract ControllerResultSet execDistributedWriteRequestWithKeys (AbstractWriteRequest request) throws SQLException
abstract ControllerResultSet execDistributedReadStoredProcedure (StoredProcedure proc) throws SQLException
abstract int execDistributedWriteStoredProcedure (StoredProcedure proc) throws SQLException
ControllerResultSet execDistributedReadStoredProcedureLocally (StoredProcedure proc) throws SQLException
int execDistributedWriteStoredProcedureLocally (StoredProcedure proc) throws SQLException

Protected Attributes

DistributedVirtualDatabase dvdb

Detailed Description

This class defines a Distributed Request Manager.

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.

Author:
Emmanuel Cecchet
Version:
1.0

Definition at line 68 of file DistributedRequestManager.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.DistributedRequestManager DistributedVirtualDatabase  vdb,
AbstractScheduler  scheduler,
AbstractResultCache  cache,
AbstractLoadBalancer  loadBalancer,
AbstractRecoveryLog  recoveryLog,
long  beginTimeout,
long  commitTimeout,
long  rollbackTimeout
throws SQLException, NotCompliantMBeanException
 

Builds a new DistributedRequestManager instance without cache.

Parameters:
vdb the virtual database this request manager belongs to
scheduler the Request Scheduler to use
cache a Query Cache implementation
loadBalancer the Request Load Balancer to use
recoveryLog the Log Recovery to use
beginTimeout timeout in seconds for begin
commitTimeout timeout in seconds for commit
rollbackTimeout timeout in seconds for rollback
Exceptions:
SQLException if an error occurs
NotCompliantMBeanException if this class is not a compliant JMX MBean

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   }


Member Function Documentation

void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.addFailedOnAllBackends AbstractRequest  request  ) 
 

Add a request that failed on all backends.

Parameters:
request the request that failed

Definition at line 185 of file DistributedRequestManager.java.

00186   {
00187     failedOnAllBackends.add(request);
00188   }

long org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.begin String  login  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.begin(java.lang.String)

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   }

void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.commit long  transactionId  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.commit(long)

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   }

void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.completeFailedOnAllBackends AbstractRequest  request,
boolean  success
 

Notify completion of a request that failed on all backends. If completion was successful, all local backends are disabled.

Parameters:
request request that completed
success true if completion is successful

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   }

abstract void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.distributedCommit long  transactionId  )  throws SQLException [pure virtual]
 

Distributed implementation of a commit

Parameters:
transactionId id of the commiting transaction
Exceptions:
SQLException if an error occurs

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().

abstract void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.distributedRollback long  transactionId  )  throws SQLException [pure virtual]
 

Distributed implementation of a rollback

Parameters:
transactionId id of the rollbacking transaction
Exceptions:
SQLException if an error occurs

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().

void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.enableBackend DatabaseBackend  db  )  throws SQLException
 

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.

Parameters:
db The database backend to enable
Exceptions:
SQLException if an error occurs

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   }

abstract ControllerResultSet org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedReadStoredProcedure StoredProcedure  proc  )  throws SQLException [pure virtual]
 

Distributed implementation of a read stored procedure execution.

Parameters:
proc stored procedure to execute
Returns:
ResultSet corresponding to this stored procedure execution
Exceptions:
SQLException if an error occurs

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().

ControllerResultSet org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedReadStoredProcedureLocally StoredProcedure  proc  )  throws SQLException
 

Once the request has been dispatched, it can be executed using the code from RequestManager

Parameters:
proc stored procedure to execute
Returns:
ResultSet corresponding to this stored procedure execution
Exceptions:
SQLException if an error occurs

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   }

abstract int org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedWriteRequest AbstractWriteRequest  request  )  throws SQLException [pure virtual]
 

Distributed implementation of a write request execution.

Parameters:
request request to execute
Returns:
number of modified rows
Exceptions:
SQLException if an error occurs

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().

abstract ControllerResultSet org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedWriteRequestWithKeys AbstractWriteRequest  request  )  throws SQLException [pure virtual]
 

Distributed implementation of a write request execution that returns auto-generated keys.

Parameters:
request request to execute
Returns:
ResultSet containing the auto-generated keys.
Exceptions:
SQLException if an error occurs

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().

abstract int org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedWriteStoredProcedure StoredProcedure  proc  )  throws SQLException [pure virtual]
 

Distributed implementation of a write stored procedure execution.

Parameters:
proc stored procedure to execute
Returns:
number of modified rows
Exceptions:
SQLException if an error occurs

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().

int org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedWriteStoredProcedureLocally StoredProcedure  proc  )  throws SQLException
 

Once the request has been dispatched, it can be executed using the code from RequestManager

Parameters:
proc stored procedure to execute
Returns:
number of modified rows
Exceptions:
SQLException if an error occurs

Definition at line 603 of file DistributedRequestManager.java.

00605   {
00606     return super.execWriteStoredProcedure(proc);
00607   }

ControllerResultSet org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execReadRequest SelectRequest  request  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.execReadRequest(org.objectweb.cjdbc.common.sql.SelectRequest)

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   }

ControllerResultSet org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execReadStoredProcedure StoredProcedure  proc  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.execReadStoredProcedure(StoredProcedure)

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   }

abstract ControllerResultSet org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execRemoteReadRequest long  controllerUniqueId,
SelectRequest  request
throws SQLException [pure virtual]
 

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).

Parameters:
controllerUniqueId unique identifier of the controller that receives this query from the client
request the request to execute
Returns:
the query ResultSet

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().

int org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execWriteRequest AbstractWriteRequest  request  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.execWriteRequest(org.objectweb.cjdbc.common.sql.AbstractWriteRequest)

Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager.

Definition at line 447 of file DistributedRequestManager.java.

References org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedWriteRequest().

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   }

ControllerResultSet org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execWriteRequestWithKeys AbstractWriteRequest  request  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.execWriteRequestWithKeys(org.objectweb.cjdbc.common.sql.AbstractWriteRequest)

Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager.

Definition at line 464 of file DistributedRequestManager.java.

References org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedWriteRequestWithKeys().

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   }

int org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execWriteStoredProcedure StoredProcedure  proc  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.execWriteStoredProcedure(org.objectweb.cjdbc.common.sql.StoredProcedure)

Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager.

Definition at line 504 of file DistributedRequestManager.java.

References org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.execDistributedWriteStoredProcedure().

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   }

long org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.getControllerId  ) 
 

Returns the unique controller identifier.

Returns:
Returns the controllerId.

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   }

Trace org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.getLogger  ) 
 

Get the trace logger of this DistributedRequestManager

Returns:
a Trace object

Definition at line 122 of file DistributedRequestManager.java.

00123   {
00124     return logger;
00125   }

VirtualDatabase org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.getVirtualDatabase  ) 
 

Returns the vdb value.

Returns:
Returns the vdb.

Reimplemented from org.objectweb.cjdbc.controller.requestmanager.RequestManager.

Definition at line 132 of file DistributedRequestManager.java.

00133   {
00134     return dvdb;
00135   }

void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.lazyTransactionStart AbstractRequest  request  )  throws SQLException
 

Check if the transaction corresponding to the given query has been started remotely and start the transaction locally in a lazy manner if needed.

Parameters:
request query to execute
Exceptions:
SQLException if an error occurs

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   }

void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.rollback long  transactionId  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.rollback(long)

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   }

void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.scheduleExecWriteRequest AbstractWriteRequest  request  )  throws SQLException
 

See also:
org.objectweb.cjdbc.controller.requestmanager.RequestManager.scheduleExecWriteRequest(org.objectweb.cjdbc.common.sql.AbstractWriteRequest)

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   }

void org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManager.setControllerId int  id  ) 
 

Sets the controller identifier value (this id must be unique).

Parameters:
id The controllerId to set.

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   }


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:04:26 2005 for C-JDBC by  doxygen 1.3.9.1