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 2011-2015 ForgeRock AS 026 */ 027package org.opends.server.replication.protocol; 028 029/** 030 * The version utility class for the replication protocol. 031 */ 032public class ProtocolVersion 033{ 034 /** 035 * The constant for the first historical version of the replication protocol. 036 */ 037 public static final short REPLICATION_PROTOCOL_V1 = 1; 038 /** 039 * The constant for the real value of the first historical version of the 040 * replication protocol (was used in start messages only). 041 */ 042 public static final short REPLICATION_PROTOCOL_V1_REAL = 49; 043 /** 044 * The constant for the second version of the replication protocol. 045 * <ul> 046 * <li>Add fields in the header for assured replication.</li> 047 * </ul> 048 */ 049 public static final short REPLICATION_PROTOCOL_V2 = 2; 050 051 /** 052 * The constant for the 3rd version of the replication protocol. 053 * <ul> 054 * <li>Add messages for remote ECL : not used as of today.</li> 055 * </ul> 056 */ 057 public static final short REPLICATION_PROTOCOL_V3 = 3; 058 059 /** 060 * The constant for the 4th version of the replication protocol. 061 * <ul> 062 * <li>Add to the body of the ADD/MOD/MODDN/DEL msgs, a list of attribute for 063 * ECL entry attributes.</li> 064 * <li>Modified algorithm for choosing a RS to connect to: introduction of a 065 * ReplicationServerDSMsg message.</li> 066 * <li>also added of the server URL in RSInfo of TopologyMsg</li> 067 * <li>Introduction of a StopMsg for proper connections ending.</li> 068 * <li>Initialization failover/flow control</li> 069 * </ul> 070 */ 071 public static final short REPLICATION_PROTOCOL_V4 = 4; 072 073 /** 074 * The constant for the 5th version of the replication protocol. 075 * <ul> 076 * <li>Add support for wild-cards in change log included attributes</li> 077 * <li>Add support for specifying additional included attributes for deletes</li> 078 * <li>See OPENDJ-194.</li> 079 * </ul> 080 */ 081 public static final short REPLICATION_PROTOCOL_V5 = 5; 082 083 /** 084 * The constant for the 6th version of the replication protocol. 085 * <ul> 086 * <li>include DS local URL in the DSInfo of TopologyMsg.</li> 087 * </ul> 088 */ 089 public static final short REPLICATION_PROTOCOL_V6 = 6; 090 091 /** 092 * The constant for the 7th version of the replication protocol. 093 * <ul> 094 * <li>compact encoding for length, CSNs, and server IDs.</li> 095 * </ul> 096 */ 097 public static final short REPLICATION_PROTOCOL_V7 = 7; 098 099 /** 100 * The constant for the 8th version of the replication protocol. 101 * <ul> 102 * <li>New ReplicaOfflineMsg.</li> 103 * </ul> 104 */ 105 public static final short REPLICATION_PROTOCOL_V8 = 8; 106 107 /** 108 * The replication protocol version used by the instance of RS/DS in this VM. 109 */ 110 private static final short CURRENT_VERSION = REPLICATION_PROTOCOL_V8; 111 112 /** 113 * Gets the current version of the replication protocol. 114 * 115 * @return The current version of the protocol. 116 */ 117 public static short getCurrentVersion() 118 { 119 return CURRENT_VERSION; 120 } 121 122 /** 123 * Specifies the oldest version of the protocol from the provided one 124 * and the current one. 125 * 126 * @param version The version to be compared to the current one. 127 * @return The minimal protocol version. 128 */ 129 public static short getCompatibleVersion(short version) 130 { 131 return version < CURRENT_VERSION ? version : CURRENT_VERSION; 132 } 133}