com.sleepycat.je.trigger
Interface ReplicatedDatabaseTrigger

All Superinterfaces:
Trigger
All Known Implementing Classes:
SyncCleanerBarrier.SyncTrigger

public interface ReplicatedDatabaseTrigger
extends 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 DatabaseConfig.setTriggers. 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.


Method Summary
 void repeatAddTrigger(Transaction txn)
          The trigger method invoked when an addTrigger operation needs to be repeated.
 void repeatCreate(Transaction txn)
          The trigger method invoked when a database create trigger needs to be repeated.
 void repeatDelete(Transaction txn, DatabaseEntry key)
          The trigger method invoked when a database delete trigger needs to be repeated.
 void repeatPut(Transaction txn, DatabaseEntry key, DatabaseEntry newData)
          The trigger method invoked when a database put trigger needs to be repeated.
 void repeatRemove(Transaction txn)
          The trigger method invoked when a database remove trigger needs to be repeated.
 void repeatRemoveTrigger(Transaction txn)
          The trigger method invoked when a removeTrigger operation needs to be repeated.
 void repeatRename(Transaction txn, String newName)
          The trigger method invoked when a database rename trigger needs to be repeated.
 void repeatTransaction(Transaction txn)
          Used to inform the application that the trigger method calls associated with the partial transaction will be repeated.
 void repeatTruncate(Transaction txn)
          The trigger method invoked when a database truncate trigger needs to be repeated.
 
Methods inherited from interface com.sleepycat.je.trigger.Trigger
addTrigger, delete, getDatabaseName, getName, put, removeTrigger, setDatabaseName
 

Method Detail

repeatTransaction

void repeatTransaction(Transaction txn)
Used to inform the application that the trigger method calls associated with the partial transaction will be repeated.

Parameters:
txn - the partial transaction

repeatAddTrigger

void repeatAddTrigger(Transaction txn)
The trigger method invoked when an addTrigger operation needs to be repeated.

See Also:
Trigger.addTrigger(com.sleepycat.je.Transaction)

repeatRemoveTrigger

void repeatRemoveTrigger(Transaction txn)
The trigger method invoked when a removeTrigger operation needs to be repeated.

See Also:
Trigger.removeTrigger(com.sleepycat.je.Transaction)

repeatCreate

void repeatCreate(Transaction txn)
The trigger method invoked when a database create trigger needs to be repeated.

See Also:
PersistentTrigger.open(com.sleepycat.je.Transaction, com.sleepycat.je.Environment, boolean)

repeatRemove

void repeatRemove(Transaction txn)
The trigger method invoked when a database remove trigger needs to be repeated.

See Also:
PersistentTrigger.remove(com.sleepycat.je.Transaction)

repeatTruncate

void repeatTruncate(Transaction txn)
The trigger method invoked when a database truncate trigger needs to be repeated.

See Also:
PersistentTrigger.truncate(com.sleepycat.je.Transaction)

repeatRename

void repeatRename(Transaction txn,
                  String newName)
The trigger method invoked when a database rename trigger needs to be repeated.

See Also:
PersistentTrigger.rename(com.sleepycat.je.Transaction, java.lang.String)

repeatPut

void repeatPut(Transaction txn,
               DatabaseEntry key,
               DatabaseEntry newData)
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.

See Also:
Trigger.put(com.sleepycat.je.Transaction, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry, com.sleepycat.je.DatabaseEntry)

repeatDelete

void repeatDelete(Transaction txn,
                  DatabaseEntry key)
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


Copyright (c) 2004-2012 Oracle. All rights reserved.