nfagent 0.9.11 → 0.9.13
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nfagent.rb +1 -1
- data/lib/nfagent/chunk.rb +2 -0
- data/lib/nfagent/payload.rb +11 -2
- data/lib/nfagent/submitter.rb +2 -2
- metadata +2 -2
data/lib/nfagent.rb
CHANGED
data/lib/nfagent/chunk.rb
CHANGED
@@ -30,6 +30,8 @@ module NFAgent
|
|
30
30
|
def dump
|
31
31
|
Payload.new do |payload|
|
32
32
|
Log.info("Dumping payload from chunk (#{@array.size} lines)")
|
33
|
+
payload.line_count = @array.size
|
34
|
+
payload.chunk_expired = expired?
|
33
35
|
payload.data = Encoder.encode64url(Zlib::Deflate.deflate(@array.join("\n"), Zlib::BEST_COMPRESSION))
|
34
36
|
payload.checksum = Digest::SHA1.hexdigest(payload.data)
|
35
37
|
end
|
data/lib/nfagent/payload.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
|
2
2
|
module NFAgent
|
3
|
-
class Payload < Struct.new(:data, :checksum, :filename)
|
3
|
+
class Payload < Struct.new(:data, :checksum, :filename, :line_count, :chunk_expired)
|
4
4
|
def initialize
|
5
5
|
yield self
|
6
6
|
end
|
7
7
|
|
8
8
|
def attempt
|
9
|
-
@attempt ||
|
9
|
+
@attempt || 0
|
10
10
|
end
|
11
11
|
|
12
12
|
def attempt=(value)
|
@@ -22,6 +22,15 @@ module NFAgent
|
|
22
22
|
(self.data || "").size + 1
|
23
23
|
end
|
24
24
|
|
25
|
+
def to_hash
|
26
|
+
{
|
27
|
+
"payload" => self.data,
|
28
|
+
"checksum" => self.checksum,
|
29
|
+
"line_count" => self.line_count,
|
30
|
+
"chunk_expired" => self.chunk_expired
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
25
34
|
def write_to_disk(directory)
|
26
35
|
File.open(File.join(directory, "#{self.checksum}-#{self.attempt}"), "w") do |file|
|
27
36
|
file << self.data
|
data/lib/nfagent/submitter.rb
CHANGED
@@ -10,9 +10,9 @@ module NFAgent
|
|
10
10
|
def perform
|
11
11
|
@payload.increment_attempt!
|
12
12
|
fail(@payload) unless [ 1, 2, 4, 8, 16 ].include?(@payload.attempt)
|
13
|
-
Log.info "Submitting Payload: #{@payload.checksum}, Attempt #{@payload.attempt}, (#{@payload.size} bytes)"
|
13
|
+
Log.info "Submitting Payload: #{@payload.checksum}, Attempt #{@payload.attempt}, (#{@payload.size} bytes, #{@payload.line_count} lines)"
|
14
14
|
@payload.lock do
|
15
|
-
response = Client.post(:collector,
|
15
|
+
response = Client.post(:collector, @payload.to_hash)
|
16
16
|
if response.ok?
|
17
17
|
succeed(@payload)
|
18
18
|
else
|