001/* 002 * The contents of this file are subject to the terms of the Common Development and 003 * Distribution License (the License). You may not use this file except in compliance with the 004 * License. 005 * 006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the 007 * specific language governing permission and limitations under the License. 008 * 009 * When distributing Covered Software, include this CDDL Header Notice in each file and include 010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL 011 * Header, with the fields enclosed by brackets [] replaced by your own identifying 012 * information: "Portions Copyright [year] [name of copyright owner]". 013 * 014 * Copyright 2013-2016 ForgeRock AS. 015 */ 016package org.opends.server.replication.server.changelog.api; 017 018import org.opends.server.replication.common.CSN; 019import org.forgerock.opendj.ldap.DN; 020 021/** 022 * The Change Number Index Record class represents records stored in the 023 * {@link ChangeNumberIndexDB}. It stores data about a change that happened with 024 * the replication. 025 */ 026public final class ChangeNumberIndexRecord 027{ 028 029 /** This is the key used to store this record. */ 030 private final long changeNumber; 031 /** The baseDN where the change happened. */ 032 private final DN baseDN; 033 /** The CSN of the change. */ 034 private final CSN csn; 035 036 /** 037 * Builds an instance of this class. 038 * 039 * @param changeNumber 040 * the change number 041 * @param baseDN 042 * the baseDN 043 * @param csn 044 * the replication CSN field 045 */ 046 public ChangeNumberIndexRecord(long changeNumber, DN baseDN, CSN csn) 047 { 048 this.changeNumber = changeNumber; 049 this.baseDN = baseDN; 050 this.csn = csn; 051 } 052 053 /** 054 * Builds an instance of this class, with changeNumber equal to 0. 055 * @param baseDN 056 * the baseDN 057 * @param csn 058 * the replication CSN field 059 * 060 * @see #ChangeNumberIndexRecord(long, DN, CSN) 061 */ 062 public ChangeNumberIndexRecord(DN baseDN, CSN csn) 063 { 064 this(0, baseDN, csn); 065 } 066 067 /** 068 * Getter for the baseDN field. 069 * 070 * @return the baseDN 071 */ 072 public DN getBaseDN() 073 { 074 return baseDN; 075 } 076 077 /** 078 * Getter for the replication CSN field. 079 * 080 * @return The replication CSN field. 081 */ 082 public CSN getCSN() 083 { 084 return csn; 085 } 086 087 /** 088 * Getter for the change number field. 089 * 090 * @return The change number field. 091 */ 092 public long getChangeNumber() 093 { 094 return changeNumber; 095 } 096 097 /** {@inheritDoc} */ 098 @Override 099 public String toString() 100 { 101 return "changeNumber=" + changeNumber + " csn=" + csn + " baseDN=" + baseDN; 102 } 103}