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

Examples of org.apache.derby.iapi.store.raw.log.LogInstant


    File oldbackup = null;
    File backupcopy = null;
    OutputStreamWriter historyFile = null;
        StorageFile dbHistoryFile = null;
        File backupHistoryFile = null;
    LogInstant backupInstant = logFactory.getFirstUnflushedInstant();
       
    try
    {
      // get name of the current db, ie. database directory of current db.
      StorageFile dbase           = storageFactory.newStorageFile(null);
View Full Code Here


                 DataFactory df,
                 TransactionFactory tf)
     throws StandardException
  {
    boolean proceed = true;
    LogInstant redoLWM;

    // we may be called to stop the database after a bad error, make sure
    // logout is set
    if (logOut == null)
    {
View Full Code Here

    Private methods.
    */
  private void setFirstUnflushed()
     throws StandardException, IOException
  {
    LogInstant firstUnflushedInstant =
      logFactory.getFirstUnflushedInstant();
    firstUnflushed = ((LogCounter)firstUnflushedInstant).getValueAsLong();
    firstUnflushedFileNumber = LogCounter.getLogFileNumber(firstUnflushed);
    firstUnflushedFilePosition = LogCounter.getLogFilePosition(firstUnflushed);

View Full Code Here

    // force WAL - and check to see if database is corrupt or is frozen.
    // last log Instant may be null if the page is being forced
    // to disk on a createPage (which violates the WAL protocol actually).
    // See FileContainer.newPage
    LogInstant flushLogTo = getLastLogInstant();
    dataFactory.flush(flushLogTo);

    if (flushLogTo != null)
        {         
      clearLastLogInstant();
View Full Code Here

  public final void doMe(Transaction xact, LogInstant instant, LimitObjectInput in)
     throws StandardException, IOException
  {

    long oldversion = 0;    // sanity check
    LogInstant oldLogInstant = null; // sanity check
    if (SanityManager.DEBUG)
    {
      oldLogInstant = this.page.getLastLogInstant();
      oldversion = this.page.getPageVersion();

      SanityManager.ASSERT(oldversion == this.getPageVersion());
      SanityManager.ASSERT(oldLogInstant == null || instant == null
               || oldLogInstant.lessThan(instant));
    }

    // if this is called during runtime rollback, PageOp.generateUndo found
    // the page and have it latched there.
    // if this is called during recovery redo, this.needsRedo found the page and
View Full Code Here

        {
      return null;
        }
    else
    {
      LogInstant logInstant = null;
           
            // bug 5632: need to sychronize so that another thread does not
            // come in and disrupt the for loop, we got an exception on next,
            // likely because hash table changed by another thread after
            // hasMoreElements() called, but before nextElement().
View Full Code Here

    synchronized(this)
    {
      int ntran = trans.size();
      tinfo = new TransactionTableEntry[ntran];

      LogInstant logInstant = null;
      int i = 0;

      for (Enumeration e = trans.elements();
         e.hasMoreElements(); )
      {
View Full Code Here

      logicalOut.writeInt(optionalDataLength);
      completeLength = logOutputBuffer.getPosition() + optionalDataLength;


      LogInstant logInstant = null;
      int encryptedLength = 0; // in case of encryption, we need to pad

      try
      {
        if (logFactory.databaseEncrypted())
        {
          // we must pad the encryption data to be multiple of block
          // size, which is logFactory.getEncryptionBlockSize()
          encryptedLength = completeLength;
          if ((encryptedLength % logFactory.getEncryptionBlockSize()) != 0)
            encryptedLength = encryptedLength + logFactory.getEncryptionBlockSize() - (encryptedLength % logFactory.getEncryptionBlockSize());

          if (encryptionBuffer == null ||
            encryptionBuffer.length < encryptedLength)
            encryptionBuffer = new byte[encryptedLength];

          System.arraycopy(logOutputBuffer.getByteArray(), 0,
                   encryptionBuffer, 0, completeLength-optionalDataLength);

          if (optionalDataLength > 0)
            System.arraycopy(preparedLog, optionalDataOffset,
                   encryptionBuffer,
                   completeLength-optionalDataLength, optionalDataLength);

          // do not bother to clear out the padding area
          int len =
            logFactory.encrypt(encryptionBuffer, 0, encryptedLength,
                       encryptionBuffer, 0);

          if (SanityManager.DEBUG)
            SanityManager.ASSERT(len == encryptedLength,
              "encrypted log buffer length != log buffer len");
        }

        if ((operation.group() & (Loggable.FIRST | Loggable.LAST)) != 0)
        {
          synchronized (logFactory)
          {
            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);
          }
        }
        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);
        }

      }
      catch (StandardException se)
      {
        throw logFactory.markCorrupt(
                        StandardException.newException(
                            SQLState.LOG_DO_ME_FAIL, se, operation));
      }
      catch (IOException ioe)
      {
        throw logFactory.markCorrupt(
                        StandardException.newException(
                            SQLState.LOG_DO_ME_FAIL, ioe, operation));
      }
      finally
      {
        logIn.clearLimit();
      }

      if (SanityManager.DEBUG)
            {
                if (SanityManager.DEBUG_ON(LogToFile.DBG_FLAG))
                {
                    SanityManager.DEBUG(
                        LogToFile.DBG_FLAG,
                        "Write log record: tranId=" + transactionId.toString() +
                        " instant: " + logInstant.toString() + " length: " +
                        completeLength + "\n" + operation + "\n");
                }
      }
      return logInstant;
    }
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

  public String getFirstLogInstantString()
  {
    if (SanityManager.DEBUG)
      SanityManager.ASSERT(isClone, "Should only call method on a clone");

    LogInstant logInstant =
            (myxact == null) ? null : myxact.getFirstLogInstant();

    return (logInstant == null) ? null : logInstant.toString();

  }   
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.store.raw.log.LogInstant

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.