Class EntryHistorical
- java.lang.Object
-
- org.opends.server.replication.plugin.EntryHistorical
-
public class EntryHistorical extends Object
This class is used to store historical information that is used to resolve modify conflictsIt is assumed that the common case is not to have conflict and therefore is optimized (in order of importance) for:
- detecting potential conflict
- fast update of historical information for non-conflicting change
- fast and efficient purge
- compact
- solve conflict. This should also be as fast as possible but not at the cost of any of the other previous objectives
-
-
Field Summary
Fields Modifier and Type Field Description static StringENTRYUUID_ATTRIBUTE_NAMEName of the entryuuid attribute.static StringHISTORICALName used to store attachment of historical information in the operation.static StringHISTORICAL_ATTRIBUTE_NAMEName of the attribute used to store historical information.
-
Constructor Summary
Constructors Constructor Description EntryHistorical()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddedOrRenamedAfter(CSN csn)Indicates if the Entry was renamed or added after the CSN that is given as a parameter.AttributeencodeAndPurge()Encode this historical information object in an operational attribute and purge it from the values older than the purge delay.static Iterable<FakeOperation>generateFakeOperations(Entry entry)Use this historical information to generate fake operations that would result in this historical information.CSNgetDNDate()Returns the lastCSN when the entry DN was modified.static StringgetEntryUUID(Entry entry)Get the entry unique Id in String form.static StringgetEntryUUID(PreOperationAddOperation op)Get the Entry Unique Id from an add operation.static Iterable<Attribute>getHistoricalAttr(Entry entry)Get the attribute used to store the historical information from the provided Entry.intgetLastPurgedValuesCount()For stats/monitoring purpose, returns the number of historical values purged the last time a purge has been applied on this entry historical.CSNgetOldestCSN()Returns the oldest CSN stored in this entry historical attribute.static booleanisHistoricalAttribute(Attribute attr)Check if a given attribute is an attribute used to store historical information.static EntryHistoricalnewInstanceFromEntry(Entry entry)Construct an Historical object from the provided entry by reading the historical attribute.booleanreplayOperation(PreOperationModifyOperation modifyOperation, Entry modifiedEntry)Process an operation.static voidsetHistoricalAttrToOperation(PreOperationAddOperation addOperation)Generate an attribute containing the historical information from the replication context attached to the provided operation and set this attribute in the operation.voidsetHistoricalAttrToOperation(PreOperationModifyDNOperation modifyDNOperation)For a MODDN operation, add new or update existing historical information.voidsetHistoricalAttrToOperation(PreOperationModifyOperation modifyOperation)Update the historical information for the provided operation.voidsetPurgeDelay(long purgeDelay)Set the delay to purge the historical information.StringtoString()
-
-
-
Field Detail
-
HISTORICAL_ATTRIBUTE_NAME
public static final String HISTORICAL_ATTRIBUTE_NAME
Name of the attribute used to store historical information.- See Also:
- Constant Field Values
-
HISTORICAL
public static final String HISTORICAL
Name used to store attachment of historical information in the operation. This attachment allows to use in several different places the historical while reading/writing ONCE it from/to the entry.- See Also:
- Constant Field Values
-
ENTRYUUID_ATTRIBUTE_NAME
public static final String ENTRYUUID_ATTRIBUTE_NAME
Name of the entryuuid attribute.- See Also:
- Constant Field Values
-
-
Method Detail
-
replayOperation
public boolean replayOperation(PreOperationModifyOperation modifyOperation, Entry modifiedEntry)
Process an operation. This method is responsible for detecting and resolving conflict for modifyOperation. This is done by using the historical information.- Parameters:
modifyOperation- the operation to be processedmodifiedEntry- the entry that is being modified (before modification)- Returns:
- true if the replayed operation was in conflict
-
setHistoricalAttrToOperation
public void setHistoricalAttrToOperation(PreOperationModifyOperation modifyOperation)
Update the historical information for the provided operation.Steps:
- compute the historical attribute
- update the mods in the provided operation by adding the update of the historical attribute
- update the modifiedEntry, already computed by core since we are in the preOperation plugin, that is called just before committing into the DB.
- Parameters:
modifyOperation- the modification.
-
setHistoricalAttrToOperation
public void setHistoricalAttrToOperation(PreOperationModifyDNOperation modifyDNOperation)
For a MODDN operation, add new or update existing historical information.This method is NOT static because it relies on this Historical object created in the HandleConflictResolution phase.
- Parameters:
modifyDNOperation- the modification for which the historical information should be created.
-
setHistoricalAttrToOperation
public static void setHistoricalAttrToOperation(PreOperationAddOperation addOperation)
Generate an attribute containing the historical information from the replication context attached to the provided operation and set this attribute in the operation. For ADD, the historical is made of the CSN read from the synchronization context attached to the operation. Called for both local and synchronization ADD preOperation. This historical information will be used to generate fake operation in case a Directory Server can not find a Replication Server with all its changes at connection time. This should only happen if a Directory Server or a Replication Server crashes. This method is static because there is no Historical object creation required here or before(in the HandleConflictResolution phase)- Parameters:
addOperation- The Operation to which the historical attribute will be added.
-
getLastPurgedValuesCount
public int getLastPurgedValuesCount()
For stats/monitoring purpose, returns the number of historical values purged the last time a purge has been applied on this entry historical.- Returns:
- the purged values count.
-
encodeAndPurge
public Attribute encodeAndPurge()
Encode this historical information object in an operational attribute and purge it from the values older than the purge delay.- Returns:
- The historical information encoded in an operational attribute.
- See Also:
the decode operation in HistoricalAttributeValue
-
setPurgeDelay
public void setPurgeDelay(long purgeDelay)
Set the delay to purge the historical information. The purge is applied only when historical attribute is updated (write operations).- Parameters:
purgeDelay- the purge delay in ms
-
addedOrRenamedAfter
public boolean addedOrRenamedAfter(CSN csn)
Indicates if the Entry was renamed or added after the CSN that is given as a parameter.- Parameters:
csn- The CSN with which the ADD or Rename date must be compared.- Returns:
- A boolean indicating if the Entry was renamed or added after the CSN that is given as a parameter.
-
getDNDate
public CSN getDNDate()
Returns the lastCSN when the entry DN was modified.- Returns:
- The lastCSN when the entry DN was modified.
-
newInstanceFromEntry
public static EntryHistorical newInstanceFromEntry(Entry entry)
Construct an Historical object from the provided entry by reading the historical attribute. Return an empty object when the entry does not contain any historical attribute.- Parameters:
entry- The entry which historical information must be loaded- Returns:
- The constructed Historical information object
-
generateFakeOperations
public static Iterable<FakeOperation> generateFakeOperations(Entry entry)
Use this historical information to generate fake operations that would result in this historical information. TODO : This is only implemented for MODIFY, MODRDN and ADD need to complete with DELETE.- Parameters:
entry- The Entry to use to generate the FakeOperation Iterable.- Returns:
- an Iterable of FakeOperation that would result in this historical information.
-
getHistoricalAttr
public static Iterable<Attribute> getHistoricalAttr(Entry entry)
Get the attribute used to store the historical information from the provided Entry.- Parameters:
entry- The entry containing the historical information.- Returns:
- The Attribute used to store the historical information. Several values on the list if several options for this attribute. Null if not present.
-
getEntryUUID
public static String getEntryUUID(Entry entry)
Get the entry unique Id in String form.- Parameters:
entry- The entry for which the unique id should be returned.- Returns:
- The Unique Id of the entry, or a fake one if none is found.
-
getEntryUUID
public static String getEntryUUID(PreOperationAddOperation op)
Get the Entry Unique Id from an add operation. This must be called after the entry uuid pre-op plugin (i.e no sooner than the replication provider pre-op)- Parameters:
op- The operation- Returns:
- The Entry Unique Id String form.
-
isHistoricalAttribute
public static boolean isHistoricalAttribute(Attribute attr)
Check if a given attribute is an attribute used to store historical information.- Parameters:
attr- The attribute that needs to be checked.- Returns:
- a boolean indicating if the given attribute is used to store historical information.
-
getOldestCSN
public CSN getOldestCSN()
Returns the oldest CSN stored in this entry historical attribute.- Returns:
- the oldest CSN stored in this entry historical attribute. Returns null when this historical object has been created from an entry that has no historical attribute and after the last historical has been purged.
-
-