bricolage 5.21.0 → 5.22.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bricolage/application.rb +39 -1
  3. data/lib/bricolage/context.rb +4 -0
  4. data/lib/bricolage/filesystem.rb +8 -0
  5. data/lib/bricolage/job.rb +4 -0
  6. data/lib/bricolage/jobnetrunner.rb +17 -19
  7. data/lib/bricolage/logfilepath.rb +76 -0
  8. data/lib/bricolage/version.rb +1 -1
  9. data/test/home/Gemfile.lock +1 -1
  10. data/test/home/log/20170117/subsys::job1/20170117_202014082/subsys-job1.log +3 -0
  11. data/test/home/log/20170117/subsys::job1/20170117_202334852/subsys-job1.log +3 -0
  12. data/test/home/log/20170117/subsys::job1/20170117_202405056/subsys-job1.log +3 -0
  13. data/test/home/log/20170117/subsys::migrate/20170117_202548409/subsys-migrate.log +80 -0
  14. data/test/home/log/20170117/subsys::migrate/20170117_202636115/subsys-migrate.log +79 -0
  15. data/test/home/log/20170117/subsys::net1/20170117_203022461/subsys-job1.log +3 -0
  16. data/test/home/log/20170117/subsys::net1/20170117_203022461/subsys-job2.log +3 -0
  17. data/test/home/log/20170117/subsys::net1/20170117_203022461/subsys-job3.log +3 -0
  18. data/test/home/log/20170117/subsys::net1/20170117_203022461/subsys-job4.log +3 -0
  19. data/test/home/log/20170117/subsys::net1/20170117_203102130/subsys-job1.log +3 -0
  20. data/test/home/log/20170117/subsys::net1/20170117_203102130/subsys-job2.log +3 -0
  21. data/test/home/log/20170117/subsys::net1/20170117_203102130/subsys-job3.log +3 -0
  22. data/test/home/log/20170117/subsys::net1/20170117_203102130/subsys-job4.log +3 -0
  23. data/test/home/log/20170117/subsys::net1/20170117_203232033/subsys-job1.log +3 -0
  24. data/test/home/log/20170117/subsys::net1/20170117_203232033/subsys-job2.log +3 -0
  25. data/test/home/log/20170117/subsys::net1/20170117_203232033/subsys-job3.log +3 -0
  26. data/test/home/log/20170117/subsys::net1/20170117_203232033/subsys-job4.log +3 -0
  27. data/test/home/subsys/my-import-delta.sql.job +6 -6
  28. data/test/test_c_streaming_load.rb +1 -1
  29. data/test/test_logfilepath.rb +19 -0
  30. metadata +20 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 38fa88f0cfbee0ae3d6cca03c6a50d9b148c2e3b
4
- data.tar.gz: 29c84154960c9a298bb0966beaf5b37586a09636
3
+ metadata.gz: e6894dfe2fad736476fc5c77d3e9f271d211e9e7
4
+ data.tar.gz: 7121e86bc937c14b91cbcfe3035dcde4e08aa027
5
5
  SHA512:
6
- metadata.gz: 6fa588561652d3108036557074222f77f8ea21e88141cfd9fa6d3cfcf6a81a32f0ec068cc05fb78eb8014ec8c925daf20b04818ff9c4ba0da42117f9d6db734e
7
- data.tar.gz: 20c5afefe133f3f49da1e3bb9b9d5f31aaa86c90fa1ef190fb6cdec31926d5366da10bd0c8959bea21c94a7aaf7cbffd77028d85ae03194ae69f76171d5da1ca
6
+ metadata.gz: 46411897c454153c4dd2b726a6d9427fe49b3ab8eb4157e2d3054ba09e623709727ddec5124be46ae02777b0c7da3c037b2a2d253dec7a68680ced7dadf96c3b
7
+ data.tar.gz: 4fe3715fee1220d98eecab7cbe1e3cdd1fe89ee14f19008017dc1f8aea0ad1ca81507f25c8026551098246fce31ddd4a8af720cc9bab2de94ce8ad5c9e7ff231
@@ -2,13 +2,16 @@ require 'bricolage/context'
2
2
  require 'bricolage/job'
3
3
  require 'bricolage/jobclass'
4
4
  require 'bricolage/jobresult'
5
+ require 'bricolage/jobnet'
5
6
  require 'bricolage/variables'
6
7
  require 'bricolage/datasource'
7
8
  require 'bricolage/eventhandlers'
8
9
  require 'bricolage/postgresconnection'
10
+ require 'bricolage/logfilepath'
9
11
  require 'bricolage/logger'
10
12
  require 'bricolage/exception'
11
13
  require 'bricolage/version'
14
+ require 'fileutils'
12
15
  require 'pathname'
13
16
  require 'optparse'
14
17
 
@@ -27,6 +30,7 @@ module Bricolage
27
30
 
28
31
  def initialize
29
32
  @hooks = Bricolage
33
+ @start_time = Time.now
30
34
  end
31
35
 
32
36
  def main
@@ -60,7 +64,9 @@ module Bricolage
60
64
 
61
65
  @hooks.run_before_all_jobs_hooks(BeforeAllJobsEvent.new(job.id, [job]))
62
66
  @hooks.run_before_job_hooks(BeforeJobEvent.new(job))
63
- result = job.execute
67
+ result = redirect_log_to_file(opts.log_path, job) {
68
+ job.execute
69
+ }
64
70
  @hooks.run_after_job_hooks(AfterJobEvent.new(result))
65
71
  @hooks.run_after_all_jobs_hooks(AfterAllJobsEvent.new(result.success?, [job]))
66
72
  exit result.status
@@ -72,6 +78,30 @@ module Bricolage
72
78
  error_exit ex.message
73
79
  end
74
80
 
81
+ def redirect_log_to_file(log_path, job)
82
+ return yield unless log_path
83
+
84
+ path = log_path.format(
85
+ job_ref: JobNet::JobRef.new(job.subsystem, job.id, '-'),
86
+ jobnet_id: "#{job.subsystem}/#{job.id}",
87
+ job_start_time: @start_time,
88
+ jobnet_start_time: @start_time
89
+ )
90
+ FileUtils.mkdir_p File.dirname(path)
91
+ stdout_save = $stdout.dup
92
+ stderr_save = $stderr.dup
93
+ begin
94
+ File.open(path, 'w+') {|f|
95
+ $stdout.reopen f
96
+ $stderr.reopen f
97
+ }
98
+ return yield
99
+ ensure
100
+ $stdout.reopen stdout_save; stdout_save.close
101
+ $stderr.reopen stderr_save; stderr_save.close
102
+ end
103
+ end
104
+
75
105
  def load_job(ctx, opts)
76
106
  if opts.file_mode?
77
107
  Job.load_file(opts.job_file, ctx)
@@ -154,6 +184,7 @@ module Bricolage
154
184
  @global_variables = Variables.new
155
185
  @dry_run = false
156
186
  @explain = false
187
+ @log_path = LogFilePath.default
157
188
  @list_global_variables = false
158
189
  @list_variables = false
159
190
  @list_declarations = false
@@ -189,6 +220,12 @@ Global Options:
189
220
  parser.on('-E', '--explain', 'Applies EXPLAIN to the SQL.') {
190
221
  @explain = true
191
222
  }
223
+ parser.on('--log-dir=PATH', 'Log file prefix.') {|path|
224
+ @log_path = LogFilePath.new("#{path}/%{std}.log")
225
+ }
226
+ parser.on('--log-path=PATH', 'Log file path template.') {|path|
227
+ @log_path = LogFilePath.new(path)
228
+ }
192
229
  parser.on('--list-job-class', 'Lists job class name and (internal) class path.') {
193
230
  JobClass.list.each do |name|
194
231
  puts name
@@ -237,6 +274,7 @@ Global Options:
237
274
  attr_reader :global_variables
238
275
 
239
276
  attr_reader :job_file
277
+ attr_reader :log_path
240
278
 
241
279
  def file_mode?
242
280
  !!@job_file
@@ -68,6 +68,10 @@ module Bricolage
68
68
  logger: @logger)
69
69
  end
70
70
 
71
+ def subsystem_name
72
+ @filesystem.scope
73
+ end
74
+
71
75
  extend Forwardable
72
76
  def_delegators '@filesystem',
73
77
  :scoped?,
@@ -36,6 +36,10 @@ module Bricolage
36
36
  false
37
37
  end
38
38
 
39
+ def scope
40
+ nil
41
+ end
42
+
39
43
  attr_reader :path
40
44
  attr_reader :environment
41
45
 
@@ -158,6 +162,10 @@ module Bricolage
158
162
  true
159
163
  end
160
164
 
165
+ def scope
166
+ @id
167
+ end
168
+
161
169
  def root
162
170
  @parent.root
163
171
  end
data/lib/bricolage/job.rb CHANGED
@@ -50,6 +50,10 @@ module Bricolage
50
50
  @job_class.id
51
51
  end
52
52
 
53
+ def subsystem
54
+ @context.subsystem_name
55
+ end
56
+
53
57
  def init_global_variables
54
58
  # Context#global_variables loads file on each call, fix global variables here.
55
59
  @global_variables = @context.global_variables
@@ -7,6 +7,7 @@ require 'bricolage/jobresult'
7
7
  require 'bricolage/datasource'
8
8
  require 'bricolage/variables'
9
9
  require 'bricolage/eventhandlers'
10
+ require 'bricolage/logfilepath'
10
11
  require 'bricolage/logger'
11
12
  require 'bricolage/exception'
12
13
  require 'bricolage/version'
@@ -25,6 +26,7 @@ module Bricolage
25
26
  @hooks = ::Bricolage
26
27
  @jobnet_id = nil
27
28
  @jobnet_start_time = Time.now
29
+ @job_start_time = nil
28
30
  @log_path = nil
29
31
  end
30
32
 
@@ -123,10 +125,11 @@ module Bricolage
123
125
 
124
126
  def execute_job(ref, queue)
125
127
  logger.debug "job #{ref}"
128
+ @job_start_time = Time.now
126
129
  job = Job.load_ref(ref, @ctx)
127
130
  job.compile
128
131
  @hooks.run_before_job_hooks(BeforeJobEvent.new(ref))
129
- result = job.execute_in_process(make_log_path(ref))
132
+ result = job.execute_in_process(instanciate_log_path(ref))
130
133
  @hooks.run_after_job_hooks(AfterJobEvent.new(result))
131
134
  result
132
135
  rescue Exception => ex
@@ -135,22 +138,14 @@ module Bricolage
135
138
  JobResult.error(ex)
136
139
  end
137
140
 
138
- def make_log_path(job_ref)
141
+ def instanciate_log_path(ref)
139
142
  return nil unless @log_path
140
- start_time = Time.now
141
- @log_path.gsub(/%\{\w+\}/) {|var|
142
- case var
143
- when '%{jobnet_start_date}' then @jobnet_start_time.strftime('%Y%m%d')
144
- when '%{jobnet_start_time}' then @jobnet_start_time.strftime('%Y%m%d_%H%M%S%L')
145
- when '%{job_start_date}' then start_time.strftime('%Y%m%d')
146
- when '%{job_start_time}' then start_time.strftime('%Y%m%d_%H%M%S%L')
147
- when '%{jobnet}', '%{net}', '%{jobnet_id}', '%{net_id}', '%{flow}', '%{flow_id}' then @jobnet_id.gsub('/', '::')
148
- when '%{subsystem}' then job_ref.subsystem
149
- when '%{job}', '%{job_id}' then job_ref.name
150
- else
151
- raise ParameterError, "bad log path variable: #{var}"
152
- end
153
- }
143
+ @log_path.format(
144
+ job_ref: ref,
145
+ jobnet_id: @jobnet_id,
146
+ job_start_time: @job_start_time,
147
+ jobnet_start_time: @jobnet_start_time
148
+ )
154
149
  end
155
150
 
156
151
  public :puts
@@ -180,7 +175,7 @@ module Bricolage
180
175
  @app = app
181
176
  @environment = nil
182
177
  @jobnet_files = nil
183
- @log_path = nil
178
+ @log_path = LogFilePath.default
184
179
  @queue_path = nil
185
180
  @check_only = false
186
181
  @list_jobs = false
@@ -191,8 +186,8 @@ module Bricolage
191
186
 
192
187
  attr_reader :environment
193
188
  attr_reader :jobnet_file
194
- attr_reader :log_path
195
189
  attr_reader :queue_path
190
+ attr_reader :log_path
196
191
 
197
192
  def queue_exist?
198
193
  !!@queue_path
@@ -221,8 +216,11 @@ Options:
221
216
  parser.on('-e', '--environment=NAME', "Sets execution environment. [default: #{Context::DEFAULT_ENV}]") {|env|
222
217
  @environment = env
223
218
  }
219
+ parser.on('--log-dir=PATH', 'Log file prefix.') {|path|
220
+ @log_path = LogFilePath.new("#{path}/%{std}.log")
221
+ }
224
222
  parser.on('--log-path=PATH', 'Log file path template.') {|path|
225
- @log_path = path
223
+ @log_path = LogFilePath.new(path)
226
224
  }
227
225
  parser.on('--queue=PATH', 'Use job queue.') {|path|
228
226
  @queue_path = Pathname(path)
@@ -0,0 +1,76 @@
1
+ module Bricolage
2
+ class LogFilePath
3
+ def LogFilePath.default
4
+ if dir = ENV['BRICOLAGE_LOG_DIR']
5
+ new("#{dir}/%{std}.log")
6
+ elsif path = ENV['BRICOLAGE_LOG_PATH']
7
+ new(path)
8
+ else
9
+ nil
10
+ end
11
+ end
12
+
13
+ def initialize(template)
14
+ @template = template
15
+ end
16
+
17
+ Params = Struct.new(:job_ref, :jobnet_id, :job_start_time, :jobnet_start_time)
18
+
19
+ def format(job_ref:, jobnet_id:, job_start_time:, jobnet_start_time:)
20
+ return nil unless @template
21
+ params = Params.new(job_ref, jobnet_id, job_start_time, jobnet_start_time)
22
+ fill_template(@template, params)
23
+ end
24
+
25
+ def fill_template(template, params)
26
+ template.gsub(/%\{\w+\}/) {|var|
27
+ case var
28
+ when '%{std}' then standard_format(params)
29
+ when '%{jobnet_start_date}' then jobnet_start_date(params)
30
+ when '%{jobnet_start_time}' then jobnet_start_time(params)
31
+ when '%{job_start_date}' then job_start_date(params)
32
+ when '%{job_start_time}' then job_start_time(params)
33
+ when '%{jobnet}', '%{net}', '%{jobnet_id}', '%{net_id}', '%{flow}', '%{flow_id}' then jobnet_id(params)
34
+ when '%{subsystem}' then subsystem_name(params)
35
+ when '%{job}', '%{job_id}' then job_name(params)
36
+ else
37
+ raise ParameterError, "bad log path variable: #{var}"
38
+ end
39
+ }
40
+ end
41
+
42
+ STD_TEMPLATE = '%{jobnet_start_date}/%{jobnet}/%{jobnet_start_time}/%{subsystem}-%{job}'
43
+
44
+ def standard_format(params)
45
+ fill_template(STD_TEMPLATE, params)
46
+ end
47
+
48
+ def jobnet_start_date(params)
49
+ params.jobnet_start_time.strftime('%Y%m%d')
50
+ end
51
+
52
+ def jobnet_start_time(params)
53
+ params.jobnet_start_time.strftime('%Y%m%d_%H%M%S%L')
54
+ end
55
+
56
+ def job_start_date(params)
57
+ params.start_time.strftime('%Y%m%d')
58
+ end
59
+
60
+ def job_start_time(params)
61
+ params.start_time.strftime('%Y%m%d_%H%M%S%L')
62
+ end
63
+
64
+ def jobnet_id(params)
65
+ params.jobnet_id.gsub('/', '::')
66
+ end
67
+
68
+ def subsystem_name(params)
69
+ params.job_ref.subsystem
70
+ end
71
+
72
+ def job_name(params)
73
+ params.job_ref.name
74
+ end
75
+ end
76
+ end
@@ -1,4 +1,4 @@
1
1
  module Bricolage
2
2
  APPLICATION_NAME = 'Bricolage'
3
- VERSION = '5.21.0'
3
+ VERSION = '5.22.0'
4
4
  end
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../..
3
3
  specs:
4
- bricolage (5.21.0)
4
+ bricolage (5.22.0)
5
5
  aws-sdk (~> 2)
6
6
  mysql2
7
7
  pg (~> 0.18.0)
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:20:14 +0900: INFO: development environment
2
+ 2017-01-17 20:20:14 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:20:14 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:23:34 +0900: INFO: development environment
2
+ 2017-01-17 20:23:34 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:23:34 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:24:05 +0900: INFO: development environment
2
+ 2017-01-17 20:24:05 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:24:05 +0900: INFO: SUCCESS
@@ -0,0 +1,80 @@
1
+ 2017-01-17 20:25:48 +0900: INFO: development environment
2
+ 2017-01-17 20:25:48 +0900: INFO: [CMD] "/Users/minero-aoki/c/bricolage/libexec/sqldump" "--json" "127.0.0.1" "9011" "work_readonly" "main" "select * from main.search_backends;" | "gzip" "{:out=>"/tmp/bricolagedev/search_backends.json.gz"}"
3
+ 2017-01-17 20:25:48.540819891 +0900 JST: [SQL] select * from main.search_backends;
4
+ 2017-01-17 20:25:48.597928759 +0900 JST: query returned
5
+ 2017-01-17 20:25:48.598038993 +0900 JST: Total 11 records
6
+ 2017-01-17 20:25:48 +0900: INFO: aws s3 cp /tmp/bricolagedev/search_backends.json.gz s3://tabemiru-data.ap-northeast-1/dev/search_backends/search_backends.json.gz
7
+ 2017-01-17 20:25:51 +0900: INFO: 3.28 secs
8
+ 2017-01-17 20:25:51 +0900: ERROR: Aws::Errors::MissingCredentialsError: unable to sign request without credentials set
9
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/request_signer.rb:104:in `require_credentials'
10
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_request_signer.rb:14:in `call'
11
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/xml/error_handler.rb:8:in `call'
12
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/helpful_socket_errors.rb:10:in `call'
13
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_request_signer.rb:65:in `call'
14
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_redirects.rb:15:in `call'
15
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/retry_errors.rb:87:in `call'
16
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_dualstack.rb:32:in `call'
17
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_accelerate.rb:49:in `call'
18
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_md5s.rb:31:in `call'
19
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_expect_100_continue.rb:21:in `call'
20
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_bucket_name_restrictions.rb:12:in `call'
21
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_bucket_dns.rb:31:in `call'
22
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/rest/handler.rb:7:in `call'
23
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/user_agent.rb:12:in `call'
24
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/seahorse/client/plugins/endpoint.rb:41:in `call'
25
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/param_validator.rb:21:in `call'
26
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/seahorse/client/plugins/raise_response_errors.rb:14:in `call'
27
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_sse_cpk.rb:19:in `call'
28
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_dualstack.rb:24:in `call'
29
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/s3_accelerate.rb:34:in `call'
30
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/idempotency_token.rb:18:in `call'
31
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/aws-sdk-core/plugins/param_converter.rb:20:in `call'
32
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/seahorse/client/plugins/response_target.rb:21:in `call'
33
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/seahorse/client/request.rb:70:in `send_request'
34
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-core-2.6.36/lib/seahorse/client/base.rb:207:in `block (2 levels) in define_operation_methods'
35
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-resources-2.6.36/lib/aws-sdk-resources/services/s3/file_uploader.rb:42:in `block in put_object'
36
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-resources-2.6.36/lib/aws-sdk-resources/services/s3/file_uploader.rb:49:in `open_file'
37
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-resources-2.6.36/lib/aws-sdk-resources/services/s3/file_uploader.rb:41:in `put_object'
38
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-resources-2.6.36/lib/aws-sdk-resources/services/s3/file_uploader.rb:34:in `upload'
39
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/aws-sdk-resources-2.6.36/lib/aws-sdk-resources/services/s3/object.rb:251:in `upload_file'
40
+ /Users/minero-aoki/c/bricolage/lib/bricolage/s3datasource.rb:188:in `block in run'
41
+ /Users/minero-aoki/c/bricolage/lib/bricolage/s3datasource.rb:165:in `block in each_src_dest'
42
+ /Users/minero-aoki/c/bricolage/lib/bricolage/s3datasource.rb:163:in `each'
43
+ /Users/minero-aoki/c/bricolage/lib/bricolage/s3datasource.rb:163:in `each_src_dest'
44
+ /Users/minero-aoki/c/bricolage/lib/bricolage/s3datasource.rb:186:in `run'
45
+ /Users/minero-aoki/c/bricolage/lib/bricolage/script.rb:82:in `block (2 levels) in run'
46
+ /Users/minero-aoki/c/bricolage/lib/bricolage/script.rb:81:in `each'
47
+ /Users/minero-aoki/c/bricolage/lib/bricolage/script.rb:81:in `block in run'
48
+ /Users/minero-aoki/c/bricolage/lib/bricolage/datasource.rb:136:in `open'
49
+ /Users/minero-aoki/c/bricolage/lib/bricolage/datasource.rb:140:in `open_for_batch'
50
+ /Users/minero-aoki/c/bricolage/lib/bricolage/script.rb:80:in `run'
51
+ /Users/minero-aoki/c/bricolage/lib/bricolage/script.rb:47:in `block in run'
52
+ /Users/minero-aoki/c/bricolage/lib/bricolage/script.rb:46:in `each'
53
+ /Users/minero-aoki/c/bricolage/lib/bricolage/script.rb:46:in `run'
54
+ /Users/minero-aoki/c/bricolage/lib/bricolage/job.rb:143:in `block in execute'
55
+ /Users/minero-aoki/c/bricolage/lib/bricolage/logger.rb:44:in `with_elapsed_time'
56
+ /Users/minero-aoki/c/bricolage/lib/bricolage/job.rb:142:in `execute'
57
+ /Users/minero-aoki/c/bricolage/lib/bricolage/application.rb:68:in `block in main'
58
+ /Users/minero-aoki/c/bricolage/lib/bricolage/application.rb:97:in `redirect_log_to_file'
59
+ /Users/minero-aoki/c/bricolage/lib/bricolage/application.rb:67:in `main'
60
+ /Users/minero-aoki/c/bricolage/lib/bricolage/application.rb:28:in `main'
61
+ /Users/minero-aoki/c/bricolage/bin/bricolage:6:in `<top (required)>'
62
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bin/bricolage:23:in `load'
63
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/bin/bricolage:23:in `<top (required)>'
64
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `load'
65
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:74:in `kernel_load'
66
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli/exec.rb:27:in `run'
67
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:332:in `exec'
68
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/command.rb:27:in `run'
69
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/invocation.rb:126:in `invoke_command'
70
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor.rb:359:in `dispatch'
71
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:20:in `dispatch'
72
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/vendor/thor/lib/thor/base.rb:440:in `start'
73
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/cli.rb:11:in `start'
74
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle:34:in `block in <top (required)>'
75
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/lib/bundler/friendly_errors.rb:100:in `with_friendly_errors'
76
+ /Users/minero-aoki/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/bundler-1.13.6/exe/bundle:26:in `<top (required)>'
77
+ /Users/minero-aoki/.rbenv/versions/2.3/bin/bundle:23:in `load'
78
+ /Users/minero-aoki/.rbenv/versions/2.3/bin/bundle:23:in `<main>'
79
+
80
+ 2017-01-17 20:25:51 +0900: ERROR: error: Aws::Errors::MissingCredentialsError: unable to sign request without credentials set
@@ -0,0 +1,79 @@
1
+ 2017-01-17 20:26:36 +0900: INFO: development environment
2
+ 2017-01-17 20:26:36 +0900: INFO: [CMD] "/Users/minero-aoki/c/bricolage/libexec/sqldump" "--json" "127.0.0.1" "9011" "work_readonly" "main" "select * from main.search_backends;" | "gzip" "{:out=>"/tmp/bricolagedev/search_backends.json.gz"}"
3
+ 2017-01-17 20:26:36.214888001 +0900 JST: [SQL] select * from main.search_backends;
4
+ 2017-01-17 20:26:36.27827597 +0900 JST: query returned
5
+ 2017-01-17 20:26:36.278393544 +0900 JST: Total 11 records
6
+ 2017-01-17 20:26:36 +0900: INFO: aws s3 cp /tmp/bricolagedev/search_backends.json.gz s3://tabemiru-data.ap-northeast-1/dev/search_backends/search_backends.json.gz
7
+ rm -f /tmp/bricolagedev/search_backends.json.gz
8
+ 2017-01-17 20:26:36 +0900: INFO: command: psql --no-psqlrc --host=dwh.ckpd.co --port=5439 --username=aamine production --echo-all -v ON_ERROR_STOP=true -f /var/folders/_t/f8rv7p995rq8m3j3tf45w4rm0000gp/T/1484652396_69460_3fd54d43f9d8_14594 --no-password
9
+ \timing on
10
+ Timing is on.
11
+ begin transaction;
12
+ BEGIN
13
+ Time: 8.269 ms
14
+ drop table if exists aamine.search_backends_old cascade;
15
+ psql:/var/folders/_t/f8rv7p995rq8m3j3tf45w4rm0000gp/T/1484652396_69460_3fd54d43f9d8_14594:5: INFO: Table "search_backends_old" does not exist and will be skipped
16
+ DROP TABLE
17
+ Time: 8.647 ms
18
+ drop table if exists aamine.search_backends_wk cascade;
19
+ psql:/var/folders/_t/f8rv7p995rq8m3j3tf45w4rm0000gp/T/1484652396_69460_3fd54d43f9d8_14594:7: INFO: Table "search_backends_wk" does not exist and will be skipped
20
+ DROP TABLE
21
+ Time: 8.031 ms
22
+ /* /Users/minero-aoki/c/bricolage/test/home/subsys/search_backends.ct */
23
+ create table aamine.search_backends_wk
24
+ ( id int
25
+ , role varchar(10)
26
+ , group_id smallint
27
+ , index_type varchar(32)
28
+ , config_key varchar(32)
29
+ , updated_at timestamp
30
+ )
31
+ distkey (id)
32
+ sortkey (id)
33
+ ;
34
+ CREATE TABLE
35
+ Time: 521.167 ms
36
+ copy aamine.search_backends_wk
37
+ from 's3://tabemiru-data.ap-northeast-1/dev/search_backends/search_backends.json.gz'
38
+ credentials 'aws_iam_role=arn:aws:iam::789035092620:role/RedshiftDWHTeamS3Access'
39
+ json 'auto'
40
+ statupdate false
41
+ compupdate false
42
+ emptyasnull
43
+ gzip
44
+ ;
45
+ psql:/var/folders/_t/f8rv7p995rq8m3j3tf45w4rm0000gp/T/1484652396_69460_3fd54d43f9d8_14594:30: INFO: Load into table 'search_backends_wk' completed, 11 record(s) loaded successfully.
46
+ COPY
47
+ Time: 1235.569 ms
48
+ grant select on aamine.search_backends_wk to aamine;
49
+ GRANT
50
+ Time: 8.580 ms
51
+ analyze aamine.search_backends_wk;
52
+ ANALYZE
53
+ Time: 43.441 ms
54
+ create table if not exists aamine.search_backends (x int);
55
+ psql:/var/folders/_t/f8rv7p995rq8m3j3tf45w4rm0000gp/T/1484652396_69460_3fd54d43f9d8_14594:36: INFO: Relation "search_backends" already exists and will be skipped
56
+ CREATE TABLE
57
+ Time: 7.768 ms
58
+ alter table aamine.search_backends rename to search_backends_old;
59
+ ALTER TABLE
60
+ Time: 10.037 ms
61
+ alter table aamine.search_backends_wk rename to search_backends;
62
+ ALTER TABLE
63
+ Time: 11.686 ms
64
+ commit;
65
+ COMMIT
66
+ Time: 8482.452 ms
67
+ drop table if exists aamine.search_backends_old cascade;
68
+ DROP TABLE
69
+ Time: 4801.919 ms
70
+ ;
71
+ Time: 8.088 ms
72
+ vacuum sort only aamine.search_backends;
73
+ VACUUM
74
+ Time: 36970.832 ms
75
+ ;
76
+ Time: 8.746 ms
77
+ 2017-01-17 20:27:29 +0900: INFO: status: 0 (pid 69478 exit 0)
78
+ 2017-01-17 20:27:29 +0900: INFO: 53.05 secs
79
+ 2017-01-17 20:27:29 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:30:22 +0900: INFO: development environment
2
+ 2017-01-17 20:30:22 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:30:22 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:30:22 +0900: INFO: development environment
2
+ 2017-01-17 20:30:22 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:30:22 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:30:22 +0900: INFO: development environment
2
+ 2017-01-17 20:30:22 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:30:22 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:30:22 +0900: INFO: development environment
2
+ 2017-01-17 20:30:22 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:30:22 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:31:02 +0900: INFO: development environment
2
+ 2017-01-17 20:31:02 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:31:02 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:31:02 +0900: INFO: development environment
2
+ 2017-01-17 20:31:02 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:31:02 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:31:02 +0900: INFO: development environment
2
+ 2017-01-17 20:31:02 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:31:02 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:31:02 +0900: INFO: development environment
2
+ 2017-01-17 20:31:02 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:31:02 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:32:32 +0900: INFO: development environment
2
+ 2017-01-17 20:32:32 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:32:32 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:32:32 +0900: INFO: development environment
2
+ 2017-01-17 20:32:32 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:32:32 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:32:32 +0900: INFO: development environment
2
+ 2017-01-17 20:32:32 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:32:32 +0900: INFO: SUCCESS
@@ -0,0 +1,3 @@
1
+ 2017-01-17 20:32:32 +0900: INFO: development environment
2
+ 2017-01-17 20:32:32 +0900: INFO: 0.00 secs
3
+ 2017-01-17 20:32:32 +0900: INFO: SUCCESS
@@ -2,7 +2,7 @@
2
2
  class: my-import-delta
3
3
  src-ds: mysql_summary
4
4
  src-tables:
5
- item_pv: summarized_data.daily_recipe_pvs
5
+ item_pv: item_pv
6
6
  s3-ds: s3
7
7
  s3-prefix: bricolage/my-import-delta/$data_date/data.
8
8
  gzip: true
@@ -28,13 +28,13 @@ analyze: true
28
28
  */
29
29
 
30
30
  select
31
- coalesce(`date`) as data_date
32
- , coalesce(recipe_id) as item_id
33
- , coalesce(page_view) as pv
34
- , coalesce(unique_ip) as uu
31
+ data_date
32
+ , item_id
33
+ , pv
34
+ , uu
35
35
  from
36
36
  $item_pv
37
37
  where
38
- `date` = date '$data_date'
38
+ date = '$data_date'
39
39
  and (@PARTITION_CONDITION@)
40
40
  ;
@@ -5,7 +5,7 @@ Bricolage::JobClass.get('streaming_load')
5
5
  module Bricolage
6
6
  class TestStreamingLoadJobClass_S3Queue < Test::Unit::TestCase
7
7
  def test_compile_name_pattern
8
- q = StreamingLoadJobClass::S3Queue.new(data_source: nil, queue_path: nil, persistent_path: nil, file_name: nil, logger: nil)
8
+ q = StreamingLoadJobClass::S3Queue.new(data_source: nil, queue_path: nil, ctl_prefix: nil, persistent_path: nil, file_name: nil, logger: nil)
9
9
  re = q.compile_name_pattern("%*%Y%m%d-%H%M_%Q.gz")
10
10
  assert_equal /\A[^\/]*(?<year>\d{4})(?<month>\d{2})(?<day>\d{2})\-(?<hour>\d{2})(?<minute>\d{2})_(?<seq>\d+)\.gz\z/, re
11
11
  end
@@ -0,0 +1,19 @@
1
+ require 'test/unit'
2
+ require 'bricolage/logfilepath'
3
+ require 'bricolage/jobnet'
4
+
5
+ module Bricolage
6
+ class TestLogFilePath < Test::Unit::TestCase
7
+ test '#format' do
8
+ path = LogFilePath.new('./log/%{std}.log')
9
+ ref = JobNet::JobRef.new('subsys', 'somejob', '-')
10
+ start = Time.new(2012,3,4,12,34,56)
11
+ assert_equal './log/20120304/subsys::rebuild/20120304_123456000/subsys-somejob.log', path.format(
12
+ job_ref: ref,
13
+ jobnet_id: 'subsys/rebuild',
14
+ job_start_time: start,
15
+ jobnet_start_time: start
16
+ )
17
+ end
18
+ end
19
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bricolage
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.21.0
4
+ version: 5.22.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Minero Aoki
@@ -187,6 +187,7 @@ files:
187
187
  - lib/bricolage/jobnet.rb
188
188
  - lib/bricolage/jobnetrunner.rb
189
189
  - lib/bricolage/jobresult.rb
190
+ - lib/bricolage/logfilepath.rb
190
191
  - lib/bricolage/logger.rb
191
192
  - lib/bricolage/mysqldatasource.rb
192
193
  - lib/bricolage/parameters.rb
@@ -222,6 +223,23 @@ files:
222
223
  - test/home/data/20141002-1355_02.txt
223
224
  - test/home/data/test.txt
224
225
  - test/home/jobnet-test.rb
226
+ - test/home/log/20170117/subsys::job1/20170117_202014082/subsys-job1.log
227
+ - test/home/log/20170117/subsys::job1/20170117_202334852/subsys-job1.log
228
+ - test/home/log/20170117/subsys::job1/20170117_202405056/subsys-job1.log
229
+ - test/home/log/20170117/subsys::migrate/20170117_202548409/subsys-migrate.log
230
+ - test/home/log/20170117/subsys::migrate/20170117_202636115/subsys-migrate.log
231
+ - test/home/log/20170117/subsys::net1/20170117_203022461/subsys-job1.log
232
+ - test/home/log/20170117/subsys::net1/20170117_203022461/subsys-job2.log
233
+ - test/home/log/20170117/subsys::net1/20170117_203022461/subsys-job3.log
234
+ - test/home/log/20170117/subsys::net1/20170117_203022461/subsys-job4.log
235
+ - test/home/log/20170117/subsys::net1/20170117_203102130/subsys-job1.log
236
+ - test/home/log/20170117/subsys::net1/20170117_203102130/subsys-job2.log
237
+ - test/home/log/20170117/subsys::net1/20170117_203102130/subsys-job3.log
238
+ - test/home/log/20170117/subsys::net1/20170117_203102130/subsys-job4.log
239
+ - test/home/log/20170117/subsys::net1/20170117_203232033/subsys-job1.log
240
+ - test/home/log/20170117/subsys::net1/20170117_203232033/subsys-job2.log
241
+ - test/home/log/20170117/subsys::net1/20170117_203232033/subsys-job3.log
242
+ - test/home/log/20170117/subsys::net1/20170117_203232033/subsys-job4.log
225
243
  - test/home/revert.sh
226
244
  - test/home/subsys/d.ct
227
245
  - test/home/subsys/insert.sql.job
@@ -257,6 +275,7 @@ files:
257
275
  - test/home/subsys/variable.yml
258
276
  - test/test_c_streaming_load.rb
259
277
  - test/test_filesystem.rb
278
+ - test/test_logfilepath.rb
260
279
  - test/test_parameters.rb
261
280
  - test/test_s3datasource.rb
262
281
  - test/test_variables.rb