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