ganapati 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/LICENSE +674 -0
  2. data/README.rdoc +86 -0
  3. data/Rakefile +32 -0
  4. data/bin/hcp +64 -0
  5. data/bin/hls +42 -0
  6. data/docs/classes/Ganapati.html +138 -0
  7. data/docs/classes/Ganapati/Client.html +666 -0
  8. data/docs/classes/Ganapati/FileUrl.html +253 -0
  9. data/docs/classes/Ganapati/HFile.html +271 -0
  10. data/docs/classes/ThriftHadoopFileSystem.html +169 -0
  11. data/docs/classes/ThriftHadoopFileSystem/Append_args.html +193 -0
  12. data/docs/classes/ThriftHadoopFileSystem/Append_result.html +198 -0
  13. data/docs/classes/ThriftHadoopFileSystem/BlockLocation.html +208 -0
  14. data/docs/classes/ThriftHadoopFileSystem/Chmod_args.html +198 -0
  15. data/docs/classes/ThriftHadoopFileSystem/Chmod_result.html +193 -0
  16. data/docs/classes/ThriftHadoopFileSystem/Chown_args.html +203 -0
  17. data/docs/classes/ThriftHadoopFileSystem/Chown_result.html +193 -0
  18. data/docs/classes/ThriftHadoopFileSystem/Client.html +1566 -0
  19. data/docs/classes/ThriftHadoopFileSystem/Close_args.html +193 -0
  20. data/docs/classes/ThriftHadoopFileSystem/Close_result.html +198 -0
  21. data/docs/classes/ThriftHadoopFileSystem/CreateFile_args.html +218 -0
  22. data/docs/classes/ThriftHadoopFileSystem/CreateFile_result.html +198 -0
  23. data/docs/classes/ThriftHadoopFileSystem/Create_args.html +193 -0
  24. data/docs/classes/ThriftHadoopFileSystem/Create_result.html +198 -0
  25. data/docs/classes/ThriftHadoopFileSystem/Exists_args.html +193 -0
  26. data/docs/classes/ThriftHadoopFileSystem/Exists_result.html +198 -0
  27. data/docs/classes/ThriftHadoopFileSystem/FileStatus.html +233 -0
  28. data/docs/classes/ThriftHadoopFileSystem/GetFileBlockLocations_args.html +203 -0
  29. data/docs/classes/ThriftHadoopFileSystem/GetFileBlockLocations_result.html +198 -0
  30. data/docs/classes/ThriftHadoopFileSystem/ListStatus_args.html +193 -0
  31. data/docs/classes/ThriftHadoopFileSystem/ListStatus_result.html +198 -0
  32. data/docs/classes/ThriftHadoopFileSystem/MalformedInputException.html +220 -0
  33. data/docs/classes/ThriftHadoopFileSystem/Mkdirs_args.html +193 -0
  34. data/docs/classes/ThriftHadoopFileSystem/Mkdirs_result.html +198 -0
  35. data/docs/classes/ThriftHadoopFileSystem/Open_args.html +193 -0
  36. data/docs/classes/ThriftHadoopFileSystem/Open_result.html +198 -0
  37. data/docs/classes/ThriftHadoopFileSystem/Pathname.html +193 -0
  38. data/docs/classes/ThriftHadoopFileSystem/Processor.html +710 -0
  39. data/docs/classes/ThriftHadoopFileSystem/Read_args.html +203 -0
  40. data/docs/classes/ThriftHadoopFileSystem/Read_result.html +198 -0
  41. data/docs/classes/ThriftHadoopFileSystem/Rename_args.html +198 -0
  42. data/docs/classes/ThriftHadoopFileSystem/Rename_result.html +198 -0
  43. data/docs/classes/ThriftHadoopFileSystem/Rm_args.html +198 -0
  44. data/docs/classes/ThriftHadoopFileSystem/Rm_result.html +198 -0
  45. data/docs/classes/ThriftHadoopFileSystem/SetInactivityTimeoutPeriod_args.html +199 -0
  46. data/docs/classes/ThriftHadoopFileSystem/SetInactivityTimeoutPeriod_result.html +188 -0
  47. data/docs/classes/ThriftHadoopFileSystem/SetReplication_args.html +198 -0
  48. data/docs/classes/ThriftHadoopFileSystem/SetReplication_result.html +193 -0
  49. data/docs/classes/ThriftHadoopFileSystem/Shutdown_args.html +193 -0
  50. data/docs/classes/ThriftHadoopFileSystem/Shutdown_result.html +188 -0
  51. data/docs/classes/ThriftHadoopFileSystem/Stat_args.html +193 -0
  52. data/docs/classes/ThriftHadoopFileSystem/Stat_result.html +198 -0
  53. data/docs/classes/ThriftHadoopFileSystem/ThriftHandle.html +193 -0
  54. data/docs/classes/ThriftHadoopFileSystem/ThriftIOException.html +220 -0
  55. data/docs/classes/ThriftHadoopFileSystem/Write_args.html +198 -0
  56. data/docs/classes/ThriftHadoopFileSystem/Write_result.html +198 -0
  57. data/docs/created.rid +1 -0
  58. data/docs/files/README_rdoc.html +209 -0
  59. data/docs/files/lib/ganapati/client_rb.html +101 -0
  60. data/docs/files/lib/ganapati/hfile_rb.html +101 -0
  61. data/docs/files/lib/ganapati/utils_rb.html +101 -0
  62. data/docs/files/lib/ganapati/version_rb.html +101 -0
  63. data/docs/files/lib/ganapati_rb.html +112 -0
  64. data/docs/files/lib/thrift/hadoopfs_constants_rb.html +117 -0
  65. data/docs/files/lib/thrift/hadoopfs_types_rb.html +110 -0
  66. data/docs/files/lib/thrift/thrift_hadoop_file_system_rb.html +118 -0
  67. data/docs/fr_class_index.html +77 -0
  68. data/docs/fr_file_index.html +35 -0
  69. data/docs/fr_method_index.html +222 -0
  70. data/docs/index.html +24 -0
  71. data/docs/rdoc-style.css +208 -0
  72. data/lib/ganapati.rb +1 -0
  73. data/lib/ganapati/client.rb +4 -2
  74. data/lib/ganapati/utils.rb +47 -0
  75. data/lib/ganapati/version.rb +3 -0
  76. metadata +79 -4
@@ -0,0 +1,86 @@
1
+ = ganapati -- Hadoop HDFS Thrift interface for Ruby
2
+
3
+ Ganapati is a Ruby thrift lib for interfacing with Hadoop's distributed file system, HDFS. It also includes a few command line client utilities.
4
+
5
+ To install:
6
+ gem install ganapati
7
+
8
+ == Starting thrift server
9
+ Documentation in Hadoop for the thrift interface to HDFS is crap. It can be found here[http://wiki.apache.org/hadoop/HDFS-APIs].
10
+
11
+ As a much simpler and safer way of auto compiling and then starting the thrift interface, use the provided script:
12
+ bin/hdfs_thrift_server <port>
13
+
14
+ This will start a thrift server on the given port (after compiling the server code provided in the Hadoop distribution).
15
+
16
+ == Basic Usage
17
+ require 'rubygems'
18
+ require 'ganapati'
19
+
20
+ # args are host, port, and optional timeout
21
+ client = Ganapati::Client.new 'localhost', 1234
22
+
23
+ # copy a file to hdfs
24
+ client.put("/some/file", "/some/hadoop/path")
25
+
26
+ # get a file from hadoop
27
+ client.get("/some/hadoop/path", "/local/path")
28
+
29
+ # Create a file
30
+ f = client.create("/home/someuser/afile.txt")
31
+ f.write("this is some text")
32
+ # Always, always close the file
33
+ f.close
34
+
35
+ # Create a file with code block
36
+ client.create("/home/someuser/afile.txt") { |f|
37
+ f.write("this is some text")
38
+ }
39
+
40
+ # Open a file for reading and read it
41
+ client.open('/home/someuser/afile.txt') { |f|
42
+ puts f.read
43
+ # or read for specific length from start
44
+ puts f.read(0, 4)
45
+ }
46
+
47
+ # read a file line by line
48
+ client.readlines('/home/someuser/afile.txt') { |line|
49
+ puts line
50
+ }
51
+
52
+ # Open a file for appending and append to it
53
+ client.append('/home/someuser/afile.txt') { |f|
54
+ f.write "new data"
55
+ }
56
+
57
+ ## Common file methods are available (chown, chmod, mkdir, stat, etc). Examples:
58
+ # move a file
59
+ client.mv "/home/someuser/afile.txt", "/home/someuser/test.txt"
60
+
61
+ # remove a file
62
+ client.rm "/home/someuser/test.txt"
63
+
64
+ # test for file existance
65
+ client.exists? "/home/someuser/test.txt"
66
+
67
+ # get a list of all files
68
+ client.ls "/home"
69
+
70
+ client.close
71
+
72
+ # Quick and dirty way to print remote file. The run class method takes care of closing the client.
73
+ puts Ganapati::Client.run('localhost', 1234) { |c| c.open('/home/someuser/afile.txt') { |f| f.read } }
74
+
75
+ == Command Line Utilities
76
+ There are a few utility programs included in the bin directory. *hls* provides a way to see the contents of HDFS (recursively and verbosely with appropriate command line options):
77
+ ./bin/hls hdfs://host:port/tmp
78
+
79
+ *hcp* provides a way to copy to/from/between HDFS servers:
80
+ ./bin/hcp hdfs://host:port/some/path/to/file ./file
81
+ ./bin/hcp ./file hdfs://host:port/some/path/to/file
82
+ ./bin/hcp hdfs://anotherhost:port/some/path/to/file hdfs://host:port/some/path/to/file
83
+
84
+
85
+
86
+
@@ -0,0 +1,32 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'rake/testtask'
4
+ require 'rake/rdoctask'
5
+
6
+ Bundler::GemHelper.install_tasks
7
+
8
+ desc "Create documentation"
9
+ Rake::RDocTask.new("doc") { |rdoc|
10
+ rdoc.title = "Ganapati - Hadoop HDFS thrift interface for Ruby"
11
+ rdoc.rdoc_dir = 'docs'
12
+ rdoc.rdoc_files.include('README.rdoc')
13
+ rdoc.rdoc_files.include('lib/**/*.rb')
14
+ }
15
+
16
+ desc "Re-generate thrift files"
17
+ task "regen_thrift" do
18
+ if ENV['HADOOP_HOME'].nil?
19
+ puts "You must set your HADOOP_HOME variable before calling this task."
20
+ return
21
+ end
22
+ system "thrift --gen rb -o /tmp #{ENV['HADOOP_HOME']}src/contrib/thriftfs/if/hadoopfs.thrift"
23
+ system "mv /tmp/gen-rb/* lib/thrift"
24
+ end
25
+
26
+ task :default => [ :gem, :doc ]
27
+
28
+
29
+
30
+
31
+
32
+
data/bin/hcp ADDED
@@ -0,0 +1,64 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'rubygems'
4
+ require 'ganapati'
5
+
6
+ options = { :recursive => false, :verbose => false }
7
+ op = OptionParser.new { |opts|
8
+ opts.banner = "Usage: hcp [options] source dest"
9
+
10
+ opts.on('-h', '--help', 'displays usage information') {
11
+ puts opts
12
+ exit
13
+ }
14
+
15
+ opts.on('-v', '--verbose', 'verbose') {
16
+ options[:verbose] = true
17
+ }
18
+
19
+ opts.on('-r', '--recursive', 'copy recursively') {
20
+ puts "Recursive option not supported yet."
21
+ exit 1
22
+ #options[:recursive] = true
23
+ }
24
+ }
25
+ op.parse!
26
+
27
+ if ARGV.length != 2
28
+ puts op.to_s
29
+ exit 1
30
+ end
31
+
32
+ class LocalFile
33
+ def create(location)
34
+ f = open(location, 'w')
35
+ yield f
36
+ f.close
37
+ end
38
+
39
+ def readlines(location)
40
+ f = open(location, 'r')
41
+ while (line = f.gets)
42
+ yield line
43
+ end
44
+ f.close
45
+ end
46
+
47
+ def close
48
+ end
49
+ end
50
+
51
+ spath = Ganapati::FileUrl.new ARGV[0], :file
52
+ dpath = Ganapati::FileUrl.new ARGV[1], :file
53
+
54
+ source = spath.hdfs? ? Ganapati::Client.new(spath.host, spath.port) : LocalFile.new
55
+ dest = dpath.hdfs? ? Ganapati::Client.new(dpath.host, dpath.port) : LocalFile.new
56
+
57
+ dest.create(dpath.path) { |f|
58
+ source.readlines(spath.path) { |line|
59
+ f.write(line)
60
+ }
61
+ }
62
+
63
+ source.close
64
+ dest.close
data/bin/hls ADDED
@@ -0,0 +1,42 @@
1
+ #!/usr/bin/env ruby
2
+ require 'optparse'
3
+ require 'rubygems'
4
+ require 'ganapati'
5
+
6
+ VERBOSE_PROPS = [:path, :length, :isdir, :modification_time, :permission, :owner, :group]
7
+
8
+ options = { :verbose => false, :recursive => false }
9
+ op = OptionParser.new { |opts|
10
+ opts.banner = "Usage: hls [options] host:port/location"
11
+
12
+ opts.on('-h', '--help', 'displays usage information') {
13
+ puts opts
14
+ exit
15
+ }
16
+
17
+ opts.on('-r', '--recursive', 'copy recursively') {
18
+ options[:recursive] = true
19
+ }
20
+
21
+ opts.on('-v', '--verbose', 'verbose output') {
22
+ puts VERBOSE_PROPS.map { |a| a.to_s }.join("\t")
23
+ options[:verbose] = true
24
+ }
25
+ }
26
+ op.parse!
27
+
28
+ if ARGV.length != 1
29
+ puts op.to_s
30
+ exit 1
31
+ end
32
+
33
+ url = Ganapati::FileUrl.new ARGV.first
34
+ client = Ganapati::Client.new url.host, url.port
35
+ client.ls(url.path, options[:verbose], options[:recursive]).each { |s|
36
+ if options[:verbose]
37
+ puts VERBOSE_PROPS.map { |p| s.send p }.join("\t")
38
+ else
39
+ puts s
40
+ end
41
+ }
42
+ client.close
@@ -0,0 +1,138 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Ganapati</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Ganapati</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/ganapati/client_rb.html">
59
+ lib/ganapati/client.rb
60
+ </a>
61
+ <br />
62
+ <a href="../files/lib/ganapati/hfile_rb.html">
63
+ lib/ganapati/hfile.rb
64
+ </a>
65
+ <br />
66
+ <a href="../files/lib/ganapati/utils_rb.html">
67
+ lib/ganapati/utils.rb
68
+ </a>
69
+ <br />
70
+ <a href="../files/lib/ganapati/version_rb.html">
71
+ lib/ganapati/version.rb
72
+ </a>
73
+ <br />
74
+ </td>
75
+ </tr>
76
+
77
+ </table>
78
+ </div>
79
+ <!-- banner header -->
80
+
81
+ <div id="bodyContent">
82
+
83
+
84
+
85
+ <div id="contextContent">
86
+
87
+
88
+
89
+ </div>
90
+
91
+
92
+ </div>
93
+
94
+
95
+ <!-- if includes -->
96
+
97
+ <div id="section">
98
+
99
+ <div id="class-list">
100
+ <h3 class="section-bar">Classes and Modules</h3>
101
+
102
+ Class <a href="Ganapati/Client.html" class="link">Ganapati::Client</a><br />
103
+ Class <a href="Ganapati/FileUrl.html" class="link">Ganapati::FileUrl</a><br />
104
+ Class <a href="Ganapati/HFile.html" class="link">Ganapati::HFile</a><br />
105
+
106
+ </div>
107
+
108
+ <div id="constants-list">
109
+ <h3 class="section-bar">Constants</h3>
110
+
111
+ <div class="name-list">
112
+ <table summary="Constants">
113
+ <tr class="top-aligned-row context-row">
114
+ <td class="context-item-name">VERSION</td>
115
+ <td>=</td>
116
+ <td class="context-item-value">&quot;0.0.5&quot;</td>
117
+ </tr>
118
+ </table>
119
+ </div>
120
+ </div>
121
+
122
+
123
+
124
+
125
+
126
+
127
+ <!-- if method_list -->
128
+
129
+
130
+ </div>
131
+
132
+
133
+ <div id="validator-badges">
134
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
135
+ </div>
136
+
137
+ </body>
138
+ </html>
@@ -0,0 +1,666 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Ganapati::Client</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Ganapati::Client</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/ganapati/client_rb.html">
59
+ lib/ganapati/client.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000180">append</a>&nbsp;&nbsp;
90
+ <a href="#M000187">chmod</a>&nbsp;&nbsp;
91
+ <a href="#M000188">chown</a>&nbsp;&nbsp;
92
+ <a href="#M000172">close</a>&nbsp;&nbsp;
93
+ <a href="#M000178">create</a>&nbsp;&nbsp;
94
+ <a href="#M000184">exists?</a>&nbsp;&nbsp;
95
+ <a href="#M000175">get</a>&nbsp;&nbsp;
96
+ <a href="#M000186">ls</a>&nbsp;&nbsp;
97
+ <a href="#M000183">mkdir</a>&nbsp;&nbsp;
98
+ <a href="#M000182">mv</a>&nbsp;&nbsp;
99
+ <a href="#M000171">new</a>&nbsp;&nbsp;
100
+ <a href="#M000179">open</a>&nbsp;&nbsp;
101
+ <a href="#M000174">put</a>&nbsp;&nbsp;
102
+ <a href="#M000176">readchunks</a>&nbsp;&nbsp;
103
+ <a href="#M000177">readlines</a>&nbsp;&nbsp;
104
+ <a href="#M000181">rm</a>&nbsp;&nbsp;
105
+ <a href="#M000190">run</a>&nbsp;&nbsp;
106
+ <a href="#M000189">set_replication</a>&nbsp;&nbsp;
107
+ <a href="#M000173">shutdown</a>&nbsp;&nbsp;
108
+ <a href="#M000185">stat</a>&nbsp;&nbsp;
109
+ </div>
110
+ </div>
111
+
112
+ </div>
113
+
114
+
115
+ <!-- if includes -->
116
+
117
+ <div id="section">
118
+
119
+
120
+
121
+
122
+
123
+
124
+
125
+
126
+ <!-- if method_list -->
127
+ <div id="methods">
128
+ <h3 class="section-bar">Public Class methods</h3>
129
+
130
+ <div id="method-M000171" class="method-detail">
131
+ <a name="M000171"></a>
132
+
133
+ <div class="method-heading">
134
+ <a href="#M000171" class="method-signature">
135
+ <span class="method-name">new</span><span class="method-args">(server, port, timeout=60)</span>
136
+ </a>
137
+ </div>
138
+
139
+ <div class="method-description">
140
+ <p><a class="source-toggle" href="#"
141
+ onclick="toggleCode('M000171-source');return false;">[Source]</a></p>
142
+ <div class="method-source-code" id="M000171-source">
143
+ <pre>
144
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 4</span>
145
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">server</span>, <span class="ruby-identifier">port</span>, <span class="ruby-identifier">timeout</span>=<span class="ruby-value">60</span>)
146
+ <span class="ruby-identifier">socket</span> = <span class="ruby-constant">Thrift</span><span class="ruby-operator">::</span><span class="ruby-constant">Socket</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">server</span>, <span class="ruby-identifier">port</span>)
147
+ <span class="ruby-ivar">@transport</span> = <span class="ruby-constant">Thrift</span><span class="ruby-operator">::</span><span class="ruby-constant">BufferedTransport</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">socket</span>)
148
+ <span class="ruby-ivar">@transport</span>.<span class="ruby-identifier">open</span>
149
+ <span class="ruby-identifier">protocol</span> = <span class="ruby-constant">Thrift</span><span class="ruby-operator">::</span><span class="ruby-constant">BinaryProtocol</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@transport</span>)
150
+ <span class="ruby-ivar">@client</span> = <span class="ruby-constant">ThriftHadoopFileSystem</span><span class="ruby-operator">::</span><span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">protocol</span>)
151
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">setInactivityTimeoutPeriod</span>(<span class="ruby-identifier">timeout</span>)
152
+ <span class="ruby-keyword kw">end</span>
153
+ </pre>
154
+ </div>
155
+ </div>
156
+ </div>
157
+
158
+ <div id="method-M000190" class="method-detail">
159
+ <a name="M000190"></a>
160
+
161
+ <div class="method-heading">
162
+ <a href="#M000190" class="method-signature">
163
+ <span class="method-name">run</span><span class="method-args">(server, port) {|c| ...}</span>
164
+ </a>
165
+ </div>
166
+
167
+ <div class="method-description">
168
+ <p><a class="source-toggle" href="#"
169
+ onclick="toggleCode('M000190-source');return false;">[Source]</a></p>
170
+ <div class="method-source-code" id="M000190-source">
171
+ <pre>
172
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 125</span>
173
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">run</span>(<span class="ruby-identifier">server</span>, <span class="ruby-identifier">port</span>)
174
+ <span class="ruby-identifier">c</span> = <span class="ruby-constant">Client</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">server</span>, <span class="ruby-identifier">port</span>)
175
+ <span class="ruby-identifier">result</span> = <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">c</span>
176
+ <span class="ruby-identifier">c</span>.<span class="ruby-identifier">close</span>
177
+ <span class="ruby-identifier">result</span>
178
+ <span class="ruby-keyword kw">end</span>
179
+ </pre>
180
+ </div>
181
+ </div>
182
+ </div>
183
+
184
+ <h3 class="section-bar">Public Instance methods</h3>
185
+
186
+ <div id="method-M000180" class="method-detail">
187
+ <a name="M000180"></a>
188
+
189
+ <div class="method-heading">
190
+ <a href="#M000180" class="method-signature">
191
+ <span class="method-name">append</span><span class="method-args">(path, &amp;block)</span>
192
+ </a>
193
+ </div>
194
+
195
+ <div class="method-description">
196
+ <p>
197
+ for appending
198
+ </p>
199
+ <p><a class="source-toggle" href="#"
200
+ onclick="toggleCode('M000180-source');return false;">[Source]</a></p>
201
+ <div class="method-source-code" id="M000180-source">
202
+ <pre>
203
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 82</span>
204
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">append</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
205
+ <span class="ruby-identifier">file_handle</span> <span class="ruby-identifier">:append</span>, <span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
206
+ <span class="ruby-keyword kw">end</span>
207
+ </pre>
208
+ </div>
209
+ </div>
210
+ </div>
211
+
212
+ <div id="method-M000187" class="method-detail">
213
+ <a name="M000187"></a>
214
+
215
+ <div class="method-heading">
216
+ <a href="#M000187" class="method-signature">
217
+ <span class="method-name">chmod</span><span class="method-args">(path, mode)</span>
218
+ </a>
219
+ </div>
220
+
221
+ <div class="method-description">
222
+ <p><a class="source-toggle" href="#"
223
+ onclick="toggleCode('M000187-source');return false;">[Source]</a></p>
224
+ <div class="method-source-code" id="M000187-source">
225
+ <pre>
226
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 113</span>
227
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chmod</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">mode</span>)
228
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">chmod</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">mode</span>
229
+ <span class="ruby-keyword kw">end</span>
230
+ </pre>
231
+ </div>
232
+ </div>
233
+ </div>
234
+
235
+ <div id="method-M000188" class="method-detail">
236
+ <a name="M000188"></a>
237
+
238
+ <div class="method-heading">
239
+ <a href="#M000188" class="method-signature">
240
+ <span class="method-name">chown</span><span class="method-args">(path, owner, group)</span>
241
+ </a>
242
+ </div>
243
+
244
+ <div class="method-description">
245
+ <p><a class="source-toggle" href="#"
246
+ onclick="toggleCode('M000188-source');return false;">[Source]</a></p>
247
+ <div class="method-source-code" id="M000188-source">
248
+ <pre>
249
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 117</span>
250
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">chown</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">owner</span>, <span class="ruby-identifier">group</span>)
251
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">chown</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">owner</span>, <span class="ruby-identifier">group</span>
252
+ <span class="ruby-keyword kw">end</span>
253
+ </pre>
254
+ </div>
255
+ </div>
256
+ </div>
257
+
258
+ <div id="method-M000172" class="method-detail">
259
+ <a name="M000172"></a>
260
+
261
+ <div class="method-heading">
262
+ <a href="#M000172" class="method-signature">
263
+ <span class="method-name">close</span><span class="method-args">()</span>
264
+ </a>
265
+ </div>
266
+
267
+ <div class="method-description">
268
+ <p><a class="source-toggle" href="#"
269
+ onclick="toggleCode('M000172-source');return false;">[Source]</a></p>
270
+ <div class="method-source-code" id="M000172-source">
271
+ <pre>
272
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 13</span>
273
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
274
+ <span class="ruby-ivar">@transport</span>.<span class="ruby-identifier">close</span>
275
+ <span class="ruby-keyword kw">end</span>
276
+ </pre>
277
+ </div>
278
+ </div>
279
+ </div>
280
+
281
+ <div id="method-M000178" class="method-detail">
282
+ <a name="M000178"></a>
283
+
284
+ <div class="method-heading">
285
+ <a href="#M000178" class="method-signature">
286
+ <span class="method-name">create</span><span class="method-args">(path, &amp;block)</span>
287
+ </a>
288
+ </div>
289
+
290
+ <div class="method-description">
291
+ <p>
292
+ for writing to a <a href="Client.html#M000171">new</a> file
293
+ </p>
294
+ <p><a class="source-toggle" href="#"
295
+ onclick="toggleCode('M000178-source');return false;">[Source]</a></p>
296
+ <div class="method-source-code" id="M000178-source">
297
+ <pre>
298
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 72</span>
299
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">create</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
300
+ <span class="ruby-identifier">file_handle</span> <span class="ruby-identifier">:create</span>, <span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
301
+ <span class="ruby-keyword kw">end</span>
302
+ </pre>
303
+ </div>
304
+ </div>
305
+ </div>
306
+
307
+ <div id="method-M000184" class="method-detail">
308
+ <a name="M000184"></a>
309
+
310
+ <div class="method-heading">
311
+ <a href="#M000184" class="method-signature">
312
+ <span class="method-name">exists?</span><span class="method-args">(path)</span>
313
+ </a>
314
+ </div>
315
+
316
+ <div class="method-description">
317
+ <p><a class="source-toggle" href="#"
318
+ onclick="toggleCode('M000184-source');return false;">[Source]</a></p>
319
+ <div class="method-source-code" id="M000184-source">
320
+ <pre>
321
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 98</span>
322
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">exists?</span>(<span class="ruby-identifier">path</span>)
323
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">exists</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">path</span>)
324
+ <span class="ruby-keyword kw">end</span>
325
+ </pre>
326
+ </div>
327
+ </div>
328
+ </div>
329
+
330
+ <div id="method-M000175" class="method-detail">
331
+ <a name="M000175"></a>
332
+
333
+ <div class="method-heading">
334
+ <a href="#M000175" class="method-signature">
335
+ <span class="method-name">get</span><span class="method-args">(remotepath, destpath)</span>
336
+ </a>
337
+ </div>
338
+
339
+ <div class="method-description">
340
+ <p>
341
+ copy remote file to local
342
+ </p>
343
+ <p><a class="source-toggle" href="#"
344
+ onclick="toggleCode('M000175-source');return false;">[Source]</a></p>
345
+ <div class="method-source-code" id="M000175-source">
346
+ <pre>
347
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 35</span>
348
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">get</span>(<span class="ruby-identifier">remotepath</span>, <span class="ruby-identifier">destpath</span>)
349
+ <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">destpath</span>, <span class="ruby-value str">'w'</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">dest</span><span class="ruby-operator">|</span>
350
+ <span class="ruby-identifier">readchunks</span>(<span class="ruby-identifier">remotepath</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">chunk</span><span class="ruby-operator">|</span>
351
+ <span class="ruby-identifier">dest</span>.<span class="ruby-identifier">write</span> <span class="ruby-identifier">chunk</span>
352
+ }
353
+ }
354
+ <span class="ruby-keyword kw">end</span>
355
+ </pre>
356
+ </div>
357
+ </div>
358
+ </div>
359
+
360
+ <div id="method-M000186" class="method-detail">
361
+ <a name="M000186"></a>
362
+
363
+ <div class="method-heading">
364
+ <a href="#M000186" class="method-signature">
365
+ <span class="method-name">ls</span><span class="method-args">(path, details=false, recursive=false)</span>
366
+ </a>
367
+ </div>
368
+
369
+ <div class="method-description">
370
+ <p><a class="source-toggle" href="#"
371
+ onclick="toggleCode('M000186-source');return false;">[Source]</a></p>
372
+ <div class="method-source-code" id="M000186-source">
373
+ <pre>
374
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 106</span>
375
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">ls</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">details</span>=<span class="ruby-keyword kw">false</span>, <span class="ruby-identifier">recursive</span>=<span class="ruby-keyword kw">false</span>)
376
+ <span class="ruby-identifier">statuses</span> = <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">listStatus</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">path</span>)
377
+ <span class="ruby-identifier">paths</span> = (<span class="ruby-identifier">details</span>) <span class="ruby-operator">?</span> <span class="ruby-identifier">statuses</span> <span class="ruby-operator">:</span> <span class="ruby-identifier">statuses</span>.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">path</span> }
378
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">paths</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">not</span> <span class="ruby-identifier">recursive</span>
379
+ <span class="ruby-identifier">paths</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">statuses</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">s</span>.<span class="ruby-identifier">isdir</span> }.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">s</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ls</span>(<span class="ruby-identifier">s</span>.<span class="ruby-identifier">path</span>, <span class="ruby-identifier">details</span>, <span class="ruby-identifier">recursive</span>) }.<span class="ruby-identifier">flatten</span>
380
+ <span class="ruby-keyword kw">end</span>
381
+ </pre>
382
+ </div>
383
+ </div>
384
+ </div>
385
+
386
+ <div id="method-M000183" class="method-detail">
387
+ <a name="M000183"></a>
388
+
389
+ <div class="method-heading">
390
+ <a href="#M000183" class="method-signature">
391
+ <span class="method-name">mkdir</span><span class="method-args">(path)</span>
392
+ </a>
393
+ </div>
394
+
395
+ <div class="method-description">
396
+ <p><a class="source-toggle" href="#"
397
+ onclick="toggleCode('M000183-source');return false;">[Source]</a></p>
398
+ <div class="method-source-code" id="M000183-source">
399
+ <pre>
400
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 94</span>
401
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mkdir</span>(<span class="ruby-identifier">path</span>)
402
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">mkdirs</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">path</span>)
403
+ <span class="ruby-keyword kw">end</span>
404
+ </pre>
405
+ </div>
406
+ </div>
407
+ </div>
408
+
409
+ <div id="method-M000182" class="method-detail">
410
+ <a name="M000182"></a>
411
+
412
+ <div class="method-heading">
413
+ <a href="#M000182" class="method-signature">
414
+ <span class="method-name">mv</span><span class="method-args">(source, dest)</span>
415
+ </a>
416
+ </div>
417
+
418
+ <div class="method-description">
419
+ <p><a class="source-toggle" href="#"
420
+ onclick="toggleCode('M000182-source');return false;">[Source]</a></p>
421
+ <div class="method-source-code" id="M000182-source">
422
+ <pre>
423
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 90</span>
424
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">mv</span>(<span class="ruby-identifier">source</span>, <span class="ruby-identifier">dest</span>)
425
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">rename</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">source</span>), <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">dest</span>)
426
+ <span class="ruby-keyword kw">end</span>
427
+ </pre>
428
+ </div>
429
+ </div>
430
+ </div>
431
+
432
+ <div id="method-M000179" class="method-detail">
433
+ <a name="M000179"></a>
434
+
435
+ <div class="method-heading">
436
+ <a href="#M000179" class="method-signature">
437
+ <span class="method-name">open</span><span class="method-args">(path, &amp;block)</span>
438
+ </a>
439
+ </div>
440
+
441
+ <div class="method-description">
442
+ <p>
443
+ for reading
444
+ </p>
445
+ <p><a class="source-toggle" href="#"
446
+ onclick="toggleCode('M000179-source');return false;">[Source]</a></p>
447
+ <div class="method-source-code" id="M000179-source">
448
+ <pre>
449
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 77</span>
450
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
451
+ <span class="ruby-identifier">file_handle</span> <span class="ruby-identifier">:open</span>, <span class="ruby-identifier">path</span>, <span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>
452
+ <span class="ruby-keyword kw">end</span>
453
+ </pre>
454
+ </div>
455
+ </div>
456
+ </div>
457
+
458
+ <div id="method-M000174" class="method-detail">
459
+ <a name="M000174"></a>
460
+
461
+ <div class="method-heading">
462
+ <a href="#M000174" class="method-signature">
463
+ <span class="method-name">put</span><span class="method-args">(localpath, destpath)</span>
464
+ </a>
465
+ </div>
466
+
467
+ <div class="method-description">
468
+ <p>
469
+ copy local file to remote
470
+ </p>
471
+ <p><a class="source-toggle" href="#"
472
+ onclick="toggleCode('M000174-source');return false;">[Source]</a></p>
473
+ <div class="method-source-code" id="M000174-source">
474
+ <pre>
475
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 23</span>
476
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">put</span>(<span class="ruby-identifier">localpath</span>, <span class="ruby-identifier">destpath</span>)
477
+ <span class="ruby-identifier">create</span>(<span class="ruby-identifier">destpath</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">dest</span><span class="ruby-operator">|</span>
478
+ <span class="ruby-constant">Kernel</span>.<span class="ruby-identifier">open</span>(<span class="ruby-identifier">localpath</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">source</span><span class="ruby-operator">|</span>
479
+ <span class="ruby-comment cmt"># read 1 MB at a time</span>
480
+ <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">record</span> = <span class="ruby-identifier">source</span>.<span class="ruby-identifier">read</span>(<span class="ruby-value">1048576</span>)
481
+ <span class="ruby-identifier">dest</span>.<span class="ruby-identifier">write</span>(<span class="ruby-identifier">record</span>)
482
+ <span class="ruby-keyword kw">end</span>
483
+ }
484
+ }
485
+ <span class="ruby-keyword kw">end</span>
486
+ </pre>
487
+ </div>
488
+ </div>
489
+ </div>
490
+
491
+ <div id="method-M000176" class="method-detail">
492
+ <a name="M000176"></a>
493
+
494
+ <div class="method-heading">
495
+ <a href="#M000176" class="method-signature">
496
+ <span class="method-name">readchunks</span><span class="method-args">(path, chunksize=1048576) {|source.read(index, chunksize)| ...}</span>
497
+ </a>
498
+ </div>
499
+
500
+ <div class="method-description">
501
+ <p>
502
+ yeild chunksize of path one chunk at a time
503
+ </p>
504
+ <p><a class="source-toggle" href="#"
505
+ onclick="toggleCode('M000176-source');return false;">[Source]</a></p>
506
+ <div class="method-source-code" id="M000176-source">
507
+ <pre>
508
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 44</span>
509
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">readchunks</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">chunksize</span>=<span class="ruby-value">1048576</span>)
510
+ <span class="ruby-identifier">open</span>(<span class="ruby-identifier">path</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">source</span><span class="ruby-operator">|</span>
511
+ <span class="ruby-identifier">size</span> = <span class="ruby-identifier">source</span>.<span class="ruby-identifier">length</span>
512
+ <span class="ruby-identifier">index</span> = <span class="ruby-value">0</span>
513
+ <span class="ruby-keyword kw">while</span> <span class="ruby-identifier">index</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">size</span>
514
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">source</span>.<span class="ruby-identifier">read</span>(<span class="ruby-identifier">index</span>, <span class="ruby-identifier">chunksize</span>)
515
+ <span class="ruby-identifier">index</span> <span class="ruby-operator">+=</span> <span class="ruby-identifier">chunksize</span>
516
+ <span class="ruby-keyword kw">end</span>
517
+ }
518
+ <span class="ruby-keyword kw">end</span>
519
+ </pre>
520
+ </div>
521
+ </div>
522
+ </div>
523
+
524
+ <div id="method-M000177" class="method-detail">
525
+ <a name="M000177"></a>
526
+
527
+ <div class="method-heading">
528
+ <a href="#M000177" class="method-signature">
529
+ <span class="method-name">readlines</span><span class="method-args">(path, sep=&quot;\n&quot;) {|lastbit if lastbit != &quot;&quot;| ...}</span>
530
+ </a>
531
+ </div>
532
+
533
+ <div class="method-description">
534
+ <p><a class="source-toggle" href="#"
535
+ onclick="toggleCode('M000177-source');return false;">[Source]</a></p>
536
+ <div class="method-source-code" id="M000177-source">
537
+ <pre>
538
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 55</span>
539
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">readlines</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">sep</span>=<span class="ruby-value str">&quot;\n&quot;</span>)
540
+ <span class="ruby-identifier">lastbit</span> = <span class="ruby-value str">&quot;&quot;</span>
541
+ <span class="ruby-identifier">readchunks</span>(<span class="ruby-identifier">path</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">chunk</span><span class="ruby-operator">|</span>
542
+ <span class="ruby-identifier">parts</span> = <span class="ruby-identifier">chunk</span>.<span class="ruby-identifier">split</span>(<span class="ruby-identifier">sep</span>)
543
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>
544
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">lastbit</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">lastbit</span> <span class="ruby-operator">!=</span> <span class="ruby-value str">&quot;&quot;</span>
545
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">==</span> <span class="ruby-value">1</span>
546
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">lastbit</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">first</span>
547
+ <span class="ruby-keyword kw">else</span>
548
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">lastbit</span> <span class="ruby-operator">+</span> <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">first</span>
549
+ <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">slice</span>(<span class="ruby-value">1</span>, <span class="ruby-identifier">parts</span>.<span class="ruby-identifier">length</span>).<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">p</span><span class="ruby-operator">|</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">p</span> }
550
+ <span class="ruby-keyword kw">end</span>
551
+ <span class="ruby-identifier">lastbit</span> = <span class="ruby-value str">&quot;&quot;</span>
552
+ }
553
+ <span class="ruby-keyword kw">end</span>
554
+ </pre>
555
+ </div>
556
+ </div>
557
+ </div>
558
+
559
+ <div id="method-M000181" class="method-detail">
560
+ <a name="M000181"></a>
561
+
562
+ <div class="method-heading">
563
+ <a href="#M000181" class="method-signature">
564
+ <span class="method-name">rm</span><span class="method-args">(path, recursive=false)</span>
565
+ </a>
566
+ </div>
567
+
568
+ <div class="method-description">
569
+ <p><a class="source-toggle" href="#"
570
+ onclick="toggleCode('M000181-source');return false;">[Source]</a></p>
571
+ <div class="method-source-code" id="M000181-source">
572
+ <pre>
573
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 86</span>
574
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">rm</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">recursive</span>=<span class="ruby-keyword kw">false</span>)
575
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">rm</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">recursive</span>
576
+ <span class="ruby-keyword kw">end</span>
577
+ </pre>
578
+ </div>
579
+ </div>
580
+ </div>
581
+
582
+ <div id="method-M000189" class="method-detail">
583
+ <a name="M000189"></a>
584
+
585
+ <div class="method-heading">
586
+ <a href="#M000189" class="method-signature">
587
+ <span class="method-name">set_replication</span><span class="method-args">(path, level)</span>
588
+ </a>
589
+ </div>
590
+
591
+ <div class="method-description">
592
+ <p><a class="source-toggle" href="#"
593
+ onclick="toggleCode('M000189-source');return false;">[Source]</a></p>
594
+ <div class="method-source-code" id="M000189-source">
595
+ <pre>
596
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 121</span>
597
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_replication</span>(<span class="ruby-identifier">path</span>, <span class="ruby-identifier">level</span>)
598
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">setReplication</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">path</span>), <span class="ruby-identifier">level</span>
599
+ <span class="ruby-keyword kw">end</span>
600
+ </pre>
601
+ </div>
602
+ </div>
603
+ </div>
604
+
605
+ <div id="method-M000173" class="method-detail">
606
+ <a name="M000173"></a>
607
+
608
+ <div class="method-heading">
609
+ <a href="#M000173" class="method-signature">
610
+ <span class="method-name">shutdown</span><span class="method-args">(status=0)</span>
611
+ </a>
612
+ </div>
613
+
614
+ <div class="method-description">
615
+ <p>
616
+ <a href="Client.html#M000173">shutdown</a> the thrift server
617
+ </p>
618
+ <p><a class="source-toggle" href="#"
619
+ onclick="toggleCode('M000173-source');return false;">[Source]</a></p>
620
+ <div class="method-source-code" id="M000173-source">
621
+ <pre>
622
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 18</span>
623
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">shutdown</span>(<span class="ruby-identifier">status</span>=<span class="ruby-value">0</span>)
624
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">shutdown</span> <span class="ruby-identifier">status</span>
625
+ <span class="ruby-keyword kw">end</span>
626
+ </pre>
627
+ </div>
628
+ </div>
629
+ </div>
630
+
631
+ <div id="method-M000185" class="method-detail">
632
+ <a name="M000185"></a>
633
+
634
+ <div class="method-heading">
635
+ <a href="#M000185" class="method-signature">
636
+ <span class="method-name">stat</span><span class="method-args">(path)</span>
637
+ </a>
638
+ </div>
639
+
640
+ <div class="method-description">
641
+ <p><a class="source-toggle" href="#"
642
+ onclick="toggleCode('M000185-source');return false;">[Source]</a></p>
643
+ <div class="method-source-code" id="M000185-source">
644
+ <pre>
645
+ <span class="ruby-comment cmt"># File lib/ganapati/client.rb, line 102</span>
646
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">stat</span>(<span class="ruby-identifier">path</span>)
647
+ <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">stat</span> <span class="ruby-identifier">pname</span>(<span class="ruby-identifier">path</span>)
648
+ <span class="ruby-keyword kw">end</span>
649
+ </pre>
650
+ </div>
651
+ </div>
652
+ </div>
653
+
654
+
655
+ </div>
656
+
657
+
658
+ </div>
659
+
660
+
661
+ <div id="validator-badges">
662
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
663
+ </div>
664
+
665
+ </body>
666
+ </html>