dynflow 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 66a2413a7e81c765f74aa9ccde49270529b1edb9a664ec52a930993e285de290
4
- data.tar.gz: fc2a618ac8d3b6959d3c01945568c2a5e6d0cb27103a46faca41dd65a50e27e4
3
+ metadata.gz: '00091e6971f6c6bbcc56f3a03564b2de6f437db1985375caa2171d3f9859a0f7'
4
+ data.tar.gz: e48ae6152594e70147b362b1e7ae4b0923cc645d38005af56b69c9e6f1cd5a31
5
5
  SHA512:
6
- metadata.gz: 1c24fb1c72d23721664cc05823bbc0fe10638fbfa9f1956c68b859e6587c6c8a7c297b20a2427e4b75d1b540812b7e5370a34b5c8966d74398dea2f0607b6c0a
7
- data.tar.gz: 0bba53b0d9f4327d86d03058e68856a7f7e4b9d64dd07c45e511bd71a7d232a566be7a5e7bfe52d3ce20aca758702f06530ba8faf4ae78826b5b85aa65b7cc6e
6
+ metadata.gz: e00b1eb7cf2bd103fe79d8a0e3046143f77548c380b2504b4fc3093b5c4a4929160f704f781e0565eacefb7cf493bd7b5ec6a8f5c2a5b0490e3f521285513a73
7
+ data.tar.gz: 1d3aef7335990a1ff72fecd0b36bb444227f0f216aaf44677d66d453a8d29b470a58e7d2ccee4349ba341a12a4ca14306d6d4c5167f5ac7e375c36fed19362cd
data/.travis.yml CHANGED
@@ -2,6 +2,11 @@ sudo: false
2
2
  language:
3
3
  - ruby
4
4
 
5
+ before_install: >-
6
+ if ruby -v | grep 'ruby 2.2'; then
7
+ gem install bundler -v '~> 1.17'
8
+ fi
9
+
5
10
  rvm:
6
11
  - "2.2.2"
7
12
  - "2.3.1"
@@ -197,7 +197,6 @@ module Dynflow
197
197
  end
198
198
 
199
199
  def action_logger
200
- phase! Executable
201
200
  world.action_logger
202
201
  end
203
202
 
@@ -12,6 +12,7 @@ module Dynflow
12
12
  yield
13
13
  ensure
14
14
  ::ActiveRecord::Base.clear_active_connections! if clear_connections
15
+ ::Logging.mdc.clear if defined? ::Logging
15
16
  end
16
17
 
17
18
  end
@@ -4,19 +4,15 @@ module Dynflow
4
4
  class Pool < Actor
5
5
  class JobStorage
6
6
  def initialize
7
- @round_robin = RoundRobin.new
8
- @jobs = Hash.new { |h, k| h[k] = [] }
7
+ @jobs = []
9
8
  end
10
9
 
11
10
  def add(work)
12
- @round_robin.add work.execution_plan_id unless tracked?(work)
13
- @jobs[work.execution_plan_id] << work
11
+ @jobs << work
14
12
  end
15
13
 
16
14
  def pop
17
- return nil if empty?
18
- execution_plan_id = @round_robin.next
19
- @jobs[execution_plan_id].shift.tap { delete execution_plan_id if @jobs[execution_plan_id].empty? }
15
+ @jobs.shift
20
16
  end
21
17
 
22
18
  def queue_size
@@ -27,27 +23,15 @@ module Dynflow
27
23
  @jobs.empty?
28
24
  end
29
25
 
30
- def execution_status(execution_plan_id = nil)
31
- source = if execution_plan_id.nil?
32
- @jobs
33
- else
34
- { execution_plan_id => @jobs.fetch(execution_plan_id, []) }
35
- end
36
- source.reduce({}) do |acc, (plan_id, work_items)|
37
- acc.update(plan_id => work_items.count)
26
+ def queue_size(execution_plan_id = nil)
27
+ if execution_plan_id
28
+ @jobs.count do |item|
29
+ item.respond_to?(:execution_plan_id) && item.execution_plan_id == execution_plan_id
30
+ end
31
+ else
32
+ @jobs.size
38
33
  end
39
34
  end
40
-
41
- private
42
-
43
- def tracked?(work)
44
- @jobs.has_key? work.execution_plan_id
45
- end
46
-
47
- def delete(execution_plan_id)
48
- @round_robin.delete execution_plan_id
49
- @jobs.delete execution_plan_id
50
- end
51
35
  end
52
36
 
53
37
  def initialize(world, core, name, pool_size, transaction_adapter)
@@ -89,7 +73,7 @@ module Dynflow
89
73
  def execution_status(execution_plan_id = nil)
90
74
  { :pool_size => @pool_size,
91
75
  :free_workers => @free_workers.count,
92
- :execution_status => @jobs.execution_status(execution_plan_id) }
76
+ :queue_size => @jobs.queue_size(execution_plan_id) }
93
77
  end
94
78
 
95
79
  private
@@ -1,3 +1,3 @@
1
1
  module Dynflow
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
@@ -41,9 +41,6 @@ module Dynflow
41
41
  load_worlds
42
42
  @executors.each do |w|
43
43
  hash = world.get_execution_status(w.data['id'], nil, 5).value!
44
- hash.each do |_queue_name, info|
45
- info[:queue_size] = info[:execution_status].values.reduce(:+) || 0
46
- end
47
44
  w.data.update(:status => hash)
48
45
  end
49
46
  erb :worlds
@@ -594,12 +594,12 @@ module Dynflow
594
594
  let(:storage) { Dynflow::Executors::Parallel::Pool::JobStorage.new }
595
595
  it do
596
596
  storage.must_be_empty
597
- storage.execution_status.must_equal({})
597
+ storage.queue_size.must_equal(0)
598
598
  storage.pop.must_be_nil
599
599
  storage.pop.must_be_nil
600
600
 
601
601
  storage.add s = FakeStep.new(1)
602
- storage.execution_status.must_equal(1 => 1)
602
+ storage.queue_size.must_equal(1)
603
603
  storage.pop.must_equal s
604
604
  storage.must_be_empty
605
605
  storage.pop.must_be_nil
@@ -611,19 +611,19 @@ module Dynflow
611
611
  storage.add s22 = FakeStep.new(2)
612
612
  storage.add s31 = FakeStep.new(3)
613
613
 
614
- storage.execution_status(1).must_equal(1 => 3)
615
- storage.execution_status(4).must_equal(4 => 0)
616
- storage.execution_status.must_equal({1 => 3, 2 => 2, 3 => 1})
614
+ storage.queue_size(1).must_equal(3)
615
+ storage.queue_size(4).must_equal(0)
616
+ storage.queue_size.must_equal(6)
617
617
 
618
- storage.pop.must_equal s21
619
- storage.pop.must_equal s31
620
618
  storage.pop.must_equal s11
621
- storage.pop.must_equal s22
622
619
  storage.pop.must_equal s12
623
620
  storage.pop.must_equal s13
621
+ storage.pop.must_equal s21
622
+ storage.pop.must_equal s22
623
+ storage.pop.must_equal s31
624
624
 
625
625
  storage.must_be_empty
626
- storage.execution_status.must_equal({})
626
+ storage.queue_size.must_equal(0)
627
627
  storage.pop.must_be_nil
628
628
  end
629
629
  end
data/test/world_test.rb CHANGED
@@ -24,16 +24,16 @@ module Dynflow
24
24
 
25
25
  describe '#get_execution_status' do
26
26
  let(:base) do
27
- { :default => { :pool_size => 5, :free_workers => 5, :execution_status => {} },
28
- :slow => { :pool_size=> 1, :free_workers=> 1, :execution_status=> {}} }
27
+ { :default => { :pool_size => 5, :free_workers => 5, :queue_size => 0 },
28
+ :slow => { :pool_size=> 1, :free_workers=> 1, :queue_size => 0} }
29
29
  end
30
30
 
31
31
  it 'retrieves correct execution items count' do
32
32
  world.get_execution_status(world.id, nil, 5).value!.must_equal(base)
33
33
  id = 'something like uuid'
34
34
  expected = base.dup
35
- expected[:default][:execution_status] = { id => 0 }
36
- expected[:slow][:execution_status] = { id => 0 }
35
+ expected[:default][:queue_size] = 0
36
+ expected[:slow][:queue_size] = 0
37
37
  world.get_execution_status(world.id, id, 5).value!.must_equal(expected)
38
38
  end
39
39
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynflow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ivan Necas
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-03 00:00:00.000000000 Z
12
+ date: 2019-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: multi_json