chef-solr 0.9.18 → 0.10.0.beta.0
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/{chef-solr-indexer → chef-solr-installer} +4 -7
- data/lib/chef/solr.rb +1 -234
- data/lib/chef/solr/application/solr.rb +71 -43
- data/lib/chef/solr/solr_installer.rb +385 -0
- data/lib/chef/solr/version.rb +7 -1
- data/solr/solr-home.tar.gz +0 -0
- data/solr/solr-jetty.tar.gz +0 -0
- metadata +11 -41
- data/lib/chef/solr/application/indexer.rb +0 -148
- data/lib/chef/solr/index.rb +0 -103
- data/lib/chef/solr/index_queue_consumer.rb +0 -82
- data/lib/chef/solr/query.rb +0 -99
- data/spec/chef/solr/index_spec.rb +0 -187
- data/spec/chef/solr/query_spec.rb +0 -14
- data/spec/chef/solr_spec.rb +0 -301
- data/spec/spec.opts +0 -1
- data/spec/spec_helper.rb +0 -14
data/lib/chef/solr/version.rb
CHANGED
data/solr/solr-home.tar.gz
CHANGED
Binary file
|
data/solr/solr-jetty.tar.gz
CHANGED
Binary file
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chef-solr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
5
|
-
version: 0.
|
4
|
+
prerelease: 7
|
5
|
+
version: 0.10.0.beta.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Adam Jacob
|
@@ -10,47 +10,25 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-03-28 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: libxml-ruby
|
18
|
-
prerelease: false
|
19
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
|
-
requirements:
|
22
|
-
- - ">="
|
23
|
-
- !ruby/object:Gem::Version
|
24
|
-
version: 1.1.3
|
25
|
-
type: :runtime
|
26
|
-
version_requirements: *id001
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: uuidtools
|
29
|
-
prerelease: false
|
30
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
-
none: false
|
32
|
-
requirements:
|
33
|
-
- - ">="
|
34
|
-
- !ruby/object:Gem::Version
|
35
|
-
version: 2.0.0
|
36
|
-
type: :runtime
|
37
|
-
version_requirements: *id002
|
38
16
|
- !ruby/object:Gem::Dependency
|
39
17
|
name: chef
|
40
18
|
prerelease: false
|
41
|
-
requirement: &
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
42
20
|
none: false
|
43
21
|
requirements:
|
44
22
|
- - "="
|
45
23
|
- !ruby/object:Gem::Version
|
46
|
-
version: 0.
|
24
|
+
version: 0.10.0.beta.0
|
47
25
|
type: :runtime
|
48
|
-
version_requirements: *
|
26
|
+
version_requirements: *id001
|
49
27
|
description:
|
50
28
|
email: adam@opscode.com
|
51
29
|
executables:
|
52
30
|
- chef-solr
|
53
|
-
- chef-solr-
|
31
|
+
- chef-solr-installer
|
54
32
|
- chef-solr-rebuild
|
55
33
|
extensions: []
|
56
34
|
|
@@ -61,23 +39,15 @@ files:
|
|
61
39
|
- Rakefile
|
62
40
|
- LICENSE
|
63
41
|
- bin/chef-solr
|
64
|
-
- bin/chef-solr-
|
42
|
+
- bin/chef-solr-installer
|
65
43
|
- bin/chef-solr-rebuild
|
66
|
-
- lib/chef/solr/application/indexer.rb
|
67
44
|
- lib/chef/solr/application/rebuild.rb
|
68
45
|
- lib/chef/solr/application/solr.rb
|
69
|
-
- lib/chef/solr/
|
70
|
-
- lib/chef/solr/index_queue_consumer.rb
|
71
|
-
- lib/chef/solr/query.rb
|
46
|
+
- lib/chef/solr/solr_installer.rb
|
72
47
|
- lib/chef/solr/version.rb
|
73
48
|
- lib/chef/solr.rb
|
74
49
|
- solr/solr-home.tar.gz
|
75
50
|
- solr/solr-jetty.tar.gz
|
76
|
-
- spec/chef/solr/index_spec.rb
|
77
|
-
- spec/chef/solr/query_spec.rb
|
78
|
-
- spec/chef/solr_spec.rb
|
79
|
-
- spec/spec.opts
|
80
|
-
- spec/spec_helper.rb
|
81
51
|
has_rdoc: true
|
82
52
|
homepage: http://wiki.opscode.com/display/chef
|
83
53
|
licenses: []
|
@@ -96,9 +66,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
66
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
67
|
none: false
|
98
68
|
requirements:
|
99
|
-
- - "
|
69
|
+
- - ">"
|
100
70
|
- !ruby/object:Gem::Version
|
101
|
-
version:
|
71
|
+
version: 1.3.1
|
102
72
|
requirements: []
|
103
73
|
|
104
74
|
rubyforge_project:
|
@@ -1,148 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: AJ Christensen (<aj@opscode.com)
|
3
|
-
# Copyright:: Copyright (c) 2008 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
|
18
|
-
require 'chef'
|
19
|
-
require 'chef/log'
|
20
|
-
require 'chef/config'
|
21
|
-
require 'chef/application'
|
22
|
-
require 'chef/solr'
|
23
|
-
require 'chef/solr/index'
|
24
|
-
require 'chef/solr/index_queue_consumer'
|
25
|
-
require 'chef/daemon'
|
26
|
-
require 'chef/webui_user'
|
27
|
-
|
28
|
-
class Chef
|
29
|
-
class Solr
|
30
|
-
class Application
|
31
|
-
class Indexer < Chef::Application
|
32
|
-
|
33
|
-
option :config_file,
|
34
|
-
:short => "-c CONFIG",
|
35
|
-
:long => "--config CONFIG",
|
36
|
-
:default => "/etc/chef/solr.rb",
|
37
|
-
:description => "The configuration file to use"
|
38
|
-
|
39
|
-
option :log_level,
|
40
|
-
:short => "-l LEVEL",
|
41
|
-
:long => "--log_level LEVEL",
|
42
|
-
:description => "Set the log level (debug, info, warn, error, fatal)",
|
43
|
-
:proc => lambda { |l| l.to_sym }
|
44
|
-
|
45
|
-
option :log_location,
|
46
|
-
:short => "-L LOGLOCATION",
|
47
|
-
:long => "--logfile LOGLOCATION",
|
48
|
-
:description => "Set the log file location, defaults to STDOUT - recommended for daemonizing",
|
49
|
-
:proc => nil
|
50
|
-
|
51
|
-
option :pid_file,
|
52
|
-
:short => "-P PID_FILE",
|
53
|
-
:long => "--pid PIDFILE",
|
54
|
-
:description => "Set the PID file location, defaults to /tmp/chef-solr-indexer.pid",
|
55
|
-
:proc => nil
|
56
|
-
|
57
|
-
|
58
|
-
option :help,
|
59
|
-
:short => "-h",
|
60
|
-
:long => "--help",
|
61
|
-
:description => "Show this message",
|
62
|
-
:on => :tail,
|
63
|
-
:boolean => true,
|
64
|
-
:show_options => true,
|
65
|
-
:exit => 0
|
66
|
-
|
67
|
-
option :user,
|
68
|
-
:short => "-u USER",
|
69
|
-
:long => "--user USER",
|
70
|
-
:description => "User to set privilege to",
|
71
|
-
:proc => nil
|
72
|
-
|
73
|
-
option :group,
|
74
|
-
:short => "-g GROUP",
|
75
|
-
:long => "--group GROUP",
|
76
|
-
:description => "Group to set privilege to",
|
77
|
-
:proc => nil
|
78
|
-
|
79
|
-
option :daemonize,
|
80
|
-
:short => "-d",
|
81
|
-
:long => "--daemonize",
|
82
|
-
:description => "Daemonize the process",
|
83
|
-
:proc => lambda { |p| true }
|
84
|
-
|
85
|
-
option :amqp_host,
|
86
|
-
:long => "--amqp-host HOST",
|
87
|
-
:description => "The amqp host"
|
88
|
-
|
89
|
-
option :amqp_port,
|
90
|
-
:long => "--amqp-port PORT",
|
91
|
-
:description => "The amqp port"
|
92
|
-
|
93
|
-
option :amqp_user,
|
94
|
-
:long => "--amqp-user USER",
|
95
|
-
:description => "The amqp user"
|
96
|
-
|
97
|
-
option :amqp_pass,
|
98
|
-
:long => "--amqp-pass PASS",
|
99
|
-
:description => "The amqp password"
|
100
|
-
|
101
|
-
option :amqp_vhost,
|
102
|
-
:long => "--amqp-vhost VHOST",
|
103
|
-
:description => "The amqp vhost"
|
104
|
-
|
105
|
-
option :version,
|
106
|
-
:short => "-v",
|
107
|
-
:long => "--version",
|
108
|
-
:description => "Show chef-solr-indexer version",
|
109
|
-
:boolean => true,
|
110
|
-
:proc => lambda {|v| puts "chef-solr-indexer: #{::Chef::Solr::VERSION}"},
|
111
|
-
:exit => 0
|
112
|
-
|
113
|
-
Signal.trap("INT") do
|
114
|
-
begin
|
115
|
-
AmqpClient.instance.stop
|
116
|
-
rescue Bunny::ProtocolError, Bunny::ConnectionError, Bunny::UnsubscribeError
|
117
|
-
end
|
118
|
-
fatal!("SIGINT received, stopping", 2)
|
119
|
-
end
|
120
|
-
|
121
|
-
Kernel.trap("TERM") do
|
122
|
-
begin
|
123
|
-
AmqpClient.instance.stop
|
124
|
-
rescue Bunny::ProtocolError, Bunny::ConnectionError, Bunny::UnsubscribeError
|
125
|
-
end
|
126
|
-
fatal!("SIGTERM received, stopping", 1)
|
127
|
-
end
|
128
|
-
|
129
|
-
def initialize
|
130
|
-
super
|
131
|
-
|
132
|
-
@index = Chef::Solr::Index.new
|
133
|
-
@consumer = Chef::Solr::IndexQueueConsumer.new
|
134
|
-
end
|
135
|
-
|
136
|
-
def setup_application
|
137
|
-
Chef::Daemon.change_privilege
|
138
|
-
Chef::Log.level = Chef::Config[:log_level]
|
139
|
-
end
|
140
|
-
|
141
|
-
def run_application
|
142
|
-
Chef::Daemon.daemonize("chef-solr-indexer") if Chef::Config[:daemonize]
|
143
|
-
@consumer.start
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
end
|
data/lib/chef/solr/index.rb
DELETED
@@ -1,103 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/log'
|
20
|
-
require 'chef/config'
|
21
|
-
require 'chef/solr'
|
22
|
-
require 'libxml'
|
23
|
-
require 'net/http'
|
24
|
-
|
25
|
-
class Chef
|
26
|
-
class Solr
|
27
|
-
class Index < Solr
|
28
|
-
|
29
|
-
UNDERSCORE = '_'
|
30
|
-
X = 'X'
|
31
|
-
|
32
|
-
X_CHEF_id_CHEF_X = 'X_CHEF_id_CHEF_X'
|
33
|
-
X_CHEF_database_CHEF_X = 'X_CHEF_database_CHEF_X'
|
34
|
-
X_CHEF_type_CHEF_X = 'X_CHEF_type_CHEF_X'
|
35
|
-
|
36
|
-
def add(id, database, type, item)
|
37
|
-
unless item.respond_to?(:keys)
|
38
|
-
raise ArgumentError, "#{self.class.name} can only index Hash-like objects. You gave #{item.inspect}"
|
39
|
-
end
|
40
|
-
|
41
|
-
to_index = flatten_and_expand(item)
|
42
|
-
|
43
|
-
to_index[X_CHEF_id_CHEF_X] = [id]
|
44
|
-
to_index[X_CHEF_database_CHEF_X] = [database]
|
45
|
-
to_index[X_CHEF_type_CHEF_X] = [type]
|
46
|
-
|
47
|
-
solr_add(to_index)
|
48
|
-
to_index
|
49
|
-
end
|
50
|
-
|
51
|
-
def delete(id)
|
52
|
-
solr_delete_by_id(id)
|
53
|
-
end
|
54
|
-
|
55
|
-
def delete_by_query(query)
|
56
|
-
solr_delete_by_query(query)
|
57
|
-
end
|
58
|
-
|
59
|
-
def flatten_and_expand(item)
|
60
|
-
@flattened_item = Hash.new {|hash, key| hash[key] = []}
|
61
|
-
|
62
|
-
item.each do |key, value|
|
63
|
-
flatten_each([key.to_s], value)
|
64
|
-
end
|
65
|
-
|
66
|
-
@flattened_item.each_value { |values| values.uniq! }
|
67
|
-
@flattened_item
|
68
|
-
end
|
69
|
-
|
70
|
-
def flatten_each(keys, values)
|
71
|
-
case values
|
72
|
-
when Hash
|
73
|
-
values.each do |child_key, child_value|
|
74
|
-
add_field_value(keys, child_key)
|
75
|
-
flatten_each(keys + [child_key.to_s], child_value)
|
76
|
-
end
|
77
|
-
when Array
|
78
|
-
values.each { |child_value| flatten_each(keys, child_value) }
|
79
|
-
else
|
80
|
-
add_field_value(keys, values)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
def add_field_value(keys, value)
|
85
|
-
value = value.to_s
|
86
|
-
each_expando_field(keys) { |expando_field| @flattened_item[expando_field] << value }
|
87
|
-
@flattened_item[keys.join(UNDERSCORE)] << value
|
88
|
-
@flattened_item[keys.last] << value
|
89
|
-
end
|
90
|
-
|
91
|
-
def each_expando_field(keys)
|
92
|
-
return if keys.size == 1
|
93
|
-
0.upto(keys.size - 1) do |index|
|
94
|
-
original = keys[index]
|
95
|
-
keys[index] = X
|
96
|
-
yield keys.join(UNDERSCORE)
|
97
|
-
keys[index] = original
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# Author:: Adam Jacob (<adam@opscode.com>)
|
3
|
-
# Copyright:: Copyright (c) 2009 Opscode, Inc.
|
4
|
-
# License:: Apache License, Version 2.0
|
5
|
-
#
|
6
|
-
# Licensed under the Apache License, Version 2.0 (the "License");
|
7
|
-
# you may not use this file except in compliance with the License.
|
8
|
-
# You may obtain a copy of the License at
|
9
|
-
#
|
10
|
-
# http://www.apache.org/licenses/LICENSE-2.0
|
11
|
-
#
|
12
|
-
# Unless required by applicable law or agreed to in writing, software
|
13
|
-
# distributed under the License is distributed on an "AS IS" BASIS,
|
14
|
-
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
15
|
-
# See the License for the specific language governing permissions and
|
16
|
-
# limitations under the License.
|
17
|
-
#
|
18
|
-
|
19
|
-
require 'chef/log'
|
20
|
-
require 'chef/config'
|
21
|
-
require 'chef/solr'
|
22
|
-
require 'chef/solr/index'
|
23
|
-
require 'chef/couchdb'
|
24
|
-
require 'chef/index_queue'
|
25
|
-
|
26
|
-
class Chef
|
27
|
-
class Solr
|
28
|
-
class IndexQueueConsumer
|
29
|
-
include Chef::IndexQueue::Consumer
|
30
|
-
|
31
|
-
expose :add, :delete
|
32
|
-
|
33
|
-
def add(payload)
|
34
|
-
index = Chef::Solr::Index.new
|
35
|
-
Chef::Log.debug("Dequeued item for indexing: #{payload.inspect}")
|
36
|
-
|
37
|
-
begin
|
38
|
-
# older producers will send the raw item, and we no longer inflate it
|
39
|
-
# to an object.
|
40
|
-
pitem = payload["item"].to_hash
|
41
|
-
pitem.delete("json_class")
|
42
|
-
response = generate_response { index.add(payload["id"], payload["database"], payload["type"], pitem) }
|
43
|
-
rescue NoMethodError
|
44
|
-
response = generate_response() { raise ArgumentError, "Payload item does not respond to :keys or :to_hash, cannot index!" }
|
45
|
-
end
|
46
|
-
|
47
|
-
msg = "Indexing #{payload["type"]} #{payload["id"]} from #{payload["database"]} status #{status_message(response)}}"
|
48
|
-
Chef::Log.info(msg)
|
49
|
-
response
|
50
|
-
end
|
51
|
-
|
52
|
-
def delete(payload)
|
53
|
-
response = generate_response { Chef::Solr::Index.new.delete(payload["id"]) }
|
54
|
-
Chef::Log.info("Removed #{payload["id"]} from the index")
|
55
|
-
response
|
56
|
-
end
|
57
|
-
|
58
|
-
private
|
59
|
-
|
60
|
-
def generate_response(&block)
|
61
|
-
response = {}
|
62
|
-
begin
|
63
|
-
block.call
|
64
|
-
rescue => e
|
65
|
-
response[:status] = :error
|
66
|
-
response[:error] = e
|
67
|
-
else
|
68
|
-
response[:status] = :ok
|
69
|
-
end
|
70
|
-
response
|
71
|
-
end
|
72
|
-
|
73
|
-
def status_message(response)
|
74
|
-
msg = response[:status].to_s
|
75
|
-
msg << ' ' + response[:error].to_s if response[:status] == :error
|
76
|
-
msg
|
77
|
-
end
|
78
|
-
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|