1208N/A/*
1208N/A * CDDL HEADER START
1208N/A *
1208N/A * The contents of this file are subject to the terms of the
1208N/A * Common Development and Distribution License, Version 1.0 only
1208N/A * (the "License"). You may not use this file except in compliance
1208N/A * with the License.
1208N/A *
1208N/A * You can obtain a copy of the license at
1208N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE
1208N/A * or https://OpenDS.dev.java.net/OpenDS.LICENSE.
1208N/A * See the License for the specific language governing permissions
1208N/A * and limitations under the License.
1208N/A *
1208N/A * When distributing Covered Code, include this CDDL HEADER in each
1208N/A * file and include the License file at
1208N/A * trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
1208N/A * add the following below this CDDL HEADER, with the fields enclosed
1208N/A * by brackets "[]" replaced with your own identifying information:
1208N/A * Portions Copyright [yyyy] [name of copyright owner]
1208N/A *
1208N/A * CDDL HEADER END
1208N/A *
1208N/A *
4567N/A * Copyright 2007-2009 Sun Microsystems, Inc.
6176N/A * Portions copyright 2013 ForgeRock, AS.
1208N/A */
1208N/A
1208N/Apackage org.opends.admin.ads;
1208N/A
1414N/Aimport java.util.HashSet;
1414N/Aimport java.util.Set;
1414N/A
6176N/A
1208N/A/**
1208N/A * The object of this class represent a Replica (i.e. a suffix in a given
1208N/A * server).
1208N/A */
1208N/Apublic class ReplicaDescriptor
1208N/A{
1208N/A private SuffixDescriptor suffix;
1208N/A private int entries = -1;
1208N/A private ServerDescriptor server;
1414N/A private Set<String> replicationServers = new HashSet<String>();
1414N/A private int replicationId = -1;
2611N/A private int missingChanges = -1;
3161N/A private long ageOfOldestMissingChange = -1;
4059N/A private String backendName;
1208N/A
1208N/A /**
1208N/A * Returns the number of entries contained in the replica.
1208N/A * @return the number of entries contained in the replica.
1208N/A */
1208N/A public int getEntries()
1208N/A {
1208N/A return entries;
1208N/A }
1208N/A
1208N/A /**
1414N/A * Returns whether this replica is replicated or not.
1414N/A * @return <CODE>true</CODE> if the replica is replicated and
1414N/A * <CODE>false</CODE> otherwise.
1414N/A */
1414N/A public boolean isReplicated()
1414N/A {
1414N/A return replicationId != -1;
1414N/A }
1414N/A
1414N/A /**
6176N/A * Returns whether replication is replicated on this server or not.
6176N/A * @return <CODE>true</CODE> if replication is enabled and
6176N/A * <CODE>false</CODE> otherwise.
6176N/A */
6176N/A public boolean isReplicationEnabled()
6176N/A {
6176N/A return server.isReplicationEnabled();
6176N/A }
6176N/A
6176N/A /**
1208N/A * Sets the number of entries contained in the replica.
1208N/A * @param entries the number of entries contained in the replica.
1208N/A */
1208N/A public void setEntries(int entries)
1208N/A {
1208N/A this.entries = entries;
1208N/A }
1208N/A
1208N/A /**
1208N/A * Returns the ServerDescriptor object associated with the server where this
1208N/A * replica is located.
1208N/A * @return the ServerDescriptor object associated with the server where this
1208N/A * replica is located.
1208N/A */
1208N/A public ServerDescriptor getServer()
1208N/A {
1208N/A return server;
1208N/A }
1208N/A
1208N/A /**
1208N/A * Sets the server where this replica is located.
1208N/A * @param server the ServerDescriptor object associated with the server where
1208N/A * this replica is located.
1208N/A */
1208N/A public void setServer(ServerDescriptor server)
1208N/A {
1208N/A this.server = server;
1208N/A }
1208N/A
1208N/A /**
1208N/A * Returns the SuffixDescriptor object representing the suffix topology
1208N/A * across servers to which this replica belongs.
1208N/A * @return the SuffixDescriptor object representing the suffix topology
1208N/A * across servers to which this replica belongs.
1208N/A */
1208N/A public SuffixDescriptor getSuffix()
1208N/A {
1208N/A return suffix;
1208N/A }
1208N/A
1208N/A /**
1208N/A * Sets the SuffixDescriptor object representing the suffix topology
1208N/A * across servers to which this replica belongs.
1208N/A * @param suffix the SuffixDescriptor object representing the suffix topology
1208N/A * across servers to which this replica belongs.
1208N/A */
1208N/A public void setSuffix(SuffixDescriptor suffix)
1208N/A {
1208N/A this.suffix = suffix;
1208N/A }
1414N/A
1414N/A /**
1414N/A * Returns a set containing the String representation of the replication
1414N/A * servers that are defined in the replication domain for this replica.
1414N/A * @return a set containing the String representation of the replication
1414N/A * servers that are defined in the replication domain for this replica.
1414N/A */
1414N/A public Set<String> getReplicationServers()
1414N/A {
1414N/A HashSet<String> copy = new HashSet<String>();
1414N/A copy.addAll(replicationServers);
1414N/A return copy;
1414N/A }
1414N/A
1414N/A /**
1414N/A * Sets the list of replication servers (in their String representation) that
1414N/A * are defined in the replication domain for this replica.
1414N/A * @param replicationServers the list of replication servers (in their String
1414N/A * representation) that are defined in the replication domain for this
1414N/A * replica.
1414N/A */
1414N/A public void setReplicationServers(Set<String> replicationServers)
1414N/A {
1414N/A this.replicationServers.clear();
1414N/A this.replicationServers.addAll(replicationServers);
1414N/A }
1414N/A
1414N/A /**
4567N/A * Returns the replication id for the replication domain associated
1414N/A * with this replica.
4567N/A * @return the replication id for the replication domain associated
1414N/A * with this replica.
1414N/A */
1414N/A public int getReplicationId()
1414N/A {
1414N/A return replicationId;
1414N/A }
1414N/A
1414N/A /**
4567N/A * Sets the replication id for the replication domain associated
1414N/A * with this replica.
4567N/A * @param replicationId the replication id for the replication domain
1414N/A * associated with this replica.
1414N/A */
1414N/A public void setReplicationId(int replicationId)
1414N/A {
1414N/A this.replicationId = replicationId;
1414N/A }
2611N/A
2611N/A /**
2611N/A * Returns the age of the oldest missing change.
2611N/A * @return the age of the oldest missing change.
2611N/A */
3161N/A public long getAgeOfOldestMissingChange()
2611N/A {
2611N/A return ageOfOldestMissingChange;
2611N/A }
2611N/A
2611N/A /**
2611N/A * Sets the age of the oldest missing change.
2611N/A * @param ageOfOldestMissingChange the age of the oldest missing change.
2611N/A */
3161N/A public void setAgeOfOldestMissingChange(long ageOfOldestMissingChange)
2611N/A {
2611N/A this.ageOfOldestMissingChange = ageOfOldestMissingChange;
2611N/A }
2611N/A
2611N/A /**
2611N/A * Returns the number of missing changes.
2611N/A * @return the number of missing changes.
2611N/A */
2611N/A public int getMissingChanges()
2611N/A {
2611N/A return missingChanges;
2611N/A }
2611N/A
2611N/A /**
2611N/A * Sets the number of missing changes.
2611N/A * @param missingChanges the number of missing changes.
2611N/A */
2611N/A public void setMissingChanges(int missingChanges)
2611N/A {
2611N/A this.missingChanges = missingChanges;
2611N/A }
4059N/A
4059N/A /**
4059N/A * Returns the name of the backend where this replica is defined.
4059N/A * @return the name of the backend where this replica is defined.
4059N/A */
4059N/A public String getBackendName()
4059N/A {
4059N/A return backendName;
4059N/A }
4059N/A
4059N/A /**
4059N/A * Sets the name of the backend where this replica is defined.
4059N/A * @param backendName the name of the backend.
4059N/A */
4059N/A public void setBackendName(String backendName)
4059N/A {
4059N/A this.backendName = backendName;
4059N/A }
1208N/A}