tengine_job 0.6.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +23 -0
- data/Gemfile.lock +109 -0
- data/README.rdoc +20 -0
- data/Rakefile +42 -0
- data/VERSION +1 -0
- data/examples/0004_retry_one_layer.rb +24 -0
- data/examples/0004_retry_one_layer.sh +38 -0
- data/examples/0005_retry_two_layer.rb +54 -0
- data/examples/0005_retry_two_layer.sh +80 -0
- data/examples/0006_retry_three_layer.rb +58 -0
- data/examples/0006_retry_three_layer.sh +74 -0
- data/examples/0007_simple_jobnet.rb +7 -0
- data/examples/0021_dynamic_env.rb +20 -0
- data/examples/VERSION +1 -0
- data/examples/tengine_job_test.sh +10 -0
- data/lib/tengine/job.rb +94 -0
- data/lib/tengine/job/category.rb +54 -0
- data/lib/tengine/job/connectable.rb +43 -0
- data/lib/tengine/job/drivers/job_control_driver.rb +82 -0
- data/lib/tengine/job/drivers/job_execution_driver.rb +30 -0
- data/lib/tengine/job/drivers/jobnet_control_driver.rb +117 -0
- data/lib/tengine/job/drivers/schedule_driver.rb +30 -0
- data/lib/tengine/job/dsl_binder.rb +12 -0
- data/lib/tengine/job/dsl_evaluator.rb +18 -0
- data/lib/tengine/job/dsl_loader.rb +180 -0
- data/lib/tengine/job/edge.rb +150 -0
- data/lib/tengine/job/element_selector_notation.rb +169 -0
- data/lib/tengine/job/end.rb +32 -0
- data/lib/tengine/job/executable.rb +74 -0
- data/lib/tengine/job/execution.rb +141 -0
- data/lib/tengine/job/expansion.rb +37 -0
- data/lib/tengine/job/fork.rb +6 -0
- data/lib/tengine/job/job.rb +23 -0
- data/lib/tengine/job/jobnet.rb +173 -0
- data/lib/tengine/job/jobnet/builder.rb +150 -0
- data/lib/tengine/job/jobnet/job_state_transition.rb +167 -0
- data/lib/tengine/job/jobnet/jobnet_state_transition.rb +110 -0
- data/lib/tengine/job/jobnet/state_transition.rb +37 -0
- data/lib/tengine/job/jobnet_actual.rb +55 -0
- data/lib/tengine/job/jobnet_template.rb +10 -0
- data/lib/tengine/job/join.rb +6 -0
- data/lib/tengine/job/junction.rb +29 -0
- data/lib/tengine/job/killing.rb +30 -0
- data/lib/tengine/job/mm_compatibility.rb +6 -0
- data/lib/tengine/job/mm_compatibility/connectable.rb +13 -0
- data/lib/tengine/job/name_path.rb +31 -0
- data/lib/tengine/job/root.rb +16 -0
- data/lib/tengine/job/root_jobnet_actual.rb +39 -0
- data/lib/tengine/job/root_jobnet_template.rb +49 -0
- data/lib/tengine/job/script_executable.rb +235 -0
- data/lib/tengine/job/signal.rb +121 -0
- data/lib/tengine/job/start.rb +20 -0
- data/lib/tengine/job/stoppable.rb +15 -0
- data/lib/tengine/job/vertex.rb +172 -0
- data/lib/tengine_job.rb +3 -0
- data/spec/fixtures/rjn_0001_simple_jobnet_builder.rb +42 -0
- data/spec/fixtures/rjn_0002_simple_parallel_jobnet_builder.rb +42 -0
- data/spec/fixtures/rjn_0003_fork_join_jobnet_builder.rb +61 -0
- data/spec/fixtures/rjn_0004_parallel_jobnet_with_finally_fixture.rb +62 -0
- data/spec/fixtures/rjn_0005_retry_two_layer_fixture.rb +153 -0
- data/spec/fixtures/rjn_0008_expansion_fixture.rb +32 -0
- data/spec/fixtures/rjn_0009_tree_sequential_jobnet_builder.rb +174 -0
- data/spec/fixtures/rjn_0010_2jobs_and_1job_parallel_jobnet_builder.rb +39 -0
- data/spec/fixtures/rjn_0011_nested_fork_jobnet_builder.rb +96 -0
- data/spec/fixtures/rjn_0012_nested_and_finally_builder.rb +157 -0
- data/spec/fixtures/rjn_1004_hadoop_job_in_jobnet_fixture.rb +105 -0
- data/spec/fixtures/rjn_means_root_jobnet +0 -0
- data/spec/fixtures/test_credential_fixture.rb +12 -0
- data/spec/fixtures/test_server_fixture.rb +28 -0
- data/spec/mongoid.yml +35 -0
- data/spec/spec_helper.rb +56 -0
- data/spec/sshd/.gitignore +1 -0
- data/spec/sshd/id_rsa +51 -0
- data/spec/sshd/id_rsa.pub +1 -0
- data/spec/sshd/ssh_host_rsa_key +51 -0
- data/spec/sshd/ssh_host_rsa_key.pub +1 -0
- data/spec/sshd/sshd_config +10 -0
- data/spec/sshd/sshd_config.erb +11 -0
- data/spec/sshd/tengine_job_test.sh +6 -0
- data/spec/support/jobnet_fixture_builder.rb +145 -0
- data/spec/support/mongo_index_key_log.rb +91 -0
- data/spec/tengine/job/category_spec.rb +193 -0
- data/spec/tengine/job/connectable_spec.rb +94 -0
- data/spec/tengine/job/drivers/job_controll_driver/connection_error_spec.rb +236 -0
- data/spec/tengine/job/drivers/job_controll_driver/duplicated_job_start_spec.rb +302 -0
- data/spec/tengine/job/drivers/job_controll_driver/expansion_spec.rb +120 -0
- data/spec/tengine/job/drivers/job_controll_driver/stop_spec.rb +159 -0
- data/spec/tengine/job/drivers/job_controll_driver_spec.rb +623 -0
- data/spec/tengine/job/drivers/job_execution_driver_spec.rb +88 -0
- data/spec/tengine/job/drivers/jobnet_control_driver/nested_and_finally_spec.rb +472 -0
- data/spec/tengine/job/drivers/jobnet_control_driver/nested_jobnet_spec.rb +231 -0
- data/spec/tengine/job/drivers/jobnet_control_driver/stop_jobnet_spec.rb +202 -0
- data/spec/tengine/job/drivers/jobnet_control_driver_spec.rb +446 -0
- data/spec/tengine/job/drivers/schedule_driver_spec.rb +202 -0
- data/spec/tengine/job/dsl_binder_spec.rb +36 -0
- data/spec/tengine/job/dsl_loader_spec.rb +403 -0
- data/spec/tengine/job/dsls/0013_hadoop_job_run.rb +29 -0
- data/spec/tengine/job/dsls/0014_join_and_join.rb +19 -0
- data/spec/tengine/job/dsls/0015_fork_and_fork.rb +18 -0
- data/spec/tengine/job/dsls/0016_complex_fork_and_join.rb +20 -0
- data/spec/tengine/job/dsls/0017_finally.rb +15 -0
- data/spec/tengine/job/dsls/0018_expansion.rb +23 -0
- data/spec/tengine/job/dsls/0019_execute_job_on_event.rb +16 -0
- data/spec/tengine/job/dsls/0020_duplicated_jobnet_name.rb +16 -0
- data/spec/tengine/job/dsls/1060_test_dir1/1060_test_dir2/0013_hadoop_job_run.rb +29 -0
- data/spec/tengine/job/dsls/2003_expansion/expansion_5.rb +11 -0
- data/spec/tengine/job/dsls/VERSION +1 -0
- data/spec/tengine/job/dynamic_env_spec.rb +95 -0
- data/spec/tengine/job/edge_spec.rb +241 -0
- data/spec/tengine/job/element_selector_notation_spec.rb +354 -0
- data/spec/tengine/job/examples_spec.rb +62 -0
- data/spec/tengine/job/execution_spec.rb +100 -0
- data/spec/tengine/job/expansion_spec.rb +116 -0
- data/spec/tengine/job/hadoop_job_run_spec.rb +65 -0
- data/spec/tengine/job/job_spec.rb +4 -0
- data/spec/tengine/job/jobnet/1015_complecated_jobnet_spec.rb +72 -0
- data/spec/tengine/job/jobnet_actual_spec.rb +175 -0
- data/spec/tengine/job/jobnet_spec.rb +399 -0
- data/spec/tengine/job/jobnet_template_spec.rb +240 -0
- data/spec/tengine/job/killing_spec.rb +91 -0
- data/spec/tengine/job/reset_spec.rb +958 -0
- data/spec/tengine/job/reset_spec/4056_1_dump.txt +1 -0
- data/spec/tengine/job/root_jobnet_actual_spec.rb +89 -0
- data/spec/tengine/job/root_jobnet_template_spec.rb +248 -0
- data/spec/tengine/job/script_executable_spec.rb +132 -0
- data/spec/tengine/job/stoppable_spec.rb +176 -0
- data/spec/tengine/job/vertex_spec.rb +25 -0
- data/spec/tengine_job_spec.rb +4 -0
- data/tengine_job.gemspec +197 -0
- data/tmp/log/.gitignore +1 -0
- metadata +296 -0
@@ -0,0 +1,121 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/job'
|
3
|
+
|
4
|
+
class Tengine::Job::Signal
|
5
|
+
|
6
|
+
class Error < StandardError
|
7
|
+
end
|
8
|
+
|
9
|
+
attr_reader :paths, :reservations, :event
|
10
|
+
|
11
|
+
# @attribute 受け渡しのためにデータを一時的に保持する属性。
|
12
|
+
# 現時点ではジョブのrunからackを返す際にPIDを保持するために使用します。
|
13
|
+
attr_accessor :data
|
14
|
+
|
15
|
+
# start.job.job.tengineイベントによって
|
16
|
+
# ジョブは :ready -> :starting -> :running に遷移するが、
|
17
|
+
# 一度のroot_jobnet.update_with_lock では :starting が保存されないので、
|
18
|
+
# 2回のroot_jobnet.update_with_lock に分けることができるようにするための
|
19
|
+
# 処理を記憶しておく属性です
|
20
|
+
attr_accessor :callback
|
21
|
+
|
22
|
+
def initialize(event)
|
23
|
+
@event = event
|
24
|
+
reset
|
25
|
+
end
|
26
|
+
|
27
|
+
def reset
|
28
|
+
@paths = []
|
29
|
+
@reservations = []
|
30
|
+
@data = nil
|
31
|
+
@callback = nil
|
32
|
+
end
|
33
|
+
|
34
|
+
def execution
|
35
|
+
@execution ||= Tengine::Job::Execution.find(event[:execution_id])
|
36
|
+
end
|
37
|
+
|
38
|
+
def leave(obj, action = :transmit)
|
39
|
+
@paths << obj
|
40
|
+
begin
|
41
|
+
if obj.is_a?(Tengine::Job::Edge)
|
42
|
+
obj.destination.send(action, self)
|
43
|
+
elsif obj.is_a?(Tengine::Job::Vertex)
|
44
|
+
obj.next_edges.each do |edge|
|
45
|
+
with_paths_backup{ edge.send(action, self) }
|
46
|
+
end
|
47
|
+
else
|
48
|
+
raise Tengine::Job::Signal::Error, "leaving unsupported object: #{obj.inspect}"
|
49
|
+
end
|
50
|
+
rescue Tengine::Job::Signal::Error => e
|
51
|
+
puts "[#{e.class.name}] #{e.message}\nsignal.paths: #{@paths.inspect}"
|
52
|
+
raise e
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def with_paths_backup
|
57
|
+
paths_backup = @paths.dup
|
58
|
+
begin
|
59
|
+
yield if block_given?
|
60
|
+
ensure
|
61
|
+
@paths = paths_backup
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
class Reservation
|
66
|
+
attr_reader :source, :event_type_name, :options
|
67
|
+
def initialize(source, event_type_name, options = {})
|
68
|
+
@source, @event_type_name = source, event_type_name
|
69
|
+
@options = options
|
70
|
+
@options[:source_name] ||= source.name_as_resource
|
71
|
+
end
|
72
|
+
|
73
|
+
def fire_args
|
74
|
+
[@event_type_name, @options]
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def fire(source, event_type_name, properties = {}, options = {})
|
79
|
+
case source
|
80
|
+
when Tengine::Job::Execution then
|
81
|
+
properties[:execution_id] ||= source.id.to_s
|
82
|
+
properties[:root_jobnet_id] ||= source.root_jobnet.id.to_s
|
83
|
+
properties[:root_jobnet_name_path] ||= source.root_jobnet.name_path
|
84
|
+
properties[:target_jobnet_id] ||= source.root_jobnet.id.to_s
|
85
|
+
properties[:target_jobnet_name_path] ||= source.root_jobnet.name_path
|
86
|
+
else
|
87
|
+
properties[:execution_id] ||= self.execution.id.to_s
|
88
|
+
properties[:root_jobnet_id] ||= source.root.id.to_s
|
89
|
+
properties[:root_jobnet_name_path] ||= source.root.name_path
|
90
|
+
end
|
91
|
+
# デバッグ用
|
92
|
+
# properties[:target_jobnet_name] = source.root.vertex(properties[:target_jobnet_id]).name_path
|
93
|
+
options ||= {}
|
94
|
+
options[:properties] = properties
|
95
|
+
properties.each do |key, value|
|
96
|
+
if value.is_a?(BSON::ObjectId)
|
97
|
+
properties[key] = value.to_s
|
98
|
+
end
|
99
|
+
end
|
100
|
+
@reservations << Reservation.new(source, event_type_name, options)
|
101
|
+
end
|
102
|
+
|
103
|
+
module Transmittable
|
104
|
+
# includeするモジュールは以下のメソッドを定義しなければならない
|
105
|
+
def transmit(signal); raise NotImplementedError; end
|
106
|
+
def activate(signal); raise NotImplementedError; end
|
107
|
+
|
108
|
+
def complete_origin_edge(signal, options = {})
|
109
|
+
origin_edge = signal.paths.last
|
110
|
+
origin_edge ||= prev_edges.first
|
111
|
+
begin
|
112
|
+
return if options[:except_closed] && origin_edge.closed?
|
113
|
+
origin_edge.complete(signal)
|
114
|
+
rescue Exception => e
|
115
|
+
puts "[#{e.class.name}] #{e.message}\nsignal.paths: #{@paths.inspect}"
|
116
|
+
raise e
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/job'
|
3
|
+
|
4
|
+
# ジョブネットの始端を表すVertex。特に状態は持たない。
|
5
|
+
class Tengine::Job::Start < Tengine::Job::Vertex
|
6
|
+
|
7
|
+
# https://cacoo.com/diagrams/hdLgrzYsTBBpV3Wj#D26C1
|
8
|
+
def transmit(signal)
|
9
|
+
activate(signal)
|
10
|
+
end
|
11
|
+
|
12
|
+
def activate(signal)
|
13
|
+
signal.leave(self)
|
14
|
+
end
|
15
|
+
|
16
|
+
def reset(signal)
|
17
|
+
signal.leave(self, :reset)
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/job'
|
3
|
+
require 'selectable_attr'
|
4
|
+
|
5
|
+
# ジョブ/ジョブネットを実行する際の情報に関するモジュール
|
6
|
+
# Tengine::Job::JobnetActual, Tengine::Job::JobnetTemplateがこのモジュールをincludeします
|
7
|
+
module Tengine::Job::Stoppable
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
included do
|
11
|
+
field :stopped_at , :type => DateTime # 停止時刻。停止を開始した時刻です。
|
12
|
+
field :stop_reason, :type => String # 停止理由。手動以外での停止ならば停止した理由が設定されます。
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,172 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require 'tengine/job'
|
3
|
+
|
4
|
+
# Edgeとともにジョブネットを構成するグラフの「頂点」を表すモデル
|
5
|
+
# 自身がツリー構造を
|
6
|
+
class Tengine::Job::Vertex
|
7
|
+
include Mongoid::Document
|
8
|
+
include Mongoid::Timestamps
|
9
|
+
include Tengine::Job::Signal::Transmittable
|
10
|
+
include Tengine::Job::NamePath
|
11
|
+
|
12
|
+
self.cyclic = true
|
13
|
+
with_options(:class_name => self.name, :cyclic => true) do |c|
|
14
|
+
c.embedded_in :parent , :inverse_of => :children
|
15
|
+
c.embeds_many :children, :inverse_of => :parent
|
16
|
+
end
|
17
|
+
|
18
|
+
# def short_inspect
|
19
|
+
# "#<%%%-30s id: %s>" % [self.class.name, self.id.to_s]
|
20
|
+
# end
|
21
|
+
# alias_method :long_inspect, :inspect
|
22
|
+
# alias_method :inspect, :short_inspect
|
23
|
+
|
24
|
+
class VertexValidations < Mongoid::Errors::Validations
|
25
|
+
def translate(key, options)
|
26
|
+
::I18n.translate(
|
27
|
+
"#{Mongoid::Errors::MongoidError::BASE_KEY}.validations",
|
28
|
+
{:errors => Tengine::Job::Vertex.flatten_errors(document).to_a.join(', ')})
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
class << self
|
34
|
+
def flatten_errors(vertex, dest = nil)
|
35
|
+
dest ||= []
|
36
|
+
children_errors = vertex.errors.messages.delete(:children)
|
37
|
+
edges_errors = vertex.errors.messages.delete(:edges)
|
38
|
+
vertex.errors.full_messages.each{|msg| dest << "#{vertex.name_path} #{msg}"}
|
39
|
+
vertex.children.each{|child| flatten_errors(child, dest)}
|
40
|
+
if vertex.respond_to?(:edges)
|
41
|
+
vertex.edges.each do|edge|
|
42
|
+
edge.errors.full_messages.each{|msg| dest << "#{edge.name_for_message} #{msg}"}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
dest
|
46
|
+
end
|
47
|
+
|
48
|
+
def raise_flatten_errors
|
49
|
+
yield if block_given?
|
50
|
+
rescue Mongoid::Errors::Validations => e
|
51
|
+
raise VertexValidations, e.document
|
52
|
+
end
|
53
|
+
|
54
|
+
def create!(*args, &block)
|
55
|
+
raise_flatten_errors{ super(*args, &block) }
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def save!(*args)
|
60
|
+
self.class.raise_flatten_errors{ super(*args) }
|
61
|
+
end
|
62
|
+
def update_attributes!(*args)
|
63
|
+
self.class.raise_flatten_errors{ super(*args) }
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
def previous_edges
|
69
|
+
return nil unless parent
|
70
|
+
parent.edges.select{|edge| edge.destination_id == self.id}
|
71
|
+
end
|
72
|
+
alias_method :prev_edges, :previous_edges
|
73
|
+
|
74
|
+
def next_edges
|
75
|
+
return nil unless parent
|
76
|
+
parent.edges.select{|edge| edge.origin_id == self.id}
|
77
|
+
end
|
78
|
+
|
79
|
+
def root
|
80
|
+
(parent = self.parent) ? parent.root : self
|
81
|
+
end
|
82
|
+
|
83
|
+
def ancestors
|
84
|
+
if parent = self.parent
|
85
|
+
parent.ancestors + [parent]
|
86
|
+
else
|
87
|
+
[]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
def ancestors_until_expansion
|
92
|
+
if (parent = self.parent) && !self.was_expansion?
|
93
|
+
parent.ancestors_until_expansion + [parent]
|
94
|
+
else
|
95
|
+
[]
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
IGNORED_FIELD_NAMES = ["_type", "_id"].freeze
|
100
|
+
|
101
|
+
def actual_class; self.class; end
|
102
|
+
def generating_attrs
|
103
|
+
field_names = self.class.fields.keys - IGNORED_FIELD_NAMES
|
104
|
+
field_names.inject({}){|d, name| d[name] = send(name); d }
|
105
|
+
end
|
106
|
+
def generating_children; self.children; end
|
107
|
+
def generating_edges; respond_to?(:edges) ? self.edges : []; end
|
108
|
+
|
109
|
+
def generate(klass = actual_class)
|
110
|
+
result = klass.new(generating_attrs)
|
111
|
+
src_to_generated = {}
|
112
|
+
generating_children.each do |child|
|
113
|
+
generated = child.generate
|
114
|
+
src_to_generated[child.id] = generated.id
|
115
|
+
result.children << generated
|
116
|
+
end
|
117
|
+
generating_edges.each do |edge|
|
118
|
+
generated = edge.class.new
|
119
|
+
generated.origin_id = src_to_generated[edge.origin_id]
|
120
|
+
generated.destination_id = src_to_generated[edge.destination_id]
|
121
|
+
result.edges << generated
|
122
|
+
end
|
123
|
+
result
|
124
|
+
end
|
125
|
+
|
126
|
+
def accept_visitor(visitor)
|
127
|
+
visitor.visit(self)
|
128
|
+
end
|
129
|
+
|
130
|
+
class AnyVisitor
|
131
|
+
def initialize(&block)
|
132
|
+
@block = block
|
133
|
+
end
|
134
|
+
def visit(vertex)
|
135
|
+
if result = @block.call(vertex)
|
136
|
+
return result
|
137
|
+
end
|
138
|
+
vertex.children.each do |child|
|
139
|
+
if result = child.accept_visitor(self)
|
140
|
+
return result
|
141
|
+
end
|
142
|
+
end
|
143
|
+
return nil
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
class AllVisitor
|
148
|
+
def initialize(&block)
|
149
|
+
@block = block
|
150
|
+
end
|
151
|
+
|
152
|
+
def visit(vertex)
|
153
|
+
@block.call(vertex)
|
154
|
+
vertex.children.each do |child|
|
155
|
+
child.accept_visitor(self)
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
class AllVisitorWithEdge < AllVisitor
|
161
|
+
def visit(obj)
|
162
|
+
if obj.respond_to?(:children)
|
163
|
+
super(obj)
|
164
|
+
else
|
165
|
+
@block.call(obj)
|
166
|
+
end
|
167
|
+
return unless obj.respond_to?(:edges)
|
168
|
+
obj.edges.each{|edge| edge.accept_visitor(self)}
|
169
|
+
end
|
170
|
+
end
|
171
|
+
|
172
|
+
end
|
data/lib/tengine_job.rb
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require File.expand_path('test_credential_fixture', File.dirname(__FILE__))
|
4
|
+
require File.expand_path('test_server_fixture', File.dirname(__FILE__))
|
5
|
+
|
6
|
+
# 以下のジョブネットについてテンプレートジョブネットや
|
7
|
+
# 実行用ジョブネットを扱うフィクスチャ生成のためのクラスです。
|
8
|
+
#
|
9
|
+
# in [rjn0001]
|
10
|
+
# (S1) --e1-->(j11)--e2-->(j12)--e3-->(E1)
|
11
|
+
|
12
|
+
class Rjn0001SimpleJobnetBuilder < JobnetFixtureBuilder
|
13
|
+
include TestCredentialFixture
|
14
|
+
include TestServerFixture
|
15
|
+
|
16
|
+
DSL = <<-EOS
|
17
|
+
jobnet("rjn0001", :server_name => "test_server1", :credential_name => "test_credential1") do
|
18
|
+
auto_sequence
|
19
|
+
job("j11", "job_test j11")
|
20
|
+
job("j12", "job_test j12")
|
21
|
+
end
|
22
|
+
EOS
|
23
|
+
|
24
|
+
def create(options = {})
|
25
|
+
root = new_root_jobnet("rjn0001", {
|
26
|
+
:server_name => test_server1.name,
|
27
|
+
:credential_name => test_credential1.name
|
28
|
+
}.update(options || { }))
|
29
|
+
root.children << Tengine::Job::Start.new
|
30
|
+
root.children << new_script("j11", :script => "job_test j11")
|
31
|
+
root.children << new_script("j12", :script => "job_test j12")
|
32
|
+
root.prepare_end
|
33
|
+
root.build_sequencial_edges
|
34
|
+
root.save!
|
35
|
+
self[:S1] = root.children[0]
|
36
|
+
self[:E1] = root.children[3]
|
37
|
+
self[:e1] = root.edges[0]
|
38
|
+
self[:e2] = root.edges[1]
|
39
|
+
self[:e3] = root.edges[2]
|
40
|
+
root
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# 以下のジョブネットについてテンプレートジョブネットや
|
3
|
+
# 実行用ジョブネットを扱うフィクスチャ生成のためのクラスです。
|
4
|
+
#
|
5
|
+
# in [rjn0002]
|
6
|
+
# |--e2-->(j11)--e4-->|
|
7
|
+
# (S1)--e1-->[F1] [J1]--e6-->(E1)
|
8
|
+
# |--e3-->(j12)--e5-->|
|
9
|
+
|
10
|
+
class Rjn0002SimpleParallelJobnetBuilder < JobnetFixtureBuilder
|
11
|
+
include TestCredentialFixture
|
12
|
+
include TestServerFixture
|
13
|
+
|
14
|
+
DSL = <<-EOS
|
15
|
+
jobnet("rjn0002", :server_name => "test_server1", :credential_name => "test_credential1") do
|
16
|
+
boot_jobs("j11", "j12")
|
17
|
+
job("j11", "job_test j11")
|
18
|
+
job("j12", "job_test j12")
|
19
|
+
end
|
20
|
+
EOS
|
21
|
+
|
22
|
+
def create(options = {})
|
23
|
+
root = new_root_jobnet("rjn0002", {
|
24
|
+
:server_name => test_server1.name,
|
25
|
+
:credential_name => test_credential1.name
|
26
|
+
}.update(options || { }))
|
27
|
+
root.children << new_start
|
28
|
+
root.children << new_fork
|
29
|
+
root.children << new_script("j11", :script => "job_test j11")
|
30
|
+
root.children << new_script("j12", :script => "job_test j12")
|
31
|
+
root.children << new_join
|
32
|
+
root.children << new_end
|
33
|
+
root.edges << new_edge(:S1, :F1)
|
34
|
+
root.edges << new_edge(:F1, :j11)
|
35
|
+
root.edges << new_edge(:F1, :j12)
|
36
|
+
root.edges << new_edge(:j11, :J1)
|
37
|
+
root.edges << new_edge(:j12, :J1)
|
38
|
+
root.edges << new_edge(:J1, :E1)
|
39
|
+
root.save!
|
40
|
+
root
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# 以下のジョブネットについてテンプレートジョブネットや
|
3
|
+
# 実行用ジョブネットを扱うフィクスチャ生成のためのクラスです。
|
4
|
+
#
|
5
|
+
# in [rjn0003]
|
6
|
+
# |--e7-->(j14)--e11-->(j16)--e14--->|
|
7
|
+
# |--e2-->(j11)--e4-->(j13)--e6-->[F2] |
|
8
|
+
# (S1)--e1-->[F1] |--e8-->[J1]--e12-->(j17)--e15-->[J2]--e16-->(E2)
|
9
|
+
# | |--e9-->[J1] |
|
10
|
+
# |--e3-->(j12)------e5---------->[F3] |
|
11
|
+
# |--e10---->(j15)---e13------------>|
|
12
|
+
class Rjn0003ForkJoinJobnetBuilder < JobnetFixtureBuilder
|
13
|
+
DSL = <<-EOS
|
14
|
+
jobnet("rjn0003") do
|
15
|
+
boot_jobs("j11", "j12")
|
16
|
+
job("j11", "job_test j11", :to => "j13")
|
17
|
+
job("j12", "job_test j12", :to => ["j15", "j17"])
|
18
|
+
job("j13", "job_test j13", :to => ["j14", "j17"])
|
19
|
+
job("j14", "job_test j14", :to => "j16")
|
20
|
+
job("j15", "job_test j15")
|
21
|
+
job("j16", "job_test j16")
|
22
|
+
job("j17", "job_test j17")
|
23
|
+
end
|
24
|
+
EOS
|
25
|
+
|
26
|
+
def create(options = {})
|
27
|
+
root = new_root_jobnet("rjn0003")
|
28
|
+
root.children << new_start
|
29
|
+
root.children << new_fork # F1
|
30
|
+
root.children << new_script("j11", :script => "job_test j11")
|
31
|
+
root.children << new_script("j12", :script => "job_test j12")
|
32
|
+
root.children << new_script("j13", :script => "job_test j13")
|
33
|
+
root.children << new_fork # F2
|
34
|
+
root.children << new_fork # F3
|
35
|
+
root.children << new_join # J1
|
36
|
+
root.children << new_script("j14", :script => "job_test j14")
|
37
|
+
root.children << new_script("j15", :script => "job_test j15")
|
38
|
+
root.children << new_script("j16", :script => "job_test j16")
|
39
|
+
root.children << new_script("j17", :script => "job_test j17")
|
40
|
+
root.children << new_join # J2
|
41
|
+
root.children << new_end
|
42
|
+
root.edges << new_edge(:S1 , :F1 ) # e1
|
43
|
+
root.edges << new_edge(:F1 , :j11) # e2
|
44
|
+
root.edges << new_edge(:F1 , :j12) # e3
|
45
|
+
root.edges << new_edge(:j11, :j13) # e4
|
46
|
+
root.edges << new_edge(:j12, :F3 ) # e5
|
47
|
+
root.edges << new_edge(:j13, :F2 ) # e6
|
48
|
+
root.edges << new_edge(:F2 , :j14) # e7
|
49
|
+
root.edges << new_edge(:F2 , :J1 ) # e8
|
50
|
+
root.edges << new_edge(:F3 , :J1 ) # e9
|
51
|
+
root.edges << new_edge(:F3 , :j15) # e10
|
52
|
+
root.edges << new_edge(:j14, :j16) # e11
|
53
|
+
root.edges << new_edge(:J1 , :j17) # e12
|
54
|
+
root.edges << new_edge(:j15 ,:J2 ) # e13
|
55
|
+
root.edges << new_edge(:j16 ,:J2 ) # e14
|
56
|
+
root.edges << new_edge(:j17 ,:J2 ) # e15
|
57
|
+
root.edges << new_edge(:J2 , :E1 ) # e16
|
58
|
+
root.save!
|
59
|
+
root
|
60
|
+
end
|
61
|
+
end
|