Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*-
   * See the file LICENSE for redistribution information.
   *
   * Copyright (c) 2002, 2013 Oracle and/or its affiliates.  All rights reserved.
   *
   */
  
  package com.sleepycat.je.rep;
  
 import static com.sleepycat.je.dbi.EnvironmentFailureReason.HARD_RECOVERY;
 
This asynchronous exception indicates that a new master has been selected, this Replica's log is ahead of the current Master, and in this case, the Replica was unable to rollback without a recovery. As a consequence, it is possible that one or more of the most recently committed transactions may need to be rolled back, before the Replica can synchronize its state with that of the current Master. Note that any CommitTokens obtained before restarting this Replica shouldn't be used after RollbackException is thrown because the token may no longer exist on the current Master node, due to failover processing.

Existing ReplicatedEnvironment, and consequently com.sleepycat.je.Database handles, are invalidated as a result of this exception. The application must close all old handles and create new handles before it can proceed. The actual rollback of any recently committed transactions is done when the application re-instantiates and thereby reopens the ReplicatedEnvironment. The application is responsible for discarding and recreating any transient state that may be associated with the committed transactions that were rolled back. getEarliestTransactionId() and getEarliestTransactionCommitTime() provide information to help determine which transactions might be rolled back. Note that it is possible that no committed transactions have been rolled back and that the application need do no adjustments, in which case getEarliestTransactionCommitTime() will return null.

This exception should be encountered relatively infrequently in practice, since the election mechanism favors nodes with the most advanced log when deciding upon a master. The exception, due to its nature, can only be encountered when the node is in the Replica state, or the node is trying to transition to the Replica state.

Use of weak durability requirements like com.sleepycat.je.Durability.ReplicaAckPolicy.NONE or a ReplicationMutableConfig.NODE_PRIORITY of zero increases the likelihood of this exception.

 
 public class RollbackException extends RestartRequiredException {
     private static final long serialVersionUID = 1;
 
     private final VLSN lastTxnEnd;
     private final VLSN matchpointVLSN;
     private final String nodeName;
     private final MatchpointSearchResults searchResults;

    
For internal use only.

Hidden:
 
     public RollbackException(RepImpl repImpl,
                              VLSN lastTxnEnd,
                              VLSN matchpointVLSN,
                              MatchpointSearchResults searchResults) {
         super(repImpl);
         this. = lastTxnEnd;
         this. = matchpointVLSN;
         this. = searchResults;
         this. = repImpl.getName();
     }
 
     @Override
     public String getMessage() {
         long matchpointLSN = .getMatchpointLSN();
         return "Node " +  + 
             " must rollback" +  .getRollbackMsg() +
             " in order to rejoin the replication group. All existing " +
             "ReplicatedEnvironment handles must be closed and " +
             "reinstantiated.  Log files were truncated to file 0x" + 
             DbLsn.getFileNumber(matchpointLSN) + ", offset 0x" +
             DbLsn.getFileOffset(matchpointLSN) + ", vlsn " +
             ;
     }

    
Return the time in milliseconds of the earliest transaction commit that has been rolled back. May return null if no commits have been rolled back.
 
         if (.getEarliestPassedTxn() == null) {
             return null;
         } 
        return .getEarliestPassedTxn()..getTime();
    }

    
Return the id of the earliest transaction commit that has been rolled back. 0 is returned if no commits have been rolled back.
    public long getEarliestTransactionId() {
        if (.getEarliestPassedTxn() == null) {
            return 0;
        }
        return .getEarliestPassedTxn().;
    }

    
For internal use only.

Hidden:
    public RollbackException(String messageRollbackException cause) {
        super(messagecause);
        this. = cause.lastTxnEnd;
        this. = cause.matchpointVLSN;
        this. = cause.searchResults;
        this. = cause.nodeName;
    }

    
For internal use only.

Hidden:
    @Override
    public RollbackException wrapSelf(String msg) {
        return new RollbackException(msgthis);
    }
New to GrepCode? Check out our FAQ X