<schema package="qpid">

<!--
  Licensed to the Apache Software Foundation (ASF) under one
  or more contributor license agreements.  See the NOTICE file
  distributed with this work for additional information
  regarding copyright ownership.  The ASF licenses this file
  to you under the Apache License, Version 2.0 (the
  "License"); you may not use this file except in compliance
  with the License.  You may obtain a copy of the License at
  
    http://www.apache.org/licenses/LICENSE-2.0
  
  Unless required by applicable law or agreed to in writing,
  software distributed under the License is distributed on an
  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  KIND, either express or implied.  See the License for the
  specific language governing permissions and limitations
  under the License.
-->

  <!-- Type information:

       Numeric types with "_wm" suffix are watermarked numbers.  These are compound
       values containing a current value, and a low and high water mark for the reporting
       interval.  The low and high water marks are set to the current value at the
       beginning of each interval and track the minimum and maximum values of the statistic
       over the interval respectively.

       Access rights for configuration elements:

           RO => Read Only
           RC => Read/Create, can be set at create time only, read-only thereafter
           RW => Read/Write

           If access rights are omitted for a configElement, they are assumed to be RO.

  -->

  <!-- Questions:  Does C++ broker round-robin dests on queues? -->

  <!--
  ===============================================================
  System
  ===============================================================
  -->
  <class name="system">
    <configElement name="sysId" index="y" type="uuid" access="RC"/>

    <configElement name="osName"   type="sstr" access="RO" desc="Operating System Name"/>
    <configElement name="nodeName" type="sstr" access="RO" desc="Node Name"/>
    <configElement name="release"  type="sstr" access="RO"/>
    <configElement name="version"  type="sstr" access="RO"/>
    <configElement name="machine"  type="sstr" access="RO"/>

  </class>

  <!--
  ===============================================================
  Broker
  ===============================================================
  -->
  <class name="broker">
    <configElement name="systemRef"            type="objId"  access="RC" index="y" desc="System ID" parentRef="y"/>
    <configElement name="port"                 type="uint16" access="RC" index="y" desc="TCP Port for AMQP Service"/>
    <configElement name="workerThreads"        type="uint16" access="RO" desc="Thread pool size"/>
    <configElement name="maxConns"             type="uint16" access="RO" desc="Maximum allowed connections"/>
    <configElement name="connBacklog"          type="uint16" access="RO" desc="Connection backlog limit for listening socket"/>
    <configElement name="stagingThreshold"     type="uint32" access="RO" desc="Broker stages messages over this size to disk"/>
    <configElement name="mgmtPubInterval"      type="uint16" access="RW" unit="second" min="1" desc="Interval for management broadcasts"/>
    <configElement name="clusterName"          type="sstr"   access="RO"
                   desc="Name of cluster this server is a member of"/>
    <configElement name="version"              type="sstr"   access="RO" desc="Running software version"/>
    <configElement name="dataDirEnabled"       type="bool"   access="RO" desc="Persistent configuration storage enabled"/>
    <configElement name="dataDir"              type="sstr"   access="RO" desc="Persistent configuration storage location"/>

    <method name="joinCluster">
      <arg name="clusterName" dir="I" type="sstr"/>
    </method>

    <method name="leaveCluster"/>

    <method name="echo" desc="Request a response to test the path to the management agent">
      <arg name="sequence" dir="IO" type="uint32" default="0"/>
      <arg name="body"     dir="IO" type="lstr"   default=""/>
    </method>

    <method name="connect" desc="Establish a connection to another broker">
      <arg name="host"          dir="I" type="sstr"/>
      <arg name="port"          dir="I" type="uint32"/>
      <arg name="useSsl"        dir="I" type="bool"/>
      <arg name="durable"       dir="I" type="bool"/>
      <arg name="authMechanism" dir="I" type="sstr"/>
      <arg name="username"      dir="I" type="sstr"/>
      <arg name="password"      dir="I" type="sstr"/>
    </method>
  </class>

  <!--
  ===============================================================
  Management Agent
  ===============================================================
  -->
  <class name="agent">
    <configElement name="sessionId"    type="uuid"  access="RO" index="y" desc="Session ID for Agent"/>
    <configElement name="label"        type="sstr"  access="RO"           desc="Label for agent"/>
    <configElement name="registeredTo" type="objId" access="RO"           desc="Broker agent is registered to"/>
    <configElement name="sysId"        type="uuid"  access="RO"           desc="Identifier of system where agent resides"/>
  </class>

  <!--
  ===============================================================
  Virtual Host
  ===============================================================
  -->
  <class name="vhost">
    <configElement name="brokerRef" type="objId"  access="RC" index="y" parentRef="y"/>
    <configElement name="name"      type="sstr"   access="RC" index="y"/>
  </class>

  <!--
  ===============================================================
  Queue
  ===============================================================
  -->
  <class name="queue">
    <configElement name="vhostRef"        type="objId"  access="RC" index="y" parentRef="y"/>
    <configElement name="name"            type="sstr"   access="RC" index="y"/>

    <configElement name="durable"         type="bool"   access="RC"/>
    <configElement name="autoDelete"      type="bool"   access="RC"/>
    <configElement name="exclusive"       type="bool"   access="RC"/>
    <configElement name="arguments"       type="ftable" access="RO" desc="Arguments supplied in queue.declare"/>
    <configElement name="storeRef"        type="objId"  access="RO" desc="Reference to persistent queue (if durable)"/>

    <instElement name="msgTotalEnqueues"    type="count64" unit="message"     desc="Total messages enqueued"/>
    <instElement name="msgTotalDequeues"    type="count64" unit="message"     desc="Total messages dequeued"/>
    <instElement name="msgTxnEnqueues"      type="count64" unit="message"     desc="Transactional messages enqueued"/>
    <instElement name="msgTxnDequeues"      type="count64" unit="message"     desc="Transactional messages dequeued"/>
    <instElement name="msgPersistEnqueues"  type="count64" unit="message"     desc="Persistent messages enqueued"/>
    <instElement name="msgPersistDequeues"  type="count64" unit="message"     desc="Persistent messages dequeued"/>
    <instElement name="msgDepth"            type="hilo32"  unit="message"     desc="Current size of queue in messages"/>
    <instElement name="byteTotalEnqueues"   type="count64" unit="octet"       desc="Total messages enqueued"/>
    <instElement name="byteTotalDequeues"   type="count64" unit="octet"       desc="Total messages dequeued"/>
    <instElement name="byteTxnEnqueues"     type="count64" unit="octet"       desc="Transactional messages enqueued"/>
    <instElement name="byteTxnDequeues"     type="count64" unit="octet"       desc="Transactional messages dequeued"/>
    <instElement name="bytePersistEnqueues" type="count64" unit="octet"       desc="Persistent messages enqueued"/>
    <instElement name="bytePersistDequeues" type="count64" unit="octet"       desc="Persistent messages dequeued"/>
    <instElement name="byteDepth"           type="hilo32"  unit="octet"       desc="Current size of queue in bytes"/>
    <instElement name="enqueueTxnStarts"    type="count64" unit="transaction" desc="Total enqueue transactions started "/>
    <instElement name="enqueueTxnCommits"   type="count64" unit="transaction" desc="Total enqueue transactions committed"/>
    <instElement name="enqueueTxnRejects"   type="count64" unit="transaction" desc="Total enqueue transactions rejected"/>
    <instElement name="enqueueTxnCount"     type="hilo32"  unit="transaction" desc="Current pending enqueue transactions"/>
    <instElement name="dequeueTxnStarts"    type="count64" unit="transaction" desc="Total dequeue transactions started"/>
    <instElement name="dequeueTxnCommits"   type="count64" unit="transaction" desc="Total dequeue transactions committed"/>
    <instElement name="dequeueTxnRejects"   type="count64" unit="transaction" desc="Total dequeue transactions rejected"/>
    <instElement name="dequeueTxnCount"     type="hilo32"  unit="transaction" desc="Current pending dequeue transactions"/>
    <instElement name="consumers"           type="hilo32"  unit="consumer"    desc="Current consumers on queue"/>
    <instElement name="bindings"            type="hilo32"  unit="binding"     desc="Current bindings"/>
    <instElement name="unackedMessages"     type="hilo32"  unit="message"     desc="Messages consumed but not yet acked"/>
    <instElement name="messageLatency"      type="mmaTime" unit="nanosecond"  desc="Broker latency through this queue"/>

    <method name="purge" desc="Discard all messages on queue"/>
  </class>

  <!--
  ===============================================================
  Exchange
  ===============================================================
  -->
  <class name="exchange">
    <configElement name="vhostRef"   type="objId" access="RC" index="y" parentRef="y"/>
    <configElement name="name"       type="sstr"  access="RC" index="y"/>
    <configElement name="type"       type="sstr"  access="RO"/>
    <configElement name="durable"    type="bool"  access="RC"/>

    <instElement name="producers"    type="hilo32"  desc="Current producers on exchange"/>
    <instElement name="bindings"     type="hilo32"  desc="Current bindings"/>
    <instElement name="msgReceives"  type="count64" desc="Total messages received"/>
    <instElement name="msgDrops"     type="count64" desc="Total messages dropped (no matching key)"/>
    <instElement name="msgRoutes"    type="count64" desc="Total routed messages"/>
    <instElement name="byteReceives" type="count64" desc="Total bytes received"/>
    <instElement name="byteDrops"    type="count64" desc="Total bytes dropped (no matching key)"/>
    <instElement name="byteRoutes"   type="count64" desc="Total routed bytes"/>
  </class>

  <!--
  ===============================================================
  Binding
  ===============================================================
  -->
  <class name="binding">
    <configElement name="exchangeRef" type="objId"  access="RC" index="y" parentRef="y"/>
    <configElement name="queueRef"    type="objId"  access="RC" index="y"/>
    <configElement name="bindingKey"  type="sstr"   access="RC" index="y"/>
    <configElement name="arguments"   type="ftable" access="RC"/>

    <instElement name="msgMatched" type="count64"/>
  </class>
  
  <!--
  ===============================================================
  Client
  ===============================================================
  -->
  <class name="client">
    <configElement name="vhostRef" type="objId"  access="RC" index="y" parentRef="y"/>
    <configElement name="address"  type="sstr"   access="RC" index="y"/>
    <configElement name="incoming" type="bool"   access="RC"/>

    <instElement name="closing"          type="bool" desc="This client is closing by management request"/>
    <instElement name="authIdentity"     type="sstr"/>
    <instElement name="framesFromClient" type="count64"/>
    <instElement name="framesToClient"   type="count64"/>
    <instElement name="bytesFromClient"  type="count64"/>
    <instElement name="bytesToClient"    type="count64"/>

    <method name="close"/> 
  </class>

  <!--
  ===============================================================
  Link
  ===============================================================
  -->
  <class name="link">

    This class represents an inter-broker connection.

    <configElement name="vhostRef"  type="objId"  access="RC" index="y" parentRef="y"/>
    <configElement name="host"      type="sstr"   access="RC" index="y"/>
    <configElement name="port"      type="uint16" access="RC" index="y"/>
    <configElement name="useSsl"    type="bool"   access="RC"/>
    <configElement name="durable"   type="bool"   access="RC"/>

    <instElement name="state"       type="sstr" desc="Operational state of the link"/>
    <instElement name="lastError"   type="sstr" desc="Reason link is not operational"/>

    <method name="close"/> 

    <method name="bridge" desc="Bridge messages over the link">
      <arg name="durable"       dir="I" type="bool"/>
      <arg name="src"           dir="I" type="sstr"/>
      <arg name="dest"          dir="I" type="sstr"/>
      <arg name="key"           dir="I" type="sstr" default=""/>
      <arg name="id"            dir="I" type="sstr" default=""/>
      <arg name="excludes"      dir="I" type="sstr" default=""/>
      <arg name="src_is_queue"  dir="I" type="bool" default="0"/>
      <arg name="src_is_local"  dir="I" type="bool" default="0"/>
    </method>
  </class>


  <!--
  ===============================================================
  Bridge
  ===============================================================
  -->
  <class name="bridge">
    <configElement name="linkRef"       type="objId"  access="RC" index="y" parentRef="y"/>
    <configElement name="channelId"     type="uint16" access="RC" index="y"/>
    <configElement name="src"           type="sstr"   access="RC"/>
    <configElement name="dest"          type="sstr"   access="RC"/>
    <configElement name="key"           type="sstr"   access="RC"/>
    <configElement name="src_is_queue"  type="bool"   access="RC"/>
    <configElement name="src_is_local"  type="bool"   access="RC"/>
    <method name="close"/> 
  </class>


  <!--
  ===============================================================
  Session
  ===============================================================
  -->
  <class name="session">
    <configElement name="vhostRef"         type="objId"  access="RC" index="y" parentRef="y"/>
    <configElement name="name"             type="sstr"   access="RC" index="y"/>
    <configElement name="channelId"        type="uint16" access="RO"/>
    <configElement name="clientRef"        type="objId"  access="RO"/>
    <configElement name="detachedLifespan" type="uint32" access="RO" unit="second"/>

    <instElement name="attached"          type="bool"/>
    <instElement name="expireTime"        type="absTime"/>
    <instElement name="framesOutstanding" type="count32"/>

    <method name="solicitAck"/>
    <method name="detach"/>
    <method name="resetLifespan"/>
    <method name="close"/>
  </class>

  <!--
  ===============================================================
  Destination
  ===============================================================
  -->
  <class name="destination">
    <configElement name="sessionRef" type="objId"  access="RC" index="y" parentRef="y"/>
    <configElement name="name"       type="sstr"   access="RC" index="y"/>

    <instElement name="flowMode"       type="uint8"/>
    <instElement name="maxMsgCredits"  type="uint32"/>
    <instElement name="maxByteCredits" type="uint32"/>
    <instElement name="msgCredits"     type="uint32"/>
    <instElement name="byteCredits"    type="uint32"/>

    <method name="throttle" desc="Apply extra rate limiting to destination: 0 = Normal, 10 = Maximum">
      <arg name="strength" type="uint8" dir="I" min="0" max="10"/> 
    </method>
    <method name="stop"/>
    <method name="start"/>
  </class>

  <!--
  ===============================================================
  Producer
  ===============================================================
  -->
  <class name="producer">
    <configElement name="destinationRef" access="RC" type="objId" index="y"/>
    <configElement name="exchangeRef"    access="RC" type="objId" index="y"/>

    <instElement name="msgsProduced"  type="count64"/>
    <instElement name="bytesProduced" type="count64"/>
  </class>

  <!--
  ===============================================================
  Consumer
  ===============================================================
  -->
  <class name="consumer">
    <configElement name="destinationRef" access="RC" type="objId" index="y"/>
    <configElement name="queueRef"       access="RC" type="objId" index="y"/>

    <instElement name="msgsConsumed"    type="count64"/>
    <instElement name="bytesConsumed"   type="count64"/>
    <instElement name="unackedMessages" type="hilo32" desc="Messages consumed but not yet acked"/>

    <method name="close"/>
  </class>
</schema>

