<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<xs:schema elementFormDefault="qualified" version="1.0"
           targetNamespace="urn:infinispan:config:store:remote:12.0"
           xmlns:tns="urn:infinispan:config:store:remote:12.0"
           xmlns:config="urn:infinispan:config:12.0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:import namespace="urn:infinispan:config:12.0"
             schemaLocation="https://infinispan.org/schemas/infinispan-config-12.0.xsd" />

  <xs:element name="remote-store" type="tns:remote-store"/>

  <xs:complexType name="remote-store">
    <xs:complexContent>
      <xs:extension base="config:store">
        <xs:sequence>
          <xs:element name="remote-server" type="config:remote-server" minOccurs="1" maxOccurs="unbounded"/>
          <xs:element name="connection-pool" type="tns:connectionPool" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                Configuration of the connection pool
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="async-executor" type="tns:executorFactory" minOccurs="0">
            <xs:annotation>
              <xs:documentation>
                Configuration for the executor service used for asynchronous work on the Transport, including asynchronous marshalling and Cache 'async operations' such as Cache.putAsync().
              </xs:documentation>
            </xs:annotation>
          </xs:element>
          <xs:element name="security" type="tns:security" minOccurs="0" maxOccurs="1">
            <xs:annotation>
              <xs:documentation>
                Hot Rod Security configuration.
              </xs:documentation>
            </xs:annotation>
          </xs:element>
        </xs:sequence>
        <xs:attribute name="socket-timeout" type="xs:long" default="60000">
          <xs:annotation>
            <xs:documentation>
              Enable/disable SO_TIMEOUT on socket connections to remote Hot Rod servers with the specified timeout, in milliseconds.
              A timeout of zero is interpreted as an infinite timeout.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="tcp-no-delay" type="xs:boolean" default="true">
          <xs:annotation>
            <xs:documentation>
              Enable/disable TCP_NODELAY on socket connections to remote Hot Rod servers.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="hotrod-wrapping" type="xs:boolean" default="false">
          <xs:annotation>
            <xs:documentation>
              Ensures that, when entries are retrieved from the remote store, they will be wrapped in a format suitable for serving via HotRod. This flag must be enabled when performing a rolling upgrade
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="raw-values" type="xs:boolean" default="false">
          <xs:annotation>
            <xs:documentation>
              Enables the storage of data on the remote server in "raw" format as opposed to wrapping the entries in InternalCacheEntry. This will make the remote cache interoperable between direct RemoteCacheManager clients and RemoteCacheStore stores
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="balancing-strategy" type="xs:string" default="org.infinispan.client.hotrod.impl.transport.tcp.RoundRobinBalancingStrategy">
          <xs:annotation>
            <xs:documentation>
              For replicated (vs distributed) Hot Rod server clusters, the client balances requests to the servers according to this strategy.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="connect-timeout" type="xs:int" default="60000">
          <xs:annotation>
            <xs:documentation>
              This property defines the maximum socket connect timeout before giving up connecting to the server.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="force-return-values" type="xs:boolean" default="false">
          <xs:annotation>
            <xs:documentation>
              Whether or not to implicitly FORCE_RETURN_VALUE for all calls.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="key-size-estimate" type="xs:int" default="64">
          <xs:annotation>
            <xs:documentation>
              Deprecated since 12.0, does nothing and will be removed in 15.0
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="marshaller" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              Allows you to specify a custom {@link org.infinispan.marshall.Marshaller} implementation to serialize and deserialize user objects.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="protocol-version" type="xs:string" default="3.1">
          <xs:annotation>
            <xs:documentation>
              This property defines the protocol version that this client should use. Defaults to 1.1. Other valid values include 1.0.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="cache" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The name of the remote cache in the remote infinispan cluster, to which to connect to. If unspecified, the default
              cache will be used
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="value-size-estimate" type="xs:int" default="512">
          <xs:annotation>
            <xs:documentation>
              Deprecated since 12.0, does nothing and will be removed in 15.0
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="connectionPool">
    <xs:attribute name="exhausted-action" type="tns:exhaustedAction">
      <xs:annotation>
        <xs:documentation>
           Specifies what happens when asking for a connection from a server's pool, and that pool is exhausted.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="max-active" type="xs:int" default="-1">
      <xs:annotation>
        <xs:documentation>
          Controls the maximum number of connections per server that are allocated (checked out to client threads, or idle in the pool) at one time. When non-positive, there is no limit to the number of connections per server. When maxActive is reached, the connection pool for that server is said to be exhausted. The default setting for this parameter is -1, i.e. there is no limit.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="min-idle" type="xs:int" default="-1">
      <xs:annotation>
        <xs:documentation>
          Sets a target value for the minimum number of idle connections (per server) that should always be available. If this parameter is set to a positive number and timeBetweenEvictionRunsMillis > 0, each time the idle connection eviction thread runs, it will try to create enough idle instances so that there will be minIdle idle instances available for each server. The default setting for this parameter is 1.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="max-pending-requests" type="xs:int" default="5">
      <xs:annotation>
        <xs:documentation>
          Specifies maximum number of requests sent over single connection at one instant. Connections with more concurrent requests will be ignored in the pool when choosing available connection
          and the pool will try to create a new connection if all connections are utilized. Only if the new connection cannot be created and the exhausted action is set to WAIT the pool will allow sending the request over one of the over-utilized connections.
          The rule of thumb is that this should be set to higher values if the values are small (&lt; 1kB) and to lower values if the entries are big (&gt; 10kB). Default setting for this parameter is 5.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="min-evictable-idle-time" type="xs:long" default="1800000">
      <xs:annotation>
        <xs:documentation>
          Specifies the minimum amount of time that an connection may sit idle in the pool before it is eligible for eviction due to idle time. When non-positive, no connection will be dropped from the pool due to idle time alone. This setting has no effect unless timeBetweenEvictionRunsMillis > 0. The default setting for this parameter is 1800000(30 minutes).
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:simpleType name="exhaustedAction">
    <xs:restriction base="xs:string">
      <xs:enumeration value="EXCEPTION">
        <xs:annotation>
          <xs:documentation>
            An exception will be thrown to the calling user
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="WAIT">
        <xs:annotation>
          <xs:documentation>
            The caller will block (invoke waits until a new or idle connections is available).
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
      <xs:enumeration value="CREATE_NEW">
        <xs:annotation>
          <xs:documentation>
            A new persistent connection will be created and returned (essentially making maxActive meaningless.)
          </xs:documentation>
        </xs:annotation>
      </xs:enumeration>
    </xs:restriction>
  </xs:simpleType>

  <xs:complexType name="executorFactory">
    <xs:sequence>
      <xs:element name="property" type="config:property" minOccurs="0" maxOccurs="unbounded">
        <xs:annotation>
          <xs:documentation>
            Add key/value property pair to this factory configuration. Example properties include "maxThreads" which sets the maximum number of threads for this executor and "threadNamePrefix" which sets the thread name prefix for threads created by this executor ( default values can be found at https://docs.jboss.org/author/display/ISPN/Default+Values+For+Property+Based+Attributes ).
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="factory" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          Fully qualified class name of the ExecutorFactory to use.  Must implement org.infinispan.executors.ExecutorFactory
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="security">
    <xs:sequence>
      <xs:element name="authentication" type="tns:authentication" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Hot Rod authentication configuration
          </xs:documentation>
        </xs:annotation>
      </xs:element>
      <xs:element name="encryption" type="tns:encryption" minOccurs="0">
        <xs:annotation>
          <xs:documentation>
            Hot Rod encryption configuration
          </xs:documentation>
        </xs:annotation>
      </xs:element>
    </xs:sequence>
  </xs:complexType>

  <xs:complexType name="authentication">
    <xs:choice minOccurs="1" maxOccurs="1">
      <xs:element name="plain" type="tns:authentication-plain" />
      <xs:element name="digest" type="tns:authentication-digest" />
      <xs:element name="external" type="tns:authentication-external" />
    </xs:choice>
    <xs:attribute name="server-name" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The SASL server name
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="authentication-plain">
    <xs:attribute name="username" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The username to use when connecting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="password" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The password to use when connecting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="authentication-digest">
    <xs:attribute name="username" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The username to use when connecting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="password" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The password to use when connecting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="realm" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The realm to use when connecting
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="authentication-external">
  </xs:complexType>

  <xs:complexType name="encryption">
    <xs:sequence>
      <xs:element name="keystore" type="tns:keystore" minOccurs="0" maxOccurs="1"/>
      <xs:element name="truststore" type="tns:truststore" minOccurs="0" maxOccurs="1"/>
    </xs:sequence>
    <xs:attribute name="protocol" type="xs:string" default="TLSv1.2">
      <xs:annotation>
        <xs:documentation>
          The TLS/SSL protocol to use. Defaults to TLSv1.2
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="sni-hostname" type="xs:string">
      <xs:annotation>
        <xs:documentation>
          The SNI hostname to use when connecting.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="basekeystore" abstract="true">
    <xs:attribute name="filename" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The path to the key store.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="password" type="xs:string" use="required">
      <xs:annotation>
        <xs:documentation>
          The password to use to access the key store.
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
    <xs:attribute name="type" type="xs:string" default="JKS">
      <xs:annotation>
        <xs:documentation>
          The key store type (JKS, JCEKS).
        </xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>

  <xs:complexType name="truststore">
    <xs:complexContent>
      <xs:extension base="tns:basekeystore" />
    </xs:complexContent>
  </xs:complexType>

  <xs:complexType name="keystore" >
    <xs:complexContent>
      <xs:extension base="tns:basekeystore">
        <xs:attribute name="certificate-password" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              The password to use when obtaining the certificate from the key store. If not specified, the password will be used.
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
        <xs:attribute name="key-alias" type="xs:string">
          <xs:annotation>
            <xs:documentation>
              If the key store contains multiple keys, use the one with the specified alias
            </xs:documentation>
          </xs:annotation>
        </xs:attribute>
      </xs:extension>
    </xs:complexContent>
  </xs:complexType>

</xs:schema>
