fluent-plugin-azurestorage-gen2 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/fluent/plugin/out_azurestorage_gen2.rb +43 -30
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bff097a151b5af0d596f82ab181d3e141abf0de
|
4
|
+
data.tar.gz: f453dabd8d7719502820e51ae870803d3845a80f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 361a92e5ab216018f95a1f0f0e331d0401bf894da0b65ea3a2bcd1ecfb62e3ce3fd599b8633e77ae385537e9590d2cffa51ec4df38917e5f42660932edc87350
|
7
|
+
data.tar.gz: da8cec0e4867005f2e794c1733c58bfcb33c5ef7e2a6f071f93436506e2d70c3b9a8ecd755ad305973af16bbc9ee163d62d50e632a7d7d26a80964de4d844cc0
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.9
|
@@ -41,6 +41,7 @@ module Fluent::Plugin
|
|
41
41
|
config_param :url_domain_suffix, :string, :default => '.dfs.core.windows.net'
|
42
42
|
config_param :format, :string, :default => "out_file"
|
43
43
|
config_param :time_slice_format, :string, :default => '%Y%m%d'
|
44
|
+
config_param :hex_random_length, :integer, default: 4
|
44
45
|
config_param :command_parameter, :string, :default => nil
|
45
46
|
|
46
47
|
DEFAULT_FORMAT_TYPE = "out_file"
|
@@ -75,16 +76,6 @@ module Fluent::Plugin
|
|
75
76
|
|
76
77
|
@formatter = formatter_create
|
77
78
|
|
78
|
-
if @localtime
|
79
|
-
@path_slicer = Proc.new {|path|
|
80
|
-
Time.now.strftime(path)
|
81
|
-
}
|
82
|
-
else
|
83
|
-
@path_slicer = Proc.new {|path|
|
84
|
-
Time.now.utc.strftime(path)
|
85
|
-
}
|
86
|
-
end
|
87
|
-
|
88
79
|
if @azure_container.nil?
|
89
80
|
raise Fluent::ConfigError, "azure_container is needed"
|
90
81
|
end
|
@@ -98,7 +89,7 @@ module Fluent::Plugin
|
|
98
89
|
else
|
99
90
|
@final_file_extension = @compressor.ext
|
100
91
|
end
|
101
|
-
|
92
|
+
@values_for_object_chunk = {}
|
102
93
|
end
|
103
94
|
|
104
95
|
def multi_workers_ready?
|
@@ -127,17 +118,16 @@ module Fluent::Plugin
|
|
127
118
|
end
|
128
119
|
|
129
120
|
def write(chunk)
|
130
|
-
metadata = chunk.metadata
|
131
121
|
if @store_as.nil? || @store_as == "none"
|
132
|
-
generate_log_name(
|
122
|
+
generate_log_name(chunk, @current_index)
|
133
123
|
if @last_azure_storage_path != @azure_storage_path
|
134
124
|
@current_index = 0
|
135
|
-
generate_log_name(
|
125
|
+
generate_log_name(chunk, @current_index)
|
136
126
|
end
|
137
127
|
raw_data = chunk.read
|
138
128
|
unless raw_data.empty?
|
139
129
|
log.debug "azurestorage_gen2: processing raw data", chunk_id: dump_unique_id_hex(chunk.unique_id)
|
140
|
-
upload_blob(raw_data,
|
130
|
+
upload_blob(raw_data, chunk)
|
141
131
|
end
|
142
132
|
chunk.close rescue nil
|
143
133
|
@last_azure_storage_path = @azure_storage_path
|
@@ -147,51 +137,68 @@ module Fluent::Plugin
|
|
147
137
|
begin
|
148
138
|
@compressor.compress(chunk, tmp)
|
149
139
|
tmp.rewind
|
150
|
-
generate_log_name(
|
140
|
+
generate_log_name(chunk, @current_index)
|
151
141
|
if @last_azure_storage_path != @azure_storage_path
|
152
142
|
@current_index = 0
|
153
|
-
generate_log_name(
|
143
|
+
generate_log_name(chunk, @current_index)
|
154
144
|
end
|
155
145
|
log.debug "azurestorage_gen2: Start uploading temp file: #{tmp.path}"
|
156
146
|
content = File.open(tmp.path, 'rb') { |file| file.read }
|
157
|
-
upload_blob(content,
|
147
|
+
upload_blob(content, chunk)
|
158
148
|
@last_azure_storage_path = @azure_storage_path
|
159
149
|
ensure
|
160
150
|
tmp.close(true) rescue nil
|
161
151
|
end
|
152
|
+
@values_for_object_chunk.delete(chunk.unique_id)
|
162
153
|
end
|
163
154
|
|
164
155
|
end
|
165
156
|
|
166
157
|
private
|
167
|
-
def upload_blob(content,
|
158
|
+
def upload_blob(content, chunk)
|
168
159
|
log.debug "azurestorage_gen2: Uploading blob: #{@azure_storage_path}"
|
169
160
|
existing_content_length = get_blob_properties(@azure_storage_path)
|
170
161
|
if existing_content_length == 0
|
171
162
|
create_blob(@azure_storage_path)
|
172
163
|
end
|
173
|
-
append_blob(content,
|
164
|
+
append_blob(content, chunk, existing_content_length)
|
174
165
|
end
|
175
166
|
|
176
167
|
private
|
177
|
-
def generate_log_name(
|
168
|
+
def generate_log_name(chunk, index)
|
169
|
+
metadata = chunk.metadata
|
178
170
|
time_slice = if metadata.timekey.nil?
|
179
171
|
''.freeze
|
180
172
|
else
|
181
173
|
Time.at(metadata.timekey).utc.strftime(@time_slice_format)
|
182
174
|
end
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
"%
|
175
|
+
if @localtime
|
176
|
+
hms_slicer = Time.now.strftime("%H%M%S")
|
177
|
+
else
|
178
|
+
hms_slicer = Time.now.utc.strftime("%H%M%S")
|
179
|
+
end
|
180
|
+
|
181
|
+
@values_for_object_chunk[chunk.unique_id] ||= {
|
182
|
+
"%{hex_random}" => hex_random(chunk),
|
183
|
+
}
|
184
|
+
values_for_object_key_pre = {
|
185
|
+
"%{path}" => @path,
|
187
186
|
"%{index}" => index,
|
188
187
|
"%{uuid_flush}" => uuid_random,
|
189
188
|
"%{file_extension}" => @final_file_extension
|
190
189
|
}
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
190
|
+
values_for_object_key_post = {
|
191
|
+
"%{date_slice}" => time_slice,
|
192
|
+
"%{time_slice}" => time_slice,
|
193
|
+
"%{hms_slice}" => hms_slicer,
|
194
|
+
}.merge!(@values_for_object_chunk[chunk.unique_id])
|
195
|
+
storage_path = @azure_object_key_format.gsub(%r(%{[^}]+})) do |matched_key|
|
196
|
+
values_for_object_key_pre.fetch(matched_key, matched_key)
|
197
|
+
end
|
198
|
+
storage_path = extract_placeholders(storage_path, chunk)
|
199
|
+
storage_path = storage_path.gsub(%r(%{[^}]+}), values_for_object_key_post)
|
200
|
+
storage_path = "/" + storage_path unless storage_path.start_with?("/")
|
201
|
+
@azure_storage_path = storage_path
|
195
202
|
end
|
196
203
|
|
197
204
|
def setup_access_token
|
@@ -427,7 +434,7 @@ module Fluent::Plugin
|
|
427
434
|
end
|
428
435
|
|
429
436
|
private
|
430
|
-
def append_blob(content,
|
437
|
+
def append_blob(content, chunk, existing_content_length)
|
431
438
|
position = 0
|
432
439
|
log.debug "azurestorage_gen2: append_blob.start: Content size: #{content.length}"
|
433
440
|
loop do
|
@@ -545,6 +552,12 @@ module Fluent::Plugin
|
|
545
552
|
require 'uuidtools'
|
546
553
|
::UUIDTools::UUID.random_create.to_s
|
547
554
|
end
|
555
|
+
|
556
|
+
def hex_random(chunk)
|
557
|
+
unique_hex = Fluent::UniqueId.hex(chunk.unique_id)
|
558
|
+
unique_hex.reverse!
|
559
|
+
unique_hex[0...@hex_random_length]
|
560
|
+
end
|
548
561
|
|
549
562
|
def timekey_to_timeformat(timekey)
|
550
563
|
case timekey
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fluent-plugin-azurestorage-gen2
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Oliver Szabo
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: fluentd
|