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 2009 Sun Microsystems, Inc.
015 * Portions copyright 2013-2015 ForgeRock AS.
016 */
017package org.opends.server.replication.protocol;
018
019import java.util.zip.DataFormatException;
020
021/**
022 * This message is part of the replication protocol.
023 * This message is sent by a server to tell a peer the communication will be
024 * terminated.
025 */
026public class StopMsg extends ReplicationMsg
027{
028  /**
029   * Creates a message.
030   */
031  public StopMsg()
032  {
033  }
034
035  /**
036   * Creates a new message by decoding the provided byte array.
037   * @param in A byte array containing the encoded information for the message,
038   * @throws DataFormatException If the in does not contain a properly,
039   *                             encoded message.
040   */
041  public StopMsg(byte[] in) throws DataFormatException
042  {
043    // First byte is the type
044    if (in[0] != MSG_TYPE_STOP)
045    {
046      throw new DataFormatException("input is not a valid Stop message: " + in[0]);
047    }
048  }
049
050  /** {@inheritDoc} */
051  @Override
052  public byte[] getBytes(short protocolVersion)
053  {
054    return new byte[] { MSG_TYPE_STOP };
055  }
056
057  /** {@inheritDoc} */
058  @Override
059  public String toString()
060  {
061    return getClass().getSimpleName();
062  }
063}