opends/src/server/org/opends/server/replication/common/DSInfo.java
@@ -27,46 +27,46 @@ */ package org.opends.server.replication.common; import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; /** * 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. * 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. * <p> * This class is almost immutable, because it does not copy the List and Set * passed into the ctor. */ public class DSInfo public final class DSInfo { // DS server id private int dsId = -1; // DS server url private String dsUrl; // Server id of the RS the DS is connected to private int 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; // Protocol version private short protocolVersion = -1; /** DS server id. */ private final int dsId; /** DS server url. */ private final String dsUrl; /** Server id of the RS that the DS is connected to. */ private final int rsId; /** DS Generation Id. */ private final long generationId; /** DS Status. */ private final ServerStatus status; /** Assured replication enabled on DS or not. */ private final boolean assuredFlag; /** DS assured mode (relevant if assured replication enabled). */ private final AssuredMode assuredMode; /** DS safe data level (relevant if assured mode is safe data). */ private final byte safeDataLevel; /** List of referrals URLs exported by the DS. */ private final List<String> refUrls; /** Group id. */ private final byte groupId; /** Protocol version. */ private final short protocolVersion; private Set<String> eclIncludes = new HashSet<String>(); private Set<String> eclIncludesForDeletes = new HashSet<String>(); private final Set<String> eclIncludes; private final Set<String> eclIncludesForDeletes; @@ -246,34 +246,32 @@ @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()) && (protocolVersion == dsInfo.getProtocolVersion()) && (refUrls.equals(dsInfo.getRefUrls())) && (((eclIncludes == null) && (dsInfo.getEclIncludes() == null)) || ((eclIncludes != null) && (eclIncludes.equals(dsInfo.getEclIncludes())))) && (((eclIncludesForDeletes == null) && (dsInfo.getEclIncludesForDeletes() == null)) || ((eclIncludesForDeletes != null) && (eclIncludesForDeletes.equals(dsInfo.getEclIncludesForDeletes()))))); } else if (obj == null) { return false; } if (obj.getClass() != getClass()) { return false; } final 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() && protocolVersion == dsInfo.getProtocolVersion() && refUrls.equals(dsInfo.getRefUrls()) && equals(eclIncludes, dsInfo.getEclIncludes()) && equals(eclIncludesForDeletes, dsInfo.getEclIncludesForDeletes()); } private boolean equals(Set<String> o1, Set<String> o2) { return (o1 == null && o2 == null) || (o1 != null && o1.equals(o2)); } /** opends/src/server/org/opends/server/replication/common/RSInfo.java
@@ -23,31 +23,35 @@ * * * Copyright 2008-2010 Sun Microsystems, Inc. * Portions Copyright 2012 ForgeRock AS * Portions Copyright 2012-2013 ForgeRock AS */ package org.opends.server.replication.common; /** * This class holds information about a RS connected to the topology. This * information is to be exchanged through the replication protocol in * topology messages, to keep every member DS of the topology aware of * the RS topology. * information is to be exchanged through the replication protocol in topology * messages, to keep every member DS of the topology aware of the RS topology. * <p> * This class is immutable. */ public class RSInfo public final class RSInfo { // Server id of the RS private int id = -1; // Generation Id of the RS private long generationId = -1; // Group id of the RS private byte groupId = (byte) -1; // The weight of the RS // It is important to keep the default value to 1 so that it is used as // default value for a RS using protocol V3: this default value will be used // in algorithms that use weight private int weight = 1; // The server URL of the RS private String serverUrl = null; /** Server id of the RS. */ private final int id; /** Generation Id of the RS. */ private final long generationId; /** Group id of the RS. */ private final byte groupId; /** * The weight of the RS. * <p> * It is important to keep the default value to 1 so that it is used as * default value for a RS using protocol V3: this default value will be used * in algorithms that use weight. */ private final int weight; /** The server URL of the RS. */ private final String serverUrl; /** * Creates a new instance of RSInfo with every given info. @@ -113,24 +117,21 @@ @Override public boolean equals(Object obj) { if (obj != null) { if (obj.getClass() != this.getClass()) { return false; } RSInfo rsInfo = (RSInfo) obj; return ((id == rsInfo.getId()) && (generationId == rsInfo.getGenerationId()) && (groupId == rsInfo.getGroupId()) && (weight == rsInfo.getWeight()) && (((serverUrl == null) && (rsInfo.getServerUrl() == null)) || ((serverUrl != null) && (rsInfo.getServerUrl() != null) && (serverUrl.equals(rsInfo.getServerUrl()))))); } else if (obj == null) { return false; } if (obj.getClass() != getClass()) { return false; } final RSInfo rsInfo = (RSInfo) obj; return id == rsInfo.getId() && generationId == rsInfo.getGenerationId() && groupId == rsInfo.getGroupId() && weight == rsInfo.getWeight() && ((serverUrl == null && rsInfo.getServerUrl() == null) || (serverUrl != null && serverUrl.equals(rsInfo.getServerUrl()))); } /** opends/src/server/org/opends/server/replication/server/LightweightServerHandler.java
@@ -58,40 +58,19 @@ public class LightweightServerHandler extends MonitorProvider<MonitorProviderCfg> { // The tracer object for the debug logger. /** The tracer object for the debug logger. */ private static final DebugTracer TRACER = getTracer(); private ReplicationServerHandler replServerHandler; private ReplicationServerDomain rsDomain; // The id of the RS this DS is connected to private int replicationServerId = -1; private final ReplicationServerHandler replServerHandler; private final ReplicationServerDomain rsDomain; // Server id of this DS private int serverId = -1; // Server URL of this DS private String serverUrl = null; // Generation id of this DS private long generationId = -1; // Group id of the DS; private byte groupId = (byte) -1; // Status of this DS private ServerStatus status = ServerStatus.INVALID_STATUS; // Referrals URLs this DS is exporting private List<String> refUrls = new ArrayList<String>(); // 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; // The protocol version private short protocolVersion = -1; private Set<String> eclInclude = new HashSet<String>(); private Set<String> eclIncludeForDeletes = new HashSet<String>(); /** Server id of this DS. */ private final int serverId; /** All the information for this DS. */ private final DSInfo dsInfo; /** * Creates a new LightweightServerHandler with the provided serverid, * Creates a new LightweightServerHandler with the provided serverId, * connected to the remote Replication Server represented by * replServerHandler. * @@ -122,23 +101,16 @@ { this.replServerHandler = replServerHandler; this.rsDomain = replServerHandler.getDomain(); this.replicationServerId = replicationServerId; this.serverId = serverId; this.serverUrl = serverUrl; this.generationId = generationId; this.groupId = groupId; this.status = status; this.refUrls = refUrls; this.assuredFlag = assuredFlag; this.assuredMode = assuredMode; this.safeDataLevel = safeDataLevel; this.eclInclude = eclInclude; this.eclIncludeForDeletes = eclIncludeForDeletes; this.protocolVersion = protocolVersion; this.dsInfo = new DSInfo(serverId, serverUrl, replicationServerId, generationId, status, assuredFlag, assuredMode, safeDataLevel, groupId, refUrls, eclInclude, eclIncludeForDeletes, protocolVersion); if (debugEnabled()) TRACER.debugInfo("In " + rsDomain.getLocalRSMonitorInstanceName() + " LWSH for remote server " + this.serverId + " connected to:" + " LWSH for remote server " + serverId + " connected to:" + this.replServerHandler.getMonitorInstanceName() + " ()"); } @@ -148,9 +120,7 @@ */ public DSInfo toDSInfo() { return new DSInfo(serverId, serverUrl, replicationServerId, generationId, status, assuredFlag, assuredMode, safeDataLevel, groupId, refUrls, eclInclude, eclIncludeForDeletes, protocolVersion); return dsInfo; } /** @@ -163,7 +133,7 @@ } /** * Stop this server handler processing. * Start this server handler processing. */ public void startHandler() { @@ -206,7 +176,8 @@ @Override public String getMonitorInstanceName() { return "Connected directory server DS(" + serverId + ") " + serverUrl return "Connected directory server DS(" + serverId + ") " + dsInfo.getDsUrl() + ",cn=" + replServerHandler.getMonitorInstanceName(); } @@ -219,14 +190,12 @@ * requested. */ @Override public ArrayList<Attribute> getMonitorData() public List<Attribute> getMonitorData() { ArrayList<Attribute> attributes = new ArrayList<Attribute>(); List<Attribute> attributes = new ArrayList<Attribute>(); attributes.add(Attributes.create("server-id", String.valueOf(serverId))); attributes.add(Attributes.create("domain-name", rsDomain.getBaseDn())); attributes.add(Attributes.create("server-id", String.valueOf(serverId))); attributes.add(Attributes.create("domain-name", rsDomain.getBaseDn())); attributes.add(Attributes.create("connected-to", replServerHandler.getMonitorInstanceName())); @@ -239,7 +208,7 @@ remoteState = new ServerState(); } /* get the Server State */ // get the Server State AttributeBuilder builder = new AttributeBuilder("server-state"); for (String str : remoteState.toStringSet()) { @@ -252,8 +221,8 @@ attributes.add(builder.toAttribute()); // Oldest missing update Long approxFirstMissingDate=md.getApproxFirstMissingDate(serverId); if ((approxFirstMissingDate != null) && (approxFirstMissingDate>0)) long approxFirstMissingDate = md.getApproxFirstMissingDate(serverId); if (approxFirstMissingDate > 0) { Date date = new Date(approxFirstMissingDate); attributes.add(Attributes.create(