001/*
002 * CDDL HEADER START
003 *
004 * The contents of this file are subject to the terms of the
005 * Common Development and Distribution License, Version 1.0 only
006 * (the "License").  You may not use this file except in compliance
007 * with the License.
008 *
009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt
010 * or http://forgerock.org/license/CDDLv1.0.html.
011 * See the License for the specific language governing permissions
012 * and limitations under the License.
013 *
014 * When distributing Covered Code, include this CDDL HEADER in each
015 * file and include the License file at legal-notices/CDDLv1_0.txt.
016 * If applicable, add the following below this CDDL HEADER, with the
017 * fields enclosed by brackets "[]" replaced with your own identifying
018 * information:
019 *      Portions Copyright [yyyy] [name of copyright owner]
020 *
021 * CDDL HEADER END
022 *
023 *
024 *      Copyright 2006-2008 Sun Microsystems, Inc.
025 *      Portions Copyright 2013-2015 ForgeRock AS.
026 */
027package org.opends.server.replication.protocol;
028
029import java.util.zip.DataFormatException;
030
031/**
032 * This message is used by LDAP or Replication Server that have been out of
033 * credit for a while and want to check if the remote servers is able to accept
034 * more messages.
035 * <p>
036 * A sending entity that is blocked because its send window is closed for a
037 * while should create such a message to check that the window closure is valid.
038 * <p>
039 * An entity that received such a message should respond with a
040 * {@link WindowMsg} indicating the current credit available.
041 */
042public class WindowProbeMsg extends ReplicationMsg
043{
044  /**
045   * Create a new WindowProbeMsg message.
046   */
047  public WindowProbeMsg()
048  {
049  }
050
051  /**
052   * Creates a new WindowProbeMsg from its encoded form.
053   *
054   * @param in The byte array containing the encoded form of the
055   *           WindowMessage.
056   * @throws DataFormatException If the byte array does not contain a valid
057   *                             encoded form of the WindowMessage.
058   */
059  public WindowProbeMsg(byte[] in) throws DataFormatException
060  {
061    // WindowProbeMsg only contains its type.
062    if (in[0] != MSG_TYPE_WINDOW_PROBE)
063    {
064      throw new DataFormatException("input is not a valid WindowProbeMsg");
065    }
066  }
067
068  /** {@inheritDoc} */
069  @Override
070  public byte[] getBytes(short protocolVersion)
071  {
072    // WindowProbeMsg only contains its type.
073    return new byte[] { MSG_TYPE_WINDOW_PROBE };
074  }
075}