Examples of LogCounter


Examples of org.apache.derby.impl.store.raw.log.LogCounter

                                    "Skipping over CLRs, reset scan to " +
                                    LogCounter.toDebugString(prepareInstant));
                        }
          }

          scanLog.resetPosition(new LogCounter(prepareInstant));
          // scanLog now positioned at the beginning of the log
          // record that was rolled back by this CLR.
          // The scan is a backward one so getNextRecord will skip
          // over the record that was rolled back and go to the one
          // previous to it
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

                                LogCounter.toDebugString(undoInstant));
                        }
                    }


          scanLog.resetPosition(new LogCounter(undoInstant));

          // scanLog now positioned at the beginning of the log
          // record that was rolled back by this CLR.
          // The scan is a backward one so getNextRecord will skip
          // over the record that was rolled back and go to the one
          // previous to it

          continue;
        }

        lop = record.getUndoable();

        if (lop != null)
        {
          int optionalDataLength = rawInput.readInt();
          int savePosition = rawInput.getPosition();
          rawInput.setLimit(savePosition, optionalDataLength);
 
          compensation = lop.generateUndo(t, rawInput);

          if (SanityManager.DEBUG)
                    {
                        if (SanityManager.DEBUG_ON(LogToFile.DBG_FLAG))
                        {
                            SanityManager.DEBUG(
                                LogToFile.DBG_FLAG,
                                "Rollback log record at instant " +
                                LogCounter.toDebugString(scanLog.getInstant()) +
                                " : " + lop);
                        }
                    }

          clrgenerated++;

          if (compensation != null)
          {
            // generateUndo may have read stuff off the
            // stream, reset it for the undo operation.
            rawInput.setLimit(savePosition, optionalDataLength);

            // log the compensation op that rolls back the
                        // operation at this instant
            t.logAndUndo(
                            compensation, new LogCounter(scanLog.getInstant()),
                            rawInput);

            compensation.releaseResource(t);
            compensation = null;
          }
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

                logFactory.openForwardsScan(
                                    undoInstant,(LogInstant)null);
            }
            else
            {
              undoScan.resetPosition(new LogCounter(undoInstant));
            }

            // undoScan now positioned at the beginning of the log
            // record was rolled back by this CLR. 
            // The scan is a forward one so getNextRecord will get
                        // the log record that needs to be rolled back.

            // reuse the buffer in logIn and logIn since CLR
                        // has no optional data and has no use for them anymore
            logIn.clearLimit();
            LogRecord undoRecord =
              undoScan.getNextRecord(logIn, null, 0);

            Undoable undoOp = undoRecord.getUndoable();

            if (SanityManager.DEBUG)
            {
              SanityManager.DEBUG(
                                LogToFile.DBG_FLAG,
                                "Redoing CLR: undoInstant = " +
                                    LogCounter.toDebugString(undoInstant) +
                                " clrinstant = " +
                                    LogCounter.toDebugString(instant));

              SanityManager.ASSERT(
                                undoRecord.getTransactionId().equals(tranId));

              SanityManager.ASSERT(undoOp != null);
            }

            ((Compensation)op).setUndoOp(undoOp);
          }

          // at this point, logIn points to the optional
          // data of the loggable that is to be redone or to be
          // rolled back
         
          if (SanityManager.DEBUG)
                    {
                        if (SanityManager.DEBUG_ON(LogToFile.DBG_FLAG))
                        {
                            SanityManager.DEBUG(
                                LogToFile.DBG_FLAG,
                                "redoing " + op +
                                " instant = " +
                                LogCounter.toDebugString(instant));
                        }
                    }

          int dataLength = logIn.readInt();
          logIn.setLimit(logIn.getPosition(), dataLength);
                   
          // even though the log has already been written, we need to
          // tie the page to the log stream so that if redo failed
          // for some reasons, the log factory's corruption will stop
          // the corrupt page from flushing to disk.

          op.doMe(
                        recoveryTransaction,
                        new LogCounter(instant), logIn);

          op.releaseResource(recoveryTransaction);

          op = null;
        }
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

      {
        // The redo LWM is the current log instant.  We are going to
                // clean the cache shortly, any log record before this point
                // will not ever need to be redone.
        redoLWM_long = currentInstant();
        redoLWM = new LogCounter(redoLWM_long);

                // The undo LWM is what we need to rollback all transactions.
                // Synchronize this with the starting of a new transaction so
                // that the transaction factory can have a consistent view
                // See FileLogger.logAndDo

        LogCounter undoLWM = (LogCounter)(tf.firstUpdateInstant());
        if (undoLWM == null)
          undoLWM_long = redoLWM_long; // no active transaction
        else
          undoLWM_long = undoLWM.getValueAsLong();

      }

      /////////////////////////////////////////////////////
      // clean the buffer cache
      /////////////////////////////////////////////////////
      df.checkpoint();


      /////////////////////////////////////////////////////
      // write out the checkpoint log record
      /////////////////////////////////////////////////////
   
      // send the checkpoint record to the log
      Formatable transactionTable = tf.getTransactionTable();

      CheckpointOperation nextCheckpoint =
        new CheckpointOperation(
                    redoLWM_long, undoLWM_long, transactionTable);

      cptran.logAndDo(nextCheckpoint);

      LogCounter checkpointInstant =
                (LogCounter)(cptran.getLastLogInstant());

      if (checkpointInstant != null)
            {
                // since checkpoint is an internal transaction, I need to
                // flush it to make sure it actually goes to the log
        flush(checkpointInstant);
            }
      else
            {
        throw StandardException.newException(
                        SQLState.LOG_CANNOT_LOG_CHECKPOINT);
            }

      cptran.commit();

      if (needCPTran)
      {
        cptran.close()// if we started it, we will close it
        cptran = null;
      }

      /////////////////////////////////////////////////////
      // write out the log control file which contains the last
      // successful checkpoint log record
      /////////////////////////////////////////////////////

      if (!writeControlFile(getControlFileName(),
                  checkpointInstant.getValueAsLong()))
      {
        throw StandardException.newException(
                        SQLState.LOG_CONTROL_FILE, getControlFileName());
      }
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

      // don't flush, just use this to check if database is frozen or
      // corrupt
      fileNumber = 0;
      wherePosition = LogCounter.INVALID_LOG_INSTANT;
    } else {
      LogCounter whereC = (LogCounter) where;
      fileNumber = whereC.getLogFileNumber();
      wherePosition = whereC.getLogFilePosition();
    }
    flush(fileNumber, wherePosition);
  }
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

      startAt = firstLogInstant();
    }

    // ensure any buffered data is written to the actual file
    if (stopAt != null) {
      LogCounter stopCounter = (LogCounter) stopAt;
      flushBuffer(stopCounter.getLogFileNumber(),
            stopCounter.getLogFilePosition());
    } else {
      synchronized (this) {
        if (logOut != null)
          // flush to the end of the log
          logOut.flushLogAccessFile();
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

    public synchronized LogInstant getFirstUnflushedInstant()
  {
    if (SanityManager.DEBUG)
      SanityManager.ASSERT(logFileNumber > 0 && lastFlush > 0);

    return new LogCounter(logFileNumber,lastFlush);
  }
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

    {
      throw markCorrupt(
                    StandardException.newException(SQLState.LOG_IO_ERROR, ioe));
    }
    //remove the stub files
    df.removeDroppedContainerFileStubs(new LogCounter(redoLWM));
   
    if (inReplicationSlaveMode) {
      truncateLog(LogCounter.getLogFileNumber(undoLWM));
    }
  }
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

      {
        // The redo LWM is the current log instant.  We are going to
                // clean the cache shortly, any log record before this point
                // will not ever need to be redone.
        redoLWM_long = currentInstant();
        redoLWM = new LogCounter(redoLWM_long);

                // The undo LWM is what we need to rollback all transactions.
                // Synchronize this with the starting of a new transaction so
                // that the transaction factory can have a consistent view
                // See FileLogger.logAndDo

        LogCounter undoLWM = (LogCounter)(tf.firstUpdateInstant());
        if (undoLWM == null)
          undoLWM_long = redoLWM_long; // no active transaction
        else
          undoLWM_long = undoLWM.getValueAsLong();

      }

      /////////////////////////////////////////////////////
      // clean the buffer cache
      /////////////////////////////////////////////////////
      df.checkpoint();


      /////////////////////////////////////////////////////
      // write out the checkpoint log record
      /////////////////////////////////////////////////////
   
      // send the checkpoint record to the log
      Formatable transactionTable = tf.getTransactionTable();

      CheckpointOperation nextCheckpoint =
        new CheckpointOperation(
                    redoLWM_long, undoLWM_long, transactionTable);

      cptran.logAndDo(nextCheckpoint);

      LogCounter checkpointInstant =
                (LogCounter)(cptran.getLastLogInstant());

      if (checkpointInstant != null)
            {
                // since checkpoint is an internal transaction, I need to
                // flush it to make sure it actually goes to the log
        flush(checkpointInstant);
            }
      else
            {
        throw StandardException.newException(
                        SQLState.LOG_CANNOT_LOG_CHECKPOINT);
            }

      cptran.commit();

      if (needCPTran)
      {
        cptran.close()// if we started it, we will close it
        cptran = null;
      }

      /////////////////////////////////////////////////////
      // write out the log control file which contains the last
      // successful checkpoint log record
      /////////////////////////////////////////////////////

      if (!writeControlFile(getControlFileName(),
                  checkpointInstant.getValueAsLong()))
      {
        throw StandardException.newException(
                        SQLState.LOG_CONTROL_FILE, getControlFileName());
      }
View Full Code Here

Examples of org.apache.derby.impl.store.raw.log.LogCounter

      // don't flush, just use this to check if database is frozen or
      // corrupt
      fileNumber = 0;
      wherePosition = LogCounter.INVALID_LOG_INSTANT;
    } else {
      LogCounter whereC = (LogCounter) where;
      fileNumber = whereC.getLogFileNumber();
      wherePosition = whereC.getLogFilePosition();
    }
    flush(fileNumber, wherePosition);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.