Package org.apache.derby.impl.store.raw.log

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


  public LogInstant getLogInstant()
  {
    if (currentInstant == LogCounter.INVALID_LOG_INSTANT)
      return null;
    else
      return new LogCounter(currentInstant);
  }
View Full Code Here


      {
        // 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

      // 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

      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

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

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

    {
      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

                appendLogRecord(logOutputBuffer.getByteArray(),
                        0, completeLength, preparedLog,
                        optionalDataOffset,
                        optionalDataLength);
            }
            logInstant = new LogCounter(instant);

            operation.doMe(xact, logInstant, logIn);
          }
        }
        else
        {
          long instant = 0;

          if (logFactory.databaseEncrypted())
          {
            // encryption has completely drained both the the
            // logOuputBuffer array and the preparedLog array
            instant = logFactory.
              appendLogRecord(encryptionBuffer, 0,
                      encryptedLength, null, -1, 0);
          }
          else
          {
            instant = logFactory.
              appendLogRecord(logOutputBuffer.getByteArray(), 0,
                      completeLength, preparedLog,
                      optionalDataOffset,
                      optionalDataLength);
          }

          logInstant = new LogCounter(instant);

          operation.doMe(xact, logInstant, logIn);
        }

      }
View Full Code Here

        instant = logFactory.
          appendLogRecord(logOutputBuffer.getByteArray(),
                  0, completeLength, null, 0, 0);
      }

      LogInstant logInstant = new LogCounter(instant);

      if (SanityManager.DEBUG)
            {
                if (SanityManager.DEBUG_ON(LogToFile.DBG_FLAG))
                {
                    SanityManager.DEBUG(
                        LogToFile.DBG_FLAG,
                        "Write CLR: Xact: " + transactionId.toString() +
                        "clrinstant: " + logInstant.toString() +
                        " undoinstant " + undoInstant + "\n");
                }
      }

      try
View Full Code Here

                                    "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

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

TOP

Related Classes of org.apache.derby.impl.store.raw.log.LogCounter

Copyright © 2018 www.massapicom. 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.