001/*
002 * The contents of this file are subject to the terms of the Common Development and
003 * Distribution License (the License). You may not use this file except in compliance with the
004 * License.
005 *
006 * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
007 * specific language governing permission and limitations under the License.
008 *
009 * When distributing Covered Software, include this CDDL Header Notice in each file and include
010 * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
011 * Header, with the fields enclosed by brackets [] replaced by your own identifying
012 * information: "Portions Copyright [year] [name of copyright owner]".
013 *
014 * Copyright 2008-2009 Sun Microsystems, Inc.
015 * Portions Copyright 2015 ForgeRock AS.
016 */
017
018package org.opends.server.tools.dsreplication;
019
020import org.opends.server.types.HostPort;
021
022/**
023 * This class is used to store the information provided by the user to
024 * initialize replication.  It is required because when we are in interactive
025 * mode the ReplicationCliArgumentParser is not enough.
026 */
027public class SourceDestinationServerUserData extends ReplicationUserData
028{
029  private String hostNameSource;
030  private int portSource;
031  private String hostNameDestination;
032  private int portDestination;
033
034  /**
035   * Returns the host name of the source server.
036   * @return the host name of the source server.
037   */
038  public String getHostNameSource()
039  {
040    return hostNameSource;
041  }
042
043  /**
044   * Sets the host name of the source server.
045   * @param hostNameSource the host name of the source server.
046   */
047  public void setHostNameSource(String hostNameSource)
048  {
049    this.hostNameSource = hostNameSource;
050  }
051
052  /**
053   * Returns the port of the source server.
054   * @return the port of the source server.
055   */
056  public int getPortSource()
057  {
058    return portSource;
059  }
060
061  /**
062   * Sets the port of the source server.
063   * @param portSource the port of the source server.
064   */
065  public void setPortSource(int portSource)
066  {
067    this.portSource = portSource;
068  }
069
070  /**
071   * Returns the host name of the destination server.
072   * @return the host name of the destination server.
073   */
074  public String getHostNameDestination()
075  {
076    return new HostPort(hostNameDestination, portDestination).toString();
077  }
078
079  /**
080   * Returns a host:port string for the source server.
081   * @return a host:port string for the source server
082   */
083  public String getSourceHostPort()
084  {
085    return new HostPort(hostNameSource, portSource).toString();
086  }
087
088  /**
089   * Returns a host:port string for the destination server.
090   * @return a host:port string for the destination server
091   */
092  public String getDestinationHostPort()
093  {
094    return hostNameDestination + ":" + portDestination;
095  }
096
097  /**
098   * Sets the host name of the destination server.
099   * @param hostNameDestination the host name of the destination server.
100   */
101  public void setHostNameDestination(String hostNameDestination)
102  {
103    this.hostNameDestination = hostNameDestination;
104  }
105
106  /**
107   * Returns the port of the destination server.
108   * @return the port of the destination server.
109   */
110  public int getPortDestination()
111  {
112    return portDestination;
113  }
114
115  /**
116   * Sets the port of the destination server.
117   * @param portDestination the port of the destination server.
118   */
119  public void setPortDestination(int portDestination)
120  {
121    this.portDestination = portDestination;
122  }
123
124  /**
125   * Returns a {@link HostPort} representing the source server.
126   * @return a {@link HostPort} representing the source server
127   */
128  public HostPort getSource()
129  {
130    return new HostPort(hostNameSource, portSource);
131  }
132
133  /**
134   * Returns a {@link HostPort} representing the destination server.
135   * @return a {@link HostPort} representing the destination server
136   */
137  public HostPort getDestination()
138  {
139    return new HostPort(hostNameDestination, portDestination);
140  }
141}