クラス org.objectweb.cjdbc.controller.requestmanager.RequestManager

org.objectweb.cjdbc.controller.requestmanager.RequestManagerに対する継承グラフ

Inheritance graph
[凡例]
すべてのメンバ一覧

説明

This class defines the Request Manager.

The RM is composed of a Request Scheduler, an optional Query Cache, and a Load Balancer and an optional Recovery Log.

作者:
Emmanuel Cecchet

Julie Marguerite

Nicolas Modrzyk

Vadim Kassin

バージョン:
1.0

RequestManager.java78 行で定義されています。

Public メソッド

 RequestManager (VirtualDatabase vdb, AbstractScheduler scheduler, AbstractResultCache cache, AbstractLoadBalancer loadBalancer, AbstractRecoveryLog recoveryLog, long beginTimeout, long commitTimeout, long rollbackTimeout) throws SQLException
ControllerResultSet execReadRequest (SelectRequest request) throws SQLException
int execWriteRequest (AbstractWriteRequest request) throws SQLException
ControllerResultSet execWriteRequestWithKeys (AbstractWriteRequest request) throws SQLException
void scheduleExecWriteRequest (AbstractWriteRequest request) throws SQLException
ControllerResultSet loadBalanceExecWriteRequestWithKeys (AbstractWriteRequest request) throws AllBackendsFailedException, SQLException
int loadBalanceExecWriteRequest (AbstractWriteRequest request) throws AllBackendsFailedException, SQLException
void updateAndNotifyExecWriteRequest (AbstractWriteRequest request, boolean notifyScheduler) throws SQLException
ControllerResultSet execReadStoredProcedure (StoredProcedure proc) throws SQLException
int execWriteStoredProcedure (StoredProcedure proc) throws SQLException
long begin (String login) throws SQLException
TransactionMarkerMetaData getTransactionMarker (Long tid) throws SQLException
void completeTransaction (Long tid)
void commit (long transactionId) throws SQLException
void rollback (long transactionId) throws SQLException
void enableBackend (DatabaseBackend db) throws SQLException
void restoreBackendFromBackupCheckpoint (DatabaseBackend db, String checkpointName) throws OctopusException, BackupException
void enableBackendFromCheckpoint (DatabaseBackend db, String checkpointName) throws SQLException
void disableBackend (DatabaseBackend db) throws SQLException
void disableBackendForCheckpoint (DatabaseBackend db, String checkpointName) throws SQLException
void removeCheckpoint (String checkpointName) throws SQLException
void disableBackendsForCheckpoint (ArrayList backends, String checkpointName) throws SQLException
void backupBackendWithCheckpoint (DatabaseBackend db, String checkpointName, ArrayList tables, boolean enableAfter) throws SQLException
void storeBackendsCheckpoint (String databaseName, ArrayList backends)
VirtualDatabase getVirtualDatabase ()
void setDatabaseSchema (DatabaseSchema schema, boolean isStatic)
void mergeDatabaseSchema (DatabaseSchema backendSchema)
DatabaseSchema getDatabaseSchema ()
AbstractLoadBalancer getLoadBalancer ()
void setLoadBalancer (AbstractLoadBalancer loadBalancer)
AbstractResultCache getResultCache ()
MetadataCache getMetadataCache ()
void setMetadataCache (MetadataCache metadataCache)
void setParsingCache (ParsingCache parsingCache)
AbstractRecoveryLog getRecoveryLog ()
void setRecoveryLog (AbstractRecoveryLog recoveryLog)
void setRequestCache (AbstractResultCache cache)
AbstractScheduler getScheduler ()
void setScheduler (AbstractScheduler scheduler)
void setCaseSensitiveParsing (boolean isCaseSensitiveParsing)
int getRequiredParsingGranularity ()
String getXml ()

Static Public メソッド

String handleSQLMacros (String originalSql, long timestampResolution, boolean handleOnlyNow)

Protected 変数

long beginTimeout
long commitTimeout
long rollbackTimeout
VirtualDatabase vdb
AbstractScheduler scheduler
AbstractResultCache requestCache
AbstractLoadBalancer loadBalancer
AbstractRecoveryLog recoveryLog
DatabaseSchema dbs
ParsingCache parsingCache = null
int schedulerParsingranularity = ParsingGranularities.NO_PARSING
int requiredGranularity = ParsingGranularities.NO_PARSING
Hashtable tidLoginTable

Static Protected 変数

Trace logger = null

Private メソッド

void setBackendsLastKnownCheckpointFromRecoveryLog ()
void assignAndCheckSchedulerLoadBalancerValidity (AbstractScheduler scheduler, AbstractLoadBalancer loadBalancer) throws SQLException
void initRequestManagerVariables (VirtualDatabase vdb, long beginTimeout, long commitTimeout, long rollbackTimeout)
void addWorkerTask (BackendWorkerThread bwt, AbstractTask task)

Private 変数

boolean schemaIsStatic = false
boolean isCaseSensitiveParsing = false
MetadataCache metadataCache = null
int cacheParsingranularity = ParsingGranularities.NO_PARSING
int loadBalancerParsingranularity = ParsingGranularities.NO_PARSING


コンストラクタとデストラクタ

org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager VirtualDatabase  vdb,
AbstractScheduler  scheduler,
AbstractResultCache  cache,
AbstractLoadBalancer  loadBalancer,
AbstractRecoveryLog  recoveryLog,
long  beginTimeout,
long  commitTimeout,
long  rollbackTimeout
throws SQLException
 

Creates a new RequestManager instance.

引数:
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
例外:
SQLException if an error occurs

RequestManager.java149 行で定義されています。

参照先 org.objectweb.cjdbc.controller.requestmanager.RequestManager.assignAndCheckSchedulerLoadBalancerValidity(), org.objectweb.cjdbc.controller.requestmanager.RequestManager.beginTimeout, org.objectweb.cjdbc.controller.requestmanager.RequestManager.cacheParsingranularity, org.objectweb.cjdbc.controller.requestmanager.RequestManager.commitTimeout, org.objectweb.cjdbc.common.log.Trace.info(), org.objectweb.cjdbc.controller.requestmanager.RequestManager.initRequestManagerVariables(), org.objectweb.cjdbc.controller.requestmanager.RequestManager.recoveryLog, org.objectweb.cjdbc.controller.requestmanager.RequestManager.requestCache, org.objectweb.cjdbc.controller.requestmanager.RequestManager.requiredGranularity, org.objectweb.cjdbc.controller.requestmanager.RequestManager.rollbackTimeout, org.objectweb.cjdbc.controller.requestmanager.RequestManager.scheduler, と org.objectweb.cjdbc.controller.requestmanager.RequestManager.setBackendsLastKnownCheckpointFromRecoveryLog().

00153   {
00154     assignAndCheckSchedulerLoadBalancerValidity(scheduler, loadBalancer);
00155     // requiredGranularity is the maximum of each component granularity
00156     this.requestCache = cache;
00157     if (requestCache != null)
00158     {
00159       cacheParsingranularity = cache.getParsingGranularity();
00160       if (cacheParsingranularity > requiredGranularity)
00161         requiredGranularity = cacheParsingranularity;
00162     }
00163     this.recoveryLog = recoveryLog;
00164     initRequestManagerVariables(vdb, beginTimeout, commitTimeout,
00165         rollbackTimeout);
00166     setBackendsLastKnownCheckpointFromRecoveryLog();
00167     logger.info(Translate.get("requestmanager.parsing.granularity",
00168         ParsingGranularities.getInformation(requiredGranularity)));
00169   }


メソッド

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.addWorkerTask BackendWorkerThread  bwt,
AbstractTask  task
[private]
 

Add a task to a BackendWorkerThread using the proper synchronization.

引数:
bwt BackendWorkerThread to synchronize on
task the task to add to the thread queue

RequestManager.java1121 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.BackendWorkerThread.addTask().

01122   {
01123     synchronized (bwt)
01124     {
01125       bwt.addTask(task);
01126       bwt.notify();
01127     }
01128   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.assignAndCheckSchedulerLoadBalancerValidity AbstractScheduler  scheduler,
AbstractLoadBalancer  loadBalancer
throws SQLException [private]
 

Check that Scheduler and Load Balancer are not null and have compatible RAIDb levels.

引数:
scheduler 
loadBalancer 
例外:
SQLException if an error occurs

RequestManager.java211 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer.getRAIDbLevel(), org.objectweb.cjdbc.controller.scheduler.AbstractScheduler.getRAIDbLevel(), と org.objectweb.cjdbc.controller.requestmanager.RequestManager.scheduler.

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

00214   {
00215     if (scheduler == null)
00216       throw new SQLException(Translate.get("requestmanager.null.scheduler"));
00217 
00218     if (loadBalancer == null)
00219       throw new SQLException(Translate.get("requestmanager.null.loadbalancer"));
00220 
00221     if (scheduler.getRAIDbLevel() != loadBalancer.getRAIDbLevel())
00222       throw new SQLException(Translate.get(
00223           "requestmanager.incompatible.raidb.levels",
00224           new String[]{"" + scheduler.getRAIDbLevel(),
00225               "" + loadBalancer.getRAIDbLevel()}));
00226 
00227     // requiredGranularity is the maximum of each component granularity
00228     this.scheduler = scheduler;
00229     schedulerParsingranularity = scheduler.getParsingGranularity();
00230     requiredGranularity = schedulerParsingranularity;
00231     this.loadBalancer = loadBalancer;
00232     loadBalancerParsingranularity = loadBalancer.getParsingGranularity();
00233     if (loadBalancerParsingranularity > requiredGranularity)
00234       requiredGranularity = loadBalancerParsingranularity;
00235   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.backupBackendWithCheckpoint DatabaseBackend  db,
String  checkpointName,
ArrayList  tables,
boolean  enableAfter
throws SQLException
 

Creates a new backup with the corresponding checkpoint Note that this will disable the backend for the time of the backup

引数:
db the backend to backup
checkpointName the checkpoint to insert in the log
tables to copy or null for copy all
enableAfter if the backend should be enable after backup
例外:
SQLException if fails

RequestManager.java1408 行で定義されています。

参照先 org.objectweb.cjdbc.controller.core.backup.Octopus.backup().

01411   {
01412     //  Sanity checks
01413     if (recoveryLog == null)
01414     {
01415       String msg = Translate.get("recovery.store.checkpoint.failed.cause.null",
01416           checkpointName);
01417       logger.error(msg);
01418       throw new SQLException(msg);
01419     }
01420 
01421     // Wait for all pending transactions to finish
01422     logger.info(Translate.get("requestmanager.wait.pending.transactions"));
01423     scheduler.suspendNewTransactionsForCheckpoint();
01424     scheduler.suspendWrites();
01425 
01426     // Disable backend if needed
01427     if (db.isReadEnabled())
01428     {
01429       disableBackend(db);
01430       logger.info(Translate.get("backend.state.disabled", db.getName()));
01431     }
01432 
01433     // Store checkpoint
01434     recoveryLog.storeCheckpoint(checkpointName);
01435     logger.info(Translate.get("recovery.checkpoint.stored", checkpointName));
01436 
01437     // Resume writes and transactions
01438     scheduler.resumeNewTransactions();
01439     scheduler.resumeWrites();
01440 
01441     try
01442     {
01443       logger.info(Translate
01444           .get("controller.backup.octopus.start", db.getName()));
01445       Octopus octopus = new Octopus(db, checkpointName, tables);
01446       octopus.backup();
01447       db.setLastKnownCheckpoint(checkpointName);
01448     }
01449     catch (OctopusException e)
01450     {
01451       logger.error(Translate.get("controller.backup.octopus.failed", e));
01452       throw new SQLException(e.getMessage());
01453     }
01454     catch (BackupException be)
01455     {
01456       logger.error(Translate.get("controller.backup.failed", be));
01457       throw new SQLException(be.getMessage());
01458     }
01459     logger.info(Translate.get("controller.backup.complete", db.getName()));
01460 
01461     //    if (enableAfter)
01462     //    {
01463     //      enableBackendFromCheckpoint(db,checkpointName);
01464     //    }
01465 
01466   }

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

Begin a new transaction and return the corresponding transaction identifier. This method is called from the driver when setAutoCommit(false) is called.

引数:
login the login used by the connection
戻り値:
int a unique transaction identifier
例外:
SQLException if an error occurs

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManagerで再定義されています。

RequestManager.java900 行で定義されています。

参照先 org.objectweb.cjdbc.controller.requestmanager.TransactionMarkerMetaData.setTransactionId().

00901   {
00902     try
00903     {
00904       TransactionMarkerMetaData tm = new TransactionMarkerMetaData(0,
00905           beginTimeout, login);
00906 
00907       // Wait for the scheduler to give us the authorization to execute
00908       long tid = scheduler.begin(tm);
00909       tm.setTransactionId(tid);
00910 
00911       if (logger.isDebugEnabled())
00912         logger.debug(Translate.get("transaction.begin", String.valueOf(tid)));
00913 
00914       try
00915       {
00916         // Send to load balancer
00917         loadBalancer.begin(tm);
00918 
00919         // Log the begin
00920         if (recoveryLog != null)
00921         {
00922           recoveryLog.begin(tm);
00923         }
00924       }
00925       catch (SQLException e)
00926       {
00927         throw e;
00928       }
00929       finally
00930       {
00931         // Notify scheduler for completion in any case
00932         scheduler.beginCompleted(tid);
00933       }
00934 
00935       tidLoginTable.put(new Long(tid), tm);
00936       return tid;
00937     }
00938     catch (RuntimeException e)
00939     {
00940       logger.fatal(Translate.get(
00941           "fatal.runtime.exception.requestmanager.begin", e));
00942       throw new SQLException(e.getMessage());
00943     }
00944   }

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

Commit a transaction given its id.

引数:
transactionId the transaction id
例外:
SQLException if an error occurs

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManagerで再定義されています。

RequestManager.java983 行で定義されています。

参照先 org.objectweb.cjdbc.controller.requestmanager.TransactionMarkerMetaData.getTransactionId().

00984   {
00985     try
00986     {
00987       Long tid = new Long(transactionId);
00988       TransactionMarkerMetaData tm = getTransactionMarker(tid);
00989 
00990       // Wait for the scheduler to give us the authorization to execute
00991       scheduler.commit(tm);
00992 
00993       if (logger.isDebugEnabled())
00994         logger.debug(Translate.get("transaction.commit", String.valueOf(tid)));
00995 
00996       try
00997       {
00998         // Send to load balancer
00999         loadBalancer.commit(tm);
01000 
01001         // Notify the cache
01002         if (requestCache != null)
01003           requestCache.commit(tm.getTransactionId());
01004 
01005         // Notify the recovery log manager
01006         if (recoveryLog != null)
01007           recoveryLog.commit(tm);
01008       }
01009       catch (SQLException e)
01010       {
01011         throw e;
01012       }
01013       catch (AllBackendsFailedException e)
01014       {
01015         String msg = "All backends failed to commit transaction "
01016             + transactionId + " (" + e + ")";
01017         logger.error(msg);
01018         throw new SQLException(msg);
01019       }
01020       finally
01021       {
01022         // Notify scheduler for completion
01023         scheduler.commitCompleted(transactionId);
01024 
01025         completeTransaction(tid);
01026       }
01027     }
01028     catch (RuntimeException e)
01029     {
01030       logger.fatal(Translate.get(
01031           "fatal.runtime.exception.requestmanager.commit", e));
01032       throw new SQLException(e.getMessage());
01033     }
01034   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.completeTransaction Long  tid  ) 
 

Complete the transaction by removing it for the tidLoginTable.

引数:
tid transaction id

RequestManager.java972 行で定義されています。

00973   {
00974     tidLoginTable.remove(tid);
00975   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.disableBackend DatabaseBackend  db  )  throws SQLException
 

Disable a backend that is currently enabled on this virtual database.

The backend is disabled without further check.

The load balancer disabled method is called on the specified backend.

引数:
db The database backend to disable
例外:
SQLException if an error occurs

RequestManager.java1308 行で定義されています。

01309   {
01310     if (db.isReadEnabled() || db.isWriteEnabled())
01311     {
01312       loadBalancer.disableBackend(db);
01313       logger.info(Translate.get("backend.state.disabled", db.getName()));
01314     }
01315     else
01316     {
01317       throw new SQLException(Translate.get("backend.already.disabled", db
01318           .getName()));
01319     }
01320   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.disableBackendForCheckpoint DatabaseBackend  db,
String  checkpointName
throws SQLException
 

The backend must belong to this virtual database and be in the enabled state.

The backend is disabled once all the pending write queries are executed. A checkpoint is inserted in the recovery log.

引数:
db The database backend to enable
checkpointName The checkpoint name to restart from
例外:
SQLException if an error occurs

RequestManager.java1333 行で定義されています。

01335   {
01336     ArrayList al = new ArrayList(1);
01337     al.add(db);
01338     this.disableBackendsForCheckpoint(al, checkpointName);
01339   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.disableBackendsForCheckpoint ArrayList  backends,
String  checkpointName
throws SQLException
 

Disable a list of backends. Only to store only one checkpoint, and to disable all the backends at the same time so the the system is in a coherent state.

引数:
backends to disable
checkpointName to store
例外:
SQLException if an error occurs

RequestManager.java1361 行で定義されています。

参照先 org.objectweb.cjdbc.controller.backend.DatabaseBackend.getName(), と org.objectweb.cjdbc.controller.backend.DatabaseBackend.setLastKnownCheckpoint().

01363   {
01364     // Sanity checks
01365     if (recoveryLog == null)
01366     {
01367       String msg = Translate.get("recovery.store.checkpoint.failed.cause.null",
01368           checkpointName);
01369       logger.error(msg);
01370       throw new SQLException(msg);
01371     }
01372 
01373     // Wait for all pending transactions to finish
01374     logger.info(Translate.get("requestmanager.wait.pending.transactions"));
01375     scheduler.suspendNewTransactionsForCheckpoint();
01376     scheduler.suspendWrites();
01377 
01378     // Store checkpoint
01379     recoveryLog.storeCheckpoint(checkpointName);
01380     logger.info(Translate.get("recovery.checkpoint.stored", checkpointName));
01381 
01382     // Disable all backends
01383     int size = backends.size();
01384     DatabaseBackend db;
01385     for (int i = 0; i < size; i++)
01386     {
01387       db = (DatabaseBackend) backends.get(i);
01388       loadBalancer.disableBackend(db);
01389       db.setLastKnownCheckpoint(checkpointName);
01390       logger.info(Translate.get("backend.state.disabled", db.getName()));
01391     }
01392 
01393     // Resume transactions and writes
01394     scheduler.resumeNewTransactions();
01395     scheduler.resumeWrites();
01396   }

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

Enable a backend that has been previously added to this virtual database and that is in the disabled state.

The backend is enabled without further check.

The enableBackend method of the load balancer is called.

引数:
db The database backend to enable
例外:
SQLException if an error occurs

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManagerで再定義されています。

RequestManager.java1109 行で定義されています。

01110   {
01111     loadBalancer.enableBackend(db, true);
01112     logger.info(Translate.get("backend.state.enabled", db.getName()));
01113   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.enableBackendFromCheckpoint DatabaseBackend  db,
String  checkpointName
throws SQLException
 

The backend must have been previously added to this virtual database and be in the disabled state.

All the queries since the given checkpoint are played and the backend state is set to enabled when it is completely synchronized.

引数:
db The database backend to enable
checkpointName The checkpoint name to restart from
例外:
SQLException if an error occurs

RequestManager.java1188 行で定義されています。

参照先 org.objectweb.cjdbc.controller.recoverylog.RecoveryTask.getId(), と org.objectweb.cjdbc.controller.recoverylog.RecoveryTask.getTask().

01190   {
01191     // Sanity check
01192     if (recoveryLog == null)
01193     {
01194       String msg = Translate.get(
01195           "recovery.restore.checkpoint.failed.cause.null", checkpointName);
01196       logger.error(msg);
01197       throw new SQLException(msg);
01198     }
01199 
01200     db.initializeConnections();
01201     recoveryLog.beginRecovery();
01202 
01203     // Get the checkpoint from the recovery log
01204     long logIdx;
01205     try
01206     {
01207       logIdx = recoveryLog.getCheckpointRequestId(checkpointName);
01208     }
01209     catch (SQLException e)
01210     {
01211       recoveryLog.endRecovery();
01212       String msg = Translate.get("recovery.cannot.get.checkpoint", e);
01213       logger.error(msg);
01214       throw new SQLException(msg);
01215     }
01216 
01217     // Get a temporary worker thread to execute the queries on this backend
01218     BackendWorkerThread bwt = new BackendWorkerThread(db, loadBalancer);
01219     bwt.start();
01220     RecoveryTask recoveryTask = null;
01221 
01222     logger.info(Translate.get("recovery.start.process"));
01223 
01224     // Replay the whole log
01225     while (logIdx != -1)
01226     {
01227       try
01228       {
01229         recoveryTask = recoveryLog.recoverNextRequest(logIdx);
01230       }
01231       catch (SQLException e)
01232       {
01233         // Signal end of recovery and kill worker thread
01234         recoveryLog.endRecovery();
01235         addWorkerTask(bwt, new KillThreadTask(1, 1));
01236         String msg = Translate.get("recovery.cannot.recover.from.index", e);
01237         logger.error(msg);
01238         throw new SQLException(msg);
01239       }
01240       if (recoveryTask == null)
01241         break;
01242       addWorkerTask(bwt, recoveryTask.getTask());
01243       logIdx = recoveryTask.getId();
01244     }
01245 
01246     // Suspend the writes
01247     scheduler.suspendWrites();
01248 
01249     // Play the remaining writes that were pending
01250     logIdx++;
01251 
01252     while (logIdx != -1)
01253     {
01254       try
01255       {
01256         recoveryTask = recoveryLog.recoverNextRequest(logIdx);
01257       }
01258       catch (SQLException e)
01259       {
01260         // Signal end of recovery and kill worker thread
01261         recoveryLog.endRecovery();
01262         addWorkerTask(bwt, new KillThreadTask(1, 1));
01263         String msg = Translate.get("recovery.cannot.recover.from.index", e);
01264         logger.error(msg);
01265         scheduler.resumeWrites();
01266         throw new SQLException(msg);
01267       }
01268       if (recoveryTask == null)
01269         break;
01270       addWorkerTask(bwt, recoveryTask.getTask());
01271       logIdx = recoveryTask.getId();
01272     }
01273 
01274     // We are done with the recovery
01275     logger.info(Translate.get("recovery.process.complete"));
01276     addWorkerTask(bwt, new KillThreadTask(1, 1));
01277     try
01278     {
01279       bwt.join();
01280     }
01281     catch (InterruptedException e)
01282     {
01283       recoveryLog.endRecovery();
01284       String msg = Translate.get("recovery.join.failed", e);
01285       logger.error(msg);
01286       scheduler.resumeWrites();
01287       throw new SQLException(msg);
01288     }
01289 
01290     recoveryLog.endRecovery();
01291 
01292     // Now enable it
01293     loadBalancer.enableBackend(db, true);
01294     scheduler.resumeWrites();
01295     logger.info(Translate.get("backend.state.enabled", db.getName()));
01296   }

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

Perform a read request and return the reply. Call first the scheduler (if defined), then the cache (if defined) and finally the load balancer.

引数:
request the request to execute
戻り値:
a ControllerResultSet value
例外:
SQLException if an error occurs

RequestManager.java290 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execReadRequest().

00292   {
00293     // Sanity check
00294     if (!request.isAutoCommit())
00295     { // Check that the transaction has been started
00296       long tid = request.getTransactionId();
00297       if (!tidLoginTable.containsKey(new Long(tid)))
00298         throw new SQLException(Translate.get("transaction.not.started", tid));
00299     }
00300 
00301     // If we need to parse the request, try to get the parsing from the cache.
00302     // Note that if we have a cache miss but backgroundParsing has been turned
00303     // on, then this call will start a ParsedThread in background.
00304     if ((requiredGranularity != ParsingGranularities.NO_PARSING)
00305         && (!request.isParsed()))
00306     {
00307       if (parsingCache == null)
00308         request.parse(dbs, requiredGranularity, isCaseSensitiveParsing);
00309       else
00310         parsingCache.getParsingFromCache(request);
00311     }
00312 
00313     //
00314     // SCHEDULER
00315     //
00316 
00317     // Get the parsing now if the request is not yet parsed. The parsing is
00318     // handled by the ParsingCache that may already have parsed the request
00319     // in background (if backgroundParsing is set).
00320     if ((schedulerParsingranularity != ParsingGranularities.NO_PARSING)
00321         && !request.isParsed())
00322     {
00323       if (parsingCache == null)
00324         request.parse(dbs, requiredGranularity, isCaseSensitiveParsing);
00325       else
00326         parsingCache.getParsingFromCacheAndParseIfMissing(request);
00327     }
00328 
00329     // Wait for the scheduler to give us the authorization to execute
00330     scheduler.scheduleReadRequest(request);
00331 
00332     if (logger.isDebugEnabled())
00333       logger.debug(Translate.get("requestmanager.read.request", new String[]{
00334           request.getId() + "",
00335           request.getSQLShortForm(vdb.getSQLShortFormLength())}));
00336 
00337     //
00338     // CACHE
00339     //
00340 
00341     ControllerResultSet result = null;
00342     try
00343     { // Check cache if any
00344       if (requestCache != null)
00345       {
00346         CacheEntry qce = requestCache.getFromCache(request, true);
00347         if (qce != null)
00348         {
00349           result = qce.getResult();
00350           if (result != null)
00351           { // Cache hit !
00352             if (vdb.getSQLMonitor() != null)
00353               vdb.getSQLMonitor().logCacheHit(request);
00354 
00355             scheduler.readCompleted(request);
00356             return result;
00357           }
00358         }
00359       }
00360 
00361       //
00362       // LOAD BALANCER
00363       //
00364 
00365       // At this point, we have a result cache miss.
00366       // If we had a parsing cache miss too, wait for the parsing to be done if
00367       // needed.
00368       if ((loadBalancerParsingranularity != ParsingGranularities.NO_PARSING)
00369           && !request.isParsed())
00370       {
00371         if (parsingCache == null)
00372           request.parse(dbs, requiredGranularity, isCaseSensitiveParsing);
00373         else
00374           parsingCache.getParsingFromCacheAndParseIfMissing(request);
00375       }
00376 
00377       // Send the request to the load balancer
00378       result = new ControllerResultSet(request, loadBalancer
00379           .execReadRequest(request), metadataCache);
00380 
00381       //
00382       // UPDATES & NOTIFICATIONS
00383       //
00384 
00385       // Update cache
00386       if ((requestCache != null)
00387           && (request.getCacheAbility() != RequestType.UNCACHEABLE))
00388       {
00389         if (!request.isParsed()
00390             && (cacheParsingranularity != ParsingGranularities.NO_PARSING))
00391         { // The cache was the only one to need parsing and
00392           // the request was not previously in the cache
00393           {
00394             if (parsingCache == null)
00395               request.parse(dbs, requiredGranularity, isCaseSensitiveParsing);
00396             else
00397               parsingCache.getParsingFromCacheAndParseIfMissing(request);
00398           }
00399         }
00400         requestCache.addToCache(request, result);
00401       }
00402     }
00403     catch (Exception failed)
00404     {
00405       if (requestCache != null)
00406         requestCache.removeFromPendingQueries(request);
00407       scheduler.readCompleted(request);
00408       String msg = Translate.get("requestmanager.request.failed", new String[]{
00409           request.getSQLShortForm(vdb.getSQLShortFormLength()),
00410           failed.getMessage()});
00411       if (failed instanceof RuntimeException)
00412         logger.warn(msg, failed);
00413       else
00414         logger.warn(msg);
00415       throw new SQLException(msg);
00416     }
00417 
00418     // Notify scheduler of completion
00419     scheduler.readCompleted(request);
00420 
00421     return result;
00422   }

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

Call a stored procedure that returns a ResultSet.

引数:
proc the stored procedure call
戻り値:
a ControllerResultSet value
例外:
SQLException if an error occurs

RequestManager.java702 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execReadStoredProcedure().

00704   {
00705     // Sanity check
00706     if (!proc.isAutoCommit())
00707     { // Check that the transaction has been started
00708       long tid = proc.getTransactionId();
00709       if (!tidLoginTable.containsKey(new Long(tid)))
00710         throw new SQLException(Translate.get("transaction.not.started", tid));
00711     }
00712 
00713     //
00714     // SCHEDULER
00715     //
00716 
00717     // Note that no parsing is required for stored procedures.
00718     // We build a fake request that span over all tables to be sure
00719     // that the scheduler will lock everything.
00720     SelectRequest spanOnAllTables = null;
00721     if (requiredGranularity != ParsingGranularities.NO_PARSING)
00722     {
00723       String sql = "SELECT * FROM";
00724       ArrayList tables = dbs.getTables();
00725       int size = tables.size();
00726       // The following code does not generate a syntaxically correct SQL
00727       // request (an extra coma at the beginning) but that is not an issue.
00728       for (int i = 0; i < size; i++)
00729         sql += " ," + ((DatabaseTable) tables.get(i)).getName();
00730 
00731       spanOnAllTables = new SelectRequest(sql, false, 0);
00732     }
00733     else
00734       spanOnAllTables = new SelectRequest("select * from x", false, 0);
00735 
00736     // Wait for the scheduler to give us the authorization to execute
00737     scheduler.scheduleReadRequest(spanOnAllTables);
00738 
00739     if (logger.isDebugEnabled())
00740       logger.debug(Translate.get("requestmanager.read.store.procedure",
00741           new String[]{String.valueOf(proc.getId()),
00742               proc.getSQLShortForm(vdb.getSQLShortFormLength())}));
00743 
00744     //
00745     // CACHE
00746     //
00747 
00748     // Cache is always flushed unless the user has explicitely set the
00749     // connection to read-only mode in which case we assume that the
00750     // users deliberately forces the cache not to be flushed when calling
00751     // this stored procedure.
00752     if ((requestCache != null) && (!proc.isReadOnly()))
00753       requestCache.flushCache();
00754 
00755     ControllerResultSet result = null;
00756     try
00757     {
00758       //
00759       // LOAD BALANCER
00760       //
00761 
00762       // Send the request to the load balancer
00763       if (proc.isReadOnly())
00764         result = new ControllerResultSet(proc, loadBalancer
00765             .execReadOnlyReadStoredProcedure(proc), metadataCache);
00766       else
00767         result = new ControllerResultSet(proc, loadBalancer
00768             .execReadStoredProcedure(proc), metadataCache);
00769 
00770       //
00771       // RECOVERY LOG
00772       //
00773 
00774       if (recoveryLog != null)
00775         recoveryLog.logRequest(proc, true);
00776 
00777     }
00778     catch (Exception failed)
00779     {
00780       scheduler.readCompleted(spanOnAllTables);
00781       String msg = Translate.get("requestmanager.store.procedure.failed",
00782           new String[]{proc.getSQLShortForm(vdb.getSQLShortFormLength()),
00783               failed.getMessage()});
00784       logger.warn(msg);
00785       throw new SQLException(msg);
00786     }
00787 
00788     // Notify scheduler of completion
00789     scheduler.readCompleted(spanOnAllTables);
00790 
00791     return result;
00792   }

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

Perform a write request and return the number of rows affected Call first the scheduler (if defined), then notify the cache (if defined) and finally call the load balancer.

引数:
request the request to execute
戻り値:
number of rows affected
例外:
SQLException if an error occurs

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManagerで再定義されています。

RequestManager.java433 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execWriteRequest().

00434   {
00435     scheduleExecWriteRequest(request);
00436     int execWriteRequestResult = 0;
00437     try
00438     {
00439       execWriteRequestResult = loadBalanceExecWriteRequest(request);
00440     }
00441     catch (AllBackendsFailedException e)
00442     {
00443       logger.fatal(Translate
00444           .get("requestmanager.write.request.failed.unexpected"), e);
00445     }
00446     updateAndNotifyExecWriteRequest(request, true);
00447     return execWriteRequestResult;
00448   }

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

Perform a write request and return the auto generated keys. Call first the scheduler (if defined), then notify the cache (if defined) and finally call the load balancer.

引数:
request the request to execute
戻り値:
auto generated keys.
例外:
SQLException if an error occurs

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManagerで再定義されています。

RequestManager.java459 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.execWriteRequestWithKeys().

00461   {
00462     scheduleExecWriteRequest(request);
00463     ControllerResultSet execWriteRequestWithKeysResult = null;
00464     try
00465     {
00466       execWriteRequestWithKeysResult = loadBalanceExecWriteRequestWithKeys(request);
00467     }
00468     catch (AllBackendsFailedException e)
00469     {
00470       logger.fatal(Translate
00471           .get("requestmanager.write.request.keys.failed.unexpected"), e);
00472     }
00473     updateAndNotifyExecWriteRequest(request, true);
00474     return execWriteRequestWithKeysResult;
00475   }

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

Call a stored procedure that performs an update.

引数:
proc the stored procedure call
戻り値:
number of rows affected
例外:
SQLException if an error occurs

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManagerで再定義されています。

RequestManager.java801 行で定義されています。

00802   {
00803     // Sanity check
00804     if (!proc.isAutoCommit())
00805     { // Check that the transaction has been started
00806       long tid = proc.getTransactionId();
00807       if (!tidLoginTable.containsKey(new Long(tid)))
00808         throw new SQLException(Translate.get("transaction.not.started", String
00809             .valueOf(tid)));
00810     }
00811 
00812     //
00813     // SCHEDULER
00814     //
00815 
00816     // Note that no parsing is required for stored procedures.
00817     // We build a fake request that span over all tables to be sure
00818     // that the scheduler will lock everything.
00819     SelectRequest spanOnAllTables = null;
00820     if (requiredGranularity != ParsingGranularities.NO_PARSING)
00821     {
00822       String sql = "SELECT * FROM";
00823       ArrayList tables = dbs.getTables();
00824       int size = tables.size();
00825       // The following code does not generate a syntaxically correct SQL
00826       // request (an extra coma at the beginning) but that is not an issue.
00827       for (int i = 0; i < size; i++)
00828         sql += " ," + ((DatabaseTable) tables.get(i)).getName();
00829 
00830       spanOnAllTables = new SelectRequest(sql, false, 0);
00831     }
00832     else
00833       spanOnAllTables = new SelectRequest("select * from x", false, 0);
00834 
00835     // Wait for the scheduler to give us the authorization to execute
00836     // We schedule a read even if it is a write because there is no
00837     // way to lock all tables for write in a single query. FIXME!
00838     scheduler.scheduleReadRequest(spanOnAllTables);
00839 
00840     if (logger.isDebugEnabled())
00841       logger.debug(Translate.get("requestmanager.read.store.procedure",
00842           new String[]{proc.getId() + "",
00843               proc.getSQLShortForm(vdb.getSQLShortFormLength())}));
00844 
00845     //
00846     // CACHE
00847     //
00848 
00849     // Flush cache if any
00850     if (requestCache != null)
00851       requestCache.flushCache();
00852 
00853     int result;
00854     try
00855     {
00856       //
00857       // LOAD BALANCER
00858       //
00859 
00860       // Send the request to the load balancer
00861       result = loadBalancer.execWriteStoredProcedure(proc);
00862 
00863       //
00864       // RECOVERY LOG
00865       //
00866 
00867       if (recoveryLog != null)
00868         recoveryLog.logRequest(proc, false);
00869 
00870     }
00871     catch (Exception failed)
00872     {
00873       scheduler.readCompleted(spanOnAllTables);
00874       String msg = Translate.get("requestmanager.store.procedure.failed",
00875           new String[]{proc.getSQLShortForm(vdb.getSQLShortFormLength()),
00876               failed.getMessage()});
00877       logger.warn(msg);
00878       throw new SQLException(msg);
00879     }
00880 
00881     // Notify scheduler of completion
00882     scheduler.readCompleted(spanOnAllTables);
00883 
00884     return result;
00885   }

DatabaseSchema org.objectweb.cjdbc.controller.requestmanager.RequestManager.getDatabaseSchema  ) 
 

Get the DatabaseSchema used by this Request Manager.

戻り値:
a DatabaseSchema value

RequestManager.java1583 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseMetaData.getDatabaseSchema(), org.objectweb.cjdbc.controller.cache.parsing.ParsingCache.getParsingFromCacheAndParseIfMissing(), org.objectweb.cjdbc.controller.virtualdatabase.protocol.VirtualDatabaseConfiguration.isCompatible(), と org.objectweb.cjdbc.controller.virtualdatabase.protocol.VirtualDatabaseConfiguration.VirtualDatabaseConfiguration().

01584   {
01585     return dbs;
01586   }

AbstractLoadBalancer org.objectweb.cjdbc.controller.requestmanager.RequestManager.getLoadBalancer  ) 
 

Get the Request Load Balancer used in this Request Controller.

戻り値:
an AbstractLoadBalancer value

RequestManager.java1593 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.protocol.VirtualDatabaseConfiguration.isCompatible(), と org.objectweb.cjdbc.controller.virtualdatabase.protocol.VirtualDatabaseConfiguration.VirtualDatabaseConfiguration().

01594   {
01595     return loadBalancer;
01596   }

MetadataCache org.objectweb.cjdbc.controller.requestmanager.RequestManager.getMetadataCache  ) 
 

Returns the metadataCache value.

戻り値:
Returns the metadataCache.

RequestManager.java1627 行で定義されています。

01628   {
01629     return metadataCache;
01630   }

AbstractRecoveryLog org.objectweb.cjdbc.controller.requestmanager.RequestManager.getRecoveryLog  ) 
 

Returns the Recovery Log Manager.

戻り値:
AbstractRecoveryLog

RequestManager.java1660 行で定義されています。

01661   {
01662     return recoveryLog;
01663   }

int org.objectweb.cjdbc.controller.requestmanager.RequestManager.getRequiredParsingGranularity  ) 
 

戻り値:
the parsing granularity required by the current configuration

RequestManager.java1729 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseWorkerThread.run().

01730   {
01731     return requiredGranularity;
01732   }

AbstractResultCache org.objectweb.cjdbc.controller.requestmanager.RequestManager.getResultCache  ) 
 

Get the result cache (if any) used in this Request Manager.

戻り値:
an AbstractResultCache value or null if no Reqsult Cache has been defined

RequestManager.java1617 行で定義されています。

01618   {
01619     return requestCache;
01620   }

AbstractScheduler org.objectweb.cjdbc.controller.requestmanager.RequestManager.getScheduler  ) 
 

Get the Request Scheduler (if any) used in this Request Controller.

戻り値:
an AbstractScheduler value or null if no Request Scheduler has been defined

RequestManager.java1694 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.protocol.VirtualDatabaseConfiguration.isCompatible(), と org.objectweb.cjdbc.controller.virtualdatabase.protocol.VirtualDatabaseConfiguration.VirtualDatabaseConfiguration().

01695   {
01696     return scheduler;
01697   }

TransactionMarkerMetaData org.objectweb.cjdbc.controller.requestmanager.RequestManager.getTransactionMarker Long  tid  )  throws SQLException
 

Get the TransactionMarkerMetaData for the given transaction id.

引数:
tid transaction id
戻り値:
the TransactionMarkerMetaData
例外:
SQLException if no marker has been found for this transaction

RequestManager.java953 行で定義されています。

参照先 org.objectweb.cjdbc.controller.requestmanager.TransactionMarkerMetaData.setTimeout().

00955   {
00956     TransactionMarkerMetaData tm = (TransactionMarkerMetaData) tidLoginTable
00957         .get(tid);
00958 
00959     if (tm == null)
00960       throw new SQLException(Translate.get("transaction.marker.not.found", ""
00961           + tid));
00962 
00963     tm.setTimeout(commitTimeout);
00964     return tm;
00965   }

VirtualDatabase org.objectweb.cjdbc.controller.requestmanager.RequestManager.getVirtualDatabase  ) 
 

Returns the vdb value.

戻り値:
Returns the vdb.

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManagerで再定義されています。

RequestManager.java1505 行で定義されています。

参照元 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseMetaData.getDatabaseSchema(), と org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabaseMetaData.getTablePrivileges().

01506   {
01507     return vdb;
01508   }

String org.objectweb.cjdbc.controller.requestmanager.RequestManager.getXml  ) 
 

Get xml information about this Request Manager

戻り値:
String in xml formatted text

RequestManager.java1743 行で定義されています。

01744   {
01745     StringBuffer info = new StringBuffer();
01746     info.append("<" + DatabasesXmlTags.ELT_RequestManager + " "
01747         + DatabasesXmlTags.ATT_caseSensitiveParsing + "=\""
01748         + isCaseSensitiveParsing + "\" " + DatabasesXmlTags.ATT_beginTimeout
01749         + "=\"" + beginTimeout / 1000 + "\" "
01750         + DatabasesXmlTags.ATT_commitTimeout + "=\"" + commitTimeout / 1000
01751         + "\" " + DatabasesXmlTags.ATT_rollbackTimeout + "=\""
01752         + rollbackTimeout / 1000 + "\">");
01753     if (scheduler != null)
01754       info.append(scheduler.getXml());
01755     if (parsingCache != null)
01756       info.append(parsingCache.getXml());
01757     if (requestCache != null)
01758       info.append(requestCache.getXml());
01759     if (loadBalancer != null)
01760       info.append(loadBalancer.getXml());
01761     if (recoveryLog != null)
01762       info.append(this.recoveryLog.getXml());
01763     info.append("</" + DatabasesXmlTags.ELT_RequestManager + ">");
01764     return info.toString();
01765   }

String org.objectweb.cjdbc.controller.requestmanager.RequestManager.handleSQLMacros String  originalSql,
long  timestampResolution,
boolean  handleOnlyNow
[static]
 

Replace all SQL macros with an instanciated value: - NOW() is replaced with a current timestamp. - RAND() is replaced with a random value

引数:
originalSql the request to handle macros
timestampResolution the timestamp resolution
handleOnlyNow true if only NOW macros must be handled
戻り値:
the new query with instanciated values

RequestManager.java270 行で定義されています。

00272   {
00273     String sql = MacrosHandler.macroNow(originalSql, timestampResolution);
00274     sql = MacrosHandler.macroCurrentTimestamp(sql, timestampResolution);
00275 
00276     if (handleOnlyNow)
00277       return sql;
00278 
00279     return MacrosHandler.macroRand(sql);
00280   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.initRequestManagerVariables VirtualDatabase  vdb,
long  beginTimeout,
long  commitTimeout,
long  rollbackTimeout
[private]
 

Method initRequestManagerVariables.

引数:
vdb 
beginTimeout 
commitTimeout 
rollbackTimeout 

RequestManager.java245 行で定義されています。

参照先 org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.getDatabaseName().

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

00247   {
00248     this.tidLoginTable = new Hashtable();
00249     this.beginTimeout = beginTimeout;
00250     this.commitTimeout = commitTimeout;
00251     this.rollbackTimeout = rollbackTimeout;
00252     this.vdb = vdb;
00253     logger = Trace.getLogger("org.objectweb.cjdbc.controller.RequestManager."
00254         + vdb.getDatabaseName());
00255   }

int org.objectweb.cjdbc.controller.requestmanager.RequestManager.loadBalanceExecWriteRequest AbstractWriteRequest  request  )  throws AllBackendsFailedException, SQLException
 

Send the given query to the load balancer.

引数:
request the request to execute
例外:
AllBackendsFailedException if all backends failed to execute the query
SQLException if an error occurs
戻り値:
number of modified lines

RequestManager.java597 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.distributed.SingleDBDistributedRequestManager.execDistributedWriteRequest().

00599   {
00600     int result;
00601     try
00602     { // Send the request to the load balancer
00603       if (request.isUpdate() && (requestCache != null))
00604       { // Try the optimization if we try to update values that are already
00605         // up-to-date.
00606         if (!requestCache.isUpdateNecessary((UpdateRequest) request))
00607         {
00608           scheduler.writeCompleted(request);
00609           return 0;
00610         }
00611       }
00612       return loadBalancer.execWriteRequest(request);
00613     }
00614     catch (Exception failed)
00615     {
00616       scheduler.writeCompleted(request);
00617       String msg = Translate.get("requestmanager.request.failed", new String[]{
00618           request.getSQLShortForm(vdb.getSQLShortFormLength()),
00619           failed.getMessage()});
00620       if (failed instanceof RuntimeException)
00621         logger.warn(msg, failed);
00622       else
00623         logger.warn(msg);
00624       if (failed instanceof AllBackendsFailedException)
00625         throw (AllBackendsFailedException) failed;
00626       else
00627         throw new SQLException(msg);
00628     }
00629   }

ControllerResultSet org.objectweb.cjdbc.controller.requestmanager.RequestManager.loadBalanceExecWriteRequestWithKeys AbstractWriteRequest  request  )  throws AllBackendsFailedException, SQLException
 

Send the given query to the load balancer.

引数:
request the request to execute
例外:
AllBackendsFailedException if all backends failed to execute the query
SQLException if an error occurs
戻り値:
auto-generated keys

RequestManager.java561 行で定義されています。

00564   {
00565     int result;
00566     try
00567     { // Send the request to the load balancer
00568       return new ControllerResultSet(request, loadBalancer
00569           .execWriteRequestWithKeys(request), metadataCache);
00570     }
00571     catch (Exception failed)
00572     {
00573       scheduler.writeCompleted(request);
00574       String msg = Translate.get("requestmanager.request.failed", new String[]{
00575           request.getSQLShortForm(vdb.getSQLShortFormLength()),
00576           failed.getMessage()});
00577       if (failed instanceof RuntimeException)
00578         logger.warn(msg, failed);
00579       else
00580         logger.warn(msg);
00581       if (failed instanceof AllBackendsFailedException)
00582         throw (AllBackendsFailedException) failed;
00583       else
00584         throw new SQLException(msg);
00585     }
00586   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.mergeDatabaseSchema DatabaseSchema  backendSchema  ) 
 

Merge the given schema with the existing database schema.

引数:
backendSchema The virtual database schema to merge.

RequestManager.java1552 行で定義されています。

01553   {
01554     try
01555     {
01556       if (dbs == null)
01557         setDatabaseSchema(new DatabaseSchema(backendSchema), false);
01558       else
01559       {
01560         dbs.mergeSchema(backendSchema);
01561         logger.info(Translate
01562             .get("requestmanager.schema.virtualdatabase.merged.new"));
01563 
01564         if (schedulerParsingranularity != ParsingGranularities.NO_PARSING)
01565           scheduler.mergeDatabaseSchema(dbs);
01566 
01567         if (cacheParsingranularity != ParsingGranularities.NO_PARSING)
01568           requestCache.mergeDatabaseSchema(dbs);
01569       }
01570     }
01571     catch (SQLException e)
01572     {
01573       logger.error(Translate.get("requestmanager.schema.merge.failed", e
01574           .getMessage()));
01575     }
01576   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.removeCheckpoint String  checkpointName  )  throws SQLException
 

Remove a checkpoint and corresponding entries from the log table

引数:
checkpointName to remove
例外:
SQLException if fails

RequestManager.java1347 行で定義されています。

01348   {
01349     recoveryLog.removeCheckpoint(checkpointName);
01350   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.restoreBackendFromBackupCheckpoint DatabaseBackend  db,
String  checkpointName
throws OctopusException, BackupException
 

Recopy all the data of a previous dump recorded by octopus into the named backend. This disables the backend and leave it disable after recovery process. The user has to call the enableBackendFromCheckpoint after this.

引数:
db the backend to restore
checkpointName the name of the checkpoint that has a dump
例外:
OctopusException if backup failed while in octopus mode
BackupException if backup failed for other reasons

RequestManager.java1141 行で定義されています。

参照先 org.objectweb.cjdbc.controller.core.backup.Octopus.restore().

01143   {
01144 
01145     try
01146     {
01147       // no check for disable as we are going to overwrite
01148       // all the database data
01149       if (db.isReadEnabled())
01150         loadBalancer.disableBackend(db);
01151       // Execute Recovery with octopus
01152       Octopus octopus = new Octopus(db, checkpointName);
01153       octopus.restore();
01154     }
01155     catch (SQLException e1)
01156     {
01157       // This comes from the loadbalancer
01158       throw new BackupException(ExceptionTypes.BACKEND_CANNOT_BE_DISABLED);
01159     }
01160     catch (OctopusException e)
01161     {
01162       logger.error(Translate.get("controller.octopus.recovery.failed", e));
01163       throw e;
01164     }
01165     catch (BackupException be)
01166     {
01167       logger.error(Translate.get("controller.backup.recovery.failed", be));
01168       throw be;
01169     }
01170     finally
01171     {
01172       logger.info(Translate
01173           .get("controller.backup.recovery.done", db.getName()));
01174     }
01175   }

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

Rollback a transaction given its id.

引数:
transactionId the transaction id
例外:
SQLException if an error occurs

org.objectweb.cjdbc.controller.requestmanager.distributed.DistributedRequestManagerで再定義されています。

RequestManager.java1042 行で定義されています。

01043   {
01044     try
01045     {
01046       Long tid = new Long(transactionId);
01047       TransactionMarkerMetaData tm = getTransactionMarker(tid);
01048 
01049       // Wait for the scheduler to give us the authorization to execute
01050       scheduler.rollback(tm);
01051 
01052       if (logger.isDebugEnabled())
01053         logger.debug(Translate.get("transaction.rollback", String
01054             .valueOf(transactionId)));
01055 
01056       try
01057       {
01058         // Send to load balancer
01059         loadBalancer.rollback(tm);
01060 
01061         // Notify the recovery log manager
01062         if (recoveryLog != null)
01063         {
01064           recoveryLog.rollback(tm);
01065         }
01066       }
01067       catch (SQLException e)
01068       {
01069         throw e;
01070       }
01071       catch (AllBackendsFailedException e)
01072       {
01073         String msg = Translate.get("requestmanager.rollback.failed.all",
01074             new String[]{String.valueOf(transactionId), e.getMessage()});
01075         logger.error(msg);
01076         throw new SQLException(msg);
01077       }
01078       finally
01079       {
01080         // Notify scheduler for completion
01081         scheduler.rollbackCompleted(transactionId);
01082 
01083         completeTransaction(tid);
01084       }
01085     }
01086     catch (RuntimeException e)
01087     {
01088       logger.fatal(Translate.get(
01089           "fatal.runtime.exception.requestmanager.rollback", e));
01090       throw new SQLException(e.getMessage());
01091     }
01092   }

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

Schedule a request for execution.

引数:
request the request to execute
例外:
SQLException if an error occurs

RequestManager.java483 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.distributed.SingleDBDistributedRequestManager.execDistributedWriteRequest().

00485   {
00486     // Sanity check
00487     if (!request.isAutoCommit())
00488     { // Check that the transaction has been started
00489       long tid = request.getTransactionId();
00490       if (!tidLoginTable.containsKey(new Long(tid)))
00491         throw new SQLException(Translate.get("transaction.not.started", tid));
00492     }
00493 
00494     // If we need to parse the request, try to get the parsing from the cache.
00495     // Note that if we have a cache miss but backgroundParsing has been turned
00496     // on, then this call will start a ParsedThread in background.
00497     if ((requiredGranularity != ParsingGranularities.NO_PARSING)
00498         && (!request.isParsed()))
00499     {
00500       if (parsingCache == null)
00501         request.parse(dbs, requiredGranularity, isCaseSensitiveParsing);
00502       else
00503         parsingCache.getParsingFromCache(request);
00504     }
00505 
00506     //
00507     // SCHEDULER
00508     //
00509 
00510     // Get the parsing now if the request is not yet parsed. The parsing is
00511     // handled by the ParsingCache that may already have parsed the request
00512     // in background (if backgroundParsing is set).
00513     if ((schedulerParsingranularity != ParsingGranularities.NO_PARSING)
00514         && !request.isParsed())
00515     {
00516       if (parsingCache == null)
00517         request.parse(dbs, requiredGranularity, isCaseSensitiveParsing);
00518       else
00519         parsingCache.getParsingFromCacheAndParseIfMissing(request);
00520     }
00521 
00522     // Wait for the scheduler to give us the authorization to execute
00523     try
00524     {
00525       scheduler.scheduleWriteRequest(request);
00526     }
00527     catch (RollbackException e)
00528     { // Something bad happened and we need to rollback this transaction
00529       rollback(request.getTransactionId());
00530       throw new SQLException(e.getMessage());
00531     }
00532 
00533     if (logger.isDebugEnabled())
00534       logger.debug(Translate.get("requestmanager.write.request", new String[]{
00535           String.valueOf(request.getId()),
00536           request.getSQLShortForm(vdb.getSQLShortFormLength())}));
00537 
00538     // If we have a parsing cache miss, wait for the parsing to be done if
00539     // needed. Note that even if the cache was the only one to require parsing,
00540     // we wait for the parsing result here, because if it fails, we must not
00541     // execute the query.
00542     if ((requiredGranularity != ParsingGranularities.NO_PARSING)
00543         && !request.isParsed())
00544     {
00545       if (parsingCache == null)
00546         request.parse(dbs, requiredGranularity, isCaseSensitiveParsing);
00547       else
00548         parsingCache.getParsingFromCacheAndParseIfMissing(request);
00549     }
00550   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setBackendsLastKnownCheckpointFromRecoveryLog  )  [private]
 

Retrieve the last known checkpoint from the recovery log and set it for each backend.

RequestManager.java175 行で定義されています。

参照先 org.objectweb.cjdbc.common.log.Trace.error(), org.objectweb.cjdbc.controller.recoverylog.AbstractRecoveryLog.getBackendCheckpoint(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.getBackends(), org.objectweb.cjdbc.controller.backend.DatabaseBackend.getName(), org.objectweb.cjdbc.controller.virtualdatabase.VirtualDatabase.getName(), org.objectweb.cjdbc.controller.requestmanager.RequestManager.recoveryLog, と org.objectweb.cjdbc.controller.backend.DatabaseBackend.setLastKnownCheckpoint().

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

00176   {
00177 
00178     if (recoveryLog == null)
00179       return;
00180     String databaseName = vdb.getName();
00181     ArrayList backends = vdb.getBackends();
00182     int size = backends.size();
00183     DatabaseBackend backend;
00184     String checkpoint;
00185     for (int i = 0; i < size; i++)
00186     {
00187       backend = (DatabaseBackend) backends.get(i);
00188       try
00189       {
00190         checkpoint = recoveryLog.getBackendCheckpoint(databaseName, backend
00191             .getName());
00192         backend.setLastKnownCheckpoint(checkpoint);
00193       }
00194       catch (SQLException e)
00195       {
00196         logger.error(Translate.get("requestmanager.checkpoint.not.found",
00197             backend.getName()), e);
00198       }
00199     }
00200 
00201   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setCaseSensitiveParsing boolean  isCaseSensitiveParsing  ) 
 

Sets the parsing case sensitivity. If true the request are parsed in a case sensitive way (table/column name must match exactly the case of the names fetched from the database or enforced by a static schema).

引数:
isCaseSensitiveParsing true if parsing is case sensitive

RequestManager.java1719 行で定義されています。

参照元 org.objectweb.cjdbc.controller.xml.DatabasesParser.endElement().

01720   {
01721     this.isCaseSensitiveParsing = isCaseSensitiveParsing;
01722     if (parsingCache != null)
01723       parsingCache.setCaseSensitiveParsing(isCaseSensitiveParsing);
01724   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setDatabaseSchema DatabaseSchema  schema,
boolean  isStatic
 

Sets the DatabaseSchema to be able to parse the requests and find dependencies.

引数:
schema a DatabaseSchema value
isStatic true if the given schema is static

RequestManager.java1517 行で定義されています。

01518   {
01519     if (schemaIsStatic)
01520     {
01521       if (isStatic)
01522       {
01523         logger.warn(Translate
01524             .get("requestmanager.schema.replace.static.with.new"));
01525         this.dbs = schema;
01526       }
01527       else
01528         logger.info(Translate.get("requestmanager.schema.ignore.new.dynamic"));
01529     }
01530     else
01531     {
01532       schemaIsStatic = isStatic;
01533       this.dbs = schema;
01534       logger.info(Translate
01535           .get("requestmanager.schema.set.new.virtualdatabase"));
01536     }
01537 
01538     if (schedulerParsingranularity != ParsingGranularities.NO_PARSING)
01539       scheduler.setDatabaseSchema(dbs);
01540 
01541     if (cacheParsingranularity != ParsingGranularities.NO_PARSING)
01542       requestCache.setDatabaseSchema(dbs);
01543 
01544     // Load balancers do not have a specific database schema to update
01545   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setLoadBalancer AbstractLoadBalancer  loadBalancer  ) 
 

Set the Request Load Balancer to use in this Request Controller.

引数:
loadBalancer a Request Load Balancer implementation

RequestManager.java1603 行で定義されています。

参照先 org.objectweb.cjdbc.controller.loadbalancer.AbstractLoadBalancer.getParsingGranularity().

01604   {
01605     this.loadBalancer = loadBalancer;
01606     loadBalancerParsingranularity = loadBalancer.getParsingGranularity();
01607     if (loadBalancerParsingranularity > requiredGranularity)
01608       requiredGranularity = loadBalancerParsingranularity;
01609   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setMetadataCache MetadataCache  metadataCache  ) 
 

Sets the metadataCache value.

引数:
metadataCache The metadataCache to set.

RequestManager.java1637 行で定義されています。

参照元 org.objectweb.cjdbc.controller.xml.DatabasesParser.endElement().

01638   {
01639     this.metadataCache = metadataCache;
01640   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setParsingCache ParsingCache  parsingCache  ) 
 

Sets the ParsingCache.

引数:
parsingCache The parsingCache to set.

RequestManager.java1647 行で定義されています。

参照先 org.objectweb.cjdbc.controller.cache.parsing.ParsingCache.setCaseSensitiveParsing(), org.objectweb.cjdbc.controller.cache.parsing.ParsingCache.setGranularity(), と org.objectweb.cjdbc.controller.cache.parsing.ParsingCache.setRequestManager().

参照元 org.objectweb.cjdbc.controller.xml.DatabasesParser.endElement().

01648   {
01649     parsingCache.setRequestManager(this);
01650     parsingCache.setGranularity(requiredGranularity);
01651     parsingCache.setCaseSensitiveParsing(isCaseSensitiveParsing);
01652     this.parsingCache = parsingCache;
01653   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setRecoveryLog AbstractRecoveryLog  recoveryLog  ) 
 

Sets the Recovery Log Manager.

引数:
recoveryLog The log recovery to set

RequestManager.java1670 行で定義されています。

01671   {
01672     this.recoveryLog = recoveryLog;
01673   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setRequestCache AbstractResultCache  cache  ) 
 

Set the Request Cache to use in this Request Controller.

引数:
cache a Request Cache implementation

RequestManager.java1680 行で定義されています。

参照先 org.objectweb.cjdbc.controller.cache.result.AbstractResultCache.getParsingGranularity().

01681   {
01682     requestCache = cache;
01683     cacheParsingranularity = cache.getParsingGranularity();
01684     if (cacheParsingranularity > requiredGranularity)
01685       requiredGranularity = cacheParsingranularity;
01686   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.setScheduler AbstractScheduler  scheduler  ) 
 

Set the Request Scheduler to use in this Request Controller.

引数:
scheduler a Request Scheduler implementation

RequestManager.java1704 行で定義されています。

参照先 org.objectweb.cjdbc.controller.scheduler.AbstractScheduler.getParsingGranularity().

01705   {
01706     this.scheduler = scheduler;
01707     schedulerParsingranularity = scheduler.getParsingGranularity();
01708     if (schedulerParsingranularity > requiredGranularity)
01709       requiredGranularity = schedulerParsingranularity;
01710   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.storeBackendsCheckpoint String  databaseName,
ArrayList  backends
 

Store all the backends checkpoint in the recoverylog

引数:
databaseName the virtual database name
backends the Arraylist of backends

RequestManager.java1474 行で定義されています。

参照先 org.objectweb.cjdbc.controller.backend.DatabaseBackend.getLastKnownCheckpoint(), と org.objectweb.cjdbc.controller.backend.DatabaseBackend.getName().

01475   {
01476     if (recoveryLog == null)
01477       return;
01478     int size = backends.size();
01479     DatabaseBackend backend;
01480     for (int i = 0; i < size; i++)
01481     {
01482       backend = (DatabaseBackend) backends.get(i);
01483       try
01484       {
01485         recoveryLog.storeBackendCheckpoint(databaseName, backend.getName(),
01486             backend.getLastKnownCheckpoint());
01487       }
01488       catch (SQLException e)
01489       {
01490         logger.error(Translate.get("recovery.store.checkpoint.failed",
01491             new String[]{backend.getName(), e.getMessage()}));
01492       }
01493     }
01494   }

void org.objectweb.cjdbc.controller.requestmanager.RequestManager.updateAndNotifyExecWriteRequest AbstractWriteRequest  request,
boolean  notifyScheduler
throws SQLException
 

Update the cache, notify the recovery log and finally the scheduler. It is possible to disable scheduler notifications (unless an error occurs in which case the scheduler is always notified). This is especially useful for distributed schedulers when all backends failed at one controller but we have to wait for the confirmation that all other controllers failed. This piece of code is then generic and reusable.

引数:
request the request to execute
notifyScheduler true if the scheduler must be notified
例外:
SQLException if an error occurs

RequestManager.java643 行で定義されています。

参照先 org.objectweb.cjdbc.common.sql.AbstractWriteRequest.getTableName().

参照元 org.objectweb.cjdbc.controller.requestmanager.distributed.SingleDBDistributedRequestManager.execDistributedWriteRequest().

00645   {
00646     try
00647     { // Notify cache if any
00648       if (requestCache != null)
00649       { // Update cache
00650         requestCache.writeNotify(request);
00651       }
00652 
00653       // Log the request
00654       if (recoveryLog != null)
00655         recoveryLog.logRequest(request);
00656 
00657       // Update the schema if needed
00658       if (requiredGranularity != ParsingGranularities.NO_PARSING)
00659       {
00660         if (request.isCreate())
00661         { // Add the table to the schema
00662           dbs.addTable(((CreateRequest) request).getDatabaseTable());
00663           if (logger.isDebugEnabled())
00664             logger.debug(Translate.get("requestmanager.schema.add.table",
00665                 request.getTableName()));
00666         }
00667         else if (request.isDrop())
00668         { // Delete the table from the schema
00669           dbs.removeTable(dbs.getTable(request.getTableName()));
00670           if (logger.isDebugEnabled())
00671             logger.debug(Translate.get("requestmanager.schema.remove.table",
00672                 request.getTableName()));
00673         }
00674       }
00675 
00676       // Notify scheduler
00677       if (notifyScheduler)
00678         scheduler.writeCompleted(request);
00679 
00680     }
00681     catch (Exception failed)
00682     {
00683       scheduler.writeCompleted(request);
00684       String msg = Translate.get("requestmanager.request.failed", new String[]{
00685           request.getSQLShortForm(vdb.getSQLShortFormLength()),
00686           failed.getMessage()});
00687       if (failed instanceof RuntimeException)
00688         logger.warn(msg, failed);
00689       else
00690         logger.warn(msg);
00691       throw new SQLException(msg);
00692     }
00693   }


変数

long org.objectweb.cjdbc.controller.requestmanager.RequestManager.beginTimeout [protected]
 

begin timeout in ms

RequestManager.java93 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

int org.objectweb.cjdbc.controller.requestmanager.RequestManager.cacheParsingranularity = ParsingGranularities.NO_PARSING [private]
 

RequestManager.java124 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

long org.objectweb.cjdbc.controller.requestmanager.RequestManager.commitTimeout [protected]
 

commit timeout in ms

RequestManager.java95 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

DatabaseSchema org.objectweb.cjdbc.controller.requestmanager.RequestManager.dbs [protected]
 

RequestManager.java115 行で定義されています。

boolean org.objectweb.cjdbc.controller.requestmanager.RequestManager.isCaseSensitiveParsing = false [private]
 

RequestManager.java117 行で定義されています。

AbstractLoadBalancer org.objectweb.cjdbc.controller.requestmanager.RequestManager.loadBalancer [protected]
 

The request load balancer to use to send requests to the databases

RequestManager.java109 行で定義されています。

int org.objectweb.cjdbc.controller.requestmanager.RequestManager.loadBalancerParsingranularity = ParsingGranularities.NO_PARSING [private]
 

RequestManager.java125 行で定義されています。

Trace org.objectweb.cjdbc.controller.requestmanager.RequestManager.logger = null [static, protected]
 

RequestManager.java130 行で定義されています。

MetadataCache org.objectweb.cjdbc.controller.requestmanager.RequestManager.metadataCache = null [private]
 

RequestManager.java119 行で定義されています。

ParsingCache org.objectweb.cjdbc.controller.requestmanager.RequestManager.parsingCache = null [protected]
 

RequestManager.java118 行で定義されています。

AbstractRecoveryLog org.objectweb.cjdbc.controller.requestmanager.RequestManager.recoveryLog [protected]
 

An optional recovery log

RequestManager.java112 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager(), と org.objectweb.cjdbc.controller.requestmanager.RequestManager.setBackendsLastKnownCheckpointFromRecoveryLog().

AbstractResultCache org.objectweb.cjdbc.controller.requestmanager.RequestManager.requestCache [protected]
 

An optional request cache to cache responses to SQL requests

RequestManager.java106 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

int org.objectweb.cjdbc.controller.requestmanager.RequestManager.requiredGranularity = ParsingGranularities.NO_PARSING [protected]
 

RequestManager.java126 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

long org.objectweb.cjdbc.controller.requestmanager.RequestManager.rollbackTimeout [protected]
 

rollback timeout in ms

RequestManager.java97 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

AbstractScheduler org.objectweb.cjdbc.controller.requestmanager.RequestManager.scheduler [protected]
 

The request scheduler to order and schedule requests

RequestManager.java103 行で定義されています。

参照元 org.objectweb.cjdbc.controller.requestmanager.RequestManager.assignAndCheckSchedulerLoadBalancerValidity(), と org.objectweb.cjdbc.controller.requestmanager.RequestManager.RequestManager().

int org.objectweb.cjdbc.controller.requestmanager.RequestManager.schedulerParsingranularity = ParsingGranularities.NO_PARSING [protected]
 

RequestManager.java123 行で定義されています。

boolean org.objectweb.cjdbc.controller.requestmanager.RequestManager.schemaIsStatic = false [private]
 

RequestManager.java116 行で定義されています。

Hashtable org.objectweb.cjdbc.controller.requestmanager.RequestManager.tidLoginTable [protected]
 

Transaction id/Login mapping

RequestManager.java128 行で定義されています。

VirtualDatabase org.objectweb.cjdbc.controller.requestmanager.RequestManager.vdb [protected]
 

The virtual database owning this Request Manager

RequestManager.java100 行で定義されています。


このクラスの説明は次のファイルから生成されました:
CJDBCversion1.0rc6に対してWed May 5 18:02:52 2004に生成されました。 doxygen 1.3.6