<?xml version="1.0" encoding="UTF-8"?>

<!--
  ~ JBoss, Home of Professional Open Source.
  ~ Copyright 2017, Red Hat, Inc., and individual contributors
  ~ as indicated by the @author tags. See the copyright.txt file in the
  ~ distribution for a full listing of individual contributors.
  ~
  ~ This is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU Lesser General Public License as
  ~ published by the Free Software Foundation; either version 2.1 of
  ~ the License, or (at your option) any later version.
  ~
  ~ This software is distributed in the hope that it will be useful,
  ~ but WITHOUT ANY WARRANTY; without even the implied warranty of
  ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  ~ Lesser General Public License for more details.
  ~
  ~ You should have received a copy of the GNU Lesser General Public
  ~ License along with this software; if not, write to the Free
  ~ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
  ~ 02110-1301 USA, or see the FSF site: http://www.fsf.org.
  -->

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
           xmlns="urn:jboss:domain:io:2.0"
           targetNamespace="urn:jboss:domain:io:2.0"
           elementFormDefault="qualified"
           attributeFormDefault="unqualified"
           version="1.0">
    <!-- The io subsystem root element -->
    <xs:element name="subsystem" type="io-subsystemType"/>
    <xs:complexType name="io-subsystemType">
        <xs:annotation>
            <xs:documentation>
                <![CDATA[
                The configuration of the io subsystem.
            ]]>
            </xs:documentation>
        </xs:annotation>
        <xs:choice minOccurs="1" maxOccurs="unbounded">
            <xs:element name="worker" type="workerType"/>
            <xs:element name="buffer-pool" type="bufferPoolType"/>
        </xs:choice>
    </xs:complexType>
    <xs:complexType name="workerType">
        <xs:choice minOccurs="0" maxOccurs="unbounded">
            <xs:element name="outbound-bind-address" type="outboundBindAddressType"/>
        </xs:choice>
        <xs:attribute name="name" use="required" type="xs:string">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[
                        Name of worker
                    ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="io-threads" type="xs:int">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[
                        Specify the number of I/O threads to create for the worker.
                        If not specified, a default will be chosen, which is calculated by cpuCount * 2
                    ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="task-keepalive" type="xs:int" default="60000">
        <xs:annotation>
            <xs:documentation>
                <![CDATA[
                       Specify the number of milliseconds to keep non-core task threads alive.
                ]]>
            </xs:documentation>
        </xs:annotation>
        </xs:attribute>
        <xs:attribute name="task-max-threads" type="xs:int">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[
                        Specify the maximum number of threads for the worker task thread pool.
                        If not set, default value used which is calculated by formula cpuCount * 16,
                        as long as MaxFileDescriptorCount jmx property allows that number,
                        otherwise calculation takes max into account to adjust it accordingly.
                    ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="stack-size" type="xs:long" default="0">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[
                        The stack size (in bytes) to attempt to use for worker threads.
                    ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="bufferPoolType">
        <xs:attribute name="name" use="required" type="xs:string">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[
                        Name of buffer pool
                    ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="buffer-size" use="optional" type="xs:int">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[
                        The size of each buffer slice in bytes, if not set optimal value is calculated based on available RAM resources in your system.
                    ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="buffers-per-slice" use="optional" type="xs:int">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[
                        How many buffers per slice, if not set optimal value is calculated based on available RAM resources in your system.
                    ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
        <xs:attribute name="direct-buffers" use="optional" type="xs:boolean">
            <xs:annotation>
                <xs:documentation>
                    <![CDATA[
                        Does the buffer pool use direct buffers, some platforms don't support direct buffers
                    ]]>
                </xs:documentation>
            </xs:annotation>
        </xs:attribute>
    </xs:complexType>
    <xs:complexType name="outboundBindAddressType">
        <annotation xmlns="http://www.w3.org/2001/XMLSchema">
            <documentation>
                A configuration of a single outbound bind address.
            </documentation>
        </annotation>
        <xs:attribute name="name" type="xs:string" use="required">
            <annotation xmlns="http://www.w3.org/2001/XMLSchema">
                <documentation>
                    The name of the bind address sub-resource.
                </documentation>
            </annotation>
        </xs:attribute>
        <xs:attribute name="match" type="xs:string" use="required">
            <annotation xmlns="http://www.w3.org/2001/XMLSchema">
                <documentation>
                    The CIDR address string which matches the destination when this rule applies.
                </documentation>
            </annotation>
        </xs:attribute>
        <xs:attribute name="bind-address" type="xs:string" use="required">
            <annotation xmlns="http://www.w3.org/2001/XMLSchema">
                <documentation>
                    The bind address to use if the destination address matches.
                </documentation>
            </annotation>
        </xs:attribute>
        <xs:attribute name="bind-port" type="xs:nonNegativeInteger" use="optional" default="0">
            <annotation xmlns="http://www.w3.org/2001/XMLSchema">
                <documentation>
                    The port number to bind to if the destination address matches.
                </documentation>
            </annotation>
        </xs:attribute>
    </xs:complexType>
</xs:schema>
