Ejemplo n.º 1
0
  private synchronized void syncLog(ILogRecord logRecord) throws ACIDException {
    ITransactionContext txnCtx = null;

    if (logRecord.getLogType() != LogType.FLUSH) {
      txnCtx = logRecord.getTxnCtx();
      if (txnCtx.getTxnState() == ITransactionManager.ABORTED
          && logRecord.getLogType() != LogType.ABORT) {
        throw new ACIDException(
            "Aborted job(" + txnCtx.getJobId() + ") tried to write non-abort type log record.");
      }
    }
    if (getLogFileOffset(appendLSN.get()) + logRecord.getLogSize() > logFileSize) {
      prepareNextLogFile();
      appendPage.isFull(true);
      getAndInitNewPage();
    } else if (!appendPage.hasSpace(logRecord.getLogSize())) {
      appendPage.isFull(true);
      getAndInitNewPage();
    }
    if (logRecord.getLogType() == LogType.UPDATE) {
      logRecord.setPrevLSN(txnCtx.getLastLSN());
    }
    appendPage.append(logRecord, appendLSN.get());

    if (logRecord.getLogType() == LogType.FLUSH) {
      logRecord.setLSN(appendLSN.get());
    }
    appendLSN.addAndGet(logRecord.getLogSize());
  }
 public LockThenSearchOperationCallback(
     int datasetId,
     int[] entityIdFields,
     ITransactionSubsystem txnSubsystem,
     ITransactionContext txnCtx,
     IOperatorNodePushable operatorNodePushable) {
   super(datasetId, entityIdFields, txnCtx, txnSubsystem.getLockManager());
   this.operatorNodePushable =
       (LSMIndexInsertUpdateDeleteOperatorNodePushable) operatorNodePushable;
   this.logManager = txnSubsystem.getLogManager();
   this.logRecord = new LogRecord();
   logRecord.setTxnCtx(txnCtx);
   logRecord.setLogSource(LogSource.LOCAL);
   logRecord.setLogType(LogType.WAIT);
   logRecord.setJobId(txnCtx.getJobId().getId());
   logRecord.computeAndSetLogSize();
 }
Ejemplo n.º 3
0
  @Override
  public void log(ILogRecord logRecord) throws ACIDException {
    if (logRecord.getLogSize() > logPageSize) {
      throw new IllegalStateException();
    }

    syncLog(logRecord);

    if ((logRecord.getLogType() == LogType.JOB_COMMIT || logRecord.getLogType() == LogType.ABORT)
        && !logRecord.isFlushed()) {
      synchronized (logRecord) {
        while (!logRecord.isFlushed()) {
          try {
            logRecord.wait();
          } catch (InterruptedException e) {
            // ignore
          }
        }
      }
    }
  }