rukawa 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -1
- data/README.md +3 -0
- data/lib/rukawa/context.rb +5 -4
- data/lib/rukawa/job.rb +10 -10
- data/lib/rukawa/job_net.rb +2 -1
- data/lib/rukawa/overview.rb +14 -3
- data/lib/rukawa/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8087ac19883cd6f2ab570ab99494db140cd86670
|
4
|
+
data.tar.gz: 4b86cea0a91ba32c838a7b80fc7b6f7dc2334666
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 074ca450e282d2a63198f357df4f0fb1b5c694c04734dea25b23ceb4ca4b8f5e7e5bb90807950ebc2b95c562a08503fa5af8627b61bd37fa266d15aa0223dbb3
|
7
|
+
data.tar.gz: 4847ee20b6163067927180c183ee4f98686f35a8e86375d7035612f04d1dbfdb11ca549dac16c2f6ef2775c1211f48a53f670ded8ba067fd6e59c04d1fa47367
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -279,6 +279,9 @@ end
|
|
279
279
|
This job use 2 concurrency. (this does not means that job use 2 threads)
|
280
280
|
If concurrency is less than jobs's resource count, resource count is set concurrency size.
|
281
281
|
|
282
|
+
You can set 0 to resource count.
|
283
|
+
If a job is set 0 resource, concurrency of the job is unlimited.
|
284
|
+
|
282
285
|
### Callback
|
283
286
|
|
284
287
|
- before\_run
|
data/lib/rukawa/context.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Rukawa
|
2
2
|
class Context
|
3
|
-
attr_reader :store, :executor, :semaphore
|
3
|
+
attr_reader :store, :executor, :semaphore, :concurrency
|
4
4
|
|
5
|
-
def initialize(
|
5
|
+
def initialize(concurrency = nil)
|
6
|
+
@concurrency = concurrency || Rukawa.config.concurrency
|
6
7
|
@store = Concurrent::Hash.new
|
7
|
-
@executor = Concurrent::
|
8
|
+
@executor = Concurrent::CachedThreadPool.new
|
8
9
|
@executor.auto_terminate = true
|
9
|
-
@semaphore = Concurrent::Semaphore.new(
|
10
|
+
@semaphore = Concurrent::Semaphore.new(@concurrency)
|
10
11
|
end
|
11
12
|
|
12
13
|
def shutdown
|
data/lib/rukawa/job.rb
CHANGED
@@ -72,8 +72,6 @@ module Rukawa
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
around_run :acquire_resource
|
76
|
-
|
77
75
|
around_run do |_, blk|
|
78
76
|
Rukawa.logger.info("Start #{self.class}")
|
79
77
|
blk.call
|
@@ -114,8 +112,10 @@ module Rukawa
|
|
114
112
|
return @dataflow = bypass_dataflow if @state.bypassed?
|
115
113
|
|
116
114
|
@dataflow = Concurrent.dataflow_with(@context.executor, *depend_dataflows) do |*results|
|
117
|
-
|
118
|
-
|
115
|
+
acquire_resource do
|
116
|
+
do_run(*results)
|
117
|
+
@state
|
118
|
+
end
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
@@ -156,6 +156,10 @@ module Rukawa
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
159
|
+
def resource_count
|
160
|
+
[self.class.resource_count, Rukawa.config.concurrency].min
|
161
|
+
end
|
162
|
+
|
159
163
|
private
|
160
164
|
|
161
165
|
def depend_dataflows
|
@@ -214,15 +218,11 @@ module Rukawa
|
|
214
218
|
@context.store[self.class][key] = value
|
215
219
|
end
|
216
220
|
|
217
|
-
def resource_count
|
218
|
-
[self.class.resource_count, Rukawa.config.concurrency].min
|
219
|
-
end
|
220
|
-
|
221
221
|
def acquire_resource
|
222
|
-
@context.semaphore.acquire(resource_count)
|
222
|
+
@context.semaphore.acquire(resource_count) if resource_count > 0
|
223
223
|
yield
|
224
224
|
ensure
|
225
|
-
@context.semaphore.release(resource_count)
|
225
|
+
@context.semaphore.release(resource_count) if resource_count > 0
|
226
226
|
end
|
227
227
|
end
|
228
228
|
end
|
data/lib/rukawa/job_net.rb
CHANGED
@@ -3,7 +3,7 @@ require 'rukawa/abstract_job'
|
|
3
3
|
module Rukawa
|
4
4
|
class JobNet < AbstractJob
|
5
5
|
include Enumerable
|
6
|
-
attr_reader :dag, :context
|
6
|
+
attr_reader :dag, :context, :variables
|
7
7
|
|
8
8
|
class << self
|
9
9
|
def dependencies
|
@@ -13,6 +13,7 @@ module Rukawa
|
|
13
13
|
|
14
14
|
def initialize(parent_job_net, variables, context, *resume_job_classes)
|
15
15
|
@parent_job_net = parent_job_net
|
16
|
+
@variables = variables
|
16
17
|
@context = context
|
17
18
|
@dag = Dag.new
|
18
19
|
@dag.build(self, variables, context, self.class.dependencies)
|
data/lib/rukawa/overview.rb
CHANGED
@@ -35,7 +35,13 @@ module Rukawa
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def display_running_status(root_job_net)
|
38
|
-
|
38
|
+
context = root_job_net.context
|
39
|
+
table = Terminal::Table.new(headings: [
|
40
|
+
"Job",
|
41
|
+
"Status",
|
42
|
+
"Elapsed Time",
|
43
|
+
"Resource Count (#{context.semaphore.available_permits}/#{context.concurrency})",
|
44
|
+
]) do |t|
|
39
45
|
root_job_net.each_with_index do |j|
|
40
46
|
running_table_row(t, j)
|
41
47
|
end
|
@@ -45,12 +51,17 @@ module Rukawa
|
|
45
51
|
|
46
52
|
def running_table_row(table, job, level = 0)
|
47
53
|
if job.is_a?(JobNet)
|
48
|
-
table << [
|
54
|
+
table << [
|
55
|
+
Paint["#{" " * level}#{job.class}", :bold, :underline],
|
56
|
+
Paint[job.state.colored, :bold, :underline],
|
57
|
+
Paint[job.formatted_elapsed_time_from, :bold, :underline],
|
58
|
+
"",
|
59
|
+
]
|
49
60
|
job.each do |inner_j|
|
50
61
|
running_table_row(table, inner_j, level + 1)
|
51
62
|
end
|
52
63
|
else
|
53
|
-
table << [Paint["#{" " * level}#{job.class}", :bold], job.state.colored, job.formatted_elapsed_time_from]
|
64
|
+
table << [Paint["#{" " * level}#{job.class}", :bold], job.state.colored, job.formatted_elapsed_time_from, job.resource_count]
|
54
65
|
end
|
55
66
|
end
|
56
67
|
end
|
data/lib/rukawa/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rukawa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- joker1007
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -209,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
209
|
version: '0'
|
210
210
|
requirements: []
|
211
211
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.
|
212
|
+
rubygems_version: 2.6.4
|
213
213
|
signing_key:
|
214
214
|
specification_version: 4
|
215
215
|
summary: Hyper simple job workflow engine
|