mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

jcduff
23.04.2008 f73b655466092169abac34833fb628fce1fcdebe
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
/*
 * CDDL HEADER START
 *
 * The contents of this file are subject to the terms of the
 * Common Development and Distribution License, Version 1.0 only
 * (the "License").  You may not use this file except in compliance
 * with the License.
 *
 * You can obtain a copy of the license at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE
 * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
 * See the License for the specific language governing permissions
 * and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL HEADER in each
 * file and include the License file at
 * trunk/opends/resource/legal-notices/OpenDS.LICENSE.  If applicable,
 * add the following below this CDDL HEADER, with the fields enclosed
 * by brackets "[]" replaced with your own identifying information:
 *      Portions Copyright [yyyy] [name of copyright owner]
 *
 * CDDL HEADER END
 *
 *
 *      Copyright 2008 Sun Microsystems, Inc.
 */
package org.opends.server.replication.common;
 
import java.util.ArrayList;
import java.util.List;
 
/**
 * This class holds information about a DS connected to the topology. This
 * information is to be exchanged through the replication protocol in
 * topology messages, to keep every member (RS or DS) of the topology aware of
 * the DS topology.
 */
public class DSInfo
{
 
  // DS server id
  private short dsId = -1;
  // Server id of the RS the DS is connected to
  private short rsId = -1;
  // DS Generation Id
  private long generationId = -1;
  // DS Status
  private ServerStatus status = ServerStatus.INVALID_STATUS;
  // Assured replication enabled on DS or not
  private boolean assuredFlag = false;
  // DS assured mode (relevant if assured replication enabled)
  private AssuredMode assuredMode = AssuredMode.SAFE_DATA_MODE;
  // DS safe data level (relevant if assured mode is safe data)
  private byte safeDataLevel = (byte) -1;
  // List of referrals URLs exported by the DS
  private List<String> refUrls = new ArrayList<String>(0);
  // Group id
  private byte groupId = (byte) -1;
 
  /**
   * Creates a new instance of DSInfo with every given info.
   *
   * @param dsId The DS id
   * @param rsId The RS id the DS is connected to
   * @param generationId The generation id the DS is using
   * @param status The DS status
   * @param assuredFlag DS assured replication enabled or not
   * @param assuredMode DS assured mode
   * @param safeDataLevel DS safe data level
   * @param groupId DS group id
   * @param refUrls DS exported referrals URLs
   */
  public DSInfo(short dsId, short rsId, long generationId, ServerStatus status,
    boolean assuredFlag, AssuredMode assuredMode, byte safeDataLevel,
    byte groupId, List<String> refUrls)
  {
 
    this.dsId = dsId;
    this.rsId = rsId;
    this.generationId = generationId;
    this.status = status;
    this.assuredFlag = assuredFlag;
    this.assuredMode = assuredMode;
    this.safeDataLevel = safeDataLevel;
    this.groupId = groupId;
    this.refUrls = refUrls;
  }
 
  /**
   * Get the DS id.
   * @return the DS id
   */
  public short getDsId()
  {
    return dsId;
  }
 
  /**
   * Get the RS id the DS is connected to.
   * @return the RS id the DS is connected to
   */
  public short getRsId()
  {
    return rsId;
  }
 
  /**
   * Get the generation id DS is using.
   * @return the generation id DS is using.
   */
  public long getGenerationId()
  {
    return generationId;
  }
 
  /**
   * Get the DS status.
   * @return the DS status
   */
  public ServerStatus getStatus()
  {
    return status;
  }
 
  /**
   * Tells if the DS has assured replication enabled.
   * @return True if the DS has assured replication enabled
   */
  public boolean isAssured()
  {
    return assuredFlag;
  }
 
  /**
   * Get the DS assured mode (relevant if DS has assured replication enabled).
   * @return The DS assured mode
   */
  public AssuredMode getAssuredMode()
  {
    return assuredMode;
  }
 
  /**
   * Get the DS safe data level (relevant if assured mode is safe data).
   * @return The DS safe data level
   */
  public byte getSafeDataLevel()
  {
    return safeDataLevel;
  }
 
  /**
   * Get the DS group id.
   * @return The DS group id
   */
  public byte getGroupId()
  {
    return groupId;
  }
 
  /**
   * Get the DS exported URLs for referrals.
   * @return The DS exported URLs for referrals
   */
  public List<String> getRefUrls()
  {
    return refUrls;
  }
 
  /**
   * Test if the passed object is equal to this one.
   * @param obj The object to test
   * @return True if both objects are equal
   */
  @Override
  public boolean equals(Object obj)
  {
    if (obj != null)
    {
      if (obj.getClass() != this.getClass())
      {
        return false;
      }
      DSInfo dsInfo = (DSInfo) obj;
      return ((dsId == dsInfo.getDsId()) &&
        (rsId == dsInfo.getRsId()) &&
        (generationId == dsInfo.getGenerationId()) &&
        (status == dsInfo.getStatus()) &&
        (assuredFlag == dsInfo.isAssured()) &&
        (assuredMode == dsInfo.getAssuredMode()) &&
        (safeDataLevel == dsInfo.getSafeDataLevel()) &&
        (groupId == dsInfo.getGroupId()) &&
        (refUrls.equals(dsInfo.getRefUrls())));
    } else
    {
      return false;
    }
  }
 
  /**
   * Computes hash code for this object instance.
   * @return Hash code for this object instance.
   */
  @Override
  public int hashCode()
  {
    int hash = 7;
    hash = 73 * hash + this.dsId;
    hash = 73 * hash + this.rsId;
    hash = 73 * hash + (int) (this.generationId ^ (this.generationId >>> 32));
    hash = 73 * hash + (this.status != null ? this.status.hashCode() : 0);
    hash = 73 * hash + (this.assuredFlag ? 1 : 0);
    hash =
      73 * hash + (this.assuredMode != null ? this.assuredMode.hashCode() : 0);
    hash = 73 * hash + this.safeDataLevel;
    hash = 73 * hash + (this.refUrls != null ? this.refUrls.hashCode() : 0);
    hash = 73 * hash + this.groupId;
    return hash;
  }
 
  /**
   * Returns a string representation of the DS info.
   * @return A string representation of the DS info
   */
  @Override
  public String toString()
  {
    StringBuffer sb = new StringBuffer();
    sb.append("DS id: ");
    sb.append(dsId);
    sb.append("\nRS id: ");
    sb.append(rsId);
    sb.append("\nGeneration id: ");
    sb.append(generationId);
    sb.append("\nStatus: ");
    sb.append(status);
    sb.append("\nAssured replication: ");
    sb.append(assuredFlag);
    sb.append("\nAssured mode: ");
    sb.append(assuredMode);
    sb.append("\nSafe data level: ");
    sb.append(safeDataLevel);
    sb.append("\nGroup id: ");
    sb.append(groupId);
    sb.append("\nReferral URLs: ");
    sb.append(refUrls);
    return sb.toString();
  }
 
}