tem_mr_search 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +2 -0
- data/Rakefile +4 -4
- data/lib/tem_mr_search/client.rb +4 -8
- data/lib/tem_mr_search/server.rb +13 -11
- data/tem_mr_search.gemspec +9 -9
- data/test/test_client_server.rb +13 -5
- data/test/test_map_reduce_executor.rb +7 -4
- data/testdata/cluster.yml +2 -2
- metadata +7 -7
data/CHANGELOG
CHANGED
data/Rakefile
CHANGED
@@ -3,17 +3,17 @@ gem 'echoe'
|
|
3
3
|
require 'echoe'
|
4
4
|
|
5
5
|
Echoe.new('tem_mr_search') do |p|
|
6
|
-
p.project = 'tem'
|
6
|
+
p.project = 'tem' # rubyforge project
|
7
7
|
p.docs_host = "costan@rubyforge.org:/var/www/gforge-projects/tem/rdoc/"
|
8
8
|
|
9
9
|
p.author = 'Victor Costan'
|
10
10
|
p.email = 'victor@costan.us'
|
11
11
|
p.summary = 'Tem Map-Reduce proof of concept: database search.'
|
12
12
|
p.url = 'http://tem.rubyforge.org'
|
13
|
-
p.dependencies = ['tem_ruby >=0.
|
13
|
+
p.dependencies = ['tem_ruby >=0.13.0', 'tem_multi_proxy >=0.2.6']
|
14
14
|
|
15
|
-
p.need_tar_gz = !
|
16
|
-
p.need_zip = !
|
15
|
+
p.need_tar_gz = !Gem.win_platform?
|
16
|
+
p.need_zip = !Gem.win_platform?
|
17
17
|
p.rdoc_pattern = /^(lib|bin|tasks|ext)|^BUILD|^README|^CHANGELOG|^TODO|^LICENSE|^COPYING$/
|
18
18
|
end
|
19
19
|
|
data/lib/tem_mr_search/client.rb
CHANGED
@@ -3,7 +3,7 @@ module Tem::Mr::Search
|
|
3
3
|
|
4
4
|
class Client
|
5
5
|
OP = Zerg::Support::Protocols::ObjectProtocol
|
6
|
-
OPAdapter
|
6
|
+
OPAdapter = Zerg::Support::Sockets::ProtocolAdapter.adapter_module OP
|
7
7
|
|
8
8
|
# Performs a private database search using a Map-Reduce.
|
9
9
|
def self.search(server_addr, client_query)
|
@@ -38,13 +38,9 @@ class Client
|
|
38
38
|
socket = Zerg::Support::SocketFactory.socket :out_addr => server_addr,
|
39
39
|
:out_port => Server::DEFAULT_PORT
|
40
40
|
socket.extend OPAdapter
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
rescue
|
45
|
-
response = nil
|
46
|
-
end
|
47
|
-
socket.close rescue nil
|
41
|
+
socket.send_object request
|
42
|
+
response = socket.recv_object response
|
43
|
+
socket.close
|
48
44
|
response
|
49
45
|
end
|
50
46
|
end
|
data/lib/tem_mr_search/server.rb
CHANGED
@@ -18,6 +18,9 @@ class Server
|
|
18
18
|
@tems = []
|
19
19
|
refresh_tems!
|
20
20
|
@port = port || DEFAULT_PORT
|
21
|
+
|
22
|
+
@listen_socket = Zerg::Support::SocketFactory.socket :in_port => @port,
|
23
|
+
:reuse_addr => true
|
21
24
|
end
|
22
25
|
|
23
26
|
# Reinitializes the TEM cluster connections.
|
@@ -30,29 +33,28 @@ class Server
|
|
30
33
|
end
|
31
34
|
|
32
35
|
# This server's loop.
|
33
|
-
def serve_loop
|
34
|
-
listen_socket
|
35
|
-
|
36
|
-
shutdown_received
|
37
|
-
until shutdown_received
|
36
|
+
def serve_loop
|
37
|
+
@listen_socket.listen
|
38
|
+
@shutdown_received = false
|
39
|
+
until @shutdown_received
|
38
40
|
begin
|
39
|
-
client_socket, client_addr = listen_socket.accept
|
41
|
+
client_socket, client_addr = @listen_socket.accept
|
40
42
|
client_socket.extend OPAdapter
|
41
43
|
request = client_socket.recv_object
|
42
44
|
begin
|
43
45
|
response = process_request request
|
44
46
|
rescue Exception => e
|
45
47
|
@logger.error e
|
46
|
-
response =
|
48
|
+
response = :error
|
47
49
|
end
|
48
|
-
client_socket.send_object response
|
49
|
-
shutdown_received = true if response == :shutdown
|
50
|
-
rescue
|
50
|
+
client_socket.send_object response
|
51
|
+
@shutdown_received = true if response == :shutdown
|
52
|
+
rescue RuntimeError => e
|
51
53
|
@logger.error e
|
52
54
|
end
|
53
55
|
client_socket.close
|
54
56
|
end
|
55
|
-
listen_socket.close
|
57
|
+
@listen_socket.close
|
56
58
|
end
|
57
59
|
|
58
60
|
# Computes the response of a single request.
|
data/tem_mr_search.gemspec
CHANGED
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = %q{tem_mr_search}
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.3"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["Victor Costan"]
|
9
|
-
s.date = %q{2009-
|
9
|
+
s.date = %q{2009-11-11}
|
10
10
|
s.default_executable = %q{tem_mr_search_server}
|
11
11
|
s.description = %q{Tem Map-Reduce proof of concept: database search.}
|
12
12
|
s.email = %q{victor@costan.us}
|
@@ -19,21 +19,21 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.rubyforge_project = %q{tem}
|
20
20
|
s.rubygems_version = %q{1.3.5}
|
21
21
|
s.summary = %q{Tem Map-Reduce proof of concept: database search.}
|
22
|
-
s.test_files = ["test/
|
22
|
+
s.test_files = ["test/test_query_builders.rb", "test/test_map_reduce_job.rb", "test/test_client_server.rb", "test/test_map_reduce_planner.rb", "test/test_db.rb", "test/test_map_reduce_executor.rb"]
|
23
23
|
|
24
24
|
if s.respond_to? :specification_version then
|
25
25
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
26
26
|
s.specification_version = 3
|
27
27
|
|
28
28
|
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
29
|
-
s.add_runtime_dependency(%q<tem_ruby>, [">= 0.
|
30
|
-
s.add_runtime_dependency(%q<tem_multi_proxy>, [">= 0.2"])
|
29
|
+
s.add_runtime_dependency(%q<tem_ruby>, [">= 0.13.0"])
|
30
|
+
s.add_runtime_dependency(%q<tem_multi_proxy>, [">= 0.2.6"])
|
31
31
|
else
|
32
|
-
s.add_dependency(%q<tem_ruby>, [">= 0.
|
33
|
-
s.add_dependency(%q<tem_multi_proxy>, [">= 0.2"])
|
32
|
+
s.add_dependency(%q<tem_ruby>, [">= 0.13.0"])
|
33
|
+
s.add_dependency(%q<tem_multi_proxy>, [">= 0.2.6"])
|
34
34
|
end
|
35
35
|
else
|
36
|
-
s.add_dependency(%q<tem_ruby>, [">= 0.
|
37
|
-
s.add_dependency(%q<tem_multi_proxy>, [">= 0.2"])
|
36
|
+
s.add_dependency(%q<tem_ruby>, [">= 0.13.0"])
|
37
|
+
s.add_dependency(%q<tem_multi_proxy>, [">= 0.2.6"])
|
38
38
|
end
|
39
39
|
end
|
data/test/test_client_server.rb
CHANGED
@@ -9,15 +9,25 @@ class ClientServerTest < MrTestCase
|
|
9
9
|
def setup
|
10
10
|
super
|
11
11
|
@server_port = 29550
|
12
|
+
@thread_abort = Thread.abort_on_exception
|
13
|
+
Thread.abort_on_exception = true
|
14
|
+
end
|
15
|
+
|
16
|
+
def teardown
|
17
|
+
Thread.abort_on_exception = @thread_abort
|
18
|
+
super
|
12
19
|
end
|
13
20
|
|
14
21
|
def _test_request
|
15
|
-
|
16
|
-
|
22
|
+
server = Server.new(@db_path, @empty_cluster_file, @server_port)
|
23
|
+
server_thread = Thread.new do
|
24
|
+
server.serve_loop
|
17
25
|
end
|
18
|
-
sleep 0.1
|
26
|
+
Kernel.sleep 0.1 # Wait for the server to start.
|
19
27
|
yield "localhost:#{@server_port}"
|
20
28
|
Client.shutdown_server "localhost:#{@server_port}"
|
29
|
+
server_thread.join
|
30
|
+
Kernel.sleep 0.1 # Wait for the server to cleanup after itself.
|
21
31
|
end
|
22
32
|
|
23
33
|
def test_fetch_item
|
@@ -28,7 +38,6 @@ class ClientServerTest < MrTestCase
|
|
28
38
|
end
|
29
39
|
|
30
40
|
def test_dump_database
|
31
|
-
@server_port = 29557
|
32
41
|
_test_request do |server_addr|
|
33
42
|
items = Client.dump_database server_addr
|
34
43
|
assert_equal @db.length, items.length, 'Wrong number of items'
|
@@ -39,7 +48,6 @@ class ClientServerTest < MrTestCase
|
|
39
48
|
end
|
40
49
|
|
41
50
|
def test_query
|
42
|
-
@server_port = 29551
|
43
51
|
flexmock(Server).should_receive(:tems_from_cluster_file).
|
44
52
|
with(@empty_cluster_file).and_return do |file|
|
45
53
|
Tem.auto_conf
|
@@ -6,14 +6,17 @@ class MapReduceExecutorTest < MrTestCase
|
|
6
6
|
def setup
|
7
7
|
super
|
8
8
|
Tem.auto_conf
|
9
|
-
$tem.activate
|
10
|
-
|
9
|
+
$tem.emit if $tem.activate
|
10
|
+
@thread_abort = Thread.abort_on_exception
|
11
|
+
Thread.abort_on_exception = true
|
11
12
|
end
|
12
13
|
|
13
14
|
def teardown
|
15
|
+
Thread.abort_on_exception = @thread_abort
|
14
16
|
$tem.disconnect
|
17
|
+
super
|
15
18
|
end
|
16
|
-
|
19
|
+
|
17
20
|
def _test_executor(tems, root_tem)
|
18
21
|
executor = MRExecutor.new @client_query, @db, tems, root_tem
|
19
22
|
packed_output = executor.execute
|
@@ -33,7 +36,7 @@ class MapReduceExecutorTest < MrTestCase
|
|
33
36
|
tems = Tem::Mr::Search::Server.tems_from_cluster_file @cluster_file
|
34
37
|
assert_equal 8, tems.length, 'Incorrect cluster setup'
|
35
38
|
|
36
|
-
tems.each { |tem| tem.
|
39
|
+
tems.each { |tem| tem.emit if tem.activate }
|
37
40
|
|
38
41
|
_test_executor tems, 0
|
39
42
|
end
|
data/testdata/cluster.yml
CHANGED
@@ -1,3 +1,3 @@
|
|
1
1
|
---
|
2
|
-
- darkbulb2.
|
3
|
-
- lightbulb2.
|
2
|
+
- darkbulb2.csail.mit.edu
|
3
|
+
- lightbulb2.csail.mit.edu
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tem_mr_search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Victor Costan
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-11-11 00:00:00 -05:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -20,7 +20,7 @@ dependencies:
|
|
20
20
|
requirements:
|
21
21
|
- - ">="
|
22
22
|
- !ruby/object:Gem::Version
|
23
|
-
version: 0.
|
23
|
+
version: 0.13.0
|
24
24
|
version:
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: tem_multi_proxy
|
@@ -30,7 +30,7 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.2.6
|
34
34
|
version:
|
35
35
|
description: "Tem Map-Reduce proof of concept: database search."
|
36
36
|
email: victor@costan.us
|
@@ -120,9 +120,9 @@ signing_key:
|
|
120
120
|
specification_version: 3
|
121
121
|
summary: "Tem Map-Reduce proof of concept: database search."
|
122
122
|
test_files:
|
123
|
+
- test/test_query_builders.rb
|
124
|
+
- test/test_map_reduce_job.rb
|
123
125
|
- test/test_client_server.rb
|
126
|
+
- test/test_map_reduce_planner.rb
|
124
127
|
- test/test_db.rb
|
125
128
|
- test/test_map_reduce_executor.rb
|
126
|
-
- test/test_map_reduce_job.rb
|
127
|
-
- test/test_map_reduce_planner.rb
|
128
|
-
- test/test_query_builders.rb
|