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 2007-2009 Sun Microsystems, Inc. 015 * Portions Copyright 2013-2016 ForgeRock AS. 016 */ 017package org.opends.admin.ads; 018 019import java.util.HashSet; 020import java.util.Set; 021 022 023/** The object of this class represent a Replica (i.e. a suffix in a given server). */ 024public class ReplicaDescriptor 025{ 026 private SuffixDescriptor suffix; 027 private int entries = -1; 028 private ServerDescriptor server; 029 private final Set<String> replicationServers = new HashSet<>(); 030 private int replicationId = -1; 031 private int missingChanges = -1; 032 private long ageOfOldestMissingChange = -1; 033 private String backendName; 034 private Set<String> objectClasses; 035 036 /** 037 * Returns the number of entries contained in the replica. 038 * @return the number of entries contained in the replica. 039 */ 040 public int getEntries() 041 { 042 return entries; 043 } 044 045 /** 046 * Returns whether this replica is replicated or not. 047 * @return <CODE>true</CODE> if the replica is replicated and 048 * <CODE>false</CODE> otherwise. 049 */ 050 public boolean isReplicated() 051 { 052 return replicationId != -1; 053 } 054 055 /** 056 * Returns whether replication is replicated on this server or not. 057 * @return <CODE>true</CODE> if replication is enabled and 058 * <CODE>false</CODE> otherwise. 059 */ 060 public boolean isReplicationEnabled() 061 { 062 return server.isReplicationEnabled(); 063 } 064 065 /** 066 * Sets the number of entries contained in the replica. 067 * @param entries the number of entries contained in the replica. 068 */ 069 public void setEntries(int entries) 070 { 071 this.entries = entries; 072 } 073 074 /** 075 * Returns the ServerDescriptor object associated with the server where this 076 * replica is located. 077 * @return the ServerDescriptor object associated with the server where this 078 * replica is located. 079 */ 080 public ServerDescriptor getServer() 081 { 082 return server; 083 } 084 085 /** 086 * Sets the server where this replica is located. 087 * @param server the ServerDescriptor object associated with the server where 088 * this replica is located. 089 */ 090 public void setServer(ServerDescriptor server) 091 { 092 this.server = server; 093 } 094 095 /** 096 * Returns the SuffixDescriptor object representing the suffix topology 097 * across servers to which this replica belongs. 098 * @return the SuffixDescriptor object representing the suffix topology 099 * across servers to which this replica belongs. 100 */ 101 public SuffixDescriptor getSuffix() 102 { 103 return suffix; 104 } 105 106 /** 107 * Sets the SuffixDescriptor object representing the suffix topology 108 * across servers to which this replica belongs. 109 * @param suffix the SuffixDescriptor object representing the suffix topology 110 * across servers to which this replica belongs. 111 */ 112 public void setSuffix(SuffixDescriptor suffix) 113 { 114 this.suffix = suffix; 115 } 116 117 /** 118 * Returns a set containing the String representation of the replication 119 * servers that are defined in the replication domain for this replica. 120 * @return a set containing the String representation of the replication 121 * servers that are defined in the replication domain for this replica. 122 */ 123 public Set<String> getReplicationServers() 124 { 125 return new HashSet<>(replicationServers); 126 } 127 128 /** 129 * Sets the list of replication servers (in their String representation) that 130 * are defined in the replication domain for this replica. 131 * @param replicationServers the list of replication servers (in their String 132 * representation) that are defined in the replication domain for this 133 * replica. 134 */ 135 public void setReplicationServers(Set<String> replicationServers) 136 { 137 this.replicationServers.clear(); 138 this.replicationServers.addAll(replicationServers); 139 } 140 141 /** 142 * Returns the replication id for the replication domain associated 143 * with this replica. 144 * @return the replication id for the replication domain associated 145 * with this replica. 146 */ 147 public int getReplicationId() 148 { 149 return replicationId; 150 } 151 152 /** 153 * Sets the replication id for the replication domain associated 154 * with this replica. 155 * @param replicationId the replication id for the replication domain 156 * associated with this replica. 157 */ 158 public void setReplicationId(int replicationId) 159 { 160 this.replicationId = replicationId; 161 } 162 163 /** 164 * Returns the age of the oldest missing change. 165 * @return the age of the oldest missing change. 166 */ 167 public long getAgeOfOldestMissingChange() 168 { 169 return ageOfOldestMissingChange; 170 } 171 172 /** 173 * Sets the age of the oldest missing change. 174 * @param ageOfOldestMissingChange the age of the oldest missing change. 175 */ 176 public void setAgeOfOldestMissingChange(long ageOfOldestMissingChange) 177 { 178 this.ageOfOldestMissingChange = ageOfOldestMissingChange; 179 } 180 181 /** 182 * Returns the number of missing changes. 183 * @return the number of missing changes. 184 */ 185 public int getMissingChanges() 186 { 187 return missingChanges; 188 } 189 190 /** 191 * Sets the number of missing changes. 192 * @param missingChanges the number of missing changes. 193 */ 194 public void setMissingChanges(int missingChanges) 195 { 196 this.missingChanges = missingChanges; 197 } 198 199 /** 200 * Returns the name of the backend where this replica is defined. 201 * @return the name of the backend where this replica is defined. 202 */ 203 public String getBackendName() 204 { 205 return backendName; 206 } 207 208 /** 209 * Sets the name of the backend where this replica is defined. 210 * @param backendName the name of the backend. 211 */ 212 public void setBackendName(String backendName) 213 { 214 this.backendName = backendName; 215 } 216 217 /** 218 * Returns object classes of the backend attached to this replica. 219 * 220 * @return object classes of the backend attached to this replica. 221 */ 222 public Set<String> getObjectClasses() 223 { 224 return objectClasses; 225 } 226 227 /** 228 * Sets the object classes of the backend attached to this replica. 229 * 230 * @param objectClasses 231 * object classes of the backend attached to this replica. 232 */ 233 public void setObjectClasses(Set<String> objectClasses) 234 { 235 this.objectClasses = objectClasses; 236 } 237}