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