Reorganized user manual into sections
[arvados.git] / doc / user / tutorials / intro-keep.textile
1 ---
2 layout: default
3 navsection: userguide
4 title: "Fetching data from Arvados using Keep"
5 navorder: 111
6 ---
7
8 h1. Fetching data from Arvados using Keep
9
10 This tutorial introduces you to the Arvados file storage system.
11
12 *This tutorial assumes that you are "logged into an Arvados VM instance":ssh-access.html#login, and have a "working environment.":check-environment.html*
13
14 The Arvados distributed file system is called *Keep*.  Keep is a content-addressable file system.  This means that files are managed using special unique identifiers derived from the _contents_ of the file, rather than human-assigned file names (specifically, the md5 hash).  This has a number of advantages:
15 * Files can be stored and replicated across a cluster of servers without requiring a central name server.
16 * Systematic validation of data integrity by both server and client because the checksum is built into the identifier.
17 * Minimizes data duplication (two files with the same contents will result in the same identifier, and will not be stored twice.)
18 * Avoids data race conditions (an identifier always points to the same data.)
19
20 In Keep, information is stored in *data blocks*.  Data blocks are normally between 1 byte and 64 megabytes in size.  If a file exceeds the maximum size of a single data block, the file will be split across multiple data blocks until the entire file can be stored.  These data blocks may be stored and replicated across multiple disks, servers, or clusters.  Each data block has its own identifier for the contents of that specific data block.
21
22 In order to reassemble the file, Keep stores a *collection* data block which lists in sequence the data blocks that make up the original file.  A collection data block may store the information for multiple files, including a directory structure.
23
24 In this example we will use @33a9f3842b01ea3fdf27cc582f5ea2af@ which is already available on {{ site.arvados_api_host }}.  First let us examine the contents of this collection using @arv keep get@:
25
26 <notextile>
27 <pre><code>$ <span class="userinput">arv keep get 33a9f3842b01ea3fdf27cc582f5ea2af</span>
28 . 204e43b8a1185621ca55a94839582e6f+67108864+K@qr1hi b9677abbac956bd3e86b1deb28dfac03+67108864+K@qr1hi fc15aff2a762b13f521baf042140acec+67108864+K@qr1hi 323d2a3ce20370c4ca1d3462a344f8fd+25885655+K@qr1hi 0:227212247:var-GS000016015-ASM.tsv.bz2
29 </code></pre>
30 </notextile>
31
32 @arv keep get@ fetches the contents of the locator @33a9f3842b01ea3fdf27cc582f5ea2af@.  This is a locator for a collection data block, so it fetches the contents of the collection.  In this example, this collection consists of a single file @var-GS000016015-ASM.tsv.bz2@ which is 227212247 bytes long, and is stored using four sequential data blocks, <code>204e43b8a1185621ca55a94839582e6f+67108864+K@qr1hi</code>, <code>b9677abbac956bd3e86b1deb28dfac03+67108864+K@qr1hi</code>, <code>fc15aff2a762b13f521baf042140acec+67108864+K@qr1hi</code>, <code>323d2a3ce20370c4ca1d3462a344f8fd+25885655+K@qr1hi</code>.
33
34 Let's use @arv keep get@ to download the first datablock:
35
36 notextile. <pre><code>$ <span class="userinput">arv keep get 204e43b8a1185621ca55a94839582e6f+67108864+K@qr1hi &gt; block1</span></code></pre>
37
38 Let's look at the size and compute the md5 hash of @block1@:
39
40 <notextile>
41 <pre><code>$ <span class="userinput">ls -l block1</span>
42 -rw-r--r-- 1 you group 67108864 Dec  9 20:14 block1
43 $ <span class="userinput">md5sum block1</span>
44 204e43b8a1185621ca55a94839582e6f  block1
45 </code></pre>
46 </notextile>
47
48 Notice that the block identifer <code>204e43b8a1185621ca55a94839582e6f+67108864+K@qr1hi</code> of:
49 * the md5 hash @204e43b8a1185621ca55a94839582e6f@ which matches the md5 hash of block1
50 * a size hint @67108864@ which matches the size of block1
51 * a location hint <code>K@qr1hi</code>
52
53 The size hint and location hint are used to access the block more quickly, but in fact _only_ the md5 hash is required to find the block.
54
55 Next, let's use @arv keep get@ to download and reassemble @var-GS000016015-ASM.tsv.bz2@ using the following command:
56
57 notextile. <pre><code>$ <span class="userinput">arv keep get 33a9f3842b01ea3fdf27cc582f5ea2af/var-GS000016015-ASM.tsv.bz2 .</span></code></pre>
58
59 This downloads the file @var-GS000016015-ASM.tsv.bz2@ described by collection @33a9f3842b01ea3fdf27cc582f5ea2af@ from Keep and places it into the local directory.  Now that we have the file, we can compute the md5 hash of the complete file:
60
61 <notextile>
62 <pre><code>$ <span class="userinput">md5sum var-GS000016015-ASM.tsv.bz2</span>
63 44b8ae3fde7a8a88d2f7ebd237625b4f  var-GS000016015-ASM.tsv.bz2
64 </code></pre>
65 </notextile>
66
67 h2. Accessing Collections
68
69 There are a couple of other ways to access a collection.  You may view the contents of a collection using @arv keep ls@:
70
71 <notextile>
72 <pre><code>$ <span class="userinput">arv keep ls 33a9f3842b01ea3fdf27cc582f5ea2af</span>
73 var-GS000016015-ASM.tsv.bz2
74 </code></pre>
75 </notextile>
76
77 You may also access through the Arvados Workbench using a URI similar to this, where the last part of the path is the Keep locator:
78
79 "https://workbench.{{ site.arvados_api_host }}/collections/33a9f3842b01ea3fdf27cc582f5ea2af":https://workbench.{{ site.arvados_api_host }}/collections/33a9f3842b01ea3fdf27cc582f5ea2af
80
81 You are now ready to proceed to the next tutorial, "running a crunch job.":tutorial-job1.html