camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Camel > HDFS
Date Sat, 28 May 2011 09:08:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=CAMEL&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background: white;" bgcolor="white" class="email-body">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
    <h2><a href="https://cwiki.apache.org/confluence/display/CAMEL/HDFS">HDFS</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~davsclaus">Claus
Ibsen</a>
    </h4>
        <br/>
                         <h4>Changes (29)</h4>
                                 
    
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
    
            <tr><td class="diff-unchanged" >h2. HDFS Component <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*Available
as of Camel 2.8* <br></td></tr>
            <tr><td class="diff-unchanged" > <br>The *hdfs* component enables
you to read and write messages from/to an HDFS file system. HDFS is the distributed file system
at the heart of [Hadoop|http://hadoop.apache.org]. <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">It
can only be built using JDK1.6 or later because  this is a strict requirement for Hadoop itself.
<br>This component is hosted at http://github.com/dgreco/camel-hdfs. We decided to put
it temporarily on this [github|http://www.github.com] because currently Camel is being built
and tested using JDK1.5 and for this reason we couldn&#39;t put that component into the
Camel official distribution. Hopefully, as soon Camel will allow to use JDK1.6 for building
and testing we will put it into the trunk. <br>This component is developed and tested
using the latest Camel snapshot, but it should work seamlessly with the latest Camel GA version
(at the time of writing 2.1.0) <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Maven
users will need to add the following dependency to their {{pom.xml}} for this component: <br>{code:xml}
<br>&lt;dependency&gt; <br>    &lt;groupId&gt;org.apache.camel&lt;/groupId&gt;
<br>    &lt;artifactId&gt;camel-hadoop&lt;/artifactId&gt; <br>
   &lt;version&gt;x.x.x&lt;/version&gt; <br>    &lt;!-- use the
same version as your Camel core version --&gt; <br>&lt;/dependency&gt; <br>{code}
<br> <br></td></tr>
            <tr><td class="diff-unchanged" >h3. URI format <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >| {{replication}} | {{3}} | The HDFS
replication factor  | <br>| {{blockSize}} | {{67108864}} | The size of the HDFS blocks
 | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{fileType}} | {{NORMAL_FILE}}
| It can be SEQUENCE_FILE, <span class="diff-added-words"style="background-color: #dfd;">MAP_FILE,
ARRAY_FILE, or BLOOMMAP_FILE, see Hadoop |</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
                                  MAP_FILE, ARRAY_FILE, or <br>                    
              BLOOMMAP_FILE, see Hadoop | <br></td></tr>
            <tr><td class="diff-unchanged" >| {{fileSystemType}} | {{HDFS}} |
It can be LOCAL for local filesystem  | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{keyType}} | {{NULL}} | The
type for the key in case of <span class="diff-added-words"style="background-color: #dfd;">sequence
or map files. See below.  |</span> <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-added-words"style="background-color:
#dfd;">| {{valueType}} | {{TEXT}} | The type for the key in case of</span> sequence
or map files. See below.  | <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">|
{{valueType}} | {{TEXT}} | The type for the key in case of <br>                    
        sequence or map files. See below.  | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{splitStrategy}} | | A string
describing the strategy on <span class="diff-added-words"style="background-color: #dfd;">how
to split the file based on different criteria. See below.  |</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
                       how to split the file based on different <br>               
        criteria. See below.  | <br>| {{openedSuffix}} | {{opened}} | When a file is
opened for reading/ <br>                                  writing the file is renamed
with this <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-added-words"style="background-color:
#dfd;">| {{openedSuffix}} | {{opened}} | When a file is opened for reading/writing the
file is renamed with this</span> suffix to avoid to read it during the <span class="diff-added-words"style="background-color:
#dfd;">writing phase. |</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
                                 writing phase. | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{readSuffix}} | {{read}} |
Once the file has been read is <span class="diff-added-words"style="background-color: #dfd;">renamed
with this suffix to avoid to read it again.  |</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
                             renamed with this suffix to avoid to <br>             
                read it again.  | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{initialDelay}} | {{0}} | For
the consumer, how much to wait (milliseconds) <span class="diff-added-words"style="background-color:
#dfd;">before to start scanning the directory.  |</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
                            before to start scanning the directory.  | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{delay}} | {{0}} | The interval
(milliseconds) between the directory <span class="diff-added-words"style="background-color:
#dfd;">scans. |</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
                     scans. | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{pattern}} | {{*}} | The pattern
used for scanning the <span class="diff-added-words"style="background-color: #dfd;">directory
 |</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
                       directory  | <br></td></tr>
            <tr><td class="diff-changed-lines" >| {{chunkSize}} | {{4096}} | When
reading a normal file, this is split <span class="diff-added-words"style="background-color:
#dfd;">into chunks producing a message per chunk. |</span> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">
                            into chunks producing a message per <br>               
             chunk   | <br></td></tr>
            <tr><td class="diff-unchanged" >{div} <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. Splitting Strategy
<br></td></tr>
            <tr><td class="diff-changed-lines" >In the current version of Hadoop
<span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">(0.20.1)</span>
opening a file in append mode is disabled since it&#39;s not enough reliable. So, for
the moment, it&#39;s only possible to create new files. The Camel HDFS endpoint tries
to solve this problem in this way: <br></td></tr>
            <tr><td class="diff-unchanged" >* If the split strategy option has
been defined, the actual file name will become a directory name and a &lt;file name&gt;/seg0
will be initially created. <br>* Every time a splitting condition is met a new file
is created with name &lt;original file name&gt;/segN where N is 1, 2, 3, etc. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>where &lt;ST&gt;
can be: <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-added-words"style="background-color:
#dfd;">*</span> BYTES a new file is created, and the old is closed when the number
of written bytes is more than &lt;value&gt; <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-added-words"style="background-color:
#dfd;">*</span> MESSAGES a new file is created, and the old is closed when the number
of written messages is more than  &lt;value&gt; <br></td></tr>
            <tr><td class="diff-changed-lines" ><span class="diff-added-words"style="background-color:
#dfd;">*</span> IDLE a new file is created, and the old is closed when no writing
happened in the last &lt;value&gt; milliseconds <br></td></tr>
            <tr><td class="diff-unchanged" > <br>for example: <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code}
<br></td></tr>
            <tr><td class="diff-unchanged" >hdfs://localhost/tmp/simple-file?splitStrategy=IDLE:1000,BYTES:5
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">{code}
<br></td></tr>
            <tr><td class="diff-changed-lines" >it means: a new file is created
either when it has been idle for more than 1 second or if more than 5 bytes have been written.
So, running <span class="diff-changed-words"><span class="diff-added-chars"style="background-color:
#dfd;">{{</span>hadoop</span> fs -ls <span class="diff-changed-words">/tmp/simple-file<span
class="diff-added-chars"style="background-color: #dfd;">}}</span></span> you&#39;ll
find the following files seg0, seg1, seg2, etc <br></td></tr>
    
            </table>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h2><a name="HDFS-HDFSComponent"></a>HDFS Component</h2>
<p><b>Available as of Camel 2.8</b></p>

<p>The <b>hdfs</b> component enables you to read and write messages from/to
an HDFS file system. HDFS is the distributed file system at the heart of <a href="http://hadoop.apache.org"
class="external-link" rel="nofollow">Hadoop</a>.</p>

<p>Maven users will need to add the following dependency to their <tt>pom.xml</tt>
for this component:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-xml">
<span class="code-tag">&lt;dependency&gt;</span>
    <span class="code-tag">&lt;groupId&gt;</span>org.apache.camel<span
class="code-tag">&lt;/groupId&gt;</span>
    <span class="code-tag">&lt;artifactId&gt;</span>camel-hadoop<span
class="code-tag">&lt;/artifactId&gt;</span>
    <span class="code-tag">&lt;version&gt;</span>x.x.x<span class="code-tag">&lt;/version&gt;</span>
    <span class="code-tag"><span class="code-comment">&lt;!-- use the same
version as your Camel core version --&gt;</span></span>
<span class="code-tag">&lt;/dependency&gt;</span>
</pre>
</div></div>

<h3><a name="HDFS-URIformat"></a>URI format</h3>

<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
hdfs:<span class="code-comment">//hostname[:port][/path][?options]</span>
</pre>
</div></div>

<p>You can append query options to the URI in the following format, <tt>?option=value&amp;option=value&amp;...</tt><br/>
The path is treated in the following way:</p>
<ol>
	<li>as a consumer, if it's a file, it just reads the file, otherwise if it represents
a directory it scans all the file under the path satisfying the configured pattern. All the
files under that directory must be of the same type.</li>
	<li>as a producer, if at least one split strategy is defined, the path is considered
a directory and under that directory the producer creates a different file per split named
seg0, seg1, seg2, etc.</li>
</ol>


<h3><a name="HDFS-Options"></a>Options</h3>
<div class="confluenceTableSmall"><div class='table-wrap'>
<table class='confluenceTable'><tbody>
<tr>
<th class='confluenceTh'> Name </th>
<th class='confluenceTh'> Default Value </th>
<th class='confluenceTh'> Description </th>
</tr>
<tr>
<td class='confluenceTd'> <tt>overwrite</tt> </td>
<td class='confluenceTd'> <tt>true</tt> </td>
<td class='confluenceTd'> The file can be overwritten </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>bufferSize</tt> </td>
<td class='confluenceTd'> <tt>4096</tt> </td>
<td class='confluenceTd'> The buffer size used by HDFS  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>replication</tt> </td>
<td class='confluenceTd'> <tt>3</tt> </td>
<td class='confluenceTd'> The HDFS replication factor  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>blockSize</tt> </td>
<td class='confluenceTd'> <tt>67108864</tt> </td>
<td class='confluenceTd'> The size of the HDFS blocks  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>fileType</tt> </td>
<td class='confluenceTd'> <tt>NORMAL_FILE</tt> </td>
<td class='confluenceTd'> It can be SEQUENCE_FILE, MAP_FILE, ARRAY_FILE, or BLOOMMAP_FILE,
see Hadoop </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>fileSystemType</tt> </td>
<td class='confluenceTd'> <tt>HDFS</tt> </td>
<td class='confluenceTd'> It can be LOCAL for local filesystem  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>keyType</tt> </td>
<td class='confluenceTd'> <tt>NULL</tt> </td>
<td class='confluenceTd'> The type for the key in case of sequence or map files. See
below.  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>valueType</tt> </td>
<td class='confluenceTd'> <tt>TEXT</tt> </td>
<td class='confluenceTd'> The type for the key in case of sequence or map files. See
below.  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>splitStrategy</tt> </td>
<td class='confluenceTd'>&nbsp;</td>
<td class='confluenceTd'> A string describing the strategy on how to split the file
based on different criteria. See below.  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>openedSuffix</tt> </td>
<td class='confluenceTd'> <tt>opened</tt> </td>
<td class='confluenceTd'> When a file is opened for reading/writing the file is renamed
with this suffix to avoid to read it during the writing phase. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>readSuffix</tt> </td>
<td class='confluenceTd'> <tt>read</tt> </td>
<td class='confluenceTd'> Once the file has been read is renamed with this suffix to
avoid to read it again.  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>initialDelay</tt> </td>
<td class='confluenceTd'> <tt>0</tt> </td>
<td class='confluenceTd'> For the consumer, how much to wait (milliseconds) before to
start scanning the directory.  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>delay</tt> </td>
<td class='confluenceTd'> <tt>0</tt> </td>
<td class='confluenceTd'> The interval (milliseconds) between the directory scans. </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>pattern</tt> </td>
<td class='confluenceTd'> <tt>*</tt> </td>
<td class='confluenceTd'> The pattern used for scanning the directory  </td>
</tr>
<tr>
<td class='confluenceTd'> <tt>chunkSize</tt> </td>
<td class='confluenceTd'> <tt>4096</tt> </td>
<td class='confluenceTd'> When reading a normal file, this is split into chunks producing
a message per chunk. </td>
</tr>
</tbody></table>
</div>
</div>

<h4><a name="HDFS-KeyTypeandValueType"></a>KeyType and ValueType</h4>
<ul>
	<li>NULL it means that the key or the value is absent</li>
	<li>BYTE for writing a byte, the java Byte class is mapped into a BYTE</li>
	<li>BYTES for writing a sequence of bytes. It maps the java ByteBuffer class</li>
	<li>INT for writing java integer</li>
	<li>FLOAT for writing java float</li>
	<li>LONG for writing java long</li>
	<li>DOUBLE for writing java double</li>
	<li>TEXT for writing java strings</li>
</ul>


<p>BYTES is also used with everything else, for example, in Camel a file is sent around
as an InputStream, int this case is written in a sequence file or a map file as a sequence
of bytes.</p>

<h3><a name="HDFS-SplittingStrategy"></a>Splitting Strategy</h3>
<p>In the current version of Hadoop opening a file in append mode is disabled since
it's not enough reliable. So, for the moment, it's only possible to create new files. The
Camel HDFS endpoint tries to solve this problem in this way:</p>
<ul>
	<li>If the split strategy option has been defined, the actual file name will become
a directory name and a &lt;file name&gt;/seg0 will be initially created.</li>
	<li>Every time a splitting condition is met a new file is created with name &lt;original
file name&gt;/segN where N is 1, 2, 3, etc.<br/>
The splitStrategy option  is defined as a string with the following syntax:<br/>
splitStrategy=&lt;ST&gt;:&lt;value&gt;,&lt;ST&gt;:&lt;value&gt;,*</li>
</ul>


<p>where &lt;ST&gt; can be:</p>
<ul>
	<li>BYTES a new file is created, and the old is closed when the number of written bytes
is more than &lt;value&gt;</li>
	<li>MESSAGES a new file is created, and the old is closed when the number of written
messages is more than  &lt;value&gt;</li>
	<li>IDLE a new file is created, and the old is closed when no writing happened in the
last &lt;value&gt; milliseconds</li>
</ul>


<p>for example:</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">
hdfs:<span class="code-comment">//localhost/tmp/simple-file?splitStrategy=IDLE:1000,BYTES:5</span>
</pre>
</div></div>
<p>it means: a new file is created either when it has been idle for more than 1 second
or if more than 5 bytes have been written. So, running <tt>hadoop fs -ls /tmp/simple-file</tt>
you'll find the following files seg0, seg1, seg2, etc</p>
    </div>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/HDFS">View Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=10388004&revisedVersion=10&originalVersion=9">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/CAMEL/HDFS?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message