blobsterix 0.0.19 → 0.0.23

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
  SHA1:
3
- metadata.gz: 552f0bd886f26d55598a1d70c64c3d67ccf0e283
4
- data.tar.gz: c2442bc068866a0bcc44b2f3eb78c4b3be012b27
3
+ metadata.gz: 8a2f7162cc83974f24c94ba4a2fbd6fc7c69c981
4
+ data.tar.gz: e0c24542aac5d21c336f1ddd04af31a60959f4fc
5
5
  SHA512:
6
- metadata.gz: 6edb548afa51c035dadbeb90b756e246b6662f6c1f16fad9730979423408cac1b176c610498acefc596919fd02ce763e8ba1360762429e33b9b8d7ce455b447d
7
- data.tar.gz: 5b9b46c8f65293fb56057d244247dbc2d5c28f47358326e9587fa277549ada89051b761512a400ef90f3d14828649a0d91ab5a14fb69b26b56bc357ba2f8fbbb
6
+ metadata.gz: 0c9e2aeca38c24f9ec9a810462c787512ce5260b2b9101894d5ccab554a3a2c669cf4832bd9e6ded058896b3b806207f29cd11908e32fb9ba26444849f488875
7
+ data.tar.gz: 69d6830a6efe0f6280ca108a0cc28579063cdb0e6ed5f2b794b9d83261eebcc8736e7a78b75970c77a365a6fddc2d650542fa2d9d041a355418be748c4c57cd5
data/CHANGELOG.txt CHANGED
@@ -1,3 +1,11 @@
1
+ = 0.0.23
2
+ * fixed output type of transformation output
3
+ = 0.0.22
4
+ * added at exit callback
5
+ = 0.0.21
6
+ * removed log that slowed down the whole system
7
+ = 0.0.20
8
+ * s3 upload does not crash the server anymore if the transformation fails
1
9
  = 0.0.19
2
10
  * s3 requests expire as expected
3
11
  = 0.0.18
data/bin/blobsterix CHANGED
@@ -141,12 +141,17 @@ if ARGV.length == 0
141
141
  puts "\t\t storage (StorageName) - Creates a new blobsterix storage with the given name or just new as name."
142
142
  exit
143
143
  end
144
- if ARGV[0] == "server"
145
- BlobsterixRunner.new(ARGV).run_blobsterix
146
- elsif ARGV[0] == "console"
147
- BlobsterixRunner.new(ARGV).run_console
148
- elsif ARGV[0] == "run"
149
- BlobsterixRunner.new(ARGV).run_command
150
- elsif ARGV[0] == "generate"
144
+ if ARGV[0] == "generate"
151
145
  Generator.new(ARGV).run
146
+ else
147
+ at_exit do
148
+ Blobsterix.run_at_exit
149
+ end
150
+ if ARGV[0] == "server"
151
+ BlobsterixRunner.new(ARGV).run_blobsterix
152
+ elsif ARGV[0] == "console"
153
+ BlobsterixRunner.new(ARGV).run_console
154
+ elsif ARGV[0] == "run"
155
+ BlobsterixRunner.new(ARGV).run_command
156
+ end
152
157
  end
@@ -48,7 +48,7 @@ module Blobsterix
48
48
  begin
49
49
  return nil if @current_id+1 > entries.size
50
50
  @current_id+=1
51
- end while (current_entry == "." || current_entry == "..")
51
+ end while (current_entry == "." || current_entry == ".." || current_entry == ".keep")
52
52
  @current_id
53
53
  end
54
54
 
@@ -8,6 +8,14 @@ class Murmur
8
8
  i % 2**16 # or equivalently: i & 0xffffffff
9
9
  end
10
10
 
11
+ def self.force_overflow_unsigned_18(i)
12
+ i % 2**18 # or equivalently: i & 0xffffffff
13
+ end
14
+
15
+ def self.force_overflow_unsigned_20(i)
16
+ i % 2**20 # or equivalently: i & 0xffffffff
17
+ end
18
+
11
19
  def self.force_overflow_unsigned(i)
12
20
  i % 2**32 # or equivalently: i & 0xffffffff
13
21
  end
@@ -136,11 +144,11 @@ class Murmur
136
144
  end
137
145
 
138
146
  def self.map_filename(filename, *additional)
139
- hash = Murmur.Hash64B(filename)
147
+ hash = Murmur.force_overflow_unsigned_20(Murmur.Hash64B(filename))
140
148
  bits = hash.to_s(2)
141
149
  parts = []
142
- 6.times { |index|
143
- len = 11
150
+ 2.times { |index|
151
+ len = 10
144
152
  len = bits.length if len >= bits.length
145
153
  value = bits.slice!(0, len).to_i(2).to_s(16).rjust(3,"0")
146
154
  parts.push(value)
@@ -57,13 +57,14 @@ module Blobsterix
57
57
 
58
58
  def self.call(env)
59
59
  Blobsterix::StatusInfo.connections+=1
60
- print_ram_usage("RAM USAGE Before")
60
+ # print_ram_usage("RAM USAGE Before")
61
61
  result=router.call(env)
62
- print_ram_usage("RAM USAGE After")
62
+ # print_ram_usage("RAM USAGE After")
63
63
  Blobsterix::StatusInfo.connections-=1
64
64
  result
65
65
  end
66
66
 
67
+ # Only use this function if you really have to it slows down the whole system
67
68
  def self.print_ram_usage(text)
68
69
  Blobsterix.logger.info "#{text}[#{Process.pid}]: " + `pmap #{Process.pid} | tail -1`[10,40].strip
69
70
  end
@@ -79,7 +79,11 @@ module Blobsterix
79
79
  blob_access=BlobAccess.new(:source => source, :bucket => bucket_current, :id => file_current, :accept_type => accept, :trafo => trafo_current)
80
80
  data = transformation.run(blob_access)
81
81
  cached_upload_clear
82
- storage.put(bucket_current, file_current, data.open, :close_after_write => true).response(false)
82
+ if data.valid?
83
+ storage.put(bucket_current, file_current, data.open, :close_after_write => true).response(false)
84
+ else
85
+ Http.ServerError "Upload failed"
86
+ end
83
87
  end
84
88
 
85
89
  def delete_bucket
@@ -1,23 +1,9 @@
1
1
  module Blobsterix
2
2
  class Service < Goliath::API
3
3
  use Goliath::Rack::Params
4
- # use SudiMiddleWare
5
- include Logable
6
- =begin
7
- def on_headers(env, headers)
8
- env.logger.info 'received headers: ' + headers.inspect
9
- env['async-headers'] = headers
10
- end
11
4
 
12
- def on_body(env, data)
13
- env.logger.info 'received data: ' + data
14
- (env['async-body'] ||= '') << data
15
- end
5
+ include Logable
16
6
 
17
- def on_close(env)
18
- env.logger.info 'closing connection'
19
- end
20
- =end
21
7
  def response(env)
22
8
  # env["params"] = params
23
9
  call_stack(env, BlobApi, StatusApi, S3Api)
@@ -16,7 +16,8 @@ module Blobsterix
16
16
 
17
17
  def initialize(path)
18
18
  @path = Pathname.new(path)
19
- FileUtils.mkdir_p(@path) if !Dir.exist?(@path)
19
+ FileUtils.mkdir_p(@path) unless Dir.exist?(@path)
20
+ FileUtils.touch File.join(@path,".keep")
20
21
  end
21
22
 
22
23
  def get(blob_access)
@@ -59,7 +60,7 @@ module Blobsterix
59
60
  else
60
61
  cache_path(blob_access).entries.each {|cache_file|
61
62
  unless cache_file.to_s.match(/\.meta$/) || cache_file.directory?
62
- base_name = cache_file.to_s.split("_")[0..1].join("_")
63
+ base_name = cache_file.to_s
63
64
  FileSystemMetaData.new(cache_path(blob_access).join(cache_file)).delete if base_name.match(cache_file_base(blob_access))
64
65
  end
65
66
  } if Dir.exist?(cache_path(blob_access))
@@ -9,7 +9,8 @@ module Blobsterix
9
9
  def initialize(path)
10
10
  logger.info "Create FileSystem at #{path}"
11
11
  @contents = path
12
- FileUtils.mkdir_p(@contents) if !Dir.exist?(@contents)
12
+ FileUtils.mkdir_p(@contents) unless Dir.exist?(@contents)
13
+ FileUtils.touch File.join(@contents,".keep")
13
14
  end
14
15
 
15
16
  def bucket_exist(bucket="root")
@@ -48,7 +49,13 @@ module Blobsterix
48
49
  def put(bucket, key, value, opts={})
49
50
  Blobsterix.storage_write(BlobAccess.new(:bucket => bucket, :id => key))
50
51
 
51
- meta = Blobsterix.wait_for(Proc.new {metaData(bucket, key).write() {|f| FileUtils.copy_stream(value, f) }})
52
+ meta = Blobsterix.wait_for(Proc.new do
53
+ result = metaData(bucket, key).write() do |f|
54
+ FileUtils.copy_stream(value, f)
55
+ end
56
+ FileUtils.touch File.join(contents(bucket), ".keep")
57
+ result
58
+ end)
52
59
 
53
60
  value.close if opts[:close_after_write]
54
61
 
@@ -59,7 +66,8 @@ module Blobsterix
59
66
 
60
67
  def create(bucket)
61
68
  logger.info "Storage: create bucket #{contents(bucket)}"
62
- FileUtils.mkdir_p(contents(bucket)) if not File.exist?(contents(bucket))
69
+ FileUtils.mkdir_p(contents(bucket)) unless File.exist?(contents(bucket))
70
+ FileUtils.touch File.join(contents(bucket), ".keep")
63
71
 
64
72
  Nokogiri::XML::Builder.new do |xml|
65
73
  end.to_s
@@ -80,8 +80,8 @@ module Blobsterix
80
80
 
81
81
  def write
82
82
  if block_given?
83
- FileUtils.mkdir_p(File.dirname(path))
84
83
  delete
84
+ FileUtils.mkdir_p(File.dirname(path))
85
85
  f = File.open(path, "wb")
86
86
  yield f
87
87
  f.close
@@ -102,7 +102,16 @@ module Blobsterix
102
102
 
103
103
  def delete
104
104
  File.delete(meta_path) if File.exists?(meta_path)
105
- File.delete(path) if valid
105
+ # File.delete(path) if valid
106
+ Pathname.new(path).ascend do |p|
107
+ begin
108
+ p.delete
109
+ rescue Errno::ENOTEMPTY
110
+ # stop deleting path when non empty dir is reached
111
+ break
112
+ end
113
+ end if valid
114
+ true
106
115
  end
107
116
 
108
117
  def to_json
@@ -28,7 +28,7 @@ module Blobsterix::Transformations::Impl
28
28
  end
29
29
 
30
30
  def self.output_type_
31
- @input
31
+ @output
32
32
  end
33
33
 
34
34
  def self.body=(obj)
@@ -83,12 +83,18 @@ module Blobsterix::Transformations
83
83
  else
84
84
  logger.debug "Transformation: run #{blob_access}"
85
85
  EM.defer(Proc.new {
86
- chain.do()
86
+ begin
87
+ chain.do()
88
+ rescue Exception => e
89
+ e
90
+ end
87
91
  }, Proc.new {|result|
88
92
  finish_connection(result, blob_access)
89
93
  })
90
94
 
91
- Fiber.yield
95
+ result = Fiber.yield
96
+ raise result if result.is_a? Exception
97
+ result
92
98
  end
93
99
  end
94
100
 
@@ -1,3 +1,3 @@
1
1
  module Blobsterix
2
- VERSION = "0.0.19"
2
+ VERSION = "0.0.23"
3
3
  end
data/lib/blobsterix.rb CHANGED
@@ -251,10 +251,19 @@ module Blobsterix
251
251
 
252
252
  def self.wait_for(op = nil)
253
253
  fiber = Fiber.current
254
- EM.defer(op, Proc.new {|result|
254
+ EM.defer(Proc.new {
255
+ begin
256
+ op.call
257
+ rescue Exception => e
258
+ e
259
+ end
260
+ },
261
+ Proc.new {|result|
255
262
  fiber.resume result
256
263
  })
257
- Fiber.yield
264
+ result = Fiber.yield
265
+ raise result if result.is_a? Exception
266
+ result
258
267
  end
259
268
 
260
269
  def self.wait_for_next(op = nil)
@@ -262,4 +271,14 @@ module Blobsterix
262
271
  wait_for(op)
263
272
  end
264
273
  end
274
+
275
+ def self.at_exit(&proc)
276
+ (@at_exit_callback||=[]).push(proc)
277
+ end
278
+
279
+ def self.run_at_exit
280
+ (@at_exit_callback||=[]).each do |proc|
281
+ proc.call
282
+ end
283
+ end
265
284
  end
metadata CHANGED
@@ -1,195 +1,195 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blobsterix
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.19
4
+ version: 0.0.23
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Sudmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-08-14 00:00:00.000000000 Z
11
+ date: 2014-09-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: 1.8.1
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: 1.8.1
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: goliath
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: 1.0.3
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 1.0.3
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: journey
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: 1.0.4
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: 1.0.4
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: nokogiri
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
61
  version: 1.6.1
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
68
  version: 1.6.1
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: ruby-webp
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - ~>
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
75
  version: 0.1.0
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - ~>
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
82
  version: 0.1.0
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: mini_magick
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: 3.5.0
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: 3.5.0
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: log4r
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - '>='
101
+ - - ">="
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - '>='
108
+ - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: rake
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ~>
115
+ - - "~>"
116
116
  - !ruby/object:Gem::Version
117
117
  version: 0.9.6
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ~>
122
+ - - "~>"
123
123
  - !ruby/object:Gem::Version
124
124
  version: 0.9.6
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rspec
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: 2.14.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: 2.14.0
139
139
  - !ruby/object:Gem::Dependency
140
140
  name: rspec-core
141
141
  requirement: !ruby/object:Gem::Requirement
142
142
  requirements:
143
- - - '>='
143
+ - - ">="
144
144
  - !ruby/object:Gem::Version
145
145
  version: '0'
146
146
  type: :development
147
147
  prerelease: false
148
148
  version_requirements: !ruby/object:Gem::Requirement
149
149
  requirements:
150
- - - '>='
150
+ - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
153
  - !ruby/object:Gem::Dependency
154
154
  name: rspec-expectations
155
155
  requirement: !ruby/object:Gem::Requirement
156
156
  requirements:
157
- - - '>='
157
+ - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  type: :development
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
- - - '>='
164
+ - - ">="
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: rspec-mocks
169
169
  requirement: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - '>='
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
173
  version: '0'
174
174
  type: :development
175
175
  prerelease: false
176
176
  version_requirements: !ruby/object:Gem::Requirement
177
177
  requirements:
178
- - - '>='
178
+ - - ">="
179
179
  - !ruby/object:Gem::Version
180
180
  version: '0'
181
181
  - !ruby/object:Gem::Dependency
182
182
  name: pry
183
183
  requirement: !ruby/object:Gem::Requirement
184
184
  requirements:
185
- - - '>='
185
+ - - ">="
186
186
  - !ruby/object:Gem::Version
187
187
  version: '0'
188
188
  type: :development
189
189
  prerelease: false
190
190
  version_requirements: !ruby/object:Gem::Requirement
191
191
  requirements:
192
- - - '>='
192
+ - - ">="
193
193
  - !ruby/object:Gem::Version
194
194
  version: '0'
195
195
  description: Blobsterix is a transcoding, caching, storage server that can transform
@@ -201,8 +201,8 @@ executables:
201
201
  extensions: []
202
202
  extra_rdoc_files: []
203
203
  files:
204
- - .gitignore
205
- - .travis.yml
204
+ - ".gitignore"
205
+ - ".travis.yml"
206
206
  - CHANGELOG.txt
207
207
  - Gemfile
208
208
  - LICENSE
@@ -307,17 +307,17 @@ require_paths:
307
307
  - lib
308
308
  required_ruby_version: !ruby/object:Gem::Requirement
309
309
  requirements:
310
- - - '>='
310
+ - - ">="
311
311
  - !ruby/object:Gem::Version
312
312
  version: 2.0.0.451
313
313
  required_rubygems_version: !ruby/object:Gem::Requirement
314
314
  requirements:
315
- - - '>='
315
+ - - ">="
316
316
  - !ruby/object:Gem::Version
317
317
  version: '0'
318
318
  requirements: []
319
319
  rubyforge_project:
320
- rubygems_version: 2.0.14
320
+ rubygems_version: 2.2.2
321
321
  signing_key:
322
322
  specification_version: 4
323
323
  summary: Blobsterix is a transcoding, caching, storage server.
@@ -333,4 +333,3 @@ test_files:
333
333
  - spec/lib/storage/cache_spec.rb
334
334
  - spec/lib/storage/file_system_spec.rb
335
335
  - spec/spec_helper.rb
336
- has_rdoc: