/** {@inheritDoc} */
  @Override
  public byte[] getBytes(short protocolVersion) {
    /*
     * The message is stored in the form:
     * <message type><requested status><new status>
     */
    byte[] encodedMsg = new byte[3];

    /* Put the type of the operation */
    encodedMsg[0] = ReplicationMsg.MSG_TYPE_CHANGE_STATUS;

    /* Put the requested status */
    encodedMsg[1] = requestedStatus.getValue();

    /* Put the requested status */
    encodedMsg[2] = newStatus.getValue();

    return encodedMsg;
  }
  /**
   * Creates a new ChangeStatusMsg from its encoded form.
   *
   * @param encodedMsg The byte array containing the encoded form of the ChangeStatusMsg.
   * @throws DataFormatException If the byte array does not contain a valid encoded form of the
   *     ChangeStatusMsg.
   */
  public ChangeStatusMsg(byte[] encodedMsg) throws DataFormatException {
    /*
     * The message is stored in the form:
     * <message type><requested status><new status>
     */

    /* First byte is the type */
    if (encodedMsg[0] != ReplicationMsg.MSG_TYPE_CHANGE_STATUS) {
      throw new DataFormatException("byte[] is not a valid msg");
    }

    try {
      /* Then the requested status */
      requestedStatus = ServerStatus.valueOf(encodedMsg[1]);

      /* Then the new status */
      newStatus = ServerStatus.valueOf(encodedMsg[2]);
    } catch (IllegalArgumentException e) {
      throw new DataFormatException(e.getMessage());
    }
  }