blobsterix 0.0.35 → 0.0.36
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/blobsterix/exceptions.rb +2 -0
- data/lib/blobsterix/storage/file_system.rb +118 -46
- data/lib/blobsterix/storage/file_system_meta_data.rb +28 -17
- data/lib/blobsterix/storage/storage.rb +3 -0
- data/lib/blobsterix/transformation/transformation_manager.rb +2 -2
- data/lib/blobsterix/version.rb +1 -1
- data/templates/storage_template.rb +4 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7445c28b6f045636c287259d79540cb33490a6e5
|
4
|
+
data.tar.gz: 301c5d44eba26cb07e3cbe0c8ca24598ecf4c0cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79d8ada8a2a3c8fe79c3f26b5f93fda2b97a36e7e6f09f326fa4e92ac55cec620a2099ee50940a7709b0a127027fcad4535c25b869cab3e04f64ca7a85643079
|
7
|
+
data.tar.gz: 0bb50d3e731c1f7868861043c9029155c44f1ac7d0e9c0175a590065b16eeaf0027ac7fc69c1b3fc4d54b02037f2b122b2f704a4d3f2200220cc2912d17ac409
|
@@ -7,93 +7,151 @@ module Blobsterix
|
|
7
7
|
include Blobsterix::Logable
|
8
8
|
|
9
9
|
def initialize(path)
|
10
|
-
|
11
|
-
@contents =
|
12
|
-
FileUtils.mkdir_p(@contents) unless Dir.exist?(@contents)
|
13
|
-
FileUtils.touch File.join(@contents,".keep")
|
10
|
+
@contents_path = path
|
11
|
+
@contents = nil
|
14
12
|
end
|
15
13
|
|
16
14
|
def bucket_exist(bucket="root")
|
17
|
-
|
15
|
+
begin
|
16
|
+
Dir.entries(contents).include?(bucket) and File.directory?(File.join(contents,bucket))
|
17
|
+
rescue => e
|
18
|
+
if e.is_a? ::Blosterix::BlobsterixStorageError
|
19
|
+
raise e
|
20
|
+
else
|
21
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not check for bucket")
|
22
|
+
end
|
23
|
+
end
|
18
24
|
end
|
19
25
|
|
20
26
|
def list(bucket="root", opts={})
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
if bucket_exist(bucket)
|
25
|
-
b = Bucket.new(bucket, time_string_of(bucket))
|
26
|
-
b.marker = opts[:start_path] if opts[:start_path]
|
27
|
-
Blobsterix.wait_for(Proc.new {
|
28
|
-
collect_bucket_entries(bucket, b, opts)
|
29
|
-
})
|
30
|
-
b
|
27
|
+
begin
|
28
|
+
if bucket =~ /root/
|
29
|
+
list_buckets
|
31
30
|
else
|
32
|
-
|
33
|
-
|
31
|
+
if bucket_exist(bucket)
|
32
|
+
b = Bucket.new(bucket, time_string_of(bucket))
|
33
|
+
b.marker = opts[:start_path] if opts[:start_path]
|
34
|
+
Blobsterix.wait_for(Proc.new {
|
35
|
+
collect_bucket_entries(bucket, b, opts)
|
36
|
+
})
|
37
|
+
b
|
38
|
+
else
|
39
|
+
Nokogiri::XML::Builder.new do |xml|
|
40
|
+
xml.Error "no such bucket"
|
41
|
+
end
|
34
42
|
end
|
35
43
|
end
|
44
|
+
rescue => e
|
45
|
+
if e.is_a? ::Blosterix::BlobsterixStorageError
|
46
|
+
raise e
|
47
|
+
else
|
48
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not list bucket(s)")
|
49
|
+
end
|
36
50
|
end
|
37
51
|
end
|
38
52
|
|
39
53
|
def get(bucket, key)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
54
|
+
begin
|
55
|
+
if (not File.directory?(contents(bucket, key))) # and bucket_files(bucket).include?(key)
|
56
|
+
Blobsterix.storage_read(BlobAccess.new(:bucket => bucket, :id => key))
|
57
|
+
metaData(bucket, key)
|
58
|
+
else
|
59
|
+
Blobsterix.storage_read_fail(BlobAccess.new(:bucket => bucket, :id => key))
|
60
|
+
Blobsterix::Storage::BlobMetaData.new
|
61
|
+
end
|
62
|
+
rescue => e
|
63
|
+
if e.is_a? ::Blosterix::BlobsterixStorageError
|
64
|
+
raise e
|
65
|
+
else
|
66
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not get bucket entry: #{@contents_path}")
|
67
|
+
end
|
46
68
|
end
|
47
69
|
end
|
48
70
|
|
49
71
|
def put(bucket, key, value, opts={})
|
50
|
-
|
72
|
+
begin
|
73
|
+
Blobsterix.storage_write(BlobAccess.new(:bucket => bucket, :id => key))
|
51
74
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
75
|
+
meta = Blobsterix.wait_for(Proc.new do
|
76
|
+
result = metaData(bucket, key).write() do |f|
|
77
|
+
FileUtils.copy_stream(value, f)
|
78
|
+
end
|
79
|
+
FileUtils.touch File.join(contents(bucket), ".keep")
|
80
|
+
result
|
81
|
+
end)
|
59
82
|
|
60
|
-
|
83
|
+
value.close if opts[:close_after_write]
|
61
84
|
|
62
|
-
|
85
|
+
Blobsterix.wait_for(Proc.new {Blobsterix.cache.invalidate(Blobsterix::BlobAccess.new(:bucket => bucket, :id => key))})
|
63
86
|
|
64
|
-
|
87
|
+
meta
|
88
|
+
rescue => e
|
89
|
+
if e.is_a? ::Blosterix::BlobsterixStorageError
|
90
|
+
raise e
|
91
|
+
else
|
92
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not create bucket entry")
|
93
|
+
end
|
94
|
+
end
|
65
95
|
end
|
66
96
|
|
67
97
|
def create(bucket)
|
68
|
-
|
69
|
-
|
70
|
-
|
98
|
+
begin
|
99
|
+
logger.info "Storage: create bucket #{contents(bucket)}"
|
100
|
+
FileUtils.mkdir_p(contents(bucket)) unless File.exist?(contents(bucket))
|
101
|
+
FileUtils.touch File.join(contents(bucket), ".keep")
|
71
102
|
|
72
|
-
|
73
|
-
|
103
|
+
Nokogiri::XML::Builder.new do |xml|
|
104
|
+
end.to_s
|
105
|
+
rescue => e
|
106
|
+
if e.is_a? ::Blosterix::BlobsterixStorageError
|
107
|
+
raise e
|
108
|
+
else
|
109
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not create bucket")
|
110
|
+
end
|
111
|
+
end
|
74
112
|
end
|
75
113
|
|
76
114
|
def delete(bucket)
|
77
|
-
|
78
|
-
|
79
|
-
|
115
|
+
begin
|
116
|
+
logger.info "Storage: delete bucket #{contents(bucket)}"
|
117
|
+
FileUtils.rm_rf(contents(bucket)) if bucket_exist(bucket) && bucket_empty?(bucket)
|
118
|
+
rescue => e
|
119
|
+
if e.is_a? ::Blosterix::BlobsterixStorageError
|
120
|
+
raise e
|
121
|
+
else
|
122
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not delete bucket")
|
123
|
+
end
|
124
|
+
end
|
80
125
|
end
|
81
126
|
|
82
127
|
def delete_key(bucket, key)
|
83
|
-
|
84
|
-
|
128
|
+
begin
|
129
|
+
Blobsterix.storage_delete(BlobAccess.new(:bucket => bucket, :id => key))
|
130
|
+
Blobsterix.wait_for(Proc.new {Blobsterix.cache.invalidate(Blobsterix::BlobAccess.new(:bucket => bucket, :id => key))})
|
131
|
+
|
132
|
+
metaData(bucket, key).delete # if bucket_files(bucket).include? key
|
133
|
+
rescue => e
|
134
|
+
if e.is_a? ::Blosterix::BlobsterixStorageError
|
135
|
+
raise e
|
136
|
+
else
|
137
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not delete bucket key")
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
85
141
|
|
86
|
-
|
142
|
+
def name
|
143
|
+
@contents_path
|
87
144
|
end
|
88
145
|
|
89
146
|
private
|
90
147
|
def list_buckets
|
91
148
|
BucketList.new do |l|
|
92
149
|
Dir.entries("#{contents}").each{|dir|
|
93
|
-
l.buckets << Bucket.new(dir, time_string_of(dir)) if File.directory? File.join("#{contents}",dir) and !(dir =='.' || dir == '..')
|
150
|
+
l.buckets << Bucket.new(dir, time_string_of(dir)) if File.directory? File.join("#{contents}",dir) and !(dir =='.' || dir == '..')
|
94
151
|
}
|
95
152
|
end
|
96
153
|
end
|
154
|
+
|
97
155
|
def collect_bucket_entries(bucket, b, opts)
|
98
156
|
start_path = map_filename(opts[:start_path].to_s.gsub("/", "\\")) if opts[:start_path]
|
99
157
|
current_obj = Blobsterix::DirectoryList.each_limit(contents(bucket), :limit => 20, :start_path => start_path) do |path, file|
|
@@ -110,7 +168,9 @@ module Blobsterix
|
|
110
168
|
b.truncated=true
|
111
169
|
end
|
112
170
|
end
|
171
|
+
|
113
172
|
def contents(bucket=nil, key=nil)
|
173
|
+
initialize_contents
|
114
174
|
if bucket
|
115
175
|
key ? File.join(@contents, bucket, map_filename(key.gsub("/", "\\"))) : File.join(@contents, bucket)
|
116
176
|
else
|
@@ -118,6 +178,18 @@ module Blobsterix
|
|
118
178
|
end
|
119
179
|
end
|
120
180
|
|
181
|
+
def initialize_contents
|
182
|
+
return if @contents != nil
|
183
|
+
begin
|
184
|
+
logger.info "Create FileSystem at #{@contents_path}"
|
185
|
+
FileUtils.mkdir_p(@contents_path) unless Dir.exist?(@contents_path)
|
186
|
+
FileUtils.touch File.join(@contents_path,".keep")
|
187
|
+
@contents = @contents_path
|
188
|
+
rescue
|
189
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not connect to FileSystem")
|
190
|
+
end
|
191
|
+
end
|
192
|
+
|
121
193
|
def map_filename(filename)
|
122
194
|
Murmur.map_filename(filename, filename)
|
123
195
|
end
|
@@ -67,7 +67,7 @@ module Blobsterix
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def header()
|
70
|
-
{"Etag" => etag, "Content-Type" => mimetype, "Last-Modified" => last_modified.strftime("%Y
|
70
|
+
{"Etag" => etag, "Content-Type" => mimetype, "Last-Modified" => last_modified.strftime("%a, %d %b %Y %H:%M:%S GMT"), "Cache-Control" => "max-age=#{60*60*24}", "Expires" => (Time.new+(60*60*24)).strftime("%a, %d %b %Y %H:%M:%S GMT")}
|
71
71
|
end
|
72
72
|
|
73
73
|
def valid
|
@@ -79,24 +79,32 @@ module Blobsterix
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def write
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
82
|
+
begin
|
83
|
+
if block_given?
|
84
|
+
delete
|
85
|
+
FileUtils.mkdir_p(File.dirname(path))
|
86
|
+
f = File.open(path, "wb")
|
87
|
+
yield f
|
88
|
+
f.close
|
89
|
+
end
|
90
|
+
save_meta_file
|
91
|
+
self
|
92
|
+
rescue
|
93
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not create MetaData entry")
|
88
94
|
end
|
89
|
-
save_meta_file
|
90
|
-
self
|
91
95
|
end
|
92
96
|
|
93
97
|
def open
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
98
|
+
begin
|
99
|
+
if block_given?
|
100
|
+
f = File.open(path, "rb")
|
101
|
+
yield f
|
102
|
+
f.close
|
103
|
+
else
|
104
|
+
File.open(path, "rb")
|
105
|
+
end
|
106
|
+
rescue
|
107
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not open FilesystemMetaData")
|
100
108
|
end
|
101
109
|
end
|
102
110
|
|
@@ -138,8 +146,11 @@ module Blobsterix
|
|
138
146
|
end
|
139
147
|
def save_meta_file
|
140
148
|
return if not valid
|
141
|
-
|
142
|
-
|
149
|
+
begin
|
150
|
+
File.write(meta_path, to_json)
|
151
|
+
rescue
|
152
|
+
raise ::Blosterix::BlobsterixStorageError.new("Could not create MetaData entry")
|
153
|
+
end
|
143
154
|
end
|
144
155
|
def load_meta_file
|
145
156
|
return if not valid
|
@@ -102,7 +102,7 @@ module Blobsterix::Transformations
|
|
102
102
|
logger.debug "Transformation: done #{blob_access} finish connections"
|
103
103
|
running_transformations[blob_access.identifier].each{|fiber|
|
104
104
|
fiber.resume(result)
|
105
|
-
}
|
105
|
+
} if running_transformations[blob_access.identifier] # check if there are pending fibers or if the connection was already closed
|
106
106
|
uncue_transformation(blob_access)
|
107
107
|
end
|
108
108
|
|
@@ -118,4 +118,4 @@ module Blobsterix::Transformations
|
|
118
118
|
trafos.empty? ? nil : trafos[0]
|
119
119
|
end
|
120
120
|
end
|
121
|
-
end
|
121
|
+
end
|
data/lib/blobsterix/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blobsterix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.36
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Daniel Sudmann
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -333,3 +333,4 @@ 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:
|