<?xml version='1.0' encoding='UTF-8'?>
<xsd:schema xmlns="http://www.cloudera.com/schema/mule/hdfs/1.0"
            xmlns:xsd="http://www.w3.org/2001/XMLSchema"
            xmlns:mule="http://www.mulesource.org/schema/mule/core/2.2"
            xmlns:schemadoc="http://www.mulesource.org/schema/mule/schemadoc/2.2"
            targetNamespace="http://www.cloudera.com/schema/mule/hdfs/1.0"
            elementFormDefault="qualified"
            attributeFormDefault="unqualified">

  <xsd:import namespace="http://www.w3.org/XML/1998/namespace"/>

  <xsd:import namespace="http://www.mulesource.org/schema/mule/core/2.2"
              schemaLocation="http://www.mulesource.org/schema/mule/core/2.2/mule.xsd"/>

  <xsd:import namespace = "http://www.mulesource.org/schema/mule/schemadoc/2.2"
              schemaLocation = "http://www.mulesource.org/schema/mule/schemadoc/2.2/mule-schemadoc.xsd"/>

  <xsd:annotation>
    <xsd:documentation>
      The HDFS transport allows for writing files to a remote, distributed HDFS system.  The connector
      can be configured to write the file to a specific URI in the distributed file system and
      relies on having an HDFS adapter an libraries in the host system.
    </xsd:documentation>
  </xsd:annotation>


  <xsd:element name='connector' type='HDFSConnectorType' substitutionGroup='mule:abstract-connector'>
    <xsd:annotation>
      <xsd:documentation>
        The HDFS connector configures the default behaviour for the HDFS endpoints that reference it.
        All HDFS endpoints will use a single connector if only one is defined.
      </xsd:documentation>
    </xsd:annotation>
  </xsd:element>

  <xsd:complexType name='HDFSConnectorType'>
    <xsd:complexContent>
      <xsd:extension base='mule:connectorType'>
        <xsd:attribute name='homeURI' type='xsd:string'>
          <xsd:annotation>
            <xsd:documentation>
              A URI in the form:  hdfs://namenode.jpmc.my.cloudera.net:9000/path/to/repository - the connector will write files to this directory. 
            </xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name='commitLimit' type='xsd:long' default='-1'>
          <xsd:annotation>
            <xsd:documentation>
							A long value controlling the number of messages that a writer will process before closing the file and rolling to a new SequenceFile. The default is -1, which corresponds to no limit. 
            </xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>
				<xsd:attribute name='doWrite' type='xsd:boolean' default='true'>
					<xsd:annotation>
            <xsd:documentation>
							If false, connector will not write to HDFS. Used for debugging.
            </xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>
				<xsd:attribute name='doCompression' type='xsd:boolean' default='true'>
					<xsd:annotation>
            <xsd:documentation>
							A boolean which governs whether compression is to be used when writing to HDFS. Default is true.
            </xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>	
				<xsd:attribute name='codecClass' type='xsd:string' default='org.apache.hadoop.io.compress.DefaultCodec'>
					<xsd:annotation>
            <xsd:documentation>
							The classname of the codec to use for compression into HDFS. The default is org.apache.hadoop.io.compress.DefaultCodec. If doCompression is false, this value is unused.
            </xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>	
				<xsd:attribute name='numWriters' type='xsd:integer' default='5'>
					<xsd:annotation>
            <xsd:documentation>
							An integer that controls how many writer threads will be created. Each writer thread opens its own SequenceFile, and there is no guarantee made about which thread will write which message. The default is 5. 
            </xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>	
				<xsd:attribute name='sleepMs' type='xsd:long' default='1000'>
					<xsd:annotation>
            <xsd:documentation>
							A long value which governs how long in milliseconds a writer thread must be idle for before it closes its current SequenceFile (thereby flushing all pending writes to disk) and opens a new one. Defaults to 1000ms.
            </xsd:documentation>
          </xsd:annotation>
        </xsd:attribute>	

      </xsd:extension>
    </xsd:complexContent>
  </xsd:complexType>

<xsd:element name="inbound-endpoint" type="inboundEndpointType" substitutionGroup="mule:abstract-inbound-endpoint"/>
<xsd:complexType name="inboundEndpointType">
  <xsd:complexContent>
    <xsd:extension base="mule:inboundEndpointType">
      <xsd:attributeGroup ref="addressAttributes"/>
      <xsd:attributeGroup ref="inboundAttributes"/>
    </xsd:extension>
  </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="outbound-endpoint" type="outboundEndpointType"
                 substitutionGroup="mule:abstract-outbound-endpoint"/>
    <xsd:complexType name="outboundEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:outboundEndpointType">
                <xsd:attributeGroup ref="addressAttributes"/>
                <xsd:attributeGroup ref="outboundAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:element name="endpoint" type="globalEndpointType" substitutionGroup="mule:abstract-global-endpoint"/>
    <xsd:complexType name="globalEndpointType">
        <xsd:complexContent>
            <xsd:extension base="mule:globalEndpointType">
                <xsd:attributeGroup ref="addressAttributes"/>
                <xsd:attributeGroup ref="inboundAttributes"/>
                <xsd:attributeGroup ref="outboundAttributes"/>
            </xsd:extension>
        </xsd:complexContent>
    </xsd:complexType>

    <xsd:attributeGroup name="addressAttributes">
        <xsd:attribute name="path" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    A file directory location.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:attributeGroup>

    <xsd:attributeGroup name="inboundAttributes">
        <xsd:attribute name="pollingFrequency" type="mule:substitutableLong">
            <xsd:annotation>
                <xsd:documentation>
                    The frequency in milliseconds that the read directory should be checked (default is 0). Note that the read directory is specified by the endpoint of the listening component.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="fileAge" type="mule:substitutableLong">
            <xsd:annotation>
                <xsd:documentation>
                    Miniumum age (ms) for a file to be processed. This can be useful when consuming large files. It tells Mule to wait for a period of time before consuming the file, allowing the file to be completely written before the file is processed.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="moveToPattern" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The pattern to use when moving a read file to a new location determined by the moveToDirectory property. This can use the patterns supported by the filename parser configured for this connector.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="moveToDirectory" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The directory path where the file should be written after it has been read. If this is not set, the file is deleted after it has been read.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="comparator" type="mule:substitutableClass">
            <xsd:annotation>
                <xsd:documentation>
                    Sorts incoming files using the specified comparator, such as {{comparator="org.mule.transport.file.comparator.OlderFirstComparator"}}. The class must implement the {{java.util.Comparator}} interface.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
        <xsd:attribute name="reverseOrder" type="mule:substitutableBoolean">
            <xsd:annotation>
                <xsd:documentation>
                    Whether the comparator order should be reversed. Default is false.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:attributeGroup>

    <xsd:attributeGroup name="outboundAttributes">
        <xsd:attribute name="outputPattern" type="xsd:string">
            <xsd:annotation>
                <xsd:documentation>
                    The pattern to use when writing a file to disk. This can use the patterns supported by the filename parser configured for this connector.
                </xsd:documentation>
            </xsd:annotation>
        </xsd:attribute>
    </xsd:attributeGroup>
</xsd:schema>

