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
010 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
011 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
012 * See the License for the specific language governing permissions
013 * and limitations under the License.
014 *
015 * When distributing Covered Code, include this CDDL HEADER in each
016 * file and include the License file at
017 * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
018 * add the following below this CDDL HEADER, with the fields enclosed
019 * by brackets "[]" replaced with your own identifying information:
020 * Portions Copyright [yyyy] [name of copyright owner]
021 *
022 * CDDL HEADER END
023 *
024 *
025 * Copyright 2007-2008 Sun Microsystems, Inc.
026 */
027
028 package org.opends.admin.ads;
029
030 import java.util.HashSet;
031 import java.util.Set;
032
033 /**
034 * The object of this class represent a Replica (i.e. a suffix in a given
035 * server).
036 */
037 public class ReplicaDescriptor
038 {
039 private SuffixDescriptor suffix;
040 private int entries = -1;
041 private ServerDescriptor server;
042 private Set<String> replicationServers = new HashSet<String>();
043 private int replicationId = -1;
044 private int missingChanges = -1;
045 private long ageOfOldestMissingChange = -1;
046
047 /**
048 * Returns the number of entries contained in the replica.
049 * @return the number of entries contained in the replica.
050 */
051 public int getEntries()
052 {
053 return entries;
054 }
055
056 /**
057 * Returns whether this replica is replicated or not.
058 * @return <CODE>true</CODE> if the replica is replicated and
059 * <CODE>false</CODE> otherwise.
060 */
061 public boolean isReplicated()
062 {
063 return replicationId != -1;
064 }
065
066 /**
067 * Sets the number of entries contained in the replica.
068 * @param entries the number of entries contained in the replica.
069 */
070 public void setEntries(int entries)
071 {
072 this.entries = entries;
073 }
074
075 /**
076 * Returns the ServerDescriptor object associated with the server where this
077 * replica is located.
078 * @return the ServerDescriptor object associated with the server where this
079 * replica is located.
080 */
081 public ServerDescriptor getServer()
082 {
083 return server;
084 }
085
086 /**
087 * Sets the server where this replica is located.
088 * @param server the ServerDescriptor object associated with the server where
089 * this replica is located.
090 */
091 public void setServer(ServerDescriptor server)
092 {
093 this.server = server;
094 }
095
096 /**
097 * Returns the SuffixDescriptor object representing the suffix topology
098 * across servers to which this replica belongs.
099 * @return the SuffixDescriptor object representing the suffix topology
100 * across servers to which this replica belongs.
101 */
102 public SuffixDescriptor getSuffix()
103 {
104 return suffix;
105 }
106
107 /**
108 * Sets the SuffixDescriptor object representing the suffix topology
109 * across servers to which this replica belongs.
110 * @param suffix the SuffixDescriptor object representing the suffix topology
111 * across servers to which this replica belongs.
112 */
113 public void setSuffix(SuffixDescriptor suffix)
114 {
115 this.suffix = suffix;
116 }
117
118 /**
119 * Returns a set containing the String representation of the replication
120 * servers that are defined in the replication domain for this replica.
121 * @return a set containing the String representation of the replication
122 * servers that are defined in the replication domain for this replica.
123 */
124 public Set<String> getReplicationServers()
125 {
126 HashSet<String> copy = new HashSet<String>();
127 copy.addAll(replicationServers);
128 return copy;
129 }
130
131 /**
132 * Sets the list of replication servers (in their String representation) that
133 * are defined in the replication domain for this replica.
134 * @param replicationServers the list of replication servers (in their String
135 * representation) that are defined in the replication domain for this
136 * replica.
137 */
138 public void setReplicationServers(Set<String> replicationServers)
139 {
140 this.replicationServers.clear();
141 this.replicationServers.addAll(replicationServers);
142 }
143
144 /**
145 * Returns the replication server id for the replication domain associated
146 * with this replica.
147 * @return the replication server id for the replication domain associated
148 * with this replica.
149 */
150 public int getReplicationId()
151 {
152 return replicationId;
153 }
154
155 /**
156 * Sets the replication server id for the replication domain associated
157 * with this replica.
158 * @param replicationId the replication server id for the replication domain
159 * associated with this replica.
160 */
161 public void setReplicationId(int replicationId)
162 {
163 this.replicationId = replicationId;
164 }
165
166 /**
167 * Returns the age of the oldest missing change.
168 * @return the age of the oldest missing change.
169 */
170 public long getAgeOfOldestMissingChange()
171 {
172 return ageOfOldestMissingChange;
173 }
174
175 /**
176 * Sets the age of the oldest missing change.
177 * @param ageOfOldestMissingChange the age of the oldest missing change.
178 */
179 public void setAgeOfOldestMissingChange(long ageOfOldestMissingChange)
180 {
181 this.ageOfOldestMissingChange = ageOfOldestMissingChange;
182 }
183
184 /**
185 * Returns the number of missing changes.
186 * @return the number of missing changes.
187 */
188 public int getMissingChanges()
189 {
190 return missingChanges;
191 }
192
193 /**
194 * Sets the number of missing changes.
195 * @param missingChanges the number of missing changes.
196 */
197 public void setMissingChanges(int missingChanges)
198 {
199 this.missingChanges = missingChanges;
200 }
201 }