001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2006-2010 Sun Microsystems, Inc. 025 * Portions Copyright 2013-2014 ForgeRock, AS. 026 * Portions Copyright 2015 ForgeRock AS. 027 */ 028package org.opends.server.replication.plugin; 029 030import java.util.Iterator; 031import java.util.Set; 032 033import org.forgerock.opendj.ldap.ByteString; 034import org.opends.server.replication.common.CSN; 035import org.opends.server.types.AttributeType; 036import org.opends.server.types.Entry; 037import org.opends.server.types.Modification; 038 039/** This class store historical information for a provided attribute. */ 040public abstract class AttrHistorical 041{ 042 /** 043 * This method will be called when replaying an operation. 044 * It should use whatever historical information is stored in this class 045 * to solve the conflict and modify the mod and the mods iterator accordingly 046 * 047 * @param modsIterator The iterator on the mods from which the mod is 048 * extracted. 049 * @param csn The CSN associated to the operation. 050 * @param modifiedEntry The entry modified by this operation. 051 * @param mod The modification. 052 * 053 * @return a boolean indicating if a conflict was detected. 054 */ 055 public abstract boolean replayOperation( 056 Iterator<Modification> modsIterator, CSN csn, Entry modifiedEntry, Modification mod); 057 058 /** 059 * This method calculates the historical information and update the hist 060 * attribute to store the historical information for modify operation that 061 * does not conflict with previous operation. 062 * This is the usual path and should therefore be optimized. 063 * <p> 064 * It does not check if the operation to process is conflicting or not with 065 * previous operations. The caller is responsible for this. 066 * 067 * @param csn The CSN of the operation to process 068 * @param mod The modify operation to process. 069 */ 070 public abstract void processLocalOrNonConflictModification(CSN csn, Modification mod); 071 072 /** 073 * Create a new object from a provided attribute type. Historical is empty. 074 * 075 * @param type the provided attribute type. 076 * @return a new AttributeInfo object. 077 */ 078 public static AttrHistorical createAttributeHistorical(AttributeType type) 079 { 080 return type.isSingleValue() ? new AttrHistoricalSingle() : new AttrHistoricalMultiple(); 081 } 082 083 /** 084 * Get the historical informations for this attribute Info. 085 * 086 * @return the historical informations 087 */ 088 public abstract Set<AttrValueHistorical> getValuesHistorical(); 089 090 /** 091 * Returns the last time when this attribute was deleted. 092 * 093 * @return the last time when this attribute was deleted 094 */ 095 public abstract CSN getDeleteTime(); 096 097 /** 098 * Assign the provided information to this object. 099 * 100 * @param histKey the key to assign. 101 * @param value the associated value or null if there is no value; 102 * @param csn the associated CSN. 103 */ 104 public abstract void assign(HistAttrModificationKey histKey, ByteString value, CSN csn); 105}