disbatch 0.0.9 → 0.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/disbatchd +3 -3
- data/lib/disbatch.rb +7 -1
- data/lib/disbatch/error.rb +7 -3
- data/lib/disbatch/plugin.rb +10 -5
- data/lib/disbatch/queue.rb +14 -0
- data/lib/disbatch/task.rb +5 -3
- metadata +3 -5
data/bin/disbatchd
CHANGED
@@ -46,13 +46,13 @@ def update_queues
|
|
46
46
|
next if @runners.has_key?(queue.id)
|
47
47
|
|
48
48
|
# node configured to ignore
|
49
|
-
|
49
|
+
next if queue.nodes_ignore.include?(Disbatch.node_id)
|
50
50
|
|
51
51
|
# node pinned but not on this node
|
52
|
-
|
52
|
+
next if !queue.nodes_pin.empty? && !queue.nodes_pin.include?(Disbatch.node_id)
|
53
53
|
|
54
54
|
# no plugin for queue
|
55
|
-
next unless Disbatch::Plugin
|
55
|
+
next unless Disbatch::Plugin.exists?(queue.plugin)
|
56
56
|
|
57
57
|
puts "Adding #{queue.plugin} runner for #{queue.id}"
|
58
58
|
|
data/lib/disbatch.rb
CHANGED
@@ -30,7 +30,13 @@ module Disbatch
|
|
30
30
|
|
31
31
|
# Return and cache the MongoDB connection pool
|
32
32
|
def db
|
33
|
-
|
33
|
+
begin
|
34
|
+
@db ||= Mongo::Connection.new(@mongo_host, @mongo_port).db(@mongo_db)
|
35
|
+
rescue
|
36
|
+
raise Disbatch::NoDatabaseError
|
37
|
+
end
|
38
|
+
|
39
|
+
@db
|
34
40
|
end
|
35
41
|
|
36
42
|
# Return and cache the local node object
|
data/lib/disbatch/error.rb
CHANGED
@@ -15,10 +15,14 @@ module Disbatch
|
|
15
15
|
# Raised when specifying a non-existant plugin
|
16
16
|
class NoPluginError < RuntimeError; end
|
17
17
|
|
18
|
-
# Raised when
|
19
|
-
class
|
18
|
+
# Raised when failing to load a plugin
|
19
|
+
class FailedLoadPluginError < RuntimeError; end
|
20
20
|
|
21
|
-
# Raised when specifying a non-
|
21
|
+
# Raised when specifying a non-existant plugin
|
22
22
|
class NoQueueError < RuntimeError; end
|
23
23
|
|
24
|
+
# Raised on failure to connect or open mongo
|
25
|
+
class NoDatabaseError < RuntimeError; end
|
26
|
+
|
24
27
|
end
|
28
|
+
|
data/lib/disbatch/plugin.rb
CHANGED
@@ -20,18 +20,23 @@ module Disbatch::Plugin
|
|
20
20
|
@plugins[name]
|
21
21
|
end
|
22
22
|
|
23
|
+
# Check for existance of plugin
|
24
|
+
def exists?(name)
|
25
|
+
@plugins.has_key?(name)
|
26
|
+
end
|
27
|
+
|
23
28
|
# Attempt to load a plugin file
|
24
29
|
def init(file)
|
25
30
|
begin
|
26
31
|
load file
|
27
|
-
rescue
|
28
|
-
|
32
|
+
rescue => e
|
33
|
+
raise Disbatch::FailedLoadPluginError, file
|
29
34
|
end
|
30
35
|
end
|
31
36
|
|
32
|
-
# Attempt to load all plugin files
|
33
|
-
def init_all(
|
34
|
-
Dir[
|
37
|
+
# Attempt to load all plugin files matched by a glob
|
38
|
+
def init_all(glob)
|
39
|
+
Dir[glob].each { |file| init(file) }
|
35
40
|
end
|
36
41
|
|
37
42
|
extend self
|
data/lib/disbatch/queue.rb
CHANGED
@@ -25,6 +25,8 @@ class Disbatch::Queue
|
|
25
25
|
end
|
26
26
|
|
27
27
|
raise Disbatch::NoQueueError if doc.nil?
|
28
|
+
|
29
|
+
new(doc['class'], doc['_id'])
|
28
30
|
end
|
29
31
|
|
30
32
|
# Get all existing queues
|
@@ -85,6 +87,18 @@ class Disbatch::Queue
|
|
85
87
|
Disbatch::Task.take(self)
|
86
88
|
end
|
87
89
|
|
90
|
+
def nodes_pin
|
91
|
+
doc = Disbatch.db[:queues].find_one({:_id => self.id}, {:fields=> [ :nodes_pin ] })
|
92
|
+
|
93
|
+
return doc['nodes_pin'] || []
|
94
|
+
end
|
95
|
+
|
96
|
+
def nodes_ignore
|
97
|
+
doc = Disbatch.db[:queues].find_one({:_id => self.id}, {:fields=> [ :nodes_ignore ] })
|
98
|
+
|
99
|
+
return doc['nodes_ignore'] || []
|
100
|
+
end
|
101
|
+
|
88
102
|
# Check equality with another queue object
|
89
103
|
#
|
90
104
|
# @param[Disbatch::Queue] queue another queue to compare against
|
data/lib/disbatch/task.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Represents a Disbatch task
|
2
2
|
class Disbatch::Task
|
3
3
|
|
4
|
+
require 'pp'
|
5
|
+
|
4
6
|
attr_reader :queue, :parameters, :id
|
5
7
|
|
6
8
|
private_class_method :new
|
@@ -126,17 +128,17 @@ class Disbatch::Task
|
|
126
128
|
|
127
129
|
# Fail task
|
128
130
|
def fail
|
129
|
-
self.status
|
131
|
+
self.status=Status::TERMINATED
|
130
132
|
end
|
131
133
|
|
132
134
|
# Release task
|
133
135
|
def release
|
134
|
-
self.status
|
136
|
+
self.status=Status::CREATED
|
135
137
|
end
|
136
138
|
|
137
139
|
# Conclude task
|
138
140
|
def conclude
|
139
|
-
self.status=
|
141
|
+
self.status=Status::CONCLUDED
|
140
142
|
end
|
141
143
|
|
142
144
|
# Execute the task
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: disbatch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.0.
|
5
|
+
version: 0.0.10
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Matthew Berg
|
@@ -10,8 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2012-
|
14
|
-
default_executable:
|
13
|
+
date: 2012-06-29 00:00:00 Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: bson
|
@@ -115,7 +114,6 @@ files:
|
|
115
114
|
- README
|
116
115
|
- LICENSE
|
117
116
|
- disbatch_specification.txt
|
118
|
-
has_rdoc: true
|
119
117
|
homepage: http://disbatch.org/projects/disbatch-ruby
|
120
118
|
licenses: []
|
121
119
|
|
@@ -139,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
139
137
|
requirements: []
|
140
138
|
|
141
139
|
rubyforge_project:
|
142
|
-
rubygems_version: 1.
|
140
|
+
rubygems_version: 1.8.24
|
143
141
|
signing_key:
|
144
142
|
specification_version: 3
|
145
143
|
summary: Distributed batch processing package
|