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


      synchronized(droppedTableStubInfo)
      {
        for (Enumeration e = droppedTableStubInfo.keys();
                     e.hasMoreElements(); )
        {
          LogInstant logInstant  = (LogInstant) e.nextElement();
          if(logInstant.lessThan(redoLWM))
          {
           
            Object[] removeInfo =
                            (Object[]) droppedTableStubInfo.get(logInstant);
            Object identity = removeInfo[1];
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 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

    DataFactory         df,
    TransactionFactory  tf,
    boolean             wait)
     throws StandardException
  {
    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

    if (state == ACTIVE)
      setUpdateState();

    seenUpdates = true;
   
    LogInstant clrInstant = logger.logAndUndo(this, compensation, undoInstant, in);

    setLastLogInstant(clrInstant);

    // set the top savepoint to rollback to this record if it doesn't yet have a point saved
    if ((savePoints != null) && !savePoints.empty()) {
View Full Code Here

   * @see Transaction#commit
     **/
  private LogInstant prepareCommit(int commitflag)
        throws StandardException
    {
    LogInstant flushTo = null;

    if (state == CLOSED)
        {
      throw StandardException.newException(
                    SQLState.XACT_PROTOCOL_VIOLATION);
View Full Code Here

    {
      if (SanityManager.DEBUG_ON("XATrace"))
        SanityManager.DEBUG("XATrace","commiting ");
    }

        LogInstant flushTo = prepareCommit(commitflag);

        completeCommit(commitflag);

        return(flushTo);
  }
View Full Code Here

      @exception StandardException  Standard Derby exception policy
    @see Transaction#logAndDo
  */
  public void logAndDo(Loggable operation) throws StandardException {

    LogInstant instant = null;

    if (logger == null)
      getLogger();

    if (logger == null)
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.