isono 0.2.11 → 0.2.12

Sign up to get free protection for your applications and to get access to all the features.
data/isono.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "isono"
5
- s.version = "0.2.11"
5
+ s.version = "0.2.12"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["axsh Ltd.", "Masahiro Fujiwara"]
9
- s.date = "2012-04-23"
9
+ s.date = "2012-06-05"
10
10
  s.email = ["dev@axsh.net", "m-fujiwara@axsh.net"]
11
11
  s.executables = ["cli"]
12
12
  s.files = [".gitignore", "LICENSE", "NOTICE", "Rakefile", "bin/cli", "isono.gemspec", "lib/ext/shellwords.rb", "lib/isono.rb", "lib/isono/amqp_client.rb", "lib/isono/daemonize.rb", "lib/isono/event_delegate_context.rb", "lib/isono/event_observable.rb", "lib/isono/logger.rb", "lib/isono/manifest.rb", "lib/isono/messaging_client.rb", "lib/isono/models/event_log.rb", "lib/isono/models/job_state.rb", "lib/isono/models/node_state.rb", "lib/isono/models/resource_instance.rb", "lib/isono/node.rb", "lib/isono/node_modules/base.rb", "lib/isono/node_modules/data_store.rb", "lib/isono/node_modules/event_channel.rb", "lib/isono/node_modules/event_logger.rb", "lib/isono/node_modules/job_channel.rb", "lib/isono/node_modules/job_collector.rb", "lib/isono/node_modules/job_worker.rb", "lib/isono/node_modules/node_collector.rb", "lib/isono/node_modules/node_heartbeat.rb", "lib/isono/node_modules/rpc_channel.rb", "lib/isono/rack.rb", "lib/isono/rack/builder.rb", "lib/isono/rack/data_store.rb", "lib/isono/rack/job.rb", "lib/isono/rack/map.rb", "lib/isono/rack/object_method.rb", "lib/isono/rack/proc.rb", "lib/isono/rack/thread_pass.rb", "lib/isono/resource_manifest.rb", "lib/isono/runner/base.rb", "lib/isono/runner/cli.rb", "lib/isono/runner/rpc_server.rb", "lib/isono/serializer.rb", "lib/isono/thread_pool.rb", "lib/isono/util.rb", "lib/isono/version.rb", "spec/amqp_client_spec.rb", "spec/event_observable_spec.rb", "spec/file_channel_spec.rb", "spec/job_channel_spec.rb", "spec/logger_spec.rb", "spec/manifest_spec.rb", "spec/node_spec.rb", "spec/resource_loader_spec.rb", "spec/rpc_channel_spec.rb", "spec/spec_helper.rb", "spec/thread_pool_spec.rb", "spec/util_spec.rb", "tasks/load_resource_manifest.rake"]
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
  s.require_paths = ["lib"]
15
15
  s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
16
16
  s.rubyforge_project = "isono"
17
- s.rubygems_version = "1.8.10"
17
+ s.rubygems_version = "1.8.24"
18
18
  s.summary = "Messaging and agent fabric"
19
19
 
20
20
  if s.respond_to? :specification_version then
@@ -13,6 +13,7 @@ module Isono
13
13
  primary_key :id, :type => Integer, :auto_increment=>true, :unsigned=>true
14
14
  column :job_id, :varchar, :size=>80, :null=>false
15
15
  column :parent_job_id, :varchar, :size=>80, :null=>true
16
+ column :session_id, :varchar, :size=>80, :null=>true
16
17
  column :node_id, :varchar, :size=>80, :null=>false
17
18
  column :state, :varchar, :size=>10, :null=>false
18
19
  column :message, :text, :null=>false, :default=>''
@@ -53,12 +53,14 @@ module Isono
53
53
  req = rpc.request("job.#{endpoint}", command, *args) { |req|
54
54
  req.timeout_sec = config_section.timeout_sec
55
55
  req.request[:job_id] = Util.gen_id
56
-
56
+ req.request[:session_id] = req.request[:job_id]
57
+
57
58
  # A job is working on this current thread if cur_job_ctx is
58
59
  # not nil. Let the new job know the current job ID
59
60
  # as its parent job ID.
60
61
  if cur_job_ctx
61
62
  req.request[:parent_job_id] = cur_job_ctx.job_id
63
+ req.request[:session_id] = cur_job_ctx.session_id
62
64
  end
63
65
 
64
66
  blk ? blk.call(req) : req.synchronize
@@ -21,7 +21,7 @@ module Isono
21
21
  params = @req.args[0]
22
22
  params[:node_id]=@req.sender
23
23
  job =Models::JobState.new
24
- job.set_fields(params, [:job_id, :parent_job_id, :node_id, :state]).save
24
+ job.set_fields(params, [:job_id, :parent_job_id, :session_id, :node_id, :state]).save
25
25
  end
26
26
 
27
27
  def update
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+ require 'ostruct'
2
3
 
3
4
  module Isono
4
5
  module NodeModules
@@ -116,13 +117,14 @@ module Isono
116
117
  attr_reader :state
117
118
 
118
119
  def initialize()
119
- super({:job_id=>Util.gen_id,
120
- :parent_job_id=>nil,
121
- :started_at=>nil,
122
- :finished_at=>nil,
123
- :finish_status=>nil,
120
+ job_id = Util.gen_id
121
+ super({:job_id => job_id,
122
+ :parent_job_id => nil,
123
+ :session_id => job_id,
124
+ :started_at => nil,
125
+ :finished_at => nil,
126
+ :finish_status => nil,
124
127
  })
125
-
126
128
  @run_cb=proc{}
127
129
  @fail_cb=nil
128
130
 
@@ -134,11 +136,11 @@ module Isono
134
136
  when [:on_start, :init]
135
137
  @state = :running
136
138
  self.started_at = Time.now
137
- logger.info("Job start #{job_id}")
139
+ logger.info("Job start #{session_id} (Local ID: #{job_id})")
138
140
  when [:on_done, :running]
139
141
  @state = :done
140
142
  self.finished_at = Time.now
141
- logger.info("Job complete #{job_id}: #{elapsed_time} sec")
143
+ logger.info("Job complete #{session_id} (Local ID: #{job_id}): #{elapsed_time} sec")
142
144
  when [:on_fail, :running]
143
145
  @state = :failed
144
146
  on_fail(args[0])
@@ -165,7 +167,7 @@ module Isono
165
167
  private
166
168
  def on_fail(e)
167
169
  self.finished_at = Time.now
168
- logger.error("Job failed #{job_id}: #{e}")
170
+ logger.error("Job failed #{session_id}: #{e}")
169
171
  logger.error(e)
170
172
  end
171
173
 
@@ -266,13 +266,10 @@ module Isono
266
266
  @active_requests[req.ticket] = req
267
267
  end
268
268
 
269
- # create receiver queue if it is requested at first time
270
- # from this node. This allows that the receiver became ready
271
- # after the sender can proceed the request.
272
- if @requested_endpoints[req.endpoint].nil?
273
- amq.queue(endpoint_queue_name(req.endpoint), {:exclusive=>false, :auto_delete=>true})
274
- @requested_endpoints[req.endpoint] = 1
275
- end
269
+ # create receiver queue every time before publish the message.
270
+ # This helps to receive messages from the failed receiver.
271
+ amq.queue(endpoint_queue_name(req.endpoint), {:exclusive=>false, :auto_delete=>true})
272
+ @requested_endpoints[req.endpoint] = 1
276
273
 
277
274
  amq.default_exchange.publish(Serializer.instance.marshal(req.request_hash),
278
275
  {:message_id => req.ticket,
@@ -51,6 +51,7 @@ module Rack
51
51
  job = @job_worker.start do |job|
52
52
  job.job_id = req.r[:job_id]
53
53
  job.parent_job_id = req.r[:parent_job_id]
54
+ job.session_id = req.r[:session_id]
54
55
  job.run_cb = proc {
55
56
  begin
56
57
  @app.call(JobRequest.new(req.r, job), JobResponse.new(res.ctx, job))
@@ -37,6 +37,12 @@ module Isono
37
37
  module RpcServer
38
38
 
39
39
  class EndpointBuilder
40
+ def session_id
41
+ job_context.session_id
42
+ end
43
+ def job_context
44
+ Thread.current[Isono::NodeModules::JobWorker::JOB_CTX_KEY]
45
+ end
40
46
  module BuildMethods
41
47
  # @exmaple
42
48
  # job 'command1', proc {
data/lib/isono/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Isono
4
- VERSION='0.2.11'
4
+ VERSION='0.2.12'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: isono
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.11
4
+ version: 0.2.12
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,33 +10,43 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-04-23 00:00:00.000000000Z
13
+ date: 2012-06-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: amqp
17
- requirement: &7228680 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
- - - =
20
+ - - '='
21
21
  - !ruby/object:Gem::Version
22
22
  version: 0.7.4
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *7228680
25
+ version_requirements: !ruby/object:Gem::Requirement
26
+ none: false
27
+ requirements:
28
+ - - '='
29
+ - !ruby/object:Gem::Version
30
+ version: 0.7.4
26
31
  - !ruby/object:Gem::Dependency
27
32
  name: eventmachine
28
- requirement: &7228160 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
29
34
  none: false
30
35
  requirements:
31
- - - =
36
+ - - '='
32
37
  - !ruby/object:Gem::Version
33
38
  version: 1.0.0.beta.4
34
39
  type: :runtime
35
40
  prerelease: false
36
- version_requirements: *7228160
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - '='
45
+ - !ruby/object:Gem::Version
46
+ version: 1.0.0.beta.4
37
47
  - !ruby/object:Gem::Dependency
38
48
  name: statemachine
39
- requirement: &7227640 !ruby/object:Gem::Requirement
49
+ requirement: !ruby/object:Gem::Requirement
40
50
  none: false
41
51
  requirements:
42
52
  - - ! '>='
@@ -44,10 +54,15 @@ dependencies:
44
54
  version: 1.0.0
45
55
  type: :runtime
46
56
  prerelease: false
47
- version_requirements: *7227640
57
+ version_requirements: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: 1.0.0
48
63
  - !ruby/object:Gem::Dependency
49
64
  name: log4r
50
- requirement: &7227120 !ruby/object:Gem::Requirement
65
+ requirement: !ruby/object:Gem::Requirement
51
66
  none: false
52
67
  requirements:
53
68
  - - ! '>='
@@ -55,10 +70,15 @@ dependencies:
55
70
  version: '0'
56
71
  type: :runtime
57
72
  prerelease: false
58
- version_requirements: *7227120
73
+ version_requirements: !ruby/object:Gem::Requirement
74
+ none: false
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
59
79
  - !ruby/object:Gem::Dependency
60
80
  name: bacon
61
- requirement: &7226520 !ruby/object:Gem::Requirement
81
+ requirement: !ruby/object:Gem::Requirement
62
82
  none: false
63
83
  requirements:
64
84
  - - ! '>='
@@ -66,10 +86,15 @@ dependencies:
66
86
  version: '0'
67
87
  type: :development
68
88
  prerelease: false
69
- version_requirements: *7226520
89
+ version_requirements: !ruby/object:Gem::Requirement
90
+ none: false
91
+ requirements:
92
+ - - ! '>='
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
70
95
  - !ruby/object:Gem::Dependency
71
96
  name: rake
72
- requirement: &7225920 !ruby/object:Gem::Requirement
97
+ requirement: !ruby/object:Gem::Requirement
73
98
  none: false
74
99
  requirements:
75
100
  - - ! '>='
@@ -77,7 +102,12 @@ dependencies:
77
102
  version: '0'
78
103
  type: :development
79
104
  prerelease: false
80
- version_requirements: *7225920
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
81
111
  description:
82
112
  email:
83
113
  - dev@axsh.net
@@ -166,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
166
196
  version: '0'
167
197
  requirements: []
168
198
  rubyforge_project: isono
169
- rubygems_version: 1.8.10
199
+ rubygems_version: 1.8.24
170
200
  signing_key:
171
201
  specification_version: 3
172
202
  summary: Messaging and agent fabric