triglav-agent-hdfs 1.0.0.rc1-java → 1.0.0.rc2-java

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: 4c845bf8090ce7c6f5d05a175b69c6e5dd7e1463
4
- data.tar.gz: aecee4e6cae2b28b44c996a858e0663b31f3a954
3
+ metadata.gz: 9a91b6b3c3c5eaed6e47873427df60d5cd527035
4
+ data.tar.gz: 03e5d911634698e925262c56dce8410fc2ecebd7
5
5
  SHA512:
6
- metadata.gz: af65de933dfd17d9bc10f9a45102754941947174266dd3bcef06860a7604049858aab2ee3922b09e354fe8b6e420e3a3f17131f5dc0e53b44fe70f2628b78109
7
- data.tar.gz: 8eaf92c5d9a1818782563a67d2042d4eacc2e9ef1fd314487735a9e687c1c0b763710561dbb39adcfacf91c1eda218724a7cf2d68ff4fb0234152f4789df6017
6
+ metadata.gz: 10942b411143434c33d50dbcb675a5780db045f5010d5be544414cecd4bb96cb48645b2e50c538bc2d951139f39bb525a1100596bf1cc55d1657f93cad64d01b
7
+ data.tar.gz: 4e61d0f7dcbfd67f7fdf87e7955e2e0977824d2a20a3bf0548af6b1a71c5cb3911ba831cce640e98d6f9371923e19182389e6d2d0dc77a55484270f46653edb2
@@ -29,7 +29,6 @@ module Triglav::Agent
29
29
  $logger.warn { "Broken resource: #{resource.to_s}" }
30
30
  return nil
31
31
  end
32
-
33
32
  $logger.debug { "Start process #{resource.uri}" }
34
33
 
35
34
  events, new_last_modification_times = get_events
@@ -45,9 +44,9 @@ module Triglav::Agent
45
44
  private
46
45
 
47
46
  def get_events
48
- latest_files = fetch_latest_files
47
+ new_last_modification_times = get_new_last_modification_times
48
+ latest_files = select_latest_files(new_last_modification_times)
49
49
  events = build_events(latest_files)
50
- new_last_modification_times = build_last_modification_times(latest_files)
51
50
  [events, new_last_modification_times]
52
51
  rescue => e
53
52
  $logger.warn { "#{e.class} #{e.message} #{e.backtrace.join("\n ")}" }
@@ -135,32 +134,29 @@ module Triglav::Agent
135
134
  @paths = paths
136
135
  end
137
136
 
138
- def fetch_latest_files
139
- latest_files = {}
137
+ def get_new_last_modification_times
138
+ new_last_modification_times = {}
140
139
  paths.each do |path, date_hour|
141
140
  latest_file = connection.get_latest_file_under(path.to_s)
142
141
  unless latest_file
143
142
  $logger.debug { "get_latest_file_under(\"#{path.to_s}\") #=> does not exist" }
144
143
  next
145
144
  end
146
- is_newer = latest_file.modification_time > last_modification_times[path]
147
- $logger.debug { "get_latest_file_under(\"#{path.to_s}\") #=> latest_modification_time:#{latest_file.modification_time}, is_newer:#{is_newer}" }
148
- next unless is_newer
149
- latest_files[path.to_sym] = latest_file
145
+ new_last_modification_times[path.to_sym] = latest_file.modification_time
150
146
  end
151
- latest_files
147
+ new_last_modification_times
152
148
  end
153
149
 
154
- def build_last_modification_times(latest_files)
155
- last_modification_times = {}
156
- latest_files.map do |path, latest_file|
157
- last_modification_times[path.to_sym] = latest_file.modification_time
150
+ def select_latest_files(new_last_modification_times)
151
+ new_last_modification_times.select do |path, new_last_modification_time|
152
+ is_newer = new_last_modification_time > (last_modification_times[path] || 0)
153
+ $logger.debug { "#{path.to_s} #=> last_modification_time:#{new_last_modification_time}, is_newer:#{is_newer}" }
154
+ is_newer
158
155
  end
159
- last_modification_times
160
156
  end
161
157
 
162
158
  def build_events(latest_files)
163
- latest_files.map do |path, latest_file|
159
+ latest_files.map do |path, last_modification_time|
164
160
  date, hour = date_hour = paths[path]
165
161
  {
166
162
  uuid: SecureRandom.uuid,
@@ -168,7 +164,7 @@ module Triglav::Agent
168
164
  resource_unit: resource.unit,
169
165
  resource_time: date_hour_to_i(date, hour, resource.timezone),
170
166
  resource_timezone: resource.timezone,
171
- payload: {path: latest_file.path.to_s, modification_time: latest_file.modification_time}.to_json, # msec
167
+ payload: {path: path.to_s, modification_time: last_modification_time}.to_json, # msec
172
168
  }
173
169
  end
174
170
  end
@@ -1,7 +1,7 @@
1
1
  module Triglav
2
2
  module Agent
3
3
  module Hdfs
4
- VERSION = "1.0.0.rc1"
4
+ VERSION = "1.0.0.rc2"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: triglav-agent-hdfs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.rc1
4
+ version: 1.0.0.rc2
5
5
  platform: java
6
6
  authors:
7
7
  - Triglav Team
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-03-14 00:00:00.000000000 Z
11
+ date: 2017-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  requirement: !ruby/object:Gem::Requirement