chef-solr 0.8.16 → 0.9.0.a3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Rakefile +44 -23
- data/lib/chef/solr.rb +5 -4
- data/lib/chef/solr/application/solr.rb +9 -6
- data/lib/chef/solr/index_queue_consumer.rb +26 -18
- data/lib/chef/solr/query.rb +17 -5
- data/lib/chef/solr/version.rb +5 -0
- metadata +28 -20
- data/VERSION +0 -1
data/Rakefile
CHANGED
@@ -16,35 +16,56 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
|
+
require File.dirname(__FILE__) + '/lib/chef/solr/version'
|
19
20
|
|
20
21
|
require 'rubygems'
|
21
22
|
require 'rake'
|
23
|
+
require 'rake/gempackagetask'
|
22
24
|
|
23
|
-
|
24
|
-
require 'jeweler'
|
25
|
-
Jeweler::Tasks.new do |gem|
|
26
|
-
gem.name = "chef-solr"
|
27
|
-
gem.summary = %Q{Search indexing for Chef}
|
28
|
-
gem.email = "adam@opscode.com"
|
29
|
-
gem.homepage = "http://wiki.opscode.com/display/chef"
|
30
|
-
gem.authors = ["Adam Jacob"]
|
31
|
-
gem.add_dependency "libxml-ruby", ">=1.1.3"
|
32
|
-
gem.add_dependency "uuidtools", ">=2.0.0"
|
33
|
-
gem.add_dependency "chef", IO.read("VERSION").strip
|
34
|
-
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
35
|
-
gem.executables = [ 'chef-solr', 'chef-solr-indexer', 'chef-solr-rebuild' ]
|
36
|
-
gem.files = [
|
37
|
-
"README.rdoc",
|
38
|
-
"Rakefile",
|
39
|
-
"VERSION"
|
40
|
-
]
|
41
|
-
gem.files.include %w{ README.rdoc Rakefile VERSION bin/* lib/**/* solr/* spec/**/* }
|
42
|
-
end
|
25
|
+
GEM_NAME = "chef-solr"
|
43
26
|
|
44
|
-
|
45
|
-
|
27
|
+
spec = Gem::Specification.new do |gem|
|
28
|
+
gem.name = "chef-solr"
|
29
|
+
gem.version = Chef::Solr::VERSION
|
30
|
+
gem.summary = %Q{Search indexing for Chef}
|
31
|
+
gem.email = "adam@opscode.com"
|
32
|
+
gem.homepage = "http://wiki.opscode.com/display/chef"
|
33
|
+
gem.authors = ["Adam Jacob"]
|
34
|
+
gem.add_dependency "libxml-ruby", ">=1.1.3"
|
35
|
+
gem.add_dependency "uuidtools", ">=2.0.0"
|
36
|
+
gem.add_dependency "chef", Chef::Solr::VERSION
|
37
|
+
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
38
|
+
gem.executables = [ 'chef-solr', 'chef-solr-indexer', 'chef-solr-rebuild' ]
|
39
|
+
gem.files = [
|
40
|
+
"README.rdoc",
|
41
|
+
"Rakefile"
|
42
|
+
]
|
43
|
+
gem.files = %w{ README.rdoc Rakefile LICENSE} + Dir.glob("{bin,lib,solr,spec}/**/*")
|
44
|
+
end
|
45
|
+
|
46
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
47
|
+
pkg.gem_spec = spec
|
48
|
+
end
|
49
|
+
|
50
|
+
desc "Install the gem"
|
51
|
+
task :install => :package do
|
52
|
+
sh %{gem install pkg/#{GEM_NAME}-#{Chef::Solr::VERSION} --no-rdoc --no-ri}
|
46
53
|
end
|
47
54
|
|
55
|
+
desc "Uninstall the gem"
|
56
|
+
task :uninstall do
|
57
|
+
sh %{gem uninstall #{GEM_NAME} -x -v #{Chef::Solr::VERSION} }
|
58
|
+
end
|
59
|
+
|
60
|
+
desc "Create a gemspec file"
|
61
|
+
task :gemspec do
|
62
|
+
File.open("#{GEM_NAME}.gemspec", "w") do |file|
|
63
|
+
file.puts spec.to_ruby
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
|
68
|
+
|
48
69
|
begin
|
49
70
|
require 'spec/rake/spectask'
|
50
71
|
Spec::Rake::SpecTask.new(:spec) do |spec|
|
@@ -79,7 +100,7 @@ Rake::RDocTask.new do |rdoc|
|
|
79
100
|
config = YAML.load(File.read('VERSION.yml'))
|
80
101
|
version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
81
102
|
else
|
82
|
-
version =
|
103
|
+
version = Chef::Solr::VERSION
|
83
104
|
end
|
84
105
|
|
85
106
|
rdoc.rdoc_dir = 'rdoc'
|
data/lib/chef/solr.rb
CHANGED
@@ -34,8 +34,6 @@ require 'uri'
|
|
34
34
|
class Chef
|
35
35
|
class Solr
|
36
36
|
|
37
|
-
VERSION = "0.8.16"
|
38
|
-
|
39
37
|
include Chef::Mixin::XMLEscape
|
40
38
|
|
41
39
|
attr_accessor :solr_url, :http
|
@@ -58,7 +56,11 @@ class Chef
|
|
58
56
|
Chef::Log.debug("Sending #{select_url} to Solr")
|
59
57
|
req = Net::HTTP::Get.new(select_url)
|
60
58
|
res = @http.request(req)
|
61
|
-
|
59
|
+
unless res.kind_of?(Net::HTTPSuccess)
|
60
|
+
Chef::Log.fatal("Search Query to Solr '#{select_url}' failed")
|
61
|
+
res.error!
|
62
|
+
end
|
63
|
+
Chef::Log.debug("Parsing Solr result set:\n#{res.body}")
|
62
64
|
eval(res.body)
|
63
65
|
end
|
64
66
|
|
@@ -211,4 +213,3 @@ class Chef
|
|
211
213
|
|
212
214
|
end
|
213
215
|
end
|
214
|
-
|
@@ -126,7 +126,8 @@ class Chef
|
|
126
126
|
@logfile = File.new(Chef::Config[:log_location], "a")
|
127
127
|
end
|
128
128
|
|
129
|
-
Chef::Log.level = Chef::Config[:log_level]
|
129
|
+
#Chef::Log.level = Chef::Config[:log_level]
|
130
|
+
Chef::Log.level = :debug
|
130
131
|
|
131
132
|
# Build up a client
|
132
133
|
node = Chef::Node.new
|
@@ -137,13 +138,14 @@ class Chef
|
|
137
138
|
|
138
139
|
solr_base = File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "..", "..", "solr"))
|
139
140
|
|
141
|
+
run_context = Chef::RunContext.new(node, {})
|
140
142
|
# Create the Jetty container
|
141
143
|
unless File.directory?(Chef::Config[:solr_jetty_path])
|
142
144
|
Chef::Log.warn("Initializing the Jetty container")
|
143
|
-
solr_jetty_dir = Chef::Resource::Directory.new(Chef::Config[:solr_jetty_path],
|
145
|
+
solr_jetty_dir = Chef::Resource::Directory.new(Chef::Config[:solr_jetty_path], run_context)
|
144
146
|
solr_jetty_dir.recursive(true)
|
145
147
|
solr_jetty_dir.run_action(:create)
|
146
|
-
solr_jetty_untar = Chef::Resource::Execute.new("untar_jetty",
|
148
|
+
solr_jetty_untar = Chef::Resource::Execute.new("untar_jetty", run_context)
|
147
149
|
solr_jetty_untar.command("tar zxvf #{File.join(solr_base, 'solr-jetty.tar.gz')}")
|
148
150
|
solr_jetty_untar.cwd(Chef::Config[:solr_jetty_path])
|
149
151
|
solr_jetty_untar.run_action(:run)
|
@@ -152,10 +154,10 @@ class Chef
|
|
152
154
|
# Create the solr home
|
153
155
|
unless File.directory?(Chef::Config[:solr_home_path])
|
154
156
|
Chef::Log.warn("Initializing Solr home directory")
|
155
|
-
solr_home_dir = Chef::Resource::Directory.new(Chef::Config[:solr_home_path],
|
157
|
+
solr_home_dir = Chef::Resource::Directory.new(Chef::Config[:solr_home_path], run_context)
|
156
158
|
solr_home_dir.recursive(true)
|
157
159
|
solr_home_dir.run_action(:create)
|
158
|
-
solr_jetty_untar = Chef::Resource::Execute.new("untar_solr_home",
|
160
|
+
solr_jetty_untar = Chef::Resource::Execute.new("untar_solr_home", run_context)
|
159
161
|
solr_jetty_untar.command("tar zxvf #{File.join(solr_base, 'solr-home.tar.gz')}")
|
160
162
|
solr_jetty_untar.cwd(Chef::Config[:solr_home_path])
|
161
163
|
solr_jetty_untar.run_action(:run)
|
@@ -164,7 +166,7 @@ class Chef
|
|
164
166
|
# Create the solr data path
|
165
167
|
unless File.directory?(Chef::Config[:solr_data_path])
|
166
168
|
Chef::Log.warn("Initializing Solr data directory")
|
167
|
-
solr_data_dir = Chef::Resource::Directory.new(Chef::Config[:solr_data_path],
|
169
|
+
solr_data_dir = Chef::Resource::Directory.new(Chef::Config[:solr_data_path], run_context)
|
168
170
|
solr_data_dir.recursive(true)
|
169
171
|
solr_data_dir.run_action(:create)
|
170
172
|
end
|
@@ -201,3 +203,4 @@ class Chef
|
|
201
203
|
end
|
202
204
|
end
|
203
205
|
end
|
206
|
+
|
@@ -40,14 +40,15 @@ class Chef
|
|
40
40
|
index = Chef::Solr::Index.new
|
41
41
|
Chef::Log.debug("Dequeued item for indexing: #{payload.inspect}")
|
42
42
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
43
|
+
begin
|
44
|
+
pitem = payload["item"].to_hash
|
45
|
+
response = generate_response { index.add(payload["id"], payload["database"], payload["type"], pitem) }
|
46
|
+
rescue NoMethodError
|
47
|
+
response = generate_response() { raise ArgumentError, "Payload item does not respond to :keys or :to_hash, cannot index!" }
|
48
|
+
end
|
49
49
|
|
50
|
-
|
50
|
+
msg = "Indexing #{payload["type"]} #{payload["id"]} from #{payload["database"]} status #{status_message(response)}}"
|
51
|
+
Chef::Log.info(msg)
|
51
52
|
response
|
52
53
|
end
|
53
54
|
|
@@ -58,18 +59,25 @@ class Chef
|
|
58
59
|
end
|
59
60
|
|
60
61
|
private
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
response
|
62
|
+
|
63
|
+
def generate_response(&block)
|
64
|
+
response = {}
|
65
|
+
begin
|
66
|
+
block.call
|
67
|
+
rescue => e
|
68
|
+
response[:status] = :error
|
69
|
+
response[:error] = e
|
70
|
+
else
|
71
|
+
response[:status] = :ok
|
72
72
|
end
|
73
|
+
response
|
74
|
+
end
|
75
|
+
|
76
|
+
def status_message(response)
|
77
|
+
msg = response[:status].to_s
|
78
|
+
msg << ' ' + response[:error].to_s if response[:status] == :error
|
79
|
+
msg
|
80
|
+
end
|
73
81
|
|
74
82
|
end
|
75
83
|
end
|
data/lib/chef/solr/query.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#
|
2
2
|
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
#
|
3
|
+
# Author:: Nuo Yan (<nuo@opscode.com>)
|
4
|
+
# Copyright:: Copyright (c) 2010 Opscode, Inc.
|
4
5
|
# License:: Apache License, Version 2.0
|
5
6
|
#
|
6
7
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
@@ -30,11 +31,22 @@ class Chef
|
|
30
31
|
class Query < Chef::Solr
|
31
32
|
|
32
33
|
# Create a new Query object - takes the solr_url and optional
|
33
|
-
#
|
34
|
-
def initialize(solr_url=Chef::Config[:solr_url],
|
34
|
+
# Chef::CouchDB object to inflate objects into.
|
35
|
+
def initialize(solr_url=Chef::Config[:solr_url], couchdb = nil)
|
35
36
|
super(solr_url)
|
36
|
-
|
37
|
-
|
37
|
+
if couchdb.nil?
|
38
|
+
@database = Chef::Config[:couchdb_database]
|
39
|
+
@couchdb = Chef::CouchDB.new(nil, Chef::Config[:couchdb_database])
|
40
|
+
else
|
41
|
+
unless couchdb.kind_of?(Chef::CouchDB)
|
42
|
+
Chef::Log.warn("Passing the database name to Chef::Solr::Query initialization is deprecated. Please pass in the Chef::CouchDB object instead.")
|
43
|
+
@database = couchdb
|
44
|
+
@couchdb = Chef::CouchDB.new(nil, couchdb)
|
45
|
+
else
|
46
|
+
@database = couchdb.couchdb_database
|
47
|
+
@couchdb = couchdb
|
48
|
+
end
|
49
|
+
end
|
38
50
|
end
|
39
51
|
|
40
52
|
# A raw query against CouchDB - takes the type of object to find, and raw
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-solr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: true
|
5
5
|
segments:
|
6
6
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
|
7
|
+
- 9
|
8
|
+
- 0
|
9
|
+
- a3
|
10
|
+
version: 0.9.0.a3
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- Adam Jacob
|
@@ -14,13 +15,14 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-06-04 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: libxml-ruby
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
@@ -35,6 +37,7 @@ dependencies:
|
|
35
37
|
name: uuidtools
|
36
38
|
prerelease: false
|
37
39
|
requirement: &id002 !ruby/object:Gem::Requirement
|
40
|
+
none: false
|
38
41
|
requirements:
|
39
42
|
- - ">="
|
40
43
|
- !ruby/object:Gem::Version
|
@@ -49,14 +52,16 @@ dependencies:
|
|
49
52
|
name: chef
|
50
53
|
prerelease: false
|
51
54
|
requirement: &id003 !ruby/object:Gem::Requirement
|
55
|
+
none: false
|
52
56
|
requirements:
|
53
57
|
- - "="
|
54
58
|
- !ruby/object:Gem::Version
|
55
59
|
segments:
|
56
60
|
- 0
|
57
|
-
-
|
58
|
-
-
|
59
|
-
|
61
|
+
- 9
|
62
|
+
- 0
|
63
|
+
- a3
|
64
|
+
version: 0.9.0.a3
|
60
65
|
type: :runtime
|
61
66
|
version_requirements: *id003
|
62
67
|
description:
|
@@ -67,23 +72,23 @@ executables:
|
|
67
72
|
- chef-solr-rebuild
|
68
73
|
extensions: []
|
69
74
|
|
70
|
-
extra_rdoc_files:
|
71
|
-
|
72
|
-
- README.rdoc
|
75
|
+
extra_rdoc_files: []
|
76
|
+
|
73
77
|
files:
|
74
78
|
- README.rdoc
|
75
79
|
- Rakefile
|
76
|
-
-
|
80
|
+
- LICENSE
|
77
81
|
- bin/chef-solr
|
78
82
|
- bin/chef-solr-indexer
|
79
83
|
- bin/chef-solr-rebuild
|
80
|
-
- lib/chef/solr.rb
|
81
84
|
- lib/chef/solr/application/indexer.rb
|
82
85
|
- lib/chef/solr/application/rebuild.rb
|
83
86
|
- lib/chef/solr/application/solr.rb
|
84
87
|
- lib/chef/solr/index.rb
|
85
88
|
- lib/chef/solr/index_queue_consumer.rb
|
86
89
|
- lib/chef/solr/query.rb
|
90
|
+
- lib/chef/solr/version.rb
|
91
|
+
- lib/chef/solr.rb
|
87
92
|
- solr/solr-home.tar.gz
|
88
93
|
- solr/solr-jetty.tar.gz
|
89
94
|
- spec/chef/solr/index_spec.rb
|
@@ -91,17 +96,17 @@ files:
|
|
91
96
|
- spec/chef/solr_spec.rb
|
92
97
|
- spec/spec.opts
|
93
98
|
- spec/spec_helper.rb
|
94
|
-
- LICENSE
|
95
99
|
has_rdoc: true
|
96
100
|
homepage: http://wiki.opscode.com/display/chef
|
97
101
|
licenses: []
|
98
102
|
|
99
103
|
post_install_message:
|
100
|
-
rdoc_options:
|
101
|
-
|
104
|
+
rdoc_options: []
|
105
|
+
|
102
106
|
require_paths:
|
103
107
|
- lib
|
104
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
|
+
none: false
|
105
110
|
requirements:
|
106
111
|
- - ">="
|
107
112
|
- !ruby/object:Gem::Version
|
@@ -109,16 +114,19 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
109
114
|
- 0
|
110
115
|
version: "0"
|
111
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
|
+
none: false
|
112
118
|
requirements:
|
113
|
-
- - "
|
119
|
+
- - ">"
|
114
120
|
- !ruby/object:Gem::Version
|
115
121
|
segments:
|
116
|
-
-
|
117
|
-
|
122
|
+
- 1
|
123
|
+
- 3
|
124
|
+
- 1
|
125
|
+
version: 1.3.1
|
118
126
|
requirements: []
|
119
127
|
|
120
128
|
rubyforge_project:
|
121
|
-
rubygems_version: 1.3.
|
129
|
+
rubygems_version: 1.3.7
|
122
130
|
signing_key:
|
123
131
|
specification_version: 3
|
124
132
|
summary: Search indexing for Chef
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.8.16
|