Examples of Loggable


Examples of org.exist.storage.journal.Loggable

            // ------- REDO ---------
            if (LOG.isInfoEnabled())
                {LOG.info("First pass: redoing " + txnCount + " transactions...");}
            final ProgressBar progress = new ProgressBar("Redo ", last.length());
            Loggable next = null;
            int redoCnt = 0;
            try {
                while ((next = reader.nextEntry()) != null) {
                    SanityCheck.ASSERT(next.getLogType() != LogEntryTypes.CHECKPOINT,
                            "Found a checkpoint during recovery run! This should not ever happen.");
                    if (next.getLogType() == LogEntryTypes.TXN_START) {
                        // new transaction starts: add it to the transactions table
                        runningTxns.put(next.getTransactionId(), next);
                    } else if (next.getLogType() == LogEntryTypes.TXN_COMMIT) {
                        // transaction committed: remove it from the transactions table
                        runningTxns.remove(next.getTransactionId());
                        redoCnt++;
                    } else if (next.getLogType() == LogEntryTypes.TXN_ABORT) {
                        // transaction aborted: remove it from the transactions table
                        runningTxns.remove(next.getTransactionId());
                    }
        //            LOG.debug("Redo: " + next.dump());
                    // redo the log entry
                    next.redo();
                    progress.set(Lsn.getOffset(next.getLsn()));
                    if (next.getLsn() == lastLsn)
                        {break;} // last readable entry reached. Stop here.
                }
            } catch (final Exception e) {
                LOG.error("Exception caught while redoing transactions. Aborting recovery to avoid possible damage. " +
                    "Before starting again, make sure to run a check via the emergency export tool.", e);
                if (next != null)
                    {LOG.info("Log entry that caused the exception: " + next.dump());}
                throw new LogException("Recovery aborted. ");
            } finally {
                LOG.info("Redo processed " + redoCnt + " out of " + txnCount + " transactions.");
            }

            // ------- UNDO ---------
            if (LOG.isInfoEnabled())
                {LOG.info("Second pass: undoing dirty transactions. Uncommitted transactions: " +
                        runningTxns.size());}
            // see if there are uncommitted transactions pending
            if (runningTxns.size() > 0) {
                // do a reverse scan of the log, undoing all uncommitted transactions
                try {
                    while((next = reader.previousEntry()) != null) {
                        if (next.getLogType() == LogEntryTypes.TXN_START) {
                            if (runningTxns.get(next.getTransactionId()) != null) {
                                runningTxns.remove(next.getTransactionId());
                                if (runningTxns.size() == 0)
                                    // all dirty transactions undone
                                    {break;}
                            }
                        } else if (next.getLogType() == LogEntryTypes.TXN_COMMIT) {
                            // ignore already committed transaction
                        } else if (next.getLogType() == LogEntryTypes.CHECKPOINT) {
                            // found last checkpoint: undo is completed
                            break;
                        }

                        // undo the log entry if it belongs to an uncommitted transaction
                        if (runningTxns.get(next.getTransactionId()) != null) {
    //          LOG.debug("Undo: " + next.dump());
                            next.undo();
                        }
                    }
                } catch (final Exception e) {
                    LOG.warn("Exception caught while undoing dirty transactions. Remaining transactions " +
                            "to be undone: " + runningTxns.size() + ". Aborting recovery to avoid possible damage. " +
                            "Before starting again, make sure to run a check via the emergency export tool.", e);
                    if (next != null)
                        {LOG.warn("Log entry that caused the exception: " + next.dump());}
                    throw new LogException("Recovery aborted");
                }
            }
        } finally {
            broker.sync(Sync.MAJOR_SYNC);
View Full Code Here

Examples of se.sics.mspsim.core.Loggable

      @Override
      public int executeCommand(CommandContext context) {
        if (context.getArgumentCount() > 0) {
          for (int i = 0, n = context.getArgumentCount(); i < n; i++) {
            String unitName = context.getArgument(i);
            Loggable unit = cpu.getLoggable(unitName);
            if (unit == null) {
              context.out.println("  " + unitName + ": NOT FOUND");
            } else {
              String id = unit.getID();
              String name = unit.getName();
              if (id == name) {
                context.out.println(unit.getName() + ": " + unit.getClass().getName());
              } else {
                context.out.println(unit.getID() + " (" + unit.getName() + "): "
                    + unit.getClass().getName());
              }
              String info = unit.info();
              if (info != null) {
                context.out.println(info);
              }
            }
          }
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.