diff --git a/lib/riak/client.rb b/lib/riak/client.rb index 2092eff2..0e148d87 100644 --- a/lib/riak/client.rb +++ b/lib/riak/client.rb @@ -246,15 +246,6 @@ def client_id end end - # Deletes a file stored via the "Luwak" interface - # @param [String] filename the key/filename to delete - def delete_file(filename) - http do |h| - h.delete_file(filename) - end - true - end - # Delete an object. See Bucket#delete def delete_object(bucket, key, options = {}) backend do |b| @@ -262,16 +253,6 @@ def delete_object(bucket, key, options = {}) end end - # Checks whether a file exists in "Luwak". - # @param [String] key the key to check - # @return [true, false] whether the key exists in "Luwak" - def file_exists?(key) - http do |h| - h.file_exists?(key) - end - end - alias :file_exist? :file_exists? - # Bucket properties. See Bucket#props def get_bucket_props(bucket) backend do |b| @@ -279,23 +260,6 @@ def get_bucket_props(bucket) end end - # Retrieves a large file/IO object from Riak via the "Luwak" - # interface. Streams the data to a temporary file unless a block - # is given. - # @param [String] filename the key/filename for the object - # @return [IO, nil] the file (also having content_type and - # original_filename accessors). The file will need to be - # reopened to be read. nil will be returned if a block is given. - # @yield [chunk] stream contents of the file through the - # block. Passing the block will result in nil being returned - # from the method. - # @yieldparam [String] chunk a single chunk of the object's data - def get_file(filename, &block) - http do |h| - h.get_file(filename, &block) - end - end - # Queries a secondary index on a bucket. See Bucket#get_index def get_index(bucket, index, query, options={}) backend do |b| @@ -527,22 +491,6 @@ def stamp @stamp ||= Riak::Stamp.new(self) end - # Stores a large file/IO-like object in Riak via the "Luwak" interface. - # @overload store_file(filename, content_type, data) - # Stores the file at the given key/filename - # @param [String] filename the key/filename for the object - # @param [String] content_type the MIME Content-Type for the data - # @param [IO, String] data the contents of the file - # @overload store_file(content_type, data) - # Stores the file with a server-determined key/filename - # @param [String] content_type the MIME Content-Type for the data - # @param [String, #read] data the contents of the file - # @return [String] the key/filename where the object was stored - def store_file(*args) - http do |h| - h.store_file(*args) - end - end # Stores an object in Riak. def store_object(object, options = {}) @@ -568,15 +516,5 @@ def ssl_disable n.ssl_disable end end - - # @private - class LuwakFile < DelegateClass(Tempfile) - attr_accessor :original_filename, :content_type - alias :key :original_filename - def initialize(fn) - super(Tempfile.new(fn)) - @original_filename = fn - end - end end end diff --git a/lib/riak/client/http_backend.rb b/lib/riak/client/http_backend.rb index a154ca75..b348179c 100644 --- a/lib/riak/client/http_backend.rb +++ b/lib/riak/client/http_backend.rb @@ -322,69 +322,6 @@ def update_search_index(index, updates) post(200, solr_update_path(index), updates, {'Content-Type' => 'text/xml'}) end - # (Luwak) Fetches a file from the Luwak large-file interface. - # @param [String] filename the name of the file - # @yield [chunk] A block which will receive individual chunks of - # the file as they are streamed - # @yieldparam [String] chunk a block of the file - # @return [IO, nil] the file (also having content_type and - # original_filename accessors). The file will need to be - # reopened to be read - def get_file(filename, &block) - if block_given? - get(200, luwak_path(filename), &block) - nil - else - tmpfile = LuwakFile.new(escape(filename)) - begin - response = get(200, luwak_path(filename)) do |chunk| - tmpfile.write chunk - end - tmpfile.content_type = response[:headers]['content-type'].first - tmpfile - ensure - tmpfile.close - end - end - end - - # (Luwak) Detects whether a file exists in the Luwak large-file - # interface. - # @param [String] filename the name of the file - # @return [true,false] whether the file exists - def file_exists?(filename) - result = head([200,404], luwak_path(filename)) - result[:code] == 200 - end - - # (Luwak) Deletes a file from the Luwak large-file interface. - # @param [String] filename the name of the file - def delete_file(filename) - delete([204,404], luwak_path(filename)) - end - - # (Luwak) Uploads a file to the Luwak large-file interface. - # @overload store_file(filename, content_type, data) - # Stores the file at the given key/filename - # @param [String] filename the key/filename for the object - # @param [String] content_type the MIME Content-Type for the data - # @param [IO, String] data the contents of the file - # @overload store_file(content_type, data) - # Stores the file with a server-determined key/filename - # @param [String] content_type the MIME Content-Type for the data - # @param [String, #read] data the contents of the file - # @return [String] the key/filename where the object was stored - def store_file(*args) - data, content_type, filename = args.reverse - if filename - put(204, luwak_path(filename), data, {"Content-Type" => content_type}) - filename - else - response = post(201, luwak_path(nil), data, {"Content-Type" => content_type}) - response[:headers]["location"].first.split("/").last - end - end - private def normalize_search_response(json) {}.tap do |result| diff --git a/lib/riak/client/http_backend/configuration.rb b/lib/riak/client/http_backend/configuration.rb index ae60c604..b31085f9 100644 --- a/lib/riak/client/http_backend/configuration.rb +++ b/lib/riak/client/http_backend/configuration.rb @@ -1,4 +1,3 @@ - require 'riak/failed_request' require 'riak/client/http_backend' require 'riak/link' @@ -148,16 +147,6 @@ def solr_update_path(index) end end - # @return [URI] a URL path for the Luwak interface - def luwak_path(key) - raise t('luwak_unsupported') unless luwak_wm_file - if key - path(luwak_wm_file, escape(key)) - else - path(luwak_wm_file) - end - end - private def server_config @server_config ||= {}.tap do |hash| @@ -217,10 +206,6 @@ def riak_solr_searcher_wm def riak_solr_indexer_wm server_config[:riak_solr_indexer_wm] end - - def luwak_wm_file - server_config[:luwak_wm_file] - end end end end diff --git a/lib/riak/client/node.rb b/lib/riak/client/node.rb index a4e57a3b..dba81669 100644 --- a/lib/riak/client/node.rb +++ b/lib/riak/client/node.rb @@ -7,7 +7,7 @@ class Node include Util::Escape VALID_OPTIONS = [:host, :http_port, :pb_port, :http_paths, :prefix, - :mapred, :luwak, :solr, :port, :basic_auth, :ssl_options, :ssl] + :mapred, :solr, :port, :basic_auth, :ssl_options, :ssl] # For a score which halves in 10 seconds, choose # ln(1/2)/10 @@ -37,7 +37,6 @@ def initialize(client, opts = {}) @http_paths = { :prefix => opts[:prefix] || "/riak/", :mapred => opts[:mapred] || "/mapred", - :luwak => opts[:luwak] || "/luwak", :solr => opts[:solr] || "/solr" # Unused? }.merge(opts[:http_paths] || {}) self.basic_auth = opts[:basic_auth] diff --git a/lib/riak/locale/en.yml b/lib/riak/locale/en.yml index d439f24f..8ddc2210 100644 --- a/lib/riak/locale/en.yml +++ b/lib/riak/locale/en.yml @@ -41,7 +41,6 @@ en: loading_bucket: "while loading bucket '%{name}'" list_buckets: "Riak::Client#buckets is an expensive operation that should not be used in production.\n %{backtrace}" list_keys: "Riak::Bucket#keys is an expensive operation that should not be used in production.\n %{backtrace}" - luwak_unsupported: "Riak server does not support Luwak. Enable it in app.config before using." missing_block: "A block must be given." missing_host_and_port: "You must specify a host and port, or use the defaults of 127.0.0.1:8098" module_function_pair_required: "function must have two elements when an array" diff --git a/lib/riak/locale/fr.yml b/lib/riak/locale/fr.yml index 03a7ed42..edce5e41 100644 --- a/lib/riak/locale/fr.yml +++ b/lib/riak/locale/fr.yml @@ -30,7 +30,6 @@ fr: loading_bucket: "pendant le chargement du bucket '%{name}'" list_buckets: "Riak::Client#buckets est une opération coûteuse et ne doit pas être utilisée en production.\n %{backtrace}" list_keys: "Riak::Bucket#keys est une opération coûteuse et ne doit pas être utilisée en production.\n %{backtrace}" - luwak_unsupported: "Le serveur Riak ne supporte pas Luwak. Activez-le dans app.config avant de l'utiliser" missing_block: "Un bloc doit être fourni." missing_host_and_port: "Vous devez spécifier un hôte et un port, utiliser la valeur par défaut : 127.0.0.1:8098" module_function_pair_required: "la fonction doit avoir deux élément lorsqu'elle est définie par un tableau" diff --git a/lib/riak/node/defaults.rb b/lib/riak/node/defaults.rb index db5be20c..0faacae7 100644 --- a/lib/riak/node/defaults.rb +++ b/lib/riak/node/defaults.rb @@ -30,9 +30,6 @@ class Node :riak_search => { :enabled => true }, - :luwak => { - :enabled => true - }, :merge_index => { :buffer_rollover_size => 1048576, :max_compact_segments => 20 diff --git a/spec/integration/riak/http_backends_spec.rb b/spec/integration/riak/http_backends_spec.rb index f4feba12..75ad1b0b 100644 --- a/spec/integration/riak/http_backends_spec.rb +++ b/spec/integration/riak/http_backends_spec.rb @@ -51,57 +51,6 @@ @backend.get_bucket_props(bucket)['n_val'].should == original_n end end - - context "using Luwak", :version => "< 1.1.0" do - let(:file) { File.open(__FILE__) } - let(:key) { "spec.rb" } - let(:string) { file.read } - - def retry_400 - begin - yield - rescue Riak::HTTPFailedRequest => e - # Riak 1.0.x (and possibly earlier) has a bug in - # mochiweb that will sometimes leave dangling 400 - # responses on the wire between requests when the - # connection is left open. This will happen sometimes - # immediately after a store_file request. - if e.code == 400 - retry - else - raise - end - end - end - - it "should store an IO with a given key" do - @backend.store_file(key, 'text/plain', file) - stored_file = retry_400 { @backend.get_file(key) } - stored_file.content_type.should == 'text/plain' - stored_file.size.should == file.size - end - - it "should store a String with a given key" do - @backend.store_file(key, 'text/plain', string) - stored_file = retry_400 { @backend.get_file(key) } - stored_file.content_type.should == 'text/plain' - stored_file.size.should == string.bytesize - end - - it "should store an IO with a server-defined key" do - key = @backend.store_file('text/plain', file) - stored_file = retry_400 { @backend.get_file(key) } - stored_file.content_type.should == 'text/plain' - stored_file.size.should == file.size - end - - it "should store a String with a server-defined key" do - key = @backend.store_file('text/plain', string) - stored_file = retry_400 { @backend.get_file(key) } - stored_file.content_type.should == 'text/plain' - stored_file.size.should == string.bytesize - end - end end end end diff --git a/spec/riak/client_spec.rb b/spec/riak/client_spec.rb index 5e9dc9eb..6b4c80d1 100644 --- a/spec/riak/client_spec.rb +++ b/spec/riak/client_spec.rb @@ -62,11 +62,6 @@ client.nodes.first.http_paths[:mapred].should == "/mr" end - it "should accept a luwak path" do - client = Riak::Client.new(:luwak => "/beans") - client.nodes.first.http_paths[:luwak].should == "/beans" - end - it "should accept a solr path" do client = Riak::Client.new(:solr => "/solar") client.nodes.first.http_paths[:solr].should == "/solar" @@ -280,54 +275,6 @@ end end - describe "Luwak (large-files) support" do - describe "storing a file" do - before :each do - @client = Riak::Client.new - @http = mock(Riak::Client::HTTPBackend) - @http.stub!(:node).and_return(@client.node) - @client.stub!(:http).and_yield(@http) - end - - it "should store the file via the HTTP interface" do - @http.should_receive(:store_file).with("text/plain", "Hello, world").and_return("123456789") - @client.store_file("text/plain", "Hello, world").should == "123456789" - end - end - - describe "retrieving a file" do - before :each do - @client = Riak::Client.new - @http = mock(Riak::Client::HTTPBackend) - @http.stub!(:node).and_return(@client.node) - @client.stub!(:http).and_yield(@http) - end - - it "should fetch via HTTP" do - @http.should_receive(:get_file).with("greeting.txt") - @client.get_file("greeting.txt") - end - end - - it "should delete a file" do - @client = Riak::Client.new - @http = mock(Riak::Client::HTTPBackend) - @http.stub!(:node).and_return(@client.nodes.first) - @client.stub!(:http).and_yield(@http) - @http.should_receive(:delete_file).with("greeting.txt") - @client.delete_file("greeting.txt") - end - - it "should detect if file exists via HTTP" do - @client = Riak::Client.new - @http = mock(Riak::Client::HTTPBackend) - @http.stub!(:node).and_return(@client.nodes.first) - @client.stub!(:http).and_yield(@http) - @http.should_receive(:file_exists?).and_return(true) - @client.file_exists?("foo").should be_true - end - end - describe "ssl", :ssl => true do before :each do @client = Riak::Client.new diff --git a/spec/riak/http_backend/configuration_spec.rb b/spec/riak/http_backend/configuration_spec.rb index 2d29cca5..0ac609bd 100644 --- a/spec/riak/http_backend/configuration_spec.rb +++ b/spec/riak/http_backend/configuration_spec.rb @@ -201,37 +201,6 @@ end end - context "when Luwak is enabled" do - before { subject.should_receive(:get).with(200, uri).and_return(:headers => {'link' => ['; rel="riak_kv_wm_raw", ; rel="riak_kv_wm_ping", ; rel="riak_kv_wm_stats", ; rel="riak_kv_wm_mapred", ; rel="luwak_wm_file"']}) } - - it "should generate a path for a file" do - url = subject.luwak_path('foo') - url.should be_kind_of(URI) - url.path.should == '/luwak/foo' - end - - it "should generate a path for the root" do - url = subject.luwak_path(nil) - url.should be_kind_of(URI) - url.path.should == '/luwak' - end - - it "should escape a nested path" do - url = subject.luwak_path("foo/bar/baz") - url.should be_kind_of(URI) - url.path.should == '/luwak/foo%2Fbar%2Fbaz' - end - end - - context "when Luwak is disabled" do - before { subject.should_receive(:get).with(200, uri).and_return(:headers => {'link' => ['; rel="riak_kv_wm_raw", ; rel="riak_kv_wm_ping", ; rel="riak_kv_wm_stats", ; rel="riak_kv_wm_mapred"']}) } - - it "should raise an error when generating the path" do - expect { subject.luwak_path(nil) }.to raise_error - expect { subject.luwak_path('foo') }.to raise_error - end - end - { :riak_kv_wm_raw => :prefix, :riak_kv_wm_link_walker => :prefix, diff --git a/spec/riak/http_backend_spec.rb b/spec/riak/http_backend_spec.rb index 9903a753..ff5b7d76 100644 --- a/spec/riak/http_backend_spec.rb +++ b/spec/riak/http_backend_spec.rb @@ -292,48 +292,4 @@ @backend.update_search_index(nil, 'postbody') end end - context "Luwak" do - before { @backend.send(:server_config)[:luwak_wm_file] = '/luwak' } - context "fetching a file" do - before do - - @backend.should_receive(:get).with(200, @backend.luwak_path("greeting.txt")).and_yield("Hello,").and_yield(" world!").and_return({:code => 200, :headers => {"content-type" => ["text/plain"]}}) - end - - it "should return a tempfile when no block is given" do - file = @backend.get_file("greeting.txt") - file.open {|f| f.read.should == "Hello, world!" } - end - - it "should expose the original key and content-type on the temporary file" do - file = @backend.get_file("greeting.txt") - file.original_filename.should == 'greeting.txt' - file.content_type.should == 'text/plain' - end - - it "should yield chunks of the file to the block and return nil" do - string = "" - result = @backend.get_file("greeting.txt"){|chunk| string << chunk } - result.should be_nil - string.should == "Hello, world!" - end - end - - context "storing a file" do - it "should store a file with the given filename" do - @backend.should_receive(:put).with(204, @backend.luwak_path("greeting.txt"), anything, {"Content-Type" => "text/plain"}).and_return({:code => 204, :headers => {}}) - @backend.store_file("greeting.txt", "text/plain", "Hello, world").should == 'greeting.txt' - end - - it "should store a file and return the key/filename when none is given" do - @backend.should_receive(:post).with(201, @backend.luwak_path(nil), anything, {"Content-Type" => "text/plain"}).and_return({:code => 201, :headers => {'location' => ["/luwak/123456789"]}}) - @backend.store_file("text/plain", "Hello, world").should == '123456789' - end - end - - it "should detect whether a file exists" do - @backend.should_receive(:head).with([200,404], @backend.luwak_path("foo")).and_return({:code => 200}) - @backend.file_exists?("foo").should be_true - end - end end diff --git a/spec/riak/node_spec.rb b/spec/riak/node_spec.rb index 50d4c06e..a5df0fe7 100644 --- a/spec/riak/node_spec.rb +++ b/spec/riak/node_spec.rb @@ -60,15 +60,6 @@ it "default solr path should be /solr" do @node.http_paths[:solr].should == "/solr" end - - it 'should accept a luwak path' do - node = Riak::Client::Node.new @client, :luwak => "/mr" - node.http_paths[:luwak].should == "/mr" - end - - it "default luwak path should be /luwak" do - @node.http_paths[:luwak].should == "/luwak" - end end describe "setting http auth" do