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.
   *
   * $Id$
   */
  package com.sleepycat.je.trigger;
  
ReplicatedTrigger defines trigger methods that are invoked on a replica when a replica needs to resume a transaction that's only partially present in the replica's logs and needs to be resumed so that it can be replayed to a conclusion, that is, to the point where the partial transaction has been committed or aborted by the master.

WARNING: This interface is not currently supported. This means that, on a replica where transactions may be rolled back without a full environment shutdown, the repeatXxx methods cannot be used to handle this circumstance. To be safe, it is best to only use TransactionTrigger methods, namely TransactionTrigger.commit.

WARNING: Only transient triggers are currently supported, and the documention below has not yet been updated to reflect this fact. See details at the top of Trigger.java.

The trigger methods can be invoked in one of two circumstances:

  1. A new environment handle is opened on the replica and its logs contain a partial transaction.
  2. A new master is elected and a replica has to switch over to the new master, while in the midst of replaying a transaction.

These trigger methods are only invoked if the partial transactions contain operations associated with triggers.

Consider a transaction consisting of two put operations:
 put k1
 put k2
 commit t
 
In the absence of a replica or master failure this would normally result in the sequence of trigger calls:
 Trigger.put(t, k1, ...)
 Trigger.put(t, k2,....)
 Trigger.commit(t)
 
If the replica failed in the midst of the transaction replay, immediately after the first put operation, the sequence of trigger invocations before the replica went down would be:
  Trigger.put(k1, ...)
 
followed by the trigger calls below when the replica handle was subsequently reopened:
  ReplicatedTrigger.repeat(t)
  Trigger.repeatPut(t, k1, ...)
  Trigger.put(t, k2, ...)
  Trigger.commit(t)
 
The interface defines one "repeat" trigger method for each of the trigger methods defined by Trigger. The methods are distinct from those defined by Trigger to highlight the fact that the trigger method is being invoked a second time for the same operation and the trigger method may not have completed the actions it intended to take when it was invoked the first time. For example, the trigger method may have been used to update a couple of local indexes and it was only finished with updating one local index and persisting it before the replica crashed. As a result the method may need to take special action to repair state maintained by it.

A ReplicatedTrigger is associated with a replicated database via com.sleepycat.je.DatabaseConfig.setTriggers(java.util.List). For a replicated database, the ReplicatedTrigger interface must be implemented for all triggers. For a non-replicated database, implementing the ReplicatedTrigger interface is allowed, but the ReplicatedTrigger methods will not be called.

 
 public interface ReplicatedDatabaseTrigger extends Trigger {

    
Used to inform the application that the trigger method calls associated with the partial transaction will be repeated.

Parameters:
txn the partial transaction
    public void repeatTransaction(Transaction txn);
    /* Trigger lifecycle operations. */

    
The trigger method invoked when an addTrigger operation needs to be repeated.

    public void repeatAddTrigger(Transaction txn);

    
The trigger method invoked when a removeTrigger operation needs to be repeated.

    public void repeatRemoveTrigger(Transaction txn);
    /* Database Granularity operations */

    
The trigger method invoked when a database create trigger needs to be repeated.

    public void repeatCreate(Transaction txn);

    
The trigger method invoked when a database remove trigger needs to be repeated.

    public void repeatRemove(Transaction txn);

    
The trigger method invoked when a database truncate trigger needs to be repeated.

    public void repeatTruncate(Transaction txn);

    
The trigger method invoked when a database rename trigger needs to be repeated.

    public void repeatRename(Transaction txnString newName);
    /* Key/value granularity operations. */

    
The trigger method invoked when a database put trigger needs to be repeated. Note that this method differs from the corresponding Trigger.put method in that it omits the oldData argument.

    public void repeatPut(Transaction txn,
                          DatabaseEntry key,
                          DatabaseEntry newData);

    
The trigger method invoked when a database delete trigger needs to be repeated. Note that this method differs from the corresponding Trigger.delete method in that it omits the oldData argument.

See also:
Trigger.remove
    public void repeatDelete(Transaction txn,
                             DatabaseEntry key);
New to GrepCode? Check out our FAQ X