isono 0.2.12 → 0.2.13
Sign up to get free protection for your applications and to get access to all the features.
- data/isono.gemspec +3 -3
- data/lib/isono.rb +1 -0
- data/lib/isono/models/job_state.rb +1 -0
- data/lib/isono/node_modules/job_channel.rb +1 -0
- data/lib/isono/node_modules/job_collector.rb +3 -11
- data/lib/isono/node_modules/job_worker.rb +7 -6
- data/lib/isono/rack/job.rb +1 -0
- data/lib/isono/rack/sequel.rb +36 -0
- data/lib/isono/version.rb +1 -1
- metadata +3 -2
data/isono.gemspec
CHANGED
@@ -2,14 +2,14 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "isono"
|
5
|
-
s.version = "0.2.
|
5
|
+
s.version = "0.2.13"
|
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-
|
9
|
+
s.date = "2012-08-08"
|
10
10
|
s.email = ["dev@axsh.net", "m-fujiwara@axsh.net"]
|
11
11
|
s.executables = ["cli"]
|
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"]
|
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/sequel.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"]
|
13
13
|
s.homepage = "http://github.com/axsh/isono"
|
14
14
|
s.require_paths = ["lib"]
|
15
15
|
s.required_ruby_version = Gem::Requirement.new(">= 1.8.7")
|
data/lib/isono.rb
CHANGED
@@ -17,6 +17,7 @@ module Isono
|
|
17
17
|
column :node_id, :varchar, :size=>80, :null=>false
|
18
18
|
column :state, :varchar, :size=>10, :null=>false
|
19
19
|
column :message, :text, :null=>false, :default=>''
|
20
|
+
column :job_name, :varchar, :size=>255, :null=>true
|
20
21
|
column :created_at, :datetime, :null=>false
|
21
22
|
column :updated_at, :datetime, :null=>false
|
22
23
|
column :started_at, :datetime, :null=>true
|
@@ -54,6 +54,7 @@ module Isono
|
|
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
|
+
req.request[:job_name] = command
|
57
58
|
|
58
59
|
# A job is working on this current thread if cur_job_ctx is
|
59
60
|
# not nil. Let the new job know the current job ID
|
@@ -16,21 +16,13 @@ module Isono
|
|
16
16
|
end
|
17
17
|
|
18
18
|
class Dispatch
|
19
|
-
|
20
|
-
def regist
|
19
|
+
def record
|
21
20
|
params = @req.args[0]
|
22
21
|
params[:node_id]=@req.sender
|
23
|
-
job =Models::JobState.
|
24
|
-
job.set_fields(params, [:
|
22
|
+
job =Models::JobState.find_or_create(:job_id=>params[:job_id])
|
23
|
+
job.set_fields(params, [:parent_job_id, :session_id, :node_id, :state, :started_at, :finished_at, :job_name]).save_changes
|
25
24
|
end
|
26
25
|
|
27
|
-
def update
|
28
|
-
params = @req.args[0]
|
29
|
-
job = Models::JobState.find(:job_id=>params[:job_id])
|
30
|
-
raise "Unknown or JOB ID: #{params[:job_id]}" if job.nil?
|
31
|
-
job.set_fields(params, [:state, :started_at, :finished_at]).save
|
32
|
-
end
|
33
|
-
|
34
26
|
def call(req, res)
|
35
27
|
@req, @res = req, res
|
36
28
|
raise Rack::UnknownMethodError if @req.command == 'call'
|
@@ -47,7 +47,7 @@ module Isono
|
|
47
47
|
@active_jobs[job.job_id] = job
|
48
48
|
rpc = RpcChannel.new(node)
|
49
49
|
|
50
|
-
rpc.request('job-collector', '
|
50
|
+
rpc.request('job-collector', 'record', job.to_hash) { |req|
|
51
51
|
req.oneshot = true
|
52
52
|
}
|
53
53
|
|
@@ -55,7 +55,7 @@ module Isono
|
|
55
55
|
begin
|
56
56
|
Thread.current[JOB_CTX_KEY]=job
|
57
57
|
job.process_event(:on_start)
|
58
|
-
rpc.request('job-collector', '
|
58
|
+
rpc.request('job-collector', 'record', job.to_hash) { |req|
|
59
59
|
req.oneshot = true
|
60
60
|
}
|
61
61
|
job.run_cb.call
|
@@ -73,7 +73,7 @@ module Isono
|
|
73
73
|
ensure
|
74
74
|
Thread.current[JOB_CTX_KEY]=nil
|
75
75
|
EventMachine.schedule {
|
76
|
-
rpc.request('job-collector', '
|
76
|
+
rpc.request('job-collector', 'record', job.to_hash) { |req|
|
77
77
|
req.oneshot = true
|
78
78
|
}
|
79
79
|
@active_jobs.delete(job.job_id)
|
@@ -121,6 +121,7 @@ module Isono
|
|
121
121
|
super({:job_id => job_id,
|
122
122
|
:parent_job_id => nil,
|
123
123
|
:session_id => job_id,
|
124
|
+
:job_name => nil,
|
124
125
|
:started_at => nil,
|
125
126
|
:finished_at => nil,
|
126
127
|
:finish_status => nil,
|
@@ -136,11 +137,11 @@ module Isono
|
|
136
137
|
when [:on_start, :init]
|
137
138
|
@state = :running
|
138
139
|
self.started_at = Time.now
|
139
|
-
logger.info("Job start #{session_id} (Local ID: #{job_id})")
|
140
|
+
logger.info("Job start #{session_id} (Local ID: #{job_id})[ #{job_name} ]")
|
140
141
|
when [:on_done, :running]
|
141
142
|
@state = :done
|
142
143
|
self.finished_at = Time.now
|
143
|
-
logger.info("Job complete #{session_id} (Local ID: #{job_id}): #{elapsed_time} sec")
|
144
|
+
logger.info("Job complete #{session_id} (Local ID: #{job_id})[ #{job_name} ]: #{elapsed_time} sec")
|
144
145
|
when [:on_fail, :running]
|
145
146
|
@state = :failed
|
146
147
|
on_fail(args[0])
|
@@ -167,7 +168,7 @@ module Isono
|
|
167
168
|
private
|
168
169
|
def on_fail(e)
|
169
170
|
self.finished_at = Time.now
|
170
|
-
logger.error("Job failed #{session_id}: #{e}")
|
171
|
+
logger.error("Job failed #{session_id} [ #{job_name} ]: #{e}")
|
171
172
|
logger.error(e)
|
172
173
|
end
|
173
174
|
|
data/lib/isono/rack/job.rb
CHANGED
@@ -52,6 +52,7 @@ module Rack
|
|
52
52
|
job.job_id = req.r[:job_id]
|
53
53
|
job.parent_job_id = req.r[:parent_job_id]
|
54
54
|
job.session_id = req.r[:session_id]
|
55
|
+
job.job_name = req.r[:job_name]
|
55
56
|
job.run_cb = proc {
|
56
57
|
begin
|
57
58
|
@app.call(JobRequest.new(req.r, job), JobResponse.new(res.ctx, job))
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
require 'sequel'
|
4
|
+
|
5
|
+
module Isono
|
6
|
+
module Rack
|
7
|
+
# Middleware for Sequel transaction.
|
8
|
+
class Sequel < Decorator
|
9
|
+
include Isono::Logger
|
10
|
+
|
11
|
+
def initialize(app, retry_count=10)
|
12
|
+
@app = app
|
13
|
+
@retry_count = retry_count
|
14
|
+
end
|
15
|
+
|
16
|
+
def call(req, res)
|
17
|
+
retry_count=0
|
18
|
+
begin
|
19
|
+
::Sequel::DATABASES.first.transaction do
|
20
|
+
@app.call(req, res)
|
21
|
+
res.response(ret) unless res.responded?
|
22
|
+
end
|
23
|
+
rescue ::Sequel::DatabaseError, ::Sequel::DatabaseConnectionError => e
|
24
|
+
retry_count += 1
|
25
|
+
if retry_count < @retry_count
|
26
|
+
logger.error("Database Error: #{e.message} retrying #{retry_count}/#{@retry_count}")
|
27
|
+
retry
|
28
|
+
end
|
29
|
+
|
30
|
+
res.response(e) unless res.responded?
|
31
|
+
raise e
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
data/lib/isono/version.rb
CHANGED
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.
|
4
|
+
version: 0.2.13
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-
|
13
|
+
date: 2012-08-08 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: amqp
|
@@ -154,6 +154,7 @@ files:
|
|
154
154
|
- lib/isono/rack/map.rb
|
155
155
|
- lib/isono/rack/object_method.rb
|
156
156
|
- lib/isono/rack/proc.rb
|
157
|
+
- lib/isono/rack/sequel.rb
|
157
158
|
- lib/isono/rack/thread_pass.rb
|
158
159
|
- lib/isono/resource_manifest.rb
|
159
160
|
- lib/isono/runner/base.rb
|